Tuesday, February 16, 2016

EC2 instance RIP 21/Sep/2011 to 15/Feb/2016

My ec2 t1.micro instance just die on me. , cause: uninstall without removing init config, after restarting it gone the lord side :'(

very sad, especially it happen in the midst of projects rushing, beside re-setup project on new ec2, i need to figure out how to spend my remaining t1.micro reserve time, as t1.micro is no longer available

together with my t1.micro instance is my favourite ip address 107.20.154.29, as classic elastic ip can't be used in vpc

Wednesday, March 20, 2013

Another step forward

I have resigned from my day job to pursue my dream, many think that it is impossible, some think that i was doing something beyond my capabilities, blindly follow the success stories.
but this blog remind me how long i have the dream to create product that truly believe by me that it will be useful by others. i have create quite number of software product but none of them are useful to mankind, now it the time test my judgement and skills. bless me please

Friday, October 26, 2012

I saw her again

I saw her again, still the same, still pretty as usual. she was looking for me, i could see the anxiety on her face. for the first time she was anxiety because of me and her smile when she found me, i felt so happy, so lucky.

Tuesday, June 5, 2012

Linux on pen drive

Recently I have been traveling quite a lot. and for ease of project development with different machines, i decided to try "mobile workstation" aka linux-os-in-a-pen-drive. It should be easy at first thought but the outcome was quite the opposite, that's why i decided to write down my finding so far.

Ingredient:

  1. UNetbootin
  2. a 8 GB pen drive
  3. a netbook, samsung n220

Desired outcome:

  • linux boot from pen drive
  • linux run on memory only, after booting the pen drive is free to remove
  • fast bootup time
  • able to detect network hardware
  • able to ssh to remote server
  • able to save changes to pen drive


Test Results:

  • SliTaz - small foot print, and able to run entirely on ram, claimed by the developer. but failed to boot up my netbook, move on...
  • puppy linux - small foot print, fast boot, run on ram, very responsive. but failed to ssh to remote server, always hung at "entering interactive session", move on...
  • ubuntu - slow to boot, actual took two step to boot, boot to installer then boot to live mode. yack. move on...
  • fedora - ok boot up time, able to ssh, but able to save changes back to pen drive??? really? move on...
  • xPud - fast boot up time, run on ram, very simple UI, responsive, but fail to ssh, same as puppy linux. move on...

Sunday, May 29, 2011

When android project return funny results or findviewbyid return null for no-sense

Most likely is because of the half-boiled eclipse auto-compile resource implementation, your XML files and the compiled resources are not sync. to solve it goto project->clean...

another tips: getDafaultSensor() should pass in Sensor.TYPE_SENSOR_xxxxx not SensorManager.SENSOR_xxxxx. the latter is for the deprecated registerListener(listener, sensor, delay)

Friday, May 6, 2011

How to setup ejabberd clustering

- change /etc/ejabberd/ejabberd.cfg hosts
- sudo ejabberdctl register NEW_ADMIN 192.168.2.xxx P@55w0rd
- change /etc/ejabberd/ejabberd.cfg admin user
- use web admin, make sure you could access the admin panel
- copy /var/lib/ejabberd/.erlang.cookie to all seondary node // might need to restart secondary nodes
- add all node name to /etc/hosts
- stop all secondary nodes
- copy .erlang.cookie to /root/ // use su bash to change to root user or a fresh restart to solve the problem?
- run sudo erl -sname ejabberd -mnesia dir '"/var/lib/ejabberd"' -mnesia extra_db_nodes "['ejabberd@HOSTNAME']" -s mnesia
// crash if ejabberd instance is running and
// /var/lib/ejabberd/ has something in it. BUT .erlang.cookie must maintain in the folder
- mnesia:change_table_copy_type(schema, node(), disc_copies). in the console
- after quitting from console make sure all the new files in /var/lib/ejabberd own by ejabberd.ejabberd
- if hav doubt remove /dev/null from /etc/init.d/ejabberd


Failed to merge schema: Incompatible schema cookies. Please, restart from old backup.'ejabberd@HOSTNAME'
- remove /var/lib/ejabberd/ content ** except .erlang.cookie

USEFUL PATH
================
/var/lib/ejabberd/ - database and .erlang.cookie. ejabberd home directory
/etc/ejabberd/ejabberd.cfg - ejabber configuration file
/usr/sbin/ejabberdctl - controller
/var/log/ejabberd/ - log folder
/usr/lib/ejabberd/ebin/ - plugin folder

USEFUL LINKS
=================
- http://www.process-one.net/docs/ejabberd/guide_en.html#ejabberdctl
- http://jabber.nes.ru/logs/ejabberd@conference.jabber.ru/2006/01/09.html // ejabberd must stop and db must clean before running erl -sname ejabberd
- http://tdewolf.blogspot.com/2009/07/clustering-ejabberd-nodes-using-mnesia.html // point 8, ejabberdctl.cfg modification is obsolete

Monday, May 2, 2011

Simple JSON parser

I have written a simple json parser in actionscript. i re-create a wheel because the one in as3corelib is too complicated for me. this is pretty straight forward, it does single pass parsing, convert JSON text into ActionScript Object. currently it supported string, object and array only. i think it is good enough for configuration purposes. so enjoy :)

/**
* Simple JSON parser. this parser does a single pass translation of JSON to
* Actionscript string, array and object. no int and float support yet and no error checking
* as well. but this parser does support nested object and array
* @param content JSON text
* @param stack parser
* @param parent Parent Object or Array depends on context
* @return Object Actionscript object that represent the JSON (content)
*/
private function parse(content:String, stack:Vector., parent:Object):Object {
var ret:Object;
var curr:uint = stack[CFG_POS];
var type:String = content.charAt(curr);
++curr;
stack[CFG_POS] = curr;
switch(type) {
case OPEN_BRACKET_OBJECT:
// push the new stack
stack.unshift(TYPE_OBJECT);
stack.unshift(PART_KEY);
stack.unshift(curr);
ret = new Object;
while(stack[CFG_TYPE] == TYPE_OBJECT){
ret = parse(content, stack, ret);
}
// pop the old stack
curr = stack.shift();
stack.shift();
stack.shift();
stack[CFG_POS] = curr;
break;
case CLOSE_BRACKET_OBJECT:
stack[CFG_TYPE] = NA; // stop the object's while loop
ret = parent;
break;
case OPEN_BRACKET_ARRAY:
// push the new stack
stack.unshift(TYPE_ARRAY);
stack.unshift(PART_VALUE);
stack.unshift(curr);
ret = new Array;
while(stack[CFG_TYPE] == TYPE_ARRAY){
ret.push(parse(content, stack, ret));
}
ret.pop(); // pop out the unwanted last null set by CLOSE_BRACKET_ARRAY
// pop the old stack
curr = stack.shift();
stack.shift();
stack.shift();
stack[CFG_POS] = curr;
break;
case CLOSE_BRACKET_ARRAY:
stack[CFG_TYPE] = NA; // stop the array's while loop
ret = null;
break;
case BRACKET_ITEM:
stack[CFG_POS] = content.indexOf(BRACKET_ITEM, curr) + 1;
if (stack[CFG_PART] == PART_KEY){
parent[content.substring(curr, stack[CFG_POS]-1)] = parse(content, stack, parent);
ret = parent;
}else{
ret = content.substring(curr, stack[CFG_POS]-1);
}
break;
case SEPARATOR_KEY_VALUE:
stack[CFG_PART] = PART_VALUE;
ret = parse(content, stack, parent);
break;
case SEPARATOR_STATEMENT:
if (stack[CFG_TYPE] == TYPE_OBJECT)
stack[CFG_PART] = PART_KEY;
else
stack[CFG_PART] = PART_VALUE;
ret = parse(content, stack, parent);
break;
}
return ret;
}