Tuesday, December 30, 2014

Set different language/locale to certain app on Mac

Just because my Mac default language is Japanese does not mean I like all apps to be Japanese language, especially when it is incomplete or roughly translated one. An example is Gramps.

This is how to set the language/locale to English:

$ defaults write -app Gramps AppleLanguages "(en, jp)"
$ defaults write -app Gramps AppleLocale "en_US"
$ defaults write -app Gramps AppleCollationOrder "en"

Voila, now the ugly Japanese interface is gone for the app.

Monday, December 29, 2014

Time Machine using NAS on Mavericks

Just typing this on Terminal.app does not seem to work anymore.

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

So here is how I made it to work on Mavericks.

1. Execute the usual command above:
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

2. Create image file on local disk first because creating directly on NAS will fail
The image file naming seems important: name it [hostname]_[MACaddress] (the MAC address is without colons). So if the Mac's hostname is "mbp" and its MAC address is 12:34:56:78:9a:bc, then the file name will be mbp_123456789abc
You can check the hostname from Sharing settings.
Create the image as hard disk and of type sparse bundle. The size can be set anything, e.g., 100MB. Set volume name to arbitrary name, for example TimeMachine.

3. Copy the image file to NAS and expand it to the size you need for Time Machine, for example 300GB. Turn off Time Machine first because resizing seems to be always reset by Time Machine when it is on.
Use Disk Utilities to resize, or use hdutil from Terminal:
hdiutil resize -size 300g /Volumes/Backup/mbp_123456789abc.sparsebundle

4. Mount the image and initialize
Mount the image and initialize. The mount point, for example /Volumes/TimeMahine.

5. Set the volume as Time Machine destination
Now at this point even if you open Time Machine settings the volume won't show up. You have to set it from Terminal:
sudo tmutil setdestination /Volumes/TimeMachine

6. You are ready to start backing up using Time Machine!

Reference

Thursday, September 18, 2014

d3 uses createWindow but latest jsdom removed it?

I was trying to use d3 with node.js. It seems that d3.js uses createWindow but latest jsdom removed it, so it gave error like:
 "Object [ null ] has no method 'createWindow' d3"
In jsdom's changelog it was mentioned that jsdom.createWindow was among removed jsdom APIs in version 1.0.0-pre.1. BTW, latest version of jsdom as of this writing is 1.0.0-pre.6, so a default installation of jsdom via "npm install jsdom" will not contain support for createWindow.
Hence, it seems that to run d3.js, older jsdom must be used, i.e., version 0.11.1 which is the latest version before 1.0.0-pre.1:
sudo npm remove jsdom 
sudo npm install jsdom@0.11.1

Monday, September 15, 2014

Analyzing contribution level to a git repository

I wondered if there is a handy tool for analyzing contribution level to a git repository, and found this: gitinspector and gitstats.

gitinspector
Once you got python installed, you can fire it with command like this:
./gitinspector.py -wTHl --format=htmlembedded --file-types=cs,cshtml,js,css  /path/to/git/repo/ >/path/to/resultdir/result.html

This will produce an HTML report
More options can be found here.

gitstats
If python is ready, on Mac another install is necessary, i.e., gnuplot. The easiest way is to use MacPorts to install it, by simply doing "sudo port install gnuplot".
Then run gitstats with command like this:

./gitstats /path/to/git/repo/ /path/to/resultdir/result

Thursday, February 13, 2014

Force installing apps to SD Card on Android

It was about time for me to actually use the lowly Android smartphone I bought about a year ago, i.e., the LG. Then I started to install Skype, Whatsapp, Line, and some other must-have apps, only to find out that many failed to install because I got no space :O

Yeah, the handset has only like 100MB or so space, but I got 1GB on SD Card, why can't I install the apps directly to it? The answer is, I simply can't. Stuck. Now I understand why Android is just about numbers, not usability. Its marketshare can be no.1 in the world of smartphones, but a very large percentage of it is probably junk.

So what, am I going to give this up as junk?

Luckily, though not for the faint of heart, with the debugger in Android SDK, it can be set to install app to SD Card by default.

On Mac, install Android SDK, open terminal, connect the Android device which is already set to USB debugging mode, go to the directory where Platform Tools are, then type:

adb devices

It should show the device ID-like data.

Then type the following to start the shell:

adb shell

Then finally set default installation destination to SD Card:

pm set-install-location 2 

Voila, now I can install the apps from Google Play, and it will install to SD Card. After installation, set it back to up to system:

pm set-install-location 0

Reference:
http://techgage.com/article/moving_your_non-movable_android_apps_to_an_sd_card/

Thursday, January 9, 2014

git commands for svn users


git commands for svn users:
http://blog.cyclogy.com/2011/05/05/git_subversion/

Well, actually I just wanted to know how to make my local repo up to date and at the same time disposing any changes on local repo, and here is the git command for it:

git clean -d -x -f
This will remove untracked files, including directories (-d) and files ignored by git (-x). Replace the -f argument with -n to perform a dry-run or -i for interactive mode and it will tell you what will be removed.