How To Instal A Git Repo & Serve Via SSH

Love Git but don’t want to pay GitHub to have a private repo? No problem. Here’s the solution. I was looking for a way to create a repo and serve it on my server via ssh. Git made it really simple and we can do in 3 steps (copied from the [Reference 1]):

1. Create a repo

server $ mkdir ~/repos/
server $ cd ~/repos/
server $ GIT_DIR=project.git git init
server $ cd project.git
server $ git --bare update-server-info
server $ cp hooks/post-update.sample hooks/post-update

2. Clone it on the client side via SSH

client $ git clone user@server:~/repos/project.git # Check the [Reference 2]
client $ mkdir project
client $ cd project
client $ git init
client $ git remote add origin user@server:~/repos/project.git/

3. Code & Push

client $ touch README
client $ git add README
client $ git commit -m "Example."
client $ git push origin master

References:

1. How to serve a Git repo via SSH: http://www.mindfuzz.net/?p=250
2. How to map SSH identity files to SSH servers & usernames: http://stackoverflow.com/questions/2419566/best-way-to-use-multiple-ssh-private-keys-on-one-client?rq=1

Listing all header files your cpp depends on

I needed to extract certain Boost headers from its huge code base for memory mapped file & shared memory containers. The first idea came to my mind was a simple grep command for ‘#include’ statements and then parse the paths. This is simple but not so useful for the cases when headers are conditionally included. For example:


#ifndef NO_STL
#include "my_class_no_stl.h"
#else
#include "my_class_stl.h"
#endif

To be honest, grep won’t be able to handle it. We need a full fledged C++ pre-processor to correctly include headers and pass necessary values/definitions (it’s done with -D for g++). I was struggling a bit and got a tip from Ralph. It turned out to be very simple:


g++ -D NO_STL -I A_PATH -M source.cpp # to get all headers, including system headers
g++ -D NO_STL -I A_PATH -MM source.cpp # to get all headers, except system headers
g++ -D NO_STL -I A_PATH -H source.cpp # to print all headers nested in as a tree

Source: http://stackoverflow.com/questions/5834778/g-how-to-tell-where-a-header-file-is-included-from

Solving password input problem with Snow Leopard

Snow Leopard is supposed to be a slimmer and more stable version than Leopard. When it comes to default password input, Leopard is far better as Snow Leopard has a few drawbacks:

1. It cannot input password in languages other than English! Leopard did that just smoothly.

2. It does not have input language at password by default like Leopard. If you have tons of unsaved work and your screen is password protected, you are as good as a dead man.

3. Default Vietnamese input sucks, it does not work well in Apple’s own Safari and also on third party apps such as Chrome, TextMate, TextWrangler, etc.

There’s no guide or mentioning why such problems are still around and what’s ETA for fixes.

Today I’m solving only the issue with login dialog to avoid the issue with locked screen and you have lots of unsaved work and your boss is whistling:

1. Go the System Preferences

System Preferences - Accounts
System Preferences - Accounts

2. Select Accounts

3. Select Login Options

Select Login Options
Select Login Options

4. Unlock & input your password (please revert input to English first)

Input password
Input password

5. Tick the option “Show input menu in login window”

Tick the option "Show input in login window"
Tick the option "Show input menu in login window"

Lock the dialog to save the change. Now every time you login from locked screen, you will see language input on your top right hand corner. Change input to English and input your password. Let your Mac sleep and wake it up to test. No more hassle 😉 !

Enabling OpenSSL for Qt C++ on Windows

By default, Nokia Qt does not ship its Qt C++ framework with OpenSSL enabled. This degrades value of the framework and you won’t be able to access HTTPS pages or SSL enabled web services. The examples that require SSL won’t work as well. Take examples\webkit\googlechat for example. This post gives an approach to enable OpenSSL for Qt C++ framework on Windows.

Make sure you have readandbefore proceeding.

  1. Open CMD console & go to the directory C:\Qt\2010.02.1\qt\src\network (given that you have Qt 4.6.2. installed using standard options offered by the installer)
  2. Make sure the directories C:\Qt\2010.02.1\qt\bin and C:\Qt\2010.02.1\mingw\bin are in the environment variable PATH. If you are unsure, enter this command:

set PATH=%PATH%;C:\Qt\2010.02.1\mingw\bin;C:\Qt\2010.02.1\qt\bin;

  1. Configure QtNetwork build using this one-liner:

qmake "PWD=C:\Qt\2010.02.1\qt\src\network" "QMAKE_LIBS_NETWORK = -lws2_32 -lcrypto -leay32 -lssl32 -lssl -lgdi32" "DEFINES += QT_LINKED_OPENSSL" "DEFINES -= QT_NO_SSL"

It’s your responsibility to ensure that OpenSSL is installed and visible to MinGW.

  1. Go ahead with building with this single command:

mingw32-make

Wait for 5-10 mins and you have QtNetwork with OpenSSL enabled. Enjoy!

Installing Qt, QtCreator and MinGW for Windows

Ever thought of developing simple & nice cross-platform applications without sweating? Nokia Qt C++ frameworks empowers you to do so. To get started, first install the Qt SDK with IDE and of course famous GNU compiler chain GCC, branded under MinGW for Windows.

Get the framework, IDE & tool chain from: http://qt.nokia.com/downloads/sdk-windows-cpp

If you are interested in particular parts of MinGW, look here: http://sourceforge.net/projects/mingw/files/

Just follow default steps and you are safe. If you are interested in free M$ C/C++ compiler, just download the Qt source and build it yourself.

Now you are ready to play with magic. To appreciate Qt, run QtDemo and also watch some clips & read some stuff:

http://labs.trolltech.com/blogs/author/qtdeclarative/

Building OpenSSL with MinGW on Windows

A number of libraries applications depend on OpenSSL, to name a few: cURL, QtNetwork, WebKit, your IMAP or secure SMTP client, etc. Building of OpenSSL is painstaking, unless you know some tricks. Read more for guidance.

  1. If you yet to have MinGW, read to learn how to install it.
  2. Download Perl from ActiveState site: . Choose version that match your Windows. MSI installer is recommended, unless you are so fluent in Windows and don’t mind spending time with little tweaks like adding PATH, etc
  3. Run the MSI installer and point path to C:\develop\tools\perl . You may choose different path, but that’s what on my machine.
  4. Having installed with Perl, now let’s fetch OpenSSL: (the latest version of OpenSSL 0.9.8 at the time of writing).  I wouldn’t recommend chasing after the version 1.0 for now.
  5. Extract openssl to C:\develop\tools\ and you will obtain directory C:\develop\tools\openssl-0.9.8n . Get inside it.
  6. Before you start building anything, take note that the macro OPENSSL_IMPLEMENT_GLOBAL causes fatal errors. Find it inside the files openssl-0.9.8n\e_os2.h , openssl-0.9.8n\include\openssl\e_os2.h and openssl-0.9.8n\outinc\openssl\e_os2.h . Find the macro’s definition and change

static type _hide_##name

to

/* static type _hide_##name */ type _hide_##name

  1. Now let’s build shared & static versions of OpenSSL with a single command (you are now inside C:\develop\tools\openssl-0.9.8n):

ms\mingw32.bat shared

Navigate to YouTube and have some snack. It may take 15-20 mins to finish building.

  1. When building is finished, you can copy outinc\openssl to your mingw\include directory. You also can copy generated *.a and *.dll files to mingw\lib directory and the *.dll to mingw\bin directory. If you hate copying, remember to make use of -I and -L flags to appropriate folders when building with MinGW.

Building & installation of OpenSSL is done.

Edit: As noted by Darrell Walisser in the comments part, Perl distributed with msys was the culprit. Installing ActiveState Perl will solve the issue without this workaround. Thanks Darrell!

References:

[1]

NTFS for Mac made easy

There are only 2 steps to enabled write option to NTFS partitions on Mac.

1. Install MacFUSE: http://code.google.com/p/macfuse/

2. Install NTFS-3G: http://macntfs-3g.blogspot.com/ , http://sourceforge.net/projects/catacombae/files/

You will be required to reboot and upon next start-up, you can write to NTFS partitions with ease. Successful installation will similar screenshot (MacFUSE & NTFS-3G at the bottom):

Successful installation of MacFUSE and NTFS-3G
Successful installation of MacFUSE and NTFS-3G

Recovery of 15GB+ of stolen space on Leopard

I’ve noticed that my Leopard partition suddenly got fat and GBs were gone somewhere. I decided to find out truth and hope for the way to get back that free space. I checked every single folder under the /. System folders were OK (access to them needs root permissions so clearly no one could dump garbage there). One important folder was suspicious, that was Users. I smelled that my home folder was that fat guy. It turned out right. Diving deeper into each sub-directory of my home folder, I found ~/Library extremely interesting: 15GB+. I was shocked how much garbage was collected in a few days time. It turned out that the Apple Mail was culprit. I downloaded everything it could from my GMail account. It weighed more than 14GB. I deleted that GMail account from Mail and then removed all related folders of that mail account inside ~/Library/Mail. Further, I found that Copernicus (a lousy screen recorder that I removed days before) has collected almost 700MB inside ~/Library/Application Support/Copernicus. I removed it with zero mercy and happy to see more than 15GB came back to me.

Building PyQt 4.7 on Leopard

PyQt is a great Python wrapper around Nokia Qt C++ framework. Binary release is not provided for Mac and Linux by the developers and maintainers of PyQt. No problem, you can build your own without sweating. 30 mins and you are done with it.

1. The first ever thing you have to do is install Qt release for Mac by Nokia: http://qt.nokia.com/downloads. For my case, it was Qt 4.6.2 (latest version).

2. The next step is to build QScintilla2. Go to your temporary directory and do the following:

[cc lang=”bash”]
wget http://www.riverbankcomputing.co.uk/static/Downloads/QScintilla2/QScintilla-gpl-2.4.2.tar.gz
tar zxvf QScintilla-gpl-2.4.2.tar.gz
cd QScintilla-gpl-2.4.2
cd Qt4/
qmake -spec macx-g++
make
sudo make install
cd ..
[/cc]

3. Now proceed to building SIP

[cc lang=”bash”]
wget http://www.riverbankcomputing.co.uk/static/Downloads/sip4/sip-4.10.tar.gz
tar zxvf sip-4.10.tar.gz
cd sip-4.10
python configure.py
make
sudo make install
cd ..
[/cc]

4. The last step is to build PyQt. It’s pretty simple but may take up 20-30 minutes to build. Grab a meal or watch GAGS while waiting for it.

[cc lang=”bash”]
wget http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-mac-gpl-4.7.tar.gz
tar zxvf PyQt-mac-gpl-4.7.tar.gz
cd PyQt-mac-gpl-4.7
python configure.py
make
sudo make install
cd ..
[/cc]

5. So you have PyQt ready! Go to the examples directory of PyQt-mac-gpl-4.7 and check the sample code, demos. Enjoy!