Quick dirty way to clean git history

Sometimes my git history got messed up due to some strange issues. I use the following quick/dirty way to create a clean new branch.
 
Step 1: use the “git clone” command to clone the master branch to a separate new folder
 
Step 2: rsync the changed content of your old branch to the new folder excluding the .git subfolder
rsync -avz --exclude .git old-folder/ new-folder
Step 3: create a new branch out of the new folder and then push
$ cd new-folder
$ git checkout -b my-new-branch

Lastly, we can avoid lots of hassles if using “git pull –rebase” instead of the simple “git pull” command.

Start Apache server on Cygwin 1.7 and Windows 7

I installed the full Cygwin 1.7 package on Windows 7. When I try to start Apache server following the linux style by running command
$ /usr/sbin/apachectl2 start
I got “Bad system call” error.

After some web search and trial and error, I finally got it work. Below are the steps that I’ve tried. Not sure whether all are necessary though.

Step 1: right click the Cygwin terminal and select “Run as adminstrator”

Step 2: create correct user and group info. Not sure whether this step is necessary.
$ mkpasswd.exe -l
$ mkgroup.exe -l

Step 3: configure server by running command
$ cygserver-config

Step 4: start cygserver
$ net start cygserver

Step 5: start apache
$ /usr/sbin/apachectl2 start

RPM builder quick steps

Step 1, install rpm tools

yum install rpmdevtools rpmlint

Step 2, set up working directory

rpmdev-setuptree

Step 3, create and edit the spec file

cd rpmbuild/SPECS
rpmdev-newspec

Miscellaneous commands:

show environment variables

rpm --showrc

show specific variable

rpm --eval %_usr

Procedures to simulate RPM building with Mock
– Build source rpm

rpmbuild -bs SPECS/myproject.spec

– Mock the build, i.e., testing the build in an isolated building environment simulating a specific platform (Redhat or Fedora etc.)

mock -r platform_name SRPMS/myproject.src.rpm

– If it’s a multiple-project task, mock install the first project first, and then mock build the 2nd, i.e.,

mock -r platform_name --install /mock_path/myproject.rpm
mock -r platform_name SRPMS/myproject2.src.rpm

Output to memory instead of file using libjpeg and libpng

I need to use libjpeg and libpng to convert an image from the raw RGB format to JPEG and PNG format and then output the result to a memory buffer, and the following two links saved me lots of coding effort:

http://www.codeguru.com/forum/archive/index.php/t-378333.html

http://stackoverflow.com/questions/1821806/how-to-encode-png-to-buffer-using-libpng

Additionally, there is also a good online tutorial showing how to do in-memory data compression using zlib at
http://www.gamedev.net/reference/articles/article2279.asp

PS: just found out that the latest libjpeg (version 8 ) coming out two weeks ago added the in-memory compression method. Cheers!