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.

Sunday, December 29, 2013

Write and display Batak script on Mac


Batak font used to be just another ASCII font with Batak script rendering. But it got place in Unicode and it is a "real" font now. Download it from Uli Kozok's site.

After you installed the font, you will be able to see this in Batak script: ᯂᯬᯒᯀ᯲
You will also see Batak script on sites like this: http://www.alanwood.net/unicode/batak.html

Now that it is a real font, typing on ASCII keyboard won't work anymore. A special keyboard mapping is necessary. For Mac, get the keyboard mapping from this Michael Everson's site.

Installing a Batak keyboard layout on the Mac OS:

1) Download the Mac OS Batak keyboard layout package. (The files are inside the folder “Batak-Mac-Keylayout”, which is compressed in .zip format.)
2) Install the keyboard layout by dragging it (the .keylayout and the .icns files, not their enclosing folder) to ~/Library/Keyboard Layouts.
3) To use a keyboard layout, activate it at System Preferences > International > Input Menu.


Saturday, April 13, 2013

Using exiftool to rename pictures from digital camera

Lots of pictures taken with digital camera (including the ones in smartphones)... so I need a way to at least easily identify when a particular picture is taken, and exiftool comes in handy.

First, create a file named .ExifTool_config at user's root directory containing something like the following:


%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyModel => {
            Require => 'Model',
            # translate spaces to underscores
            ValueConv => '$val =~ s/Canon DIGITAL IXUS v2/IXUSV2/; $val =~ s/KODAK DX4330 DIGITAL CAMERA/DX4330/; $val =~ s/C860L,D360L/C860L/; $val =~ s/Canon IXY DIGITAL 320/IXY320/; $val =~ s/ |-//; $val =~ s/(.*)/uc($1)/e; $val',
        },
        MyMake => {
            Require => 'Make',
            # translate spaces to underscores
            ValueConv => '$val =~ s/EASTMAN KODAK COMPANY/KODAK/; $val =~ s/OLYMPUS OPTICAL CO.,LTD/OLYMPUS/; $val =~ s/CASIO COMPUTER CO.,LTD/CASIO/; $val =~ s/ |-//; $val =~ s/(.*)/uc($1)/e; $val',
},

    },
);
1;  #end

Then run the following command:


exiftool -d %Y%m%d-%H%M%S '-FileName<${CreateDate}-${mymake}${mymodel}.%e'

File names of images files on will become like the following:

20040228-133116-CASIOEXS20.jpg

Use "c" to add counter, like below:

exiftool '-FileName<${DateTimeOriginal}_$Model.%e' -d %Y-%m-%d_%H-%M-%S%%-.c 

Rerences:
http://www.sno.phy.queensu.ca/~phil/exiftool/
http://www.sno.phy.queensu.ca/~phil/exiftool/faq.html#Q11


Monday, February 18, 2013

Metadata for image file

How many standards are there for embedding metadata into image files?

We usually hear Exif, IPTC and XMP, but when we mean standards related to metadata, it turns out to be more complex. There are Exif, DCF, IPTC-IIM, XMP (a.k.a IPTC Core), and FlashPix. Some standards are not just about metadata, but also among others how to save image files on digital camera.

Here are some standards that I found out so far:
Exif 1 (standardized by JEIDA)
Exif 2 (standardized by JEITA in 1997) *JEIDA changed name to JEITA
Exif 2.1 (standardized by JEITA in 1998)

DCF JEITA in 1999) *This is Exif 2.1+CIFF

Exif 2.2 (standardized by JEITA in 2002)
Exif 2.3 (standardized by JEITA+CIPA in 2010)
FlashPix
IPTC-IIM (standardized by IPTC in 1994) *descriptive metadata only, for JPEG only, largely superseded by XMP

XMP  any file 2001 (standardized by Adobe in 2001) *a.k.a. IPTC Core

Links to standards:
IPTC (Information Interchange Model (IIM))
http://en.wikipedia.org/wiki/IPTC_Information_Interchange_Model
XMP
http://en.wikipedia.org/wiki/Extensible_Metadata_Platform
Exif
http://en.wikipedia.org/wiki/Exchangeable_image_file_format
Design rule for Camera File system
http://en.wikipedia.org/wiki/Design_rule_for_Camera_File_system

References:
http://en.wikipedia.org/wiki/Exchangeable_image_file_format#FlashPix_extensions
http://gcoupe.wordpress.com/2011/12/10/picasa-versus-windows-live-photo-gallery/
http://www.controlledvocabulary.com/blog/top-metadata-myths.html