git Cheatsheet

February 1, 2010 0 comments

When you’re new to git, it can get difficult to wrap your head around it at first. This is especially true if you’re migrating from subversion or when you’d rather spend more time writing your code than trying to learn git.

Git requires some learning, and you might as well spend the time doing it rather than wondering what just happened after running a command. Learn.github is a good place to start to learn the basics.

But even after spending some time learning git, there are going to be times that you’ve to painfully search the web/manual for basic stuff like working with remote branches or more complex stuff like handling a failed merge.

For the same reason, I’m creating this post as a reference point for myself to avoid repetitive searches. I’ll keep adding new commands here if and when I use them.

This is no way near to a complete reference for git and there might be better ways to do the things listed here. These are just the commands I use the most, in the manner I prefer to use them.

Basics

Commit & Stage all changes:

git commit -am  "log-message"

Push Changes to remote repo:

git push

Pull Changes to local repo:

git pull

Check current status of working tree:

git status

View diff:

git diff

Discard local uncommitted changes to a file (in this case, abc.txt):

git checkout -- abc.txt

Branches (Branch name is assumed to be ‘abc’)

Working with local branches

Create a branch:

git branch abc

Switch to a branch:

git checkout abc

View all existing branches:

git branch

Remove a branch:

git branch -d abc

Merge a branch :

#In this case, merging abc into master
git checkout master
git merge abc

Working with remote branches

Push a local branch to remote repo:

git push origin abc

Delete a remote branch:

git push origin :abc

Setup a local branch to track a remote branch:

git --track branch abc origin/abc

Create a local branch, push it to remote repo. and then pull changes from it:

# Creating the new branch and switching to it
git checkout -b abc;
 
# Pushing the changes
git push

# Meanwhile someone else made changes to the remote version
# Pulling those changes
git pull origin abc
# if you want to simply use 'git pull' to get the changes, do the following
git config branch.abc.remote origin
git config branch.abc.merge refs/heads/abc

Alternative methods listed here.

Tags (Tag name is assumed to be v1.0 here)

View all tags:

git tag

Create a tag referencing a particular commit using its checksum (annotated):

#here commit checksum is assumed to be 98eda02.
 
#to view the checksum of a commit, you can do
git log --pretty=oneline
git tag -a v1.0 98eda02

Push tags to remote repo:

git push --tags

Useful git references:
Learn.github
Github’s git cheat sheet

How gleeBox makes browsing the web faster and more fun

January 28, 2010 0 comments

gleeBox started out as a weekend hack project for me and Sameer. But, we ended up spending a lot more time working on it. Not that I’m complaining, I think we managed to build a tool that is really useful once you get used to it. We made our last major release (1.0) a couple of weeks back. From now on, gleeBox development will be carried out at ease (and not the 20 commits/day rate at which it was being carried out earlier ^^ )

If you’re not familiar with gleeBox, you should take a look at this screencast or read the user manual.

After continually using gleeBox for some time, I’ve discovered several ways in which it makes browsing and doing stuff on the web quicker and more fun. Here are some of them:

ESP Visions:

This is my favorite feature of gleeBox. What this means is, you can specify jQuery selectors for specific URLs and when you visit that particular page and open gleeBox, that selector will automatically be executed and all the matching elements will be highlighted on the page. You can TAB through them and press enter to execute a link.

This is especially useful on pages like the Google search results page, where all you would ever want to do is to go through the results. You don’t need to scroll using the mouse. This makes searching a lot more fun and less tiresome for the fingers.

This is also really useful for automating stuff, especially for pages where you have to click the same link everytime you visit them.

Several useful ESP Visions are listed on TipJar.

Default Link Search:

You start typing something and gleeBox highlights all the links on the page that match the text. This means you don’t need to take your hands off the keyboard to navigate the web.

Page commands and bookmarklet execution:

You can execute any bookmarklet by typing in !bookmarklet-name. There are also some inbuilt-commands. A couple of examples are:

!rss – opens the RSS feed of the current page in Google Reader so that you can easily subscribe to it.
!share m/g/fb/t/.. – share current page through mail, gmail, facebook, twitter, etc.

All of them are listed in the user manual.

Bookmark Search:

If turned on, gleeBox searches browser bookmarks if no links are found matching the entered text. This is useful, instead of manually going through a long list of sites in the bookmarks menu.

Yubnub commands:

You can execute yubnub commands preceded by :. Some of the ones that I use a lot are

:tw gleebox – Search twitter for gleeBox
:imdb avatar – search imdb for avatar

I haven’t really explored these in detail yet.

Scraper commands:

With these you can select headings (?h), linked images (?img), etc. You can also define custom scrapers. An example of a custom scraper  is:

?t - a.web will select all shared links on twitter.com

If you’re an advanced gleeBox user, you should go ahead and share tips on Tipjar. You can login using your Twitter/Facebook/other accounts and start posting right away from the main page.

The mental catastrophe that is the social web

October 4, 2009 4 comments

I may sound a bit like a hypocrite, being myself involved in so many social networks and the social web. But, my mind has finally come to the standpoint that it cannot keep up with all the bucket loads of useless information that I put it through daily. Starting today, I will be limiting the use of social networks that seem to serve no useful purpose for me which mostly includes Facebook and Orkut.

I’ve deleted my Wakoopa account (sorry Wakoopa!), since I didn’t see it help me in any way besides maybe me taking a look at it every now and then to look at an abstract graph of how I spent my last week on the computer.

I am not going to all together delete my Facebook or Orkut accounts since they let me stay in touch with friends with whom I’m not in touch with in real (non-internet) life and share stuff ( photos, links, etc. ) with friends with whom I am in touch with in real life. I would instead be limiting my use of both these social networks to a trickle. At least that’s the plan.

It wasn’t until I heard Conan O’Brien joke around about the “attention deficit disorder” on The Tonight Show that I realised that I was actually suffering from a minor form of it. One of the culprits is Twitter, where one follows so many people that it actually pushes you to skip through information. I will gradually start to unfollow people who create a lot of noise and tend to feed my habit of ignoring information. I’m also going to avoid running a Twitter client in the background ( in my case, Tweetie ). On a more positive note, Twitter, for me, is useful to keep up to date with the latest news in areas of my choice ( Design and Technology ) and have conversations with interesting people on the Web. And yes, ofcourse, it lets me rant about me.

Google Reader and Friendfeed are useful and almost my main sources of news and information (along with Twitter) and since I use them in proportion, they don’t really hinder me. I like Last.fm as it allows me to listen to its radio and I’m not addicted to it so it doesn’t eat up my productivity.

So, what led me to the brink? Over the past few weeks, I had been overtly commenting on Facebook and checking my Gmail. It made me realise how much time and energy I was wasting doing nothing.
Then, I asked myself the following questions about each social app I use frequently:

  • Does it generate content that is meaningful and useful to me?
  • Does it connect me with people who are interesting and like-minded to me?
  • Is it a time-sucker?
  • Does it make me less productive?

Social Web does have a lot of Pros in favor of it, that is if you keep your usage in check.

  • It allows you to have conversations with interesting and like-minded people on the Web, no matter where they may be physically located, eventually expanding your intellectual horizons.
  • It lets you stay up-to-date with what is happening in the world.
  • It allows you to collaborate with other people on creative projects.
  • It lets you create your own individual presence on the web.
  • It allows you to share content with your friends and family.

If kept under a check, the social web will continue to be useful to everyone instead of making everyone unproductive.

So, if I don’t reply to your Orkut scrap or Facebook comment, and if it is really important, @reply me on Twitter or email me.

Installing the Front End Editor extension on Joomla 1.5

October 1, 2009 33 comments

Many of you already know that I created the “Front End Editor” aka “Enhanced Front End Editing” extension for Joomla! as part of Google Summer of Code 2009. The extension only works in 1.5.x right now. Even though I tried to make it easy to adopt the extension by making it easy to setup, the extension does rely on the template quite a bit. I thought if I explain the installation process, all the hacks the extension makes and the underlying dependencies in a blogpost, it should help in getting rid of confusion to some degree.

You can download the extension from JED.

Installation

  1. Install ‘com_frontendeditor’, ‘plg_frontendeditor’ and ‘plg_articleeditor’ from here.
  2. Enable the plugins “System – Frontend Editor” and “Content – Frontend Article Editor”.
  3. Go to “Components->Enhanced Frontend Editor” at the backend and click on “Apply Changes”. You can modify the settings there to suit your template and needs.

Hacks ( applied when you click on “Apply Changes”)

  1. Adds the module chrome “modChromefreditor” to the “html/modules.php” file of the current template. Before doing this, it creates a backup file ‘html/modules.php.backup’.
  2. After creating a backup of “index.php” as “index.php.backup”, it modifies the following statements in the “index.php” of the current template:
    • All the jdoc statements get the style “freditor”. Eg.:
      <jdoc:include type="modules" name="top">

      gets changed into

      <jdoc:include type="modules" name="top" style="freditor" />
    • Surrounds the jdoc statements with a DIV that has class in the format
      frpos.position-name

      Eg.:

      <jdoc:include type="modules" name="user3" style=" freditor" >

      gets changed into

      <div class="frpos.user3">
      <jdoc:include type="modules" name="user3" style=" freditor" />
      </div>
  3. Replaces the existing “/html/com_content/article/form.php” file with a custom “form.php” ( after creating a backup file i.e. “form.php.backup”)

