How to write and build a QT app on Ubuntu

$ sudo apt-get install libqt4-dev $ mkdir qthello $ cd qthello $ cat > hello.cpp #include #include int main(int argc, char *argv[]) { QApplication app(argc, argv); QLabel hello("hello, world"); hello.show(); return app.exec(); } $ qmake -p…

How to write and build a GTK+ app on Ubuntu

$ cat hello.c #include int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *label; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); label = gtk_label_new("hello, world"); gtk_container_add(GTK_CONTAINER(win…

Remove DOS line endings (^M) in Vim

The recommended way to remove DOS line endings (^M) in Vim is the following :s command. :%s/\r//Source: http://vim.wikia.com/wiki/Change_end-of-line_format_for_dos-mac-unix

How I boosted my Vim

This is a clear and informative article about Vim customization:http://nvie.com/posts/how-i-boosted-my-vim/

Vim regex

I have a difficult time remembering the regex escaping rules in vim, so here is an example that I might refer to later.Add <br> to all lines: :%s/\(.*\)/\1\/

Subversive Connector Discovery does not work with proxy

More proxy woes:https://bugs.eclipse.org/bugs/show_bug.cgi?id=306786

Telling Maven Integration plugin for Eclipse where Maven installation directory is under Ubuntu

The Maven plugin for Eclipse by default uses an embedded Maven installation which is Maven 3.0. It turns out this has some incompatibilities with Maven 2.x and you are likely better off using Maven 2.x, which is fortunately still the versi…

Vim: Reopen a file with a different encoding

:e! ++enc=utf-8 Reopens current file with UTF-8 encoding :e ++enc=utf-8 filename.txt Opens filename.txt with UTF-8 encodingSee :help encoding-values for a list of supported encodings. Typical ones are latin1, utf-8, euc-jp, sjis, big5.

Moving a window that's off screen or otherwise hidden.

When using Windows, you may run into the problem of trying to access a window that is not visible because it is far off the screen or hidden under something. This is not a bad trick to remember, from Raymond Chen:http://blogs.msdn.com/b/ol…

Undo a bad SVN commit

I made a bad SVN commit that I wanted to undo. This blog post helped me out. In particular, if the bad commit was revision r34, just do: $ svn merge -c -34 . $ svn commitThat is a negative sign in front of the revision number.

Multiple paths in a grant codebase block in a Java security policy file.

The documentation doesn't say this, but you can grant codebase "path" multiple paths by separating the paths with a colon (":"). For example, grant codebase "/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/ext:/usr/java/packages/lib/ext" { ... }

How to add a class to an existing JAR file.

Say we have a jar file start.jar and want to add a class to it. $ mkdir jarbuild $ cp start.jar jarbuild $ cd jarbuild $ jar -xf start.jar $ rm start.jar $ cp -r ~/secmgr . $ find secmgr/ secmgr/ secmgr/manager secmgr/manager/ProfilingSecu…

Numbers everyone should know.

I reproduce below Slide 24 from Jeff Dean's keynote (PDF) at LADIS 2009. L1 cache reference0.5 ns Branch mispredict5 ns L2 cache reference7 ns Mutex lock/unlock25 ns Main memory reference100 ns Compress 1K bytes with Zippy3,000 ns Send 2K …

Installing rubygems on CentOS 5.5

Here is how to get rubygems working on CentOS 5.5. Remove the old Ruby packaged with CentOS.$ sudo yum erase rubyMake sure you have zlib and zlib-devel installed.$ sudo yum install zlib zlib-develInstall a newer Ruby like 1.8.7-p299. $ wget…

Moving VMware image from one directory to another.

I had to move a VMware image from one hard disk to another because I wanted to add more space to it (I use VMWare Player).I just copied the whole VM folder to the new directory, added the copied VM to VMware, and ran it. It asked if the VM…

Run multiple instances of Jetty on different ports on Ubuntu 9.04.

My goal today was to run multiple instances of Jetty on different ports on Ubuntu 9.04.The Ubuntu 9.04 repository has Jetty 5.x only. It might be best to just uninstall the Jetty package and download a Jetty 6.x from the Jetty website. But…

Setting the From header in mail from GNU Mailutils

$ mail -aFrom:me@example.comTook a while to find.

Google Japanese IME Correction

If you notice Google Japanese IME does not bring up the correct kanji for some kana, it looks like you can report it.

Extracting audio from video

FFmpeg does this well:ffmpeg -i movie.flv -ab 256k -vn -ss 23 -t 00:04:58 -vol 512 mysong.mp4The optional arguments mean: -ab 256k: 256k bitrate (seems to mean the upper bound, the actual bitrate seems to turn out to be less and setting hi…

Why I don't like Textile

This is mostly a reminder to myself of why I prefer HTML over lighter markup languages like Textile or Markdown. I often come up with judgements of what I like or not, but it's difficult to recall the reasons when pressed.Here are some exa…

ssh without password on Ubuntu Jaunty

Mostly lifted from here but for my own notes. On client, runssh-keygenDo not supply a passphrase. This creates a keypair in ~/.ssh. Copy the newly created file id_rsa.pub to server.scp -P 22 .ssh/id_rsa.pub bob@server:~/ On server, append …

Scale on, scale in, scale out

I get these confused, for the sake of my own memory: scale out (or scale horizontally): add nodes to the systems scale up (or scale vertically): increase resources of a node scale down: decrease resources of a node

Very simple file upload in Rails.

I made a very simple file upload page in Rails so my friend could send me some images from her camera in a zip file.In app/views/file_upload/index.erb: true do %> <br> In app/controllers/file_upload_controller.rb: class FileUploadController de…

How to encode a big uncompressed avi movie.

I had some big uncompressed avi files from my digital camera that I just wanted to compress in a highly portable format. The following is probably not optimal but results in a small avi file that plays basically everywhere (Linux and Windo…

Bulk rename in sh

I had a directory of files like "really long name with spaces 14.jpg" that I wanted to rename to files like "14.jpg".My solution was the following. ls -d *jpg | sed 's/.* \([0-9]\+\.jpg\)/mv "\0" \1/' | shSo I can decipher this later: The …

How to use the IME on the Windows command prompt (cmd) to input Japanese

If you've ever tried to input Japanese in a Windows command prompt, you probably found that the typical method to activate the IME does not work. Here is the secret combo: Hit Alt + the 半角/全角 key (for Japanese keyboards), or Hit Alt + …

Firefox: add-ons, extensions, and plugins

Most documentation uses these terms seemingly interchangeably, making it difficult to find good definitions. So I don't have to go on a wild Google chase again:An add-on is an installable component for Firefox (or any Mozilla project). Ext…

Vim shortcuts I can't remember.

:set tabstop=8 Set hard tab width to 8, useful if you open a file by Emacs which uses 4 spaces for one level of indent and hard tab for 2. "+gp Paste from system clipboard after cursor "+gP Paste from system clipboard before cursor "+y Cop…

GNU screen on gnome-terminal

On a vanilla Ubuntu 9.04, you might run into some keyboard input troubles with the default screen configuration. For example, Shift+Tab in Vim (to go backwards through a directory listing) does not work properly.SolutionAdding term xtermto…

MySQL dump database

mysqldump writes a database to stdout. mysqldump -u -p > file