Category: Technology

Fake pass-code from Ubuntu Bluetooth GUI

Posted by – March 27, 2015

Today, I bought a Bluetooth 4.0 dongle to connect my Logitech K760 keyboard. But I could not get it working with my Ubuntu system. Initially, I thought the Bluetooth adaptor does not support Ubuntu, as the product description says it only supports Windows… But lsusb shows the below output, which to me does not look like an OS issue.

xinquan@:~$ lsusb 
Bus 002 Device 003: ID 03f0:0324 Hewlett-Packard SK-2885 keyboard
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 007: ID 0b95:772a ASIX Electronics Corp. AX88772A Fast Ethernet
Bus 001 Device 006: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

After attempting to connect via the Bluetooth GUI, it gave me a passcode to type in on my wireless keyboard, which I proceed to do. It immediately gave me this error: ‘Logitech K760 failed to connect’.


After some googling, it turns out that the passcode from the Bluetooth GUI was bogus, the correct passcode can be obtained from the command tool hcidump! Goshi… After I typed the passcode from hcidump, it connected successfully!

sudo apt-get install bluez-hcidump
sudo hcidump -at | grep -A 1 "User Passkey"

2015-03-27 11:29:29.787512 > HCI Event: User Passkey Notification (0x3b) plen 10
    bdaddr 00:1F:20:3E:53:A2 passkey 359872

Double quotes in SQL

Posted by – March 23, 2015

For an hour or so, I have been debugging an SQL error thrown by the PostgresSQL in my CakePHP application. The error message was also not really helpful. Below is the SQL generated by the CakePHP update function

UPDATE "public"."posts" SET "value" = asap WHERE id = (1) 

Undefined column: 7 ERROR: column "asap" does not exist LINE 1:

The culprit turns out to be that how quote is used to identify a string in SQL.
I have to explicitly put the single quote in the string value ‘asap’ in the CakePHP function below when updating a record of the Model Post.

The below is the signature of the updateAll function from CakePHP library.

public function updateAll($fields, $conditions);

The tricky part is you can’t quote strings in the conditions, but for the updating value of the fields, the string has to be single quoted.

       array('Post.value' =>  "'asap'" ),
       array('Post.key = ' => "when"));

A further discussion can be seen at the stackoverflow page

Using Casperjs to test your website

Posted by – July 24, 2014

Today, I discovered a great tool called “casperjs”, which allows you to test your website with Headless WebKit. Having just tried a few minutes, I instantly fall in love with this tool. You can use it to simulate almost any browser behavior.

Installing it on ubunutu is quite straightforward.


#clone the repository from the master branch
git clone git://

#Symlink the relevant file into your bin or /usr/local/bin
ln -sf ~/repositories/casperjs/bin/casperjs /bin/casperj
ln -sf ~/repositories/casperjs/bin/casperjs /usr/bin/casperj

realy cool photo effect

Posted by – June 14, 2009

Who is that guy the woman is gazing at?


This is created by this website:

iphone application

Posted by – October 30, 2008

It’s been a while since last time I updated this blog. Actually, I was busy with all sorts of stuffs that I rarely have any time do things like writing something here on the blog.

My life has changed a lot with this global financial turmoil and Now I believe everything could happen like my company Lehman Brothers, that I thought would work for a long period, went bankruptcy.

My written English is getting worse and my Japanese level does not improve much neither. However, one more exciting thing was that the Dictionaries in Apple’s iphone app store are surprisingly selling well.

Today I checked out, Korean English Dictionary KE No.4 in Korean app store. Chinese English Dictionary CE No.5 in China app store!

Chinese/English Dictionary
Korean/English Dictionary
And all applications

Multiple Emacs Shell Buffers

Posted by – September 25, 2007

Having my work changed a lot during the last year, from a Lunix developer to a half developer half support and now are purely support, I do not have many chance to use Emacs that often anymore, but I keep to use to it as much as possible. After all it’s my first editor in my programmer career. One thing I like is its shell buffers. Unfortunately, It only support one shell as I thought before. Because if you type M-x shell to open a new shell buffer, if you already have one open that will just switch to the existing one.


C++ training

Posted by – July 29, 2006

I just finished four days C++ training. I was extremely impressed by the instructor’s deep insight into C++ knowledge. Before I join Morgan Stanley, I thought I had a pretty good knowledge of C++. After this class, I found that still have a long way to go!

My First MFC Application using COM

Posted by – April 20, 2006

I am excited to tell you that I have built a simple MFC applcation using COM objects, which used to be somehow mysterious to me. The COM objects are created by ATL. Before reading this article, I assume that you have the basic knowledge of COM and be experienced programming in C++. One thing I should pointed out is that I am a newbie of COM and there may be some errors in this article. Still, The reason I write this article is to record my growth of my technical career and share it with you.



Posted by – April 17, 2006

I thought I would stick on my Linux path and finally to be a Unix/Linux expert when I took the current job. But just like Groom said, “Life is like a box of chocolate, you never know what you’re going to get”. I realize that there are some more interesting technologies there waiting for my exploring. I must confess that The Microsoft® COM (Component Object Model) has made a great effort on platform-independent and object-oriented software development. This technology is so popular that many large companies are using it to build complicated applications and also so many software job positions require knowledge of COM explicitly.


Use Regular Expressions in Emacs

Posted by – April 13, 2006

What is Regular Expression? A regular expression is a special text string for describing a certain amount of text. Generally, A regular expression contains a few special characters and ordinary characters. If you have used Linux/Windows systems, you will probably familiar with wildcard notations such as *.txt to find all text files in a folder. That’s a simple regular expression example (Thanks for netcasper’s correcting . The regex equivalent to “.txt” is .*.txt). Nowadays, Most of the text editors support regular expression such as vi, emacs and Ultra Editor(not a free software). Today, I would like introduce some basic knowledge about regular expression and use it in Emacs to improve the efficiency of your coding work.


A memory bug detector

Posted by – April 11, 2006

This interesting tool valgrind is a debug tool and can been used to find memory bug, include memory leak. There is a rpm in Fedora Core 3 CD. You can get it from CD or download the source code from their website. Moreover, this tool is a Free Software, and is freely available under the GNU General Public License. You can use it to debug Linux programs and it’s very easy to use.


A small piece of anti-spam JavaScript code

Posted by – April 4, 2006

I found out that there was a spam in my Blog several days ago and I deleted it manually. The spam is created by MoableType’s comment system. Although MovableType has great anti-spam features. It blocked most of them, but it seems that there are some exceptions. My site is very small though, the spam still came up. I can imagine the serious problem when the traffic of my site increases. so I made some change in my site’s comment system.