• 31 May 2015

Use git reflog to restore reset commit

The last day of the workday of last week, my colleague told me that he lost his previous two days of work because he reset his local git commit to a prior one without pushing his work to the remote first. Upon receive this alarming news, while I have many other things to finalize, honestly my heart was virtually fall out. Fortunately, I believe in the power of git that it must be able to restore this thing! And sure enough, it turned out very easy to do:

      1. This assuming you are not yet run “git gc” ( garbage collector), so all the dangling commits are still available.
      2. Run the “git reflog” command (reflog starnds for reference log). This will list of series of history commits with short commit messages and SHA1s, including all those dangling commits. The short commit message is very helpful because normally you won’t remember your commit’s SHA1, but you recognize your commit message.
      3. Find the commit SHA1 you want to restore. For example, assume our commit needs to be restored here is [SHA33ddf]
      4. run “git branch [branchName] [SHA33ddf]”, this will create a new branch with the head point to this commit’s SHA1. Your work has magically restored!
      5. The last step would be setting up your new branch for tracking with the corresponding remote branch: “git branch -u upstream/branchName branchName”, assuming upstream is your remote origin.
  • 8 July 2014

Just another successful Git Branching Model for flexible sprint cycle

This Git Branching Strategy is based on the famous “Git Flow“ process (http://nvie.com/posts/a-successful-git-branching-model/ ). However, according to our project’s sepcific needs, we adapted the basic branching principle and made some modification on the original model. In the end, this branching model is shown by the picture below:

Git Branching Model illustration
Git Branching Model illustration


last comments

good thing that git has cheap branching.
James Ting
James Ting

What would be the meaning of the Main Branch?
David Adam

you mean the Master Branch?

  • 8 December 2012

Use Drupal as a direct project prototype and project management tool

Currently, I manage a Drupal project based on Drupal Commerce. While I am writing the specs for the project, I really feel that actually, we can use Drupal as a platform serve as prototype and project document management tool. (more…)

  • 2 December 2012

Protected: My experience with eZ Systems

This content is password protected. To view it please enter your password below:

  • 9 September 2012


Those who do not understand Unix are condemned to reinvent it, poorly – Henry Spencer

  • 6 September 2012

HTML 5 the language that one should learn about

HTML 5 is known as a markup language which is used in organising the World Wide Web and also it is the hard-core technology for the Internet. The number five in the HTML denotes that it is the fifth version of it. Many improvements and features are added in this language. (more…)

  • 27 August 2012

Use instead of localhost on Zend Server

When install some system on Zend Server locally, such as Magento, sometimes, you need change the database server name from “localhost” to “”.

It is just a note written as a record for future reference.

  • 20 July 2012

Drupal 8 and eZ Publish 5 and Symfony

As the future Drupal8 and eZ Publish 5 will both base on Symfony as their core, a few days ago one of my colleague at eZ Systems asked the technical difference between future Drupal 8 and eZ Publish 5. Here is my opinion about their difference: (more…)

last comments
Mahmoud Fawzy
Mahmoud Fawzy

Man, your post is clearly biased towards eZPublish :) ... not saying that is bad or completely wrong but it…
David Adam

You are right, it is biased towards eZ Publish because it is an originally a post for the market purpose…
Kapil Dave
Kapil Dave

Well, saying this and that is not available in Drupal's core system and hence it is not good enough is…
David Adam

I agree with you. But the article had some bias in the other system. Drupal is a great system.…

  • 9 July 2012

Redis Internals

Everything in Redis is ultimately represented as a string. Even collections like lists, sets, sorted sets, and maps are composed of strings. Redis defines a special structure, which it calls simple dynamic string or SDS. This structure consists of three parts, namely:

  • buff — A character array that stores the string
  • len — A long type that stores the length of the buff array
  • free — Number of additional bytes available for use

Although you may think of storing len separately as an overhead, because it can be easily calculated based on the buff array, it allows for string length lookup in fixed time.

Redis keeps its data set in the primary memory, persisting it to disk as required. Unlike MongoDB, it does not use memory-mapped files for that purpose. Instead, Redis implements its own virtual memory subsystem. When a value is swapped to disk, a pointer to that disk page is stored with the key. Read more about the virtual memory technical specification at http://code.google.com/p/redis/wiki/VirtualMemorySpecification.

In addition to the virtual memory manager, Redis also includes an event library that helps coordinate the non-blocking socket operations.


  • Redis doesn’t rely on operating system swapping because:
    Redis objects don’t map one-to-one with swap pages. Swap pages are 4,096 bytes long and Redis objects could span more than one page. Similarly, more than one Redis object could be in a single swap page. Therefore, even when a small percentage of the Redis objects are accessed, it’s possible a large number of swap pages are touched. Operating system swapping keeps track of swap page access. Therefore, even if a byte in a swap page is accessed it is left out by the swapping system.
  • Unlike MongoDB, Redis data format when in RAM and in disk are not similar. Data on disk is compressed way more as compared to its RAM counterpart. Therefore, using custom swapping involves less disk I/O.

Salvatore Sanfillipo, the creator of Redis, talks about the Redis virtual memory system in his blog post titled, “Redis Virtual Memory: the story and the code,” at http://antirez.com/post/redis-virtual-memory-story.html.

  • 6 July 2012

NoSql Notes

In NoSQL stores, the create and read operations are more important than the update and delete operations, so much so that sometimes those are the only operations.