Monday, November 26, 2012

Re-route default BHM remote tun0

Apparently the route list is locked by the new-terminated remote access via
openvpn. And these are the steps to release our current ip and to set
the default gateway to current.

10.0.4.0             192.168.111.1   255.255.255.0   UG    0      0        0 tun0
10.0.5.0             192.168.111.1   255.255.255.0   UG    0      0        0 tun0
10.0.6.0             192.168.111.1   255.255.255.0   UG    0      0        0 tun0
192.168.2.0       192.168.111.1   255.255.255.0   UG    0      0        0 tun0
10.0.2.0             192.168.111.1   255.255.255.0   UG    0      0        0 tun0
192.168.1.0       192.168.111.1   255.255.255.0   UG    0      0        0 tun0     <<<
192.168.1.0        *                        255.255.255.0   U      2      0         0  wlan0 <<<
10.0.3.0             192.168.111.1   255.255.255.0   UG    0      0        0 tun0
192.168.0.0       192.168.111.1   255.255.255.0   UG    0      0        0 tun0
192.168.111.0   *                         255.255.255.0   U      0      0        0 tun0
default             192.168.1.1        0.0.0.0               UG   0      0        0 wlan0

I've marked down with <<< which are ip overlapping, every packet to
192.168.1.0 will be routed to 192.168.111.1 instead of 192.168.1.1.
And we have to fix this


$ sudo route del -net 192.168.1.0/24 gw 192.168.111.1


Done, hope it helps

Saturday, November 17, 2012

Codeigniter Pass Object through SESSION variable how to

Codeigniter Can not pass Object through SESSION variable

Untuk yg kesulitan pass object dari controller ke view,
via session. Ini obat nya,
// controller file mu, test1.php
// Location: ./system/application/controllers/test1.php
...
  $buffer = array();

  $dummy_object       = new stdClass;
  $dummy_object->name = 'ade1';
  $dummy_object->id   = 'ADEX1';

  array_push($buffer, $dummy_object);

  $dummy_object->name = 'ade2';
  $dummy_object->id   = 'ADEX2';

  array_push($buffer, $dummy_object);

  /**
   * Kalau passing nya spt ini pasti error
   * can't convert object to string
   *
   * $this->session->set_userdata('passed_object', $buffer);
   *
   * Jadi gimana?
   */

  $this->session->set_userdata('passed_object', serialize($buffer));
...
?>

// controller file mu, test2.php
// Location: ./system/application/controllers/test2.php
...
 
  /**
   * utk mengambil kembali data nya dlm object tinggal
   * di unserialize :D
   */
  
  $passed_object = $this->session->userdata('passed_object', unserialize($buffer));
...
?>


Smoga obat nya ampuh.

Coding for life, coding with ethic.

Friday, November 9, 2012

MYSQL -- Error 2002, Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I hit this error during my ERPNEXT installation process.
Where the MySQL was came with LAMPP installation
thus the mysql.sock is located in ../lampp/var/mysql/mysql.sock

I googled and found this, mysql-install-db-problems as my solution.

The steps :
1. set the environment variable to LAMPP mysql.sock path
    $ export MYSQL_UNIX_SOCK='/opt/lampp/var/mysql/mysql.sock'
    *) the path may vary make sure you do below steps to get the right path
        or location:
        $ sudo updatedb
        $ locate mysql.sock
2. Re-install the MySQLdb

Edit:
I had this same problem in fedora 19 64bit and the yum reinstall just didn't work.
So i tried to make a symbolic link to LAMPP mysql.sock and turns out work like charm.

# ln -s /opt/lampp/var/mysql/mysql.lock /var/lib/mysql/mysql.sock

Hope it helps and happy coding!