Free memoryWednesday, July 14. 2010
My VPS was running out of memory so I started googling to see what could be done about it. The best tip was this:
SSH into the system with putty or some other ssh utility My my.cnf happened to be in /etc/mysql/my.cnf, but after restart mysqld was using 80MB less memory! Before you do this though, make sure you don't have any tables using innodb or bdb. Well, that took long enough...Wednesday, June 23. 2010
New in Windows 7: select some files in explorer and press SHIFT + RIGHT-CLICK on the selection. Lo and behold, a secret option appears: "Copy As Paths"!
Similarly, SHIFT + RIGHT-CLICK on a folder offers "Open command window here" and "Open in new process." The things you learn when you work at MS. China Mobile SIMs explainedSaturday, May 15. 2010
A reader (!) complained about not being able to get GPRS to work with China Mobile. Although I'm in no way an expert on the subject, I think I know enough to make a useful remark, or two..
The problem with China Mobile is that they have two kinds of SIM cards: 神州行 ShenZhouXing, also known as EasyOwn, versus 动感地带 DongGanDiDai also known as M-Zone.
M-Zone supports GPRS and EDGE. Even 3G, but China Mobile's 3G standard is not UMTS or HSDPA, but some other TD-SCDMA standard, which is not supported by most phones that originate from abroad. For what it's worth, I thought EDGE worked quite well, to be honest. When using 3G, China's internet connection is probably the limiting factor. There are two ways to tell which card you have. First of all, the actual SIM cards are of a different color. ShenZhouXing SIMs are green, whereas M-Zone are orange. Also, when you turn on your phone (at least with Android) it should popup a message saying what SIM you have. For example, my phone shows something like 没错!我是动感地带!"Not Bad! I'm M-Zone!" Apart from being able to use GPRS, receiving calls with M-Zone is FREE, contrary to ShenZhouXing where you pay when you pick up the phone. Note that M-Zone does require you to subscribe to some kind of package deal, which means some money will be subtracted at the beginning of each month. The cheapest package is about 11 RMB, if I remember correctly, and includes local (Beijing only) minutes, short messages and 20MB of traffic. If you currently have a ShenZhouXing SIM, you can change it into an M-Zone SIM by going to your local China Mobile office (real CM office, not just any reseller.) Bring your passport and the PUK code of the ShenZhouXing SIM. The PUK code is written on the bank-card-shaped piece of plastic that used to contain the SIM card. The change will active from the beginning of the next month. Hope this helps. New phone numberTuesday, May 11. 2010
A few days ago I've moved to Shanghai and, since using a Beijing phone number in Shanghai is expensive, I decided to get a new phone number. I've decided to go with China Unicom, because their 3G standard is the same as the rest of the world's, so now I finally have 3G! (Although, youtube is still blocked, but at least Android 2.1 supports VPN now.)
To get my new Shanghai phone number, add 3410941632 to my old phone number Converting mailbox format from mbox to MaildirThursday, April 29. 2010
The default mailbox format used by postfix and dovecot is the mbox format. This basically boils down to a single file per user in /var/mail/ with all mails concatenated, one after the other. (Mail in folders other than inbox are stored in ~/mail/)
Mail stored in the Maildir format uses 1 file per mail. Accessing individual mails is faster, but because there are many small files, the disk space overhead is bigger. The mbox format is fairly simple and compact, but has a couple of problems. For one, being a single flat file it's easy to append new incoming mails, but it's not straightforward to remove a mail from the middle of the file. Another problem that I've noticed in Thunderbird 3 is that sometimes two mails would appear to be combined. I'd suddenly see another mail's attachments appearing on a mail without attachments. I'm not sure whether this is a problem with Thunderbird, dovecot, or perhaps a corrupt mbox file? The steps:
You should also stop postifx to prevent mail being delivered to the wrong mailbox during conversion: sudo /etc/init.d/postfix stop The easiest way to convert the mailbox format is to let dovecot do it for us. Make the following changes to /etc/dovecot/dovecot.conf: mail_location = maildir:~/Maildir(Search for the settings and change them.) Apply the changes by restarting dovecot: sudo /etc/init.d/dovecot restart Now start your mail client. Dovecot will convert the mailbox at login, so this might take a while. Also, chances are the client will start to download all mail again. (There seem to be some scripts that can prevent this.) Before we start postfix, edit /etc/postfix/main.cf to tell it where to deliver the mail: home_mailbox = Maildir/ Restart postfix: sudo /etc/init.d/postfix start How long is one month?Monday, April 26. 2010
Depends who you ask:
mysql> select "2010-01-31" + INTERVAL 1 MONTH; php > print date("Y-m-d",strtotime("2010-01-31 +1 month")); sqlite> select date('2010-01-31',"+1 month");I'm siding with PHP/sqlite on this one. QingHai memorial dayWednesday, April 21. 2010Android 2.1, here we goWednesday, April 21. 2010
I've had it. I've been waiting since November last year for an official firmware update from HTC for my HTC Hero. Since then the update has been postponed numerous times and all the while I see these reports from people using leaked Android 2.1 ROMs. Now, it appears the official update will come in May, but I'm done waiting!
As we speak I'm installing Villainrom 5.22, which appears to be the most popular 2.1 ROM out there. Unfortunately it's not that straightforward to update your ROM and the necessary information is scattered among several forums and posts. Below is a list of the steps that I did to get 2.1 on my HTC Hero. Basically there are two kinds of updates: flash images and update packages. Flash images have the extension .img and are flashed using the command flash_image from the android shell. To install an update package you put the package as update.zip on the sdcard and reboot the phone into recovery mode. From there you can install the update package. Flash a new Radio ROM I've read somewhere on the XDA Hero forum (sorry, can't remember the post) that the newer ROMs need a newer Radio ROM as well, so I've decided to flash a new radio ROM first. I suggest you make a backup first (step 2+3) and flash the Radio ROM afterwards. I've downloaded version 63.18.55.06JU_6.35.09.26 and put it on my sdcard as update.zip using the USB cable and enabling USB mass storage. I've shutdown my phone and then, while keeping the home key pressed, turned it on again. My phone booted into the recovery mode, displaying a menu from where I selected flash sdcard:update.zip. Flash a new Recovery boot loader The first step went well but I really should have created a backup before flashing the new radio. Better late than never, I suppose. I booted into the recovery mode again and selected backup but I instead of a backup I got an error message: error running rom backup. backup not performed. First thought: update the recovery image. I've downloaded recovery-RA-hero-v1.6.2.img and followed the steps in this post, using adb (android debug bridge): adb shell reboot bootloader Make a Nandroid backup Reboot into the (new) recovery mode and selected nand backup. There was also a nand + ext and BART backup options, but I don't quite know what each does, so I ignored them Wipe all data From Android version 1.5 to 2.1 is a big step so I followed XDA poster's advice and wiped all the data from my phone before flashing the new firmware. Boot into recovery (if not already done) and select each of the following options from the recovery menu: Wipe Data/Factory Reset Flash the new ROM I opted to go for the VillainROM 5.2 (aka 5.22) You can get it here. The trick is the same: download the file and put it on the sdcard as update.zip. Then, boot into recovery mode and flash the zip from the sdcard. Reboot. Rinse. Repeat. This should have done the trick. Note that the first time the phone boots it might take a while for all the components to initialize, so go easy on your phone. Another great guide is found here. And I've just got word that the official 2.1 has been postponed yet again until June. Now I'm really glad I've decided to go for the leaked 2.1. Converting my mobile phone into an IR remote control, part 3Thursday, April 15. 2010
After confirming the signal and still failing to turn on my TV, I figured my Panasonic Viera TV was using a different protocol from the RC5 that I had initially implemented. I tried to decode the protocol by pointing my remote at the IR sensor attached to the O-scope, but I was unable to get a complete code on the scope:
![]() It's immediately apparent however that the Panasonic IR protocol uses space modulation, where the spaces between the pulses are used to differentiate a 1 from a 0. But since I was not able to get a picture of a complete code, I still didn't know what signal I should create to turn my TV on! Fortunately, the LIRC remote control database had an entry for just my remote and I could confirm that the bits from the picture above are indeed a match for Panasonic's standby button. Above: .....000001000000001011110010...... From LIRC: Power = 0x0100BCBD = ....00000001000000001011110010111101 Now to change my code to write the right signal. Be right back... UPDATE: OK, so I actually got it to work using the audio out from my PC! I had to create a 72Khz wav to make it work. For some reason a 36Khz wouldn't work, but simply doubling the frequency (and duplicating all values) did the trick. Unfortunately, neither the 36Khz nor the 72Khz wav worked when played on my android mobile phone. In fact, the music player failed to load the 72Khz wav completely. Checking the LEDs with a digital camera when playing any loud wav file I could not see the LEDs light up the way they did when attached to my PC's audio out. Not enough power? Does the phone do some smart "ear piece present" check? More for tomorrow... It's alive!Thursday, April 15. 2010
(Continued from below.)
It works! I've attached the O-scope to an IR sensor (TSOP31238, 38Khz) which also demodulates the signal, and the demodulated signal is correct! This proves that using the 2 LED trick works fine, and it further proves that a 38Khz sensor will also demodulate a 36KHz signal!
Converting my mobile phone into an IR remote controlThursday, April 15. 2010
I had this silly idea a few weeks back: to simply attach an LED to an 3,5" audio jack and make a mobile phone application with which you can control all your devices, simply by playing a generated sound file.
So when I was in Shenzhen the other day I decided to buy an audio jack and some IR LEDs to keep myself busy in the hotel room. I attached a LED to the audio jack and played some mp3 on full volume. By using my phone's digital camera to look at the LED I could see it clearly light up, so at least the voltage of the audio out was high enough to drive a LED. First problem I've encountered: the RC5 signal (and many other IR protocols) is modulated at 36Khz and there's no way my PC, let alone my mobile phone, will play a 36Khz tone. I slept on this for a few nights and suddenly had an idea: I use two LEDs! One will shine on a positive signal and the other on a negative signal. This way I'll be able to get the LEDs to flash up to a theoretic frequency of 44.1Khz. In practice this limit is lower because audio-out has a high pass (and low pass) filter, but with some luck I'll be able to get a decent 18Khz AC signal to achieve the required 36Khz modulation. I quickly wrote a program (in D, of course) to generate a .wav file with a modulated RC5 signal to turn TVs on or off. The RC5 signal consists of 14 data bits, each data bit is sent as two modulated bits: a data bit 1 is sent as 01 (a pause followed by the modulated signal) and a data bit 0 is sent as 10 (signal followed by a pause.) Unfortunately, when I played this generated .wav file and held my laptop in front of my TV, nothing happened. In order to debug this, I bought a cheap O-scope on taobao: only 350 RMB! Below you'll see the IR signal with the 14 bits: ![]() The signal appears to be correct, so there must be something else wrong. Are the modulated pulses too wide, not wide enough? Is my TV not using the RC5 protocol? To be continued... The D Programming LanguageTuesday, April 13. 2010LinkStation playing music!Friday, March 19. 2010
Inspired by this page on NAS-Central, I ordered a USB sound card on TaoBao (15 RMB including delivery!) and plugged it into my LinkStation. A quick dmesg showed that the device was detected, but not recognized.
The NAS-Central page mentions that some kernel modules are needed to get USB audio to work, but of course, the device does not have these modules by default. After googling for a few hours I still could not find any precompiled modules that matched my LinkStation's kernel version, 2.6.22. I decided to jump in and try to compile the modules myself. So how do you compile kernel modules? Well, first of all you'll need the correct kernel sources, but that's easy: Buffalo provides them. Download the linux-* package that matches your NAS. Now you need a compiler. Turns out Buffalo uses CodeSourcery so we best stick to that as well. Get the pre-compiled cross-compilation toolchain here. Select "ARM GNU/linux" and the operating system that you will use for building. No need to download the toolchain source. Before we can compile the modules we need a kernel configuration file. Some Buffalo source packages seem to include it (the file is called .config and is hidden because of the leading dot) but the one I downloaded did not include one. Copy this file into the root of the folder where you've extracted the Buffalo sources. This .config file most likely has all support for audio disabled so we'll enable it by adding CONFIG_SND=m (or check whether there's a CONFIG_SND present and change that to =m). The 'm' tells the make file to build it as a separately loadable module, instead of building it into the kernel. (Since I didn't want to change the stock kernel, I had to build loadable modules instead.) Now the good part starts: make modules The make file should notice the new CONFIG_SND directive and ask you about the specific sound related modules. Make sure you answer 'm' to all of 'em. You don't need them all, but figuring which you need/don't need is too much work. When make is done we need to 'install' the modules, but not in our host/build system of course! Use the INSTALL_MOD_PATH directive to copy the built modules into a separate folder: make modules_install INSTALL_MOD_PATH=/tmp/MyModules When done, copy all the files from /tmp/MyModules/lib/modules/2.6.22.7ownkernel/kernel/sound (recursive) to your NAS. Now comes another the tricky part: loading the needed modules. The module you need is snd-usb-audio and snd-pcm-oss, but before this one will need you'll have to load a couple of others. The normal way this is done is to move the modules into the NAS's kernel folder and issue a depmod -a to update the module dependecies and a modprobe snd-usb-audio to load the module with its dependencies. I did it the wrong way: using insmod to load each module by hand, and trying to figure out the order in which to load them by trial-and-error. Eventually, insmod snd-usb-audio.ko loaded without complaints. Last step: create the device nodes. As per the NAS-Central page: cd /dev I am now able to stream music using mpg123, madplay, mpd (all installable using ipkg.) The sound quality of that 15 RMB sound card sucks though Here's the final .config file I used to build the sound modules. My first published Android app!Thursday, March 11. 2010 I've just finished my first app and have published it on the market! The app is very simple: it shows the current air quality in Beijing, as measured by the US Embassy. Scan the QR Code on the right and my app will pop up in the market app.(project page on Google code) Presenting the D Programming LanguageWednesday, March 10. 2010
I'll be presenting the D Programming Language at the next monthly BLUG meeting. It'll mostly be for people who haven't heard of D yet. There'll be a fair chunk of D1 in there, but I'm hoping to touch some of D2's new features as well.
These meetings are free for everyone to attend, so come by if you live in Beijing, or you happen to be there. More information at the BLUG website. See you there! UPDATE: my slides are now available.
(Page 1 of 8, totaling 110 entries)
» next page
Competition entry by David Cummins powered by Serendipity v1.0 |
QuicksearchMy Favorites
CategoriesTimezones
Blog Administration |