The backup files are created so that you can undo the changes anytime by clicking on “Revert Changes”. You would probably want to revert the hack if you choose to uninstall the extension.

You’ll also need to apply the hack separately for each template you want to use.

Dependencies & Limitations

  1. Mootools 1.2
    Perhaps the biggest limitation of this extension is that it uses mootools 1.2 instead of 1.1 which is used in Joomla! 1.5. Consequently, some of your javascript that uses mootools 1.1 may not work properly when you’re logged in. Mootools 1.2 will only replace 1.1 when you’re logged in at the front-end and have the plugins enabled. The reason I chose 1.2 is that Joomla! 1.6 will use mootools 1.2.
  2. Menu-item title editing
    The menu-item titles must be enclosed in LI elements with the class in format item<menu-id> Eg.:

    <li class="item13">
    <span>Joomla! Documentation</span>
    </li>

    If your template uses a different layout, you may want to modify it a little to support menu-item title editing. In case you don’t, you need not worry as each of these features degrade gracefully, without affecting the functionality or presentation of your site.

  3. Default article edit icons are hidden
    The default edit icons are hidden and the extension displays its own edit icons. You can specify their selector in the admin component. In case your template uses a different selector than the default one and you don’t specify it, a pair of edit icons can appear for each article which will lead to confusion.
  4. Selectors for article and page titles
    If they are not the default, you can modify them in the admin so that editing of article and page titles works.

Future Versions

You can report any bugs here. Since my college semester has now begun, any updates to the extension will probably come slowly. I plan to remove any trivial withstanding bugs, add new features with time and improve the extension in general. I would love to spend any free time in fixing bugs of the overall Joomla! project as well.

As far as Joomla! 1.6 is concerned, I did create a patch for 1.6 but due to time constraints, it wasn’t included in the feature-set for 1.6. So, when a stable version of 1.6 is released, I’ll port this extension to support 1.6.

I will love to know if the extension worked for you and any suggestions or feedback you want to give. You can either contact me via the Contact page or send me an @reply on twitter.

Update:

This is a common recurring problem for version 0.3.7 of the extension. If you’re getting the following error:

Parse error: syntax error, unexpected ‘&’, expecting T_VARIABLE or ‘$’
in your-install/administrator/components/com_frontendeditor/controller.php
on line 99

it means you’re probably using a version of PHP earlier than 5. Unfortunately, this piece of code only works in PHP 5. You’ll either need to update to PHP 5 or get the patch from here. You’ll need to apply the patch to your-install/administrator/components/com_frontendeditor/controller.php

In case you’re not familiar with applying a patch, you’ll have to execute the following command from the shell:

patch -p1 -i 99line.patch controller.php

Update 2:
If you would like to promote the development of this extension and make a contribution, please go to the project page.

Twitkut v2.0 to be an OAuth Gadget

September 28, 2009 0 comments

I’ve been working on the next version of Twitkut in whatever little free time I’ve had in the past couple weeks ( mostly weekends ). The next version of Twitkut will feature a number of new and exciting features, the most major one being support for OAuth. Some of the features have already been deployed on Orkut:

1. Displaying user tweets in the Orkut profile page (deployed): I had to rewrite the whole code for this due the new server-side templates and data-pipelining standards enforced by Orkut. It has certain limitations in that you cannot click on any link that links to any external source. Clicking on the user’s pic or username leads you to the application page.

2. OAuth Support: Twitkut will now enable you to authorize it with your Twitter account via OAuth. Doing this will enable you to post updates from Twitkut, add your Orkut friends as your Twitter friends and many more things (listed as separate features). I chose OAuth since then you won’t have to worry about me storing your Twitter passwords.

3. Post updates from Twitkut: If you enable OAuth, you’ll be able to post updates to your Twitter account from within Twitkut.

4. Follow your Orkut friends on Twitter: Enabling OAuth will enable you to follow your Orkut friends on Twitter from within Twitkut.

5. Selective Updates: This will be similar to the “Selective Twitter Updater” Facebook app. You will able to selectively display updates on Twitkut by adding a hashtag to the end of updates similar to “#orktw” or “#orkut”. I’ve still to decide upon the hashtag. Only the updates containing the hashtag will be displayed on Twitkut.

Unfortunately, the popular demand for automatic updates to the user’s activity stream ( without the user having to visit the application page ) won’t be possible due to the limitations enforced by Orkut. If Orkut ever allows it, it’ll be the first feature I’ll add.

I cannot promise if and when I’ll add all these features. There are too many variables, time being the biggest one. You can keep abreast with the latest updates to Twitkut by following @twitkut.

You can also suggest features that you’ll like to be added to Twitkut as comments to this blogpost or as @replies to @twitkut.

Enabling Twitkut with OAuth has been/will be a complicated task. I’ll probably write a separate blog on writing an Opensocial OAuth Gadget.


Next Page »