2013年2月22日 星期五

[Html][CSS] Image has strange border in Chrome

if you set border = 0 still got a strange border in Chrome, then is will help you to fix it.
The problem cause by only setting background-image in css file.

Solution : don't let , put something inside the src.

2013年2月17日 星期日

[Node.js][Javascript] Print javascript object

var obj = {a:'a', b:'b'};
console.log( JSON.stringify(obj, null, 4) );

This will print the object content with json format and indent = 4.

2013年2月15日 星期五

[Node.js] node-expat, XML parser for node.js

node-expat, if you like to use libxml, this is a simular module for you, in their test.js file, they have many examples for using it. Here is a simple example for it.

var expat = require('node-expat');
var parser = new expat.Parser('UTF-8');


var text = '';

// start point for parsing one tag
parser.addListener('startElement', function(name, attrs) {
   // name : name for this tag
   // attrs : attributes in this tag
});

// Get the value for one tag
parser.addListener('text', function(s) {
   // s : value for this tag
});

// end point for parsing one tag
parser.addListener('endElement', function(name) {
   // name : name for this tag
});

// start to parse
parser.parse(str);


Reference :
node-expat github : https://github.com/astro/node-expat
discussion about html parser : http://stackoverflow.com/questions/7977945/html-parser-on-nodejs

2013年2月10日 星期日

[Node.js] GraphicsMagick for node.js, install on MacOS

GraphicsMagick for node.js, this is a powerful framework. It's based on many different frameworks, so, that first and hardest one we need to do, is to install it.

1. Download Command tools for MacOS, if you don't have gcc compiler

2. Download libpng-1.4.7.tar.gz. For displaying PNG image, and install it with :
     1. ./configure
     2. make && sudo make install

3. Download libjpeg-6b.tar.bz2. For displaying JPEG image, and install it with :
     1. ./configure
     2. make && sudo make install

4. Visit their home page : http://www.graphicsmagick.org/, download GraphicsMagick-1.3.17.tar.bz2. and Install it with :
     1. ./configure CC=clang
           (*NOTE*, I got Undefined symbols for architecture x86_64 because I didn't add CC=clang, and cause lots of time, if you got the same problem, please remember to add it)
           After run the configure, it'll show the result for it, you'll need these two as yes.
              JPEG v1   --with-jpeg=yes    yes(Need to install jpeg delegate library)
              PNG       --with-png=yes     yes(Need to install png delegate library)

     2. make && sudo make install

5. In node.js, put the following code :
     var gm = require('gm');
     gm('image.jpg').size(function(err, value){
          if(err) return;
          console.log(value);
     }




If you still get any problems or found something wrong in this post, please feel free to tell me. :)


Reference :

https://github.com/rsms/node-imagemagick
http://aheckmann.github.com/gm
http://rritw.com/a/bianchengyuyan/C__/20130201/301529.html
http://qing.weibo.com/1838939461/6d9bfd4533000j33.html

2013年2月9日 星期六

[Mac] Command Line Tools for Xcode

If you need gcc or other default tools ( gcc: command not found ), just download Command Line Tools for Xcode, it's maintained by Apple developer center, and easy to install.

Downloads for Apple Developers : https://developer.apple.com/downloads/index.action
Reference : http://www.mkyong.com/mac/how-to-install-gcc-compiler-on-mac-os-x/