How to migrate a subversion repository to Dreamhost
Posted by Kelvin on 23 Jun 2010 | Tagged as: programming
I recently decided to host a subversion repository that was located on another server to Dreamhost. Here are the steps:
1. LOCAL STEP: Create your Dreamhost svn repository via CPanel.
2. LOCAL STEP: Verify that your new svn repository has been created.
cd /tmp svn co http://svn.mydreamhostserver.com/project
3. REMOTE STEP: SSH into your dreamhost account and remote copy your external subversion repo to a temp folder in your Dreamhost home directory.
ssh mydreamhostserver.com mkdir tmp cd tmp rsync -avz myserver:/var/svn/repo/project .
4. REMOTE STEP:With your open ssh account,
cd ~/svn mv project project-dh cp -fr ~/tmp/project .
5. LOCAL STEP:Verify that it succeeded.
cd /tmp/project svn up
Should work like a charm!
Use Proxoid with subversion with proxychains
Posted by Kelvin on 17 Jun 2010 | Tagged as: programming
Proxoid doesn't support subversion methods. The workaround on Linux is simple: use proxychains!
Install proxychains
sudo apt-get install proxychains
Setup your proxychains.conf
mkdir ~/.proxychains gedit ~/.proxychains/proxychains.conf
Paste this into the text editor
DynamicChain tcp_read_time_out 15000 tcp_connect_time_out 10000 [ProxyList] http 127.0.0.1 8080
Now instead of running
svn up
run
proxychains svn up
Done!
Definitive guide to svn post-commit emails with nice colored diffs on DreamHost
Posted by Kelvin on 08 Jun 2010 | Tagged as: programming
Step 1
mkdir ~/perl
Step 2
perl -MCPAN -e 'install SVN::Notify'
This command will try to do something, then most probably fail. That's OK.
Step 3
Change ~/.cpan/CPAN/MyConfig.pm to contain:
'makepl_arg' => q[PREFIX=/home/username/perl LIB=/home/username/perl/lib],
'mbuildpl_arg' => q[install_base=/home/username/perl],
Step 4
perl -MCPAN -e 'install SVN::Notify'
This should now install properly
Step 5
Running
~/perl/bin/svnnotify
should produce:
Missing required "--repos-path" parameter
Step 6
cd ~/svn/REPO/hooks vim post-commit
Paste this
#!/bin/sh REPOS="$1" REV="$2" PATH=/usr/bin:/bin:~/perl/bin PROJECT=CHANGEME export PERL5LIB="$HOME/perl/lib/perl5:$PERL5LIB" svnnotify --repos-path "$REPOS" \ --revision "$REV" \ --svnlook /usr/bin/svnlook \ --to CHANGEME \ --from $COMMITTER@$PROJECT.com \ --with-diff --subject-cx --handler HTML::ColorDiff \ --max-diff-length 15000 --subject-prefix commit-
The last line
--max-diff-length 15000 --subject-prefix commit-
is optional.
Save and exit.
Step 7
chmod a+x post-commit
You're done!
MySQL collations demystified
Posted by Kelvin on 07 Jun 2010 | Tagged as: programming
Good article here: http://code.openark.org/blog/mysql/mysqls-character-sets-and-collations-demystified
MySQL’s character sets and collations are often considered as a mystery, and many users either completely disregard them and keep with the defaults, or set everything to UTF8.
This post will attempt to shed some light on the mystery, and provide with some best practices for use with text columns with regard to character sets.
Character Sets
A thorough discussion of how the character sets have evolved through history is beyond the scope of this post. While the Unicode standard is gaining recognition, the “older” character sets are still around. Understanding the difference between Unicode and local character sets is crucial.
Consider, for example, MySQL’s latin1 character set. In this character set there are 256 different characters, represented by one byte. The first 128 characters map to ASCII, the standard “ABCabc012 dot comma” set, of which most of this post is composed. The latter 128 characters in latin1 are composed of West European specific characters, such as À, ë, õ, Ñ.
A Name VARCHAR(60) CHARSET latin1 column can describe names with West European characters. But it cannot describe Russian or Hebrew names. To represent a name in Hebrew, you’d need the hebrew charset (ISO 8859-8), in which the first 128 characters are, as always, mapped to ASCII, and the latter 128 characters describe the Hebrew alphabet and punctuation marks, such as ?,?,?,?. The Cyrillic, Arabic and Turkish charsets follow in a similar manner.
Assume now I’m building a world wide web application, such as a popular social network. I would like to store the first names of my users, in every possible language. None of the above character sets support all languages. I therefore turn to Unicode. In particular, MySQL supports utf8, a Unicode encoding scheme, which is commonly used due to its economic storage requirements.
In Unicode there is a dedicated number for each letter in the known languages, in ancient languages, and some imaginary or otherwise non existing languages, such as Klingon (yes, I know there are people who actually speak Klingon), may yet find their way into the standard…
Django not setting default column value in MySQL
Posted by Kelvin on 07 Jun 2010 | Tagged as: programming
Django 1.1 refuses to set the default value of columns when creating SQL.
For example, given this model,
class Test(models.Model): price = models.IntegerField(default=0)
Django generates the following SQL:
CREATE TABLE `test` ( `id` INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, `price` INTEGER NOT NULL ) ;
Its a relatively easy fix:
1. Hunt down the django installation directory. On debian, using the python egg installation method, django is located /usr/lib/python2.5/site-packages/Django-1.1-py2.5.egg/django
2. Open db/backends/creation.py in a text editor.
3. Search for 'def sql_create_model'
4. Scroll down abit, and you should see the following block of code:
if f.primary_key: field_output.append(style.SQL_KEYWORD('PRIMARY KEY')) elif f.unique: field_output.append(style.SQL_KEYWORD('UNIQUE'))
BELOW it, add this:
if(f.default != models.fields.NOT_PROVIDED): field_output.append(style.SQL_KEYWORD('DEFAULT ' + f.default.__str__()))
5. Save and you're done!
The SQL now generated looks like this:
CREATE TABLE `test` ( `id` INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, `price` INTEGER NOT NULL DEFAULT 0 ) ;
EVDO/3G as preferred network on Android 2.1+
Posted by Kelvin on 05 Jun 2010 | Tagged as: programming, android
Found this out through a friend:
1. Hit *#*#4636#*#*
2. Phone Info
3. Select WCDMA in Preferred Network.
More information on preferred networks available here: http://www.google.com/support/forum/p/android/thread?tid=6a327a95211ac789&hl=en
WCDMA preferred – The GSM phone is capable of using both 2G and 3G data communication and when signal strength is low 3G is favored more.
GSM only – The GSM phone is capable of using only 2G data communication. When the 2G signal is too low you get nothing at all.
WCDMA only – The GSM phone is capable of using only 3G data communication. When the 3G signal is too low you get nothing at all.
GSM auto (PRL) – The GSM phone is capable of using both 2G and 3G data communication and when signal strength is low 2G is favored more. This one is a bit confusing to me since PRL is associated mostly with CDMA technology and not GSM technology.
CDMA auto (PRL) – The CDMA phone is capable of using both 2G and 3G data communication and when signal strength is low 2G is favored more.
CDMA only – The CDMA phone is capable of using only 2G data communication. When the 2G signal is too low you get nothing at all.
EvDo only – The CDMA phone is capable of using only 3G data communication. When the 3G signal is too low you get nothing at all.
GSM/CDMA auto (PRL) – Some phones are equipped with both GSM and CDMA capabilities. This setting appears to just have the phone attempt to stay connected to the data communication type that works the best. (Maybe the Samsung Galaxy S will take advantage of this???)
Unknown – If none of the above fit or the phone is acting weird as far as connecting to the carrier, you will see your preferred network type is set to this
Accepting remote proxy connections on Android
Posted by Kelvin on 02 Jun 2010 | Tagged as: android, programming
Android's adb bridge, when performing port forwarding to the Android device, only accepts connections from localhost. This is most probably for security reasons, but is a nuisance when you want to be able to access the net via your Android device from >1 computer over the network.
The solution: http://rxwen.blogspot.com/2009/11/adb-for-remote-connections.html
Its a drop-in replacement for your ANDROID_HOME/tools/adb file.
[SOLVED] Android 2.1 + HTC Droid Eris on Windows XP
Posted by Kelvin on 28 May 2010 | Tagged as: programming, android
After updating to Android 2.1, Windows XP no longer recognized my HTC Droid Eris.
The fix:
1. download the USB Driver via the Windows Android SDK
2.check your Android's VID and PID via Windows Device Manager
3. Open android_winusb.inf in the usb_driver folder and check that the VID/PID combo exists in the file.
4. If it doesn't, add it in into the respective INI section. For example, I added this for Droid Eris under the [Google.NTx86] section:
%CompositeAdbInterface% = USB_Install, USB\VID_0BB4&PID_0C98&MI_01
5. Save and reinstall the USB driver and that's it!
Proxoid users
If you're currently using Proxoid's windows drivers, they're not updated for Android 2.1. Try using the Android SDK version instead.
Also, you'll need to copy over adb.exe and AdbWinAPI.dll from the android sdk tools folder over to the proxoid-adb folder.
[SOLVED] Ubuntu 10.04 Lucid and VMWare Workstation 6.5.4
Posted by Kelvin on 26 May 2010 | Tagged as: programming, Ubuntu
After following a number of unsuccessful links, the definitive solution for installing VMWare Workstation 6.5.x on Ubuntu 10.04:
http://blog.digital-scurf.org/2010/04/20#vmware-6.5.4-ubuntu-10.04
[SOLVED] Set cd-rom speed on Ubuntu
Posted by Kelvin on 03 May 2010 | Tagged as: Ubuntu, programming
My cdrom is a speedy 48x drive. Unfortunately when it revs up, its often rather loud. Here's how to lower the speed on Ubuntu.
sudo apt-get install setcd setcd -x 1
Change -x 1 to -x [some number] where the higher the number, the faster the drive.