Cyanogenmod on Defy
After a few anxious attempts, I managed to root and upgrade my phone to Cyanogenmod ROM. These are the steps.
1. Rooting the phone.
I tried a few versions of SuperOneClick and had no success but then I found SuperOneClickv2.2-ShortFuse.zip and it ran without problems. The prerequisites are the Motorola USB drivers and MotoConnect. SuperOneClick is a windows program. The phone must first be set to USB debugging under Applications.
2. Installing 2nd Init
http://forum.xda-developers.com/showthread.php?t=1065798
This is required to bypass the locked boot loader. It used to be available as a Market app but now has to be dowloaded from one of many sites. Look for bootmenu 0.6.1.
Prerequistes are Android SDK (installer_r15-windows.exe) from Android Developers http://developer.android.com/sdk
2nd Init also installs ClockworkMod Recovery for backup and recovery. (AKA CWM)
After installing and booting, the phone may end up in the boot menu which is disconcerting. However, selecting the default boot mode as Normal fixes the boot process.
Perform a custom backup (AKA Nandroid Backup) in case something goes wrong. Copy the backup directory to your PC for safety.
3. Installing Titanium Backup Free
This is not required for upgrading the ROM but is in case something goes wrong. Run a Batch backup of everything and then copy the backup directory to your PC for safety.
4. Download RSD Lite and stock (Full) SBF
This is not required for upgrading the ROM but in case something goes wrong and you need to flash a Full ROM. I downloaded JRDNEM_U3_3.4.2_177-003_BLUR_SIGN_SIGNED_USAJRDNEMARAB1B8RTGB03A.0R_PDS03C_USAJRDNFRYORTGB_P019_A010_HWp3_Service1FF.sbf.gz from http://and-developers.com/sbf:defy
5. Download Cyanogenmod ROM from http://www.cyanogenmod.com/
I downloaded update-cm-7.1.0-jordan-signed.zip and renamed it update.zip in the top level directory of the SD Card
6. Download Google Apps if you need GMail, Maps etc
I downloaded gapps-gb-20110828-signed.zip and renamed it gapps.zip in the top level directory of the SD Card.
7. Installing the ROM
I followed this guide http://forum.xda-developers.com/showthread.php?t=1054447 and it ran in about 10 mins with no problems.
8. Adding themes
I downloaded Ice Cream Sandwich CM7 Theme, Black Glass ADW theme and Sense Analog Clock Dark from the market.

HTPC Specs
MediaPortal Version: 1.2.0
MediaPortal Skin: StreamedMP
Windows Version: Windows 7 Home Premium 64bit
CPU Type: i3-2100
Motherboard: ASUS P8H67-I Deluxe
HDD: Samsung 2TB EcoGreen HD204UI
Optical Drive; LG CH10LS20 Blu-Ray Combo Drive
Memory: 4GB DDR3-1333
Video Card: Intel HD Graphics 2000 (Onboard)
Sound Card: Realtek ALC892 (Onboard)
HTPC Case: Silverstone ML03B
Cooling: Thermaltake Slim X3, Arctic F8 Pro
Power Supply: Antec EA-380D
Remote: Windows MCE remote
MPEG2 Video Codec: PDVD11
MPEG2 Audio Codec: ffdshow
h.264 Video Codec: PDVD11
TV: SAMSUNG Plasma PS50B650
TV – HTPC Connection: HDMI
Reset MySQL root password
First things first. Log in as root and stop the mysql daemon. Now lets start up the mysql daemon and skip the grant tables which store the passwords.
mysqld_safe –skip-grant-tables
You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password.
mysql –user=root mysql
update user set Password=PASSWORD(‘new-password’) where user=’root’;
flush privileges;
exit
Oracle User Locking
The DBMS_LOCK package can be used to lock sections of code for concurrency control. Simple usage is as follows;
DECLARE
lock_handle VARCHAR2(128);
lock_status number;
BEGIN
DBMS_LOCK.ALLOCATE_UNIQUE (lockname => 'mylockset', lockhandle => lock_handle);
-- If this is taking a long time to run check if a lock is being held and kill the session
-- e.g. select osuser,program,sys.v_$lock.type,lmode,request
-- from sys.v_$lock,v$session
-- where v$session.sid = sys.v_$lock.sid
-- and sys.v_$lock.type = 'UL'
lock_status := DBMS_LOCK.REQUEST(lockhandle => lock_handle, lockmode => DBMS_LOCK.X_MODE, timeout => 60, release_on_commit => FALSE);
--- Some protected code ---
lock_status := DBMS_LOCK.RELEASE(lockhandle => lock_handle);
Add a user to a group in linux
Simple things I always forget
Add a user
useradd -p howardb howardb
Add a user to the wheel group
gpasswd -a howardb wheel
Edit sudoers
visudo
Ampersand in SOAP body
Broadworks OCI interface uses SOAP as its transport. In the past, I’m sure I replaced ampersands in the request body with the html equivalent & just using the encode function.
$req = HTML::Entities::encode($xmlrequest);
This has stopped working and hangs the request. I have found a work around using
$req = HTML::Entities::encode($xmlrequest);
$req =~ s/&/&/g;
Oracle group_concat
Oracle has the MySQL equivalent of group_concat using the following procedure
SELECT USER_ID, wmsys.wm_concat(SERVICE_PACK_NAME), FROM USERS, SERVICE_PACKS, group by USER_ID;
returns
user1 servicepack1,servicepack2,servicepack3
user2 servicepack3
etc
Read a file backwards in linux – the elegant way
Sometimes you may need to read a file such as a log file backwards to see the most recent events first. This can be easily done using tac – cat backwards
e.g. tac soapserver.log
Cloning a VirtualBox Drive
I recently tried to clone a 3G virtual disk to a 40G virtual disk. i.e. resize a disk. This was much more difficult than I thought.
After reading up blogs on the internet such as using VboxManager “cloneHD”, “cloneVDI” and “internalcommands sethduuid” which all failed, I was able to do it by booting an ISO of clonezilla and using the advanced options.
I setup my 2 virtual drives and the CD image in VirtualBox and booted up clonezilla. Then I chose a partition to partition copy (not disk to disk) and used the default options except not to install grub and keep the mbr.
I then was able to shutdown the VM and remove the original 3G disk and boot from the 40G disk.
MySQL delete with a left join
delete older.* from radacct older
left outer join radacct newer
on older.framedipaddress = newer.framedipaddress
where older.acctstoptime is null
and newer.acctstarttime > older.acctstarttime;