Running Xdebug with Sublime Text from Command Line

Tags: July 11, 2015 6:15 PM
0 comments

Overview

Sometimes there is a case we spending more time on command line rather than on browser when developing a PHP application. It is true especially when we are in unit testing phase. Usually Xdebug remote debugging activated by sending XDEBUG_SESSION_START=session_key in query string or http post body. For debugging from command line we need to set environment variable XDEBUG_CONFIG="idkey=session_key".

Debugging with Sublime and Xdebug

Default Xdebug session name for Sublime Xdebug Client is "sublime.xdebug". Assuming all the configuration related with Xdebug and Sublime are done, here is the way to begin debugging from command line.

  1. Start Xdebug on Sublime by going to Tools » Xdebug » Start Debugging
  2. Set your break point somewhere in your code
  3. Run your PHP script on command line, here I'm using phpunit.
    $ XDEBUG_CONFIG="idkey=sublime.xdebug" phpunit app/tests/notifier/v1/UserLoginNotifierQueueTest.php
    
  4. Go back to Sublime and all the debugging window are presented, the execution still paused at the break point.
  5. We can start to examine variables or doing "Step-In/Out".

References

Share on Facebook Twitter

How to Detect Disconnected Client from Our Network

Tags: February 19, 2015 9:01 PM
0 comments

Overview

If you have a Linux box which act as gateway or Captive Portal, you might want to do something fancy when client get connected or disconnected from your box. As an example, you want to modify some iptables rules as soon as client leave your network.

Problem

You want to detect status of a machine as soon as it disconnected form your network. The arp command utility still displaying client which already gone from our network. The default cache time inside Linux kernel might be set for longer period of time.

Solution

Instead of using arp utility, we can use ip command utility as tool for displaying statistics of our "neighbors". Below is an example of showing status of our neighbors.

Share on Facebook Twitter

How to Fix MySQL Fatal error: Illegal or unknown default time zone

Tags: October 19, 2014 2:36 PM
0 comments

Problem

You want to set the default timezone for MySQL using my.cnf configuration file. But MySQL unable to start and the error log says:

Fatal error: Illegal or unknown default time zone 'NAMED_TIMEZONE'

Solution

Do not use named timezone unless you had timezone data populated on your mysql database. Instead use an offset relative to the UTC e.g: '+07:00' or '-04:00'.

Share on Facebook Twitter

XenServer 6.2: Fix Unrecognized LVM Volume on Boot

Tags: May 18, 2014 6:44 PM
0 comments

Default Xenserver 6.2 root partition is 4GiB that's very small. So I want to separate the /tmp and swap to other partition in this case a LVM volume. The bad news is LVM volumes does not activate on boot. So entries in /etc/fstab which relies on LVM would fail and the boot process got stuck since the system would try to do some file system checking on every partition listed.

Activate LVM on Boot on XenServer 6.2

To activate on boot we need to make small modification to file /etc/rc.sysinit around line 487 to 489. Take a look into these lines:
#if [ -x /sbin/lvm.static ]; then
# action $"Setting up Logical Volume Management:" /sbin/lvm.static vgchange -a y --ignorelockingfailure
#fi
That's the problem, the lines which activate the LVM volume is commented. That's why we ended up with the problem. Now just uncomment those lines and save the file. But make sure you made a copy of it. Reboot the server and all LVM volumes should be detected on boot. Here's an example of my XenServer custom partition scheme:
LABEL=root-mterkkri    /         ext3     defaults   1  1
#/var/swap/swap.001          swap      swap   defaults   0  0
none        /dev/pts  devpts defaults   0  0
none        /dev/shm  tmpfs  defaults   0  0
none        /proc     proc   defaults   0  0
none        /sys      sysfs  defaults   0  0
/opt/xensource/packages/iso/XenCenter.iso   /var/xen/xc-install   iso9660   loop,ro   0  0

/dev/mapper/VG--XEN01-Dom0--TMP /tmp ext2 defaults,noexec,nosuid,nodev 1 2
/dev/mapper/VG--XEN01-Dom0--SWAP swap swap defaults 0 0

/tmp /var/tmp   none rw,noexec,nosuid,nodev,bind 1 2

Share on Facebook Twitter

Switching USB Modem to Serial Manually

Tags: May 12, 2014 3:56 AM
0 comments

Without having to use usb-modeswitch switching the USB modem can be done easily. In this example I use USB CDMA modem with vendor ID 201e and product ID 1023 (when detected as CD-ROM storage) and product ID 1022 (when detected as USB modem or USB storage).

Requirements

Most of these module are present in all modern linux distro.
  • Kernel module: option (USB Driver for GSM modems)
  • Kernel module: usbserial (USB Serial Driver core)

Step 1: Detach the CD-ROM Storage

When you first plug your USB modem it might detected as CD-ROM storage. To identify the modem you can use dmesg and lsusb commands. Make sure running these commands as root.

Share on Facebook Twitter

Ubuntu TP-Link TL-WN723N Ad-Hoc Network

Tags: May 11, 2014 3:20 PM
0 comments

The Wifi ad-hoc network configuration that will be created for this task are composed from the following devices:

  1. Computer A (TP-Link TL-WN723N) IP: 192.168.1.25/29
  2. Computer B (Other Wireless) IP: 192.168.1.26/29

Step by Step Ad-Hoc Configuration

This is important, the Computer B should be configured first followed by Computer A. It might not work if configured using opposite order. Bug: https://github.com/lwfinger/rtl8188eu/issues/4

Share on Facebook Twitter

Ubuntu Linux TP-Link TL-WN723N Driver

Tags: May 9, 2014 11:18 PM
0 comments

Update

The more recent driver for TP-Link TL-WN723N can be found on https://github.com/lwfinger/rtl8188eu. This new driver address problem for kernel 3.8+. Do not forget to copy the firmware file rtl8188eufw.bin to /lib/firmware/rtlwifi/. Failed to do so, you might can not bring the device up.

 

I just bought a nano wireless adapter from TP-Link, the TL-WN723N. But my Xubuntu 12.04 did not recognize it, well that sucks. But thanks to this guy he made the driver for it: https://github.com/gleb-chipiga/rtl8188eu.

Driver Installation

Make sure the compiler and git already installed on the system.
$ mkdir -p /tmp/tp-link && cd /tmp/tp-link
$ git clone https://github.com/gleb-chipiga/rtl8188eu
$ cd rtl8188eu
$ make
$ CURRENT_KERNEL=$( uname -r )
$ sudo cp 8188eu.ko /lib/modules/$CURRENT_KERNEL/kernel/drivers/net/wireless/
$ sudo depmod -a
$ sudo modprobe 8188eu
$ ip link show
The wireless adapter should be detected, no need to reboot.

References

Share on Facebook Twitter