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/
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:
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
To confess, this is the first time I write unit testing for Java & C++ and it turned out this was rather simple. This weekend Daniel is hosting hackathon at his place and invited Kong & me to come over. The first thing we did was TDD. Daniel was fluent in TDD & pair-programming as his company used Ruby and actively worshiped agile development.
I was given a task: To implement a set data structure in Java as simple as possible to pass the test cases that he would write to challenge the implementation. The first test case was to assert emptiness of a new set via the method `bool isEmpty`. Returning `true` was easy. Then Daniel wrote another task to add a new element and requested the set must return `false`. I added a count & array as private data members. Daniel said I should implement as simple as possible. So I used private one member _isEmpty and set it to `true` by default and `false` when invoking `add(int value)`.
And we went on to add test cases to cover methods `int count()`, `void remove(int value)`, `int getIndexOf(int value)`… I got 2 bugs and JUnit was able to point out which test cases failed and I was able to locate the bugs with ease.
The real value is seen when refactoring was involved in the process. TDD approach & the written test cases greatly aided me in verifying that code refactoring worked like the old code. When it comes to real life projects with hundeds of modules and millions of lines of code, refactoring without test coverage is like walking into a minefield. If you were diligent enough to write test cases to cover all functions and methods, then you can refactor at will and then run against the accumulated test cases with confidence.
However, one must be clear that test cases guarantee only the cases they cover. Passing the refactored code against the test cases doesn’t guarantee correct outcomes of untested cases. So, be diligent and creative enough to write quality test cases to cover all possible cases to exactly define the behavior of the functions & methods.
Lastly, TDD enforces no optimization. TDD requires you to write simplest possible code to pass all the test cases. Refactor along the way and pass the test cases. Profile when you need performance. That’s not to downplay the importance of throughout & mindful design of algorithms and data structures. One must find a good balance between TDD & efficient implementation that is crafted since the very beginning, not leaving refactoring to the very late stage.
The NginX server from the Ubuntu LTS repo was 1.1.x and did not support WebSockets. The minimum version of NginX that supports WebSockets is 1.3.13. Note that supports comes in the proxy module. I upgraded to 1.4.1 by compiling from source and the proxy module is enabled by default. Now you can taste WebSockets via NginX proxy at http://pico.simpleit.us/ . Only valid users can log in and fully experience it. If you want to test our new app, comment below.
After much consideration, I finally moved away from Apache & mod_php to NginX & PHP FPM. The site works much faster and no more I/O & CPU issues. I suspect my Apache was hacked last time, resulting in weird I/O behaviour and spikes in CPU usage.
I was cleaning up Apache config and removed the default 000-default & default-ssl from the Apache sites-enabled sub-folder. To my surprise the default page now goes to a web app that I did not expect. It took me a sec to realize 2 things:
The first VirtualHost config that has format *:80 (HTTP) or *:443 (HTTPS) was considered the default site
Apache loaded files in alphabetical order
So I prepended my blog config file with 000- and now blog is the default site across simpleit.us
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
2. Select Accounts
3. Select Login Options
4. Unlock & input your password (please revert input to English first)
5. 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 😉 !
Previously I hosted all DNS records for simpleit.us with NearlyFreeSpeech (https://www.nearlyfreespeech.net/). They provide cheap DNS hosting at 1c/day per zone. Initially I didn’t hosted my DNS records with Linode as I was interested in redundancy. However, later I realized that I didn’t have any back-up/disaster recovery site on par with the VPS hosted with Linode. The account I have with NearlyFreeSpeech is meant for low performance and HTML-only content did not match with my VPS. Thus having DNS hosting with NFS didn’t give any extra advantage and I migrated to Linode to centralize my control.
Unlike NFS which gave me freedom to add any kind of records, the Linode DNS manager has the most basic records (SOA, NS, A/AAAA, MX, CNAME, TXT and SRV). That would suffice for any daily needs. I had experience with NFS and Zonomi (DNS host provider). They both require technical details such as the trailing dot “.” at the end of each alias/MX mail server. Linode, however, simplified this and caused little confusion. Linode also does not give as much freedom on cache time like NFS or Zonomi do.
Linode was good at hiding technical details for simplicity and I got all SOA, NS and A/AAAA records populated. That saved me lots of typing effort and time as well. I was able to get my domain and subdomains back to running status within 15 minutes. The only issue I had is all emails I sent to @simpleit.us were rejected with 554 error. I have Google Apps hosted on my simpleit.us and enjoyed using emails like email@example.com. Linode had MX records interface what were little confusing. I had to read their manual http://library.linode.com/email/google-mail to fix the issue of email rejection. I went little further by adding the SPF record as advised by Google manual: http://www.google.com/support/a/bin/answer.py?answer=33786.
There were handy tools that helped me verify my MX records, you may find them useful too:
Was not using this blog for quite a while as it lacked the features I needed such as reordering of the images in a gallery. Today I got an email from Posterous announcing a bundle of new features such as updated web editor, more flexible image/photo management and 2 new themes.
I love the new theme named “Minimal” (currently in use). It’s clean & elegant. There are a few important additions to the themes, such as show on click and show on hover widgets. JS is not yet allowed but let’s hope that there are will be more dynamic widgets to compensate the designers and users.
I’m waiting for the moment when designers can add their own JS snippets. The meta language by Posterous for theme design is not feature rich yet. The editor always lacks the “justified” text alignment feature. Let’s wait for a surprise from them.
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.
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)
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: