iPhone & Ubuntu notes…

No Flash stuff this time 🙂
During my last trip to New York city I finally decided to buy an iPhone for me too (I think I have everything from Apple right now.. except a mac 🙂 ).
The most annoying thing for a linux user like me is obviously the fact that the iPhone syncronization should pass from iTunes, which is not available for linux…
Ok, there are some ways indeed to copy music like this: http://help.ubuntu.com/community/PortableDevices/iPhone, but as you can see is not so smart.

Sync your address book isn’t easy too. The AddressBook sqlite can be easily browse using an SQLite browser such as SQLite Database Browser http://sqlitebrowser.sourceforge.net/, just get the AddressBook.sqlitedb (it’s into  /private/var/mobile/Library/AddressBook/)  from the iphone via sftp (just remember to install BSD Subsystem and OpenSSH) and call a simple query like this:
SELECT t1.First, t1.Last, t2.value from ABPerson as t1, ABMultiValue as t2 WHERE t2.record_id = t1.ROWID
For a full AddressBook sync you can read more here: http://www.estamos.de/blog/…the-making-of/

Another tip I just discovered is how to upload into the iPhone my own Ringtones.
First convert the mp3 file into an M4R file using this command line script:
mplayer -ao pcm input_file.mp3 -ao pcm:file="~temp.wav"
faac ~temp.wav -o output_file.m4r -w
rm ~temp.wav

then using sftp put the output_file.m4r into /Library/Ringtones directory. A sample workflow can be this one:
~/iphone/Ringtones$ mplayer -ao pcm The_Spell.mp3 -ao pcm:file="~temp.wav"
MPlayer 1.0rc2-4.2.3 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 CPU T7600 @ 2.33GHz (Family: 6, Model: 15, Stepping: 6)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing The_Spell.mp3.
Audio file file format detected.
Clip info:
Title: The Spell
Artist: Lunatica
Album: Fables & Dreams
Year: 2004
Comment: 00001A75 000016D0 00004374
Track: 6
Genre: Other
==========================================================================
Forced audio codec: mad
Opening audio decoder: [libmad] libmad mpeg audio decoder
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [mad] afm: libmad (libMAD MPEG layer 1-2-3)
==========================================================================
[AO PCM] File: ~temp.wav (WAVE)
PCM: Samplerate: 44100Hz Channels: Stereo Format s16le
[AO PCM] Info: Faster dumping is achieved with -vc null -vo null -ao pcm:fast
[AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default).
AO: [pcm] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
Cannot sync MAD frame 538.0 (08:58.0) 0.8%
Cannot sync MAD frame
Cannot sync MAD frame
Cannot sync MAD frame 538.0 (08:58.0) 0.8%
A: 288.3 (04:48.2) of 538.0 (08:58.0) 0.8%
Exiting... (End of file)
alessandro@alessandro-u-laptop:~/iphone/Ringtones$ faac ~temp.wav -o The_Spell.m4r
Freeware Advanced Audio Coder
FAAC 1.26.1 (Jan 22 2008) UNSTABLE
Quantization quality: 100
Bandwidth: 16000 Hz
Object type: Low Complexity(MPEG-2) + M/S
Container format: Transport Stream (ADTS)
Encoding ~temp.wav to The_Spell.m4r
frame | bitrate | elapsed/estim | play/CPU | ETA
12388/12388 (100%)| 137.8 | 12.5/12.5 | 22.95x | 0.0
alessandro@alessandro-u-laptop:~/iphone/Ringtones$ sftp root@192.168.1.203
Connecting to 192.168.1.203...
root@192.168.1.203's password:
sftp> cd /Library/Ringtones
sftp> put The_Spell.m4r

Backup your batabases w/o phpmyadmin

I often read threads about export/import data from MySQL and it’s always mentioned phpmyadmin as the only way to do that (with PHP indeed).
But that’s not true, and it’s indeed the slower way to do that, expecially when importing large database files (because phpmyadmin has problems with large db)…
This would be just a reminder 🙂
Use an SSH client, like putty (if your database is on a remote server), to connect to your server and export the databse you want simply with:

mysqldump –user=username –password=1234 –databases your_database –opt –quote-names –allow-keywords –complete-insert | bzip2 -c > your_database.sql.bz2

download the .bz2 file created, unzip it using 7-zip (if you dont have any other uncompress utility), and backup your database in mysql using:

mysql –user=username –password your_database < your_database.sql

that’s faster than using “import” from phpmyadmin
http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html