Wednesday, 16 November 2016

restart MySQL Server on MacOSX after Sierra Upgrade

After each upgrade of MacOS X, MySQL won't restart, as the upgrade process delete the logging directory of MySQL :


If you try to run mysqld_safe manually, you'll get cristal clear error :

[10:45] tmanson@busyboxy:/usr/local/mysql/bin$ ./mysqld_safe
./mysqld_safe: line 544: /usr/local/mysql/data/mysqld_safe.pid: Permission denied
awk: i/o error occurred while closing /dev/stdout
 input record number 3, file
 source line number 1
161116 10:46:07 mysqld_safe Logging to '/var/log/mysql/error.log'.
touch: /var/log/mysql/error.log: No such file or directory
chmod: /var/log/mysql/error.log: No such file or directory
161116 10:46:07 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
./mysqld_safe: line 129: /var/log/mysql/error.log: No such file or directory
./mysqld_safe: line 166: /var/log/mysql/error.log: No such file or directory
touch: /var/log/mysql/error.log: No such file or directory
chown: /var/log/mysql/error.log: No such file or directory
chmod: /var/log/mysql/error.log: No such file or directory
161116 10:46:07 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
./mysqld_safe: line 129: /var/log/mysql/error.log: No such file or directory


(note: the error about mysql_safe.pid is just here because I've launch mysqld_safe as my regular user instead of root, but the path exists and the mysql tool that starts mysql is starting it as root)

To solve this :

sudo mkdir /var/log/mysql/
sudo chown _mysql:admin /var/log/mysql/

normally, MySQL is tried to start periodically, so you actually don't need to startit manually!
so you should just check, in the system preference/mysql :



Friday, 30 September 2016

Stellaris and AZERTY Keyboard




Paradox Interactive did a great job with Stellaris Game, as you may read on internet.
So I did spent 40€ for the game, and I was unpleasantly surprised that AZERTY Keyboard are not supported... WTF in 2016 !!! In 1995 we had configurable key binding and probably before that... (Can't remember).

I've search a bit and couldn't find an Out Of The Box solution, so here is a step by step instruction.

  1. Go to the AutoHotkey Homepage. https://autohotkey.com/
  2. Click Download. https://autohotkey.com/download/ahk-install.exe
  3. Run akh-install.exe to install AutoHotkey
  4. Right click on your desktop, New, "AutoHotkey", name it "Stellaris AZERTY.ahk"
  5. Copy paste the script below : 
     #SingleInstance Force  
     #MaxHotkeysPerInterval 99999  
     ;start game  
     Run, "steam://rungameid/281990"  
     ;"fix" keys  
     ;#IfWinActive ahk_class stellaris  
     ;#Persistent  
     ;#UseHook  
     z::w  
     w::z  
     a::q  
     q::a  
    
  6. Save
  7. Right click on the .ahk file and click "Compile".
    This will create an executable file of the name of the script, that will run Stellaris.
  8. Launch "Stellaris azerty key bindings.exe" to launch the game in AZERTY mode

Note :
  • Run, "steam://rungameid/281990" :  to get this, you just need to right click, properties on the Stellaris shortcut from Steam.
  • IfWinActive, uncommenting and setting the proper keyword (like Stellaris) would limit the keybinding to the Stellaris game.
    With this commented, the keybinding are changed for the whole system, and you have to kill the "Stellaris azerty key bindings.exe" process to revert back.
    I'll test later, for now, I want to play ;)
  • It only change zqwa keys for now, I'll update the script if more is needed

Tuesday, 29 October 2013

Using a PC Keyboard layout on Mac OS X Mavericks

Hopefully they don't sell it... I've switched to Mac at the beginning of this year, and the one thing that did annoy me the most is the keyboard layout...

I know by heart the PC keyboard, I can type and code without watching the keyboard or the screen.

Now I'm using a Mac and VMware Fusion to run Linux or Windows images and when you're in the virtual machine, the keyboard layout switch from Mac to PC layout...  It was just a nightmare as the two keyboard layout are close except on the special characters so useful to developers ({[]}) \/!- etc...

Until now, I used PCKeyboardHack and KeyRemap4Macbook that allow me to have almost a PC Keyboard layout on my Mac and I thank them very much for that !

With the Mavericks update, which is free from the App Store, I've notice a French Flag in the upper right corner of my screen... So I did click on it, then click on "Open Keyboard Preferences", by curiosity I clicked on "+" on the lower left corner to add a keyboard layout...

I was dreaming of a PC layout, so I just type "PC" in the search field and it shown a list of Flag, French one included... I clicked on the French and Houurraaaaa it's a PC Keyboard layout...


So I clicked on Add and I was now able to switch to this PC keyboard :


 And the good thing is that I don't need to switch back to the original Mac Keyboard layout in VM Ware Fusion :)


EDIT : I'm using Quartz to have an X11 server on Mac, to be able to launch linux graphical application remotely... and it appears for some reason that it do not uses the "PC" Version, annoying when you try to type a password in a graphical application ;)

Friday, 20 April 2012

Bypass email server filtering provided you have a JDK installed

A few days ago I was facing a funny issue at a client :
  • No usb key access
  • Only CDROM Drive, but I replaced my laptop CDROM by an hardrive
  • Mail attachment agressively scanned and filtered
So the project binaries I had to deliver (that contains .bat files, .jar, which are likely to cause the rejection) was rejected by the mail server.

So I had the idea to make a base64 encoding of the zip file, zip the text resutlt and send it by email...
and it did work ;)

The only requirement is to have a JDK on the traget machine.
I found this sample of code as a start : 

http://www.xinotes.org/notes/note/736/

I used the SUN.MISC version as it's shipped with the JDK and requires no additional jar.

So Open a text editor, paste the following code : 

import java.io.*;
import sun.misc.BASE64Encoder;

public class EncodeFileWithBase64 {
    public static void main(String[] args) throws Exception {
 if (args.length < 2) {
     System.out.println("Usage: java EncodeFileWithBASE64 <inputfile> <outputfile>");
     return;
 }

 String inputFile = args[0];
 String outputFile = args[1];

 BASE64Encoder encoder = new BASE64Encoder();
 encoder.encode(
     new FileInputStream(inputFile),
     new FileOutputStream(outputFile)
 );
    }
}

Save it in EncodeFileWithBase64.java

Open another text editor and paste the following code :

import java.io.*; 
import sun.misc.BASE64Encoder; 
import sun.misc.BASE64Decoder; 
  
public class DecodeFileWithBase64 { 
    public static void main(String[] args) throws Exception { 
        if (args.length < 2) { 
            System.out.println("Usage: java DecodeFileWithBASE64 <inputfile> <outputfile>"); 
            return; 
        } 
  
        String inputFile = args[0]; 
        String outputFile = args[1]; 
  
        BASE64Decoder decoder = new BASE64Decoder(); 
        
        decoder.decodeBuffer(new FileInputStream(inputFile), 
        new FileOutputStream(outputFile)); 
        
    } 
} 

And save it to DecodeFileWithBase64.java
Copiy also a small .rar file to make a test so that we can test the integrity of the process


C:\temp\base64>dir
 Volume in drive C is SSD 150GB
 Volume Serial Number is E4B6-8C1D

 Directory of C:\temp\base64

20/04/2012  22:06    <dir>          .
20/04/2012  22:06    <dir>          ..
20/04/2012  22:05               613 DecodeFileWithBase64.java
19/04/2012  23:36               484 EncodeFileWithBase64.java
20/04/2012  22:12           127 025 etc1tool.rar
               3 File(s)        268 873 bytes
               2 Dir(s)  13 491 298 304 bytes free

C:\temp\base64>c:\dev\jdk1.6.0_25\bin\javac.exe *.java
DecodeFileWithBase64.java:2: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release
import sun.misc.BASE64Encoder;
               ^
DecodeFileWithBase64.java:3: warning: sun.misc.BASE64Decoder is Sun proprietary API and may be removed in a future release
import sun.misc.BASE64Decoder;
               ^
EncodeFileWithBase64.java:2: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release
import sun.misc.BASE64Encoder;
               ^
DecodeFileWithBase64.java:15: warning: sun.misc.BASE64Decoder is Sun proprietary API and may be removed in a future release
        BASE64Decoder decoder = new BASE64Decoder();
        ^
DecodeFileWithBase64.java:15: warning: sun.misc.BASE64Decoder is Sun proprietary API and may be removed in a future release
        BASE64Decoder decoder = new BASE64Decoder();
                                    ^
EncodeFileWithBase64.java:14: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release
        BASE64Encoder encoder = new BASE64Encoder();
        ^
EncodeFileWithBase64.java:14: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release
        BASE64Encoder encoder = new BASE64Encoder();
                                    ^
7 warnings

C:\temp\base64>
C:\temp\base64>dir
 Volume in drive C is SSD 150GB
 Volume Serial Number is E4B6-8C1D

 Directory of C:\temp\base64

20/04/2012  22:07    <dir>          .
20/04/2012  22:07    <dir>          ..
20/04/2012  22:07               812 DecodeFileWithBase64.class
20/04/2012  22:05               613 DecodeFileWithBase64.java
20/04/2012  22:07               806 EncodeFileWithBase64.class
19/04/2012  23:36               484 EncodeFileWithBase64.java
20/04/2012  22:12           127 025 etc1tool.rar
               5 File(s)        270 491 bytes
               2 Dir(s)  13 490 741 248 bytes free

C:\temp\base64>

Warning are normal are these class are not supposed to be used.

Now make a test :

C:\temp\base64>java EncodeFileWithBase64 etc1tool.rar etc1tool.rar.txt

C:\temp\base64>dir
 Volume in drive C is SSD 150GB
 Volume Serial Number is E4B6-8C1D

 Directory of C:\temp\base64

20/04/2012  22:15              .
20/04/2012  22:15              ..
20/04/2012  22:07               812 DecodeFileWithBase64.class
20/04/2012  22:05               613 DecodeFileWithBase64.java
20/04/2012  22:07               806 EncodeFileWithBase64.class
19/04/2012  23:36               484 EncodeFileWithBase64.java
20/04/2012  22:12           127 025 etc1tool.rar
20/04/2012  22:15           173 824 etc1tool.rar.txt
               6 File(s)        303 564 bytes
               2 Dir(s)  13 488 807 936 bytes free

C:\temp\base64>
check the produce file, it's a text file :
UmFyIRoHAJvXc0gADQAAAAAAAAB4DXSAgCwAyucBAAAWBAACtdHsHZtGfkAdNQwAIAAAAGV0YzF0
b29sLmV4ZRglkRTMyNmcGCJXxjicFBoBgOEZIy2BZKQBsJSxkZam3G3AI6JNDbhAYFtK67LAs8gl
...
Kvxhs8e6Pi+mM5R3mynJQuXpCFu5svGg1zFS/peYfl2J/Cbr3TZDIsMOJ4SXDwRK9CHm7q8iruk5
E/Rs2mZWjv9Wkiner6lw+Bj3pSb3i8Q9ewBABwA=
Decode the produced file :
C:\temp\base64>java DecodeFileWithBase64 etc1tool.rar.txt etc1tool_decoded.rar

C:\temp\base64>dir
 Volume in drive C is SSD 150GB
 Volume Serial Number is E4B6-8C1D

 Directory of C:\temp\base64

20/04/2012  22:20              .
20/04/2012  22:20              ..
20/04/2012  22:07               812 DecodeFileWithBase64.class
20/04/2012  22:05               613 DecodeFileWithBase64.java
20/04/2012  22:07               806 EncodeFileWithBase64.class
19/04/2012  23:36               484 EncodeFileWithBase64.java
20/04/2012  22:12           127 025 etc1tool.rar
20/04/2012  22:15           173 824 etc1tool.rar.txt
20/04/2012  22:20           127 025 etc1tool_decoded.rar
               7 File(s)        430 589 bytes
               2 Dir(s)  13 486 784 512 bytes free

C:\temp\base64>
Open the produced file and check for error :



No error !
Now you can send it by mail, it will pass as the mail gateway will only see an archive with text inside...

Wednesday, 9 November 2011

Is Blackberry platform starting to die ?

Google has announced the deprecation of the Gmail application on blackberry...

Still usable but won’t be supported or improved anymore...

The ersatz is the gmail.com which is far from offering the same level of functionality, like "new mail notification"... without this last functionality, Gmail is useless... Or the phone is...

This is severe drawback for blackberry users, and maybe we can see a sign of the end of the Blackberry... And that Google, with the buyout of Motorola, tries to kill a serious opponent...      

The blackberry phones are great, even if the current “App World” plateform is far behind the Android Market (or iPhone one).

My plan for dropping the HTC Desire HD (the worst phone I ever possessed) and switching to Blackberry needs some second thought... anyway, keeping the HTC is out of question...

The official announcement of google :



Tuesday, 17 May 2011

Google Chrome complaining about Flash plugin being too old...


It's been quite some time that my google chrome was complaining about flash plugin beeing too old while I can see it updated regularly.

I've been able to get rid of this message by deleting the old version on my system :

thomas@daisybox:/opt/google/chrome$ locate libflashplayer.so
/home/thomas/.mozilla/plugins/libflashplayer.so
/home/thomas/.mozilla_backup_2009-08-13T21:48:02+0200/plugins/libflashplayer.so
/usr/share/ubufox/plugins/npwrapper.libflashplayer.so
/var/lib/flashplugin-installer/npwrapper.libflashplayer.so

thomas@daisybox:/opt/google/chrome$ rm -rf /home/thomas/.mozilla_backup_2009-08-13T21:48:02+0200/plugins/libflashplayer.so 


thomas@daisybox:/opt/google/chrome$ ll /home/thomas/.mozilla/plugins/libflashplayer.so
-rwxr-xr-x 1 thomas thomas 9543400 2009-04-11 00:16 /home/thomas/.mozilla/plugins/libflashplayer.so

thomas@daisybox:/opt/google/chrome$  ll /var/lib/flashplugin-installer/npwrapper.libflashplayer.so
-rwxr-xr-x 1 root root 121992 2011-05-17 01:21 /var/lib/flashplugin-installer/npwrapper.libflashplayer.so

thomas@daisybox:/opt/google/chrome$ ll /usr/share/ubufox/plugins/npwrapper.libflashplayer.so
lrwxrwxrwx 1 root root 58 2011-05-17 01:21 /usr/share/ubufox/plugins/npwrapper.libflashplayer.so -> /usr/lib/flashplugin-installer/npwrapper.libflashplayer.so
thomas@daisybox:/opt/google/chrome$ 
thomas@daisybox:/opt/google/chrome$ rm /home/thomas/.mozilla/plugins/libflashplayer.so

Restarts browsers and no more annoying message about flash.

Monday, 31 May 2010

Android Phone locked out - how to unlock it without Hard resetting it

I was watching heroes season 3, playing with the unlock schema of my phone (Android(1.6) HTC Magic) drawing strange pattern until I locked it down.

The phone shows a message : wait 30 seconds until next try (translated from french).

I did hit by mistake the recovery button which lead me to a login form asking me for username and password to unlock the device.

My phone is set-up with my google apps account 'login'@mansonthomas.com.

I've tryed everything and it fails to unlock telling me 'wrong username or password'...

For example I've tryed : login@mansonthomas.com, login, my other gmail address with and without the @gmail.com...

I've googled and find why it won't works :

Apparently, the phone needs a wifi internet connection so that the login/password check passes. It's plausible as the login failure is instantaneous while it should take some time to check your password over the internet through a 3G connection

it's said here by ladygrant87 :

http://www.google.com/support/forum/p/Google+Mobile/thread?tid=66fb49eae3015c6b&hl=en&fid=66fb49eae3015c6b000487d837

but the given solution won't work for me : call yourself, pickup, send you a mail, get it for the drop down menu(top of the screen), click the link, activate wifi, try login/password again to get it unlocked.

I couldn't get the drop down menu.

Any other solution fails (which involve playing with home/menu physical buttons) expect this one which do not involve an Hard Reset of the phone :

type your login address that you use to configure your phone without the @domain.tld extension and as password type the 'null' string without quotes.
(big big security hole btw !)


For example, if you use a gmail.com address  like toto@gmail.com, type :

toto
null

if you use a google apps mail account like login@mansonthomas.com, type :

login
null


Then it ask a new lock schema. Once it's done, your phone works as before.

(Even if I use mylookout.com solution for backup I didn't want to hardreset !)

sources:

Thursday, 27 May 2010

Thecus NAS N4100Pro




I've purchased a year and a half ago a NAS from Thecus. It's the N4100Pro model which you can see on the right.




The purpose of this post is to tell how I'm satisfied with my Thecus NAS !

It's so rare that the product is good and the support by the company is so good that It needs to be shout ! ;)
Usually, what you can read on internet is complains, issue...

Here it's just about satisfaction !

First, the installation and setup was easy, the features was here and working.
Ok it's what I've paid for...

But I've been quite surprised that Thecus was actually updating the firmware and adding functionality regularly which gives some new functionality, new user interface.

Just compare this situation to Sony :  I've bought a laptop half a year ago, with windows vista. I've upgrade to windows 7 :  they offer no support for windows 7 at all for my laptop. No driver, no help. The result : My laptop battery hold 1 hour max. The webcam do not work...

There is plenty of other lack of support : My old mobiles (sony Z5, siemens, samsung U600): very few or no firmware update.

My Current HTC Magic, I'm stuck with Android 1.6 and I can only drool over Android 2.1/2.2...

But let's get back to Thecus.

They've switch the user interface in a major firmware upgrade (2.x to 3.x) to ExtJS which end to a very user-friendly interface, and they recently upgrade it again and it's even nicer, with a flash login interface ! (if no flash is available, a standart interface will replace it)

A module system, which is share with many other products allow to add functionnality to the NAS :


Item Version Date Download
NZB module (wget download style) v1.0.0 2010.04.15
USB & eSATA schedule backup module v1.01 2010.03.05
RAID Volume Replication module v1.0 2010.03.05
Twonky media server module v1.0 2010.03.05
DLM2 module (Bit Torrent Client, FTP Client,
eMule Client)
v1.0.9 2009.10.06
MySQL module v1.00.02 2009.09.23
Web Server module v1.0.4 2009.09.23
Bi-directional USB copy module v1.0.3 2009.09.23
IP CAM module v2.0.1 2009.09.23
Even some modules from 5200PRO are compatible, see this link. Noteworthy : SSH Deamon !


And finally, they've got a JIRA style support interface (it uses http://www.kayako.com/ software and it's very nice) where you can get help or ask for feature request. They do respond like normal brained human ;)

Here is some screenshots of the web interface  :




Some resources :
Note : unsponsored blog post... I'm really happy with this product and the company!

    Wednesday, 26 May 2010

    Bacula upgrade while updating ubuntu to 10.04

    When you update your ubuntu to 10.04, the upgrade process forgets to update the bacula database which ends with this in bacula logs :

    02-May 17:39 bacula-dir JobId 0: Fatal error: Version error for database "bacula". Wanted 12, got 10
    02-May 17:39 bacula-dir JobId 0: Fatal error: Could not open Catalog "MyCatalog", database "bacula".
    02-May 17:39 bacula-dir JobId 0: Fatal error: Version error for database "bacula". Wanted 12, got 10
    02-May 17:39 bacula-dir ERROR TERMINATION
    Please correct configuration file: /etc/bacula/bacula-dir.conf
    

    to correct this you need to run manuall two SQL scripts to upgrade the database (extracted from sources of bacula).


    First you need to edit ~/.my.cnf so that 'mysql' command use this file to connect to the database :

    [client]
    user=root
    password=YOU_MYSQL_ROOT_PWD_HERE
    protocol=tcp

    or change the scripts so that

    this line :

    if $bindir/mysql $* -f <<END-OF-DATA

    is changed to this line :

    if $bindir/mysql -uroot -p $* -f <<END-OF-DATA



    here is this scripts you need to upgrade the database :

    upgrade-v10-to-v11.sh

    upgrade-v11-to-v12.sh

    Download theses files on your server, review what changes it brings (you should always check these kind of things found on internet ;)
    edit these files to update the bacula database name

    db_name=bacula

    and run it :

    root@home:~/upgradeBacula# ./upgrade-v10-to-v11.sh
    
    This script will update a Bacula MySQL database from version 10 to 11
     which is needed to convert from Bacula version 2.0.x to 3.0.x or higher
    
    Update of Bacula MySQL tables succeeded.
    root@home:~/upgradeBacula# ./upgrade-v11-to-v12.sh
    
    This script will update a Bacula MySQL database from version 11 to 12
     which is needed to convert from Bacula Enterprise 2.6 to 4.0 or
     Standard version 3.0 to 5.0
    
    Update of Bacula MySQL tables succeeded.
    

    Next, try to start bacula :

    sudo service bacula-director start
    sudo service bacula-fd       start
    sudo service bacula-sd       start
    

    you should now be able to connect with bconsole and run a job !


    This post was written based on information found on this bug report : https://bugs.launchpad.net/ubuntu/+source/bacula/+bug/579924

    Tuesday, 11 May 2010

    Ubuntu 10.04 : Install and set Sun JDK as default

     
    Since ubuntu 10.04, Sun JDK has been dropped and replaced by openjdk.
    Literally replaced, ie : Sun JDK remove, openjdk installed.

    This is performed during the upgrade without explicitly asking you for your consent...
    which is quite ugly... After the upgrade, my tomcat was not working anymore...

    Anyway, in order to install Sun JDK back you just have to :
    vi /etc/apt/sources.list
    and check if the following line is present :
    deb http://archive.canonical.com/ lucid partner
    if not, add it at the end of the file.
    then run
    sudo aptitude update

    to get the package list from the new repo.
    and then run :
    sudo aptitude install sun-java6-jdk
    but after that, if you run java -version, it's still the openjdk version.

    thomas@daisybox:/usr/lib/jvm/java-6-sun$ java -version
    java version "1.6.0_18"
    OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
    OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
    
    thomas@daisybox:/usr/lib/jvm/java-6-sun$ which java
    /usr/bin/java
    thomas@daisybox:/usr/lib/jvm/java-6-sun$ ll /usr/bin/java
    lrwxrwxrwx 1 root root 22 2010-05-11 23:44 /usr/bin/java -> /etc/alternatives/java
    thomas@daisybox:/usr/lib/jvm/java-6-sun$ ll /etc/alternatives/java
    lrwxrwxrwx 1 root root 40 2010-05-11 23:44 /etc/alternatives/java -> /usr/lib/jvm/java-6-openjdk/jre/bin/java

    You could try to remove openjdk, but you'll hit some annoying dependency issue.

    Instead of removing you can configure the system to default to Sun JDK


    thomas@daisybox:~$ sudo update-alternatives --config java
    There are 2 choices for the alternative java (providing /usr/bin/java).
    
      Selection    Path                                      Priority   Status
    ------------------------------------------------------------
    * 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode
      1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
      2            /usr/lib/jvm/java-6-sun/jre/bin/java       63        manual mode
    
    Press enter to keep the current choice[*], or type selection number: 2
    update-alternatives: using /usr/lib/jvm/java-6-sun/jre/bin/java to provide /usr/bin/java (java) in manual mode.
    
    thomas@daisybox:/usr/lib/jvm/java-6-sun$ ll /etc/alternatives/java
    lrwxrwxrwx 1 root root 36 2010-05-11 23:48 /etc/alternatives/java -> /usr/lib/jvm/java-6-sun/jre/bin/java
    
    thomas@daisybox:~$ java -version
    java version "1.6.0_20"
    Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
    Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)



    Or more directly like "Daniel Bos" suggest in the comments :

    sudo update-java-alternatives -s java-6-sun



    image taken from : http://www.sucka.net/2010/04/jdk-linux-update-script/