A co-worker of mine had the following tree structure in his git repository and he wanted to get rid of the 2abaf35 and 607f016 commits. The solution is a simple
git reset --hard e5e67d0
But, for the sake of fun, I wanted to do it without referring to a SHA value. The HEAD commit has two parents e5e67d0 and 2abaf35. HEAD^ will refer to the first parent and HEAD^2 will refer to the second parent. But how do we know which parent is the first?
According to charon at #git on freenode, HEAD at the time of invoking the merge will always be the first parent. This is the left-most (straight line) branch. The remaining commits will be the remaining parents, in the order you specify. So, in this case,
git reset --hard HEAD^
would have achieved the same feat.
This was posted in r/linux three days back. Turns out it’s actually been written by a human. And someone has spoiled the fun by sending a patch to gnome with the correct version of the error message: PostScript is not supported on this printer. That makes sense anyway.
Also discussed in the Comments section is the famous error message “Error: Success”. Apparently this mistake is common due to the fact that errors are communicated via a global errorno variable [source].
if (some_c_function() < 0) {
some_other_c_function();
print_error(errno);
}
This can be fixed without much hassle though.
One thing I hate about the C Shell is the lack of function support. You’re left with aliases but they don’t work out all the time.
The other I wanted to add the git branch you’re on to the csh (tcsh, in fact) prompt. I tried out adding the following to the .cshrc:
alias GIT_BRANCH_CMD "sh -c 'git branch --no-color 2> /dev/null' | sed -e '/^[^*]/d' -e 's/* (.*)/(1)/'"
alias cd 'chdir !*;set prompt=`whoami`@`hostname`": %~"`GIT_BRANCH_CMD`" > "'
cd ~
But it only works when you cd to the directory. Out of luck when you git checkout, etc. To my knowledge csh has no advantage over bash, so the lesson is to use bash whenever possible.
You may have noticed that apart from the read (r), write (w) and executable (x) permissions in Unix, there’s an ‘s’ permission as well. This is called the setuid permission. If you have access to an setuid-enabled file, then you can execute that file with admin privileges even though you’re an unprivileged user. So, s means that the file is both executable and has root privileges.
It’s possible to add enable setuid permission just as you do with any other permission.
chmod u+s filename
Be wary though, mistakenly assigned setuid can cause havoc if some stupid user takes advantage of the root privileges.
Hey look, it’s not just the code changes we can track with Git! Randomly came across this article from The H Open today. BundesGit uses Git to track changes in the German federal law. This is a pretty cool use for something that is intended to be a source code management system. Tracking something that may change every now and then, so you can keep track of what changed. Laws of a country, company policies, documentation; the possibilities are endless.
One day I boasted to my little sis that my inbox receives 20+ emails a day. She was amazed.
Today I came home after three days away from the computer and had to deal with 50+ unread mails. The sad truth is that 95% of those were automated emails. 16 of them were triggered by ifttt recipes, 5 were from goodreads, 4 from twitter. The rest were from StackOverflow, WordPress, Evernote forums, LinkedIn, and so on. Only two mails had been sent by real people, and out of the two, one was a forward. Is this pathetic? Maybe. Maybe not.
If you haven’t activated 2-step verification for Google / Gmail already, it’s high time you did. 2-step verification essentially requires you to provide two proofs to show that you are actually you. After getting the password correct, you’ll get an SMS with a verification code which you have to enter to sign in. In case the phone is lost, no cellular coverage, etc you can add recovery options.
Why bother? Because you never know when your account’s gonna get compromised, and when you do, you’d wish you were dead.
In case you didn’t know, Windows Explorer sucks. There are about a dozen alternatives available, but most aren’t free. I’ve used Cubic Explorer and Nomad.NET in the past, both of which are free and open source, but didn’t stay with any. Lifehacker reported today about Clover, which is in fact an extension to Windows Explorer which brings a Chrome-style tabbed interface. Click on a tab and you get a menu just like the one you get in Chrome.
No more half-a-dozen Windows Explorers cluttering the task bar.
I’ve always failed at remembering how to create and extract tar archives. But hey, why not create a mnemonic!?
Creating a tar.gz file:
Create Zip File
tar <em>czf</em> newarchive.tar.gz /path/to/file
Extracting
eXtract Zip File
tar <em>xzf</em> somearchive.tar.gz
You can of course add the v option to turn on the verbose mode. eg:
tar xzfv <em>somearchive.tar.gz</em>
Or add a -C option to explicitly mention where you’d like the archive to extract to, like this:
tar xzf <em>somearchive.tar.gz</em> -C ~/ws