Deploying on Dreamhost using Git

May 6, 2011 1 comment

I’ve had to this multiple times for multiple projects and thankfully I had written down the instructions when I first did it in a .txt file. Before I lose those instructions, I wanted to jot those down here.

As a side note, I find this to be extremely useful. You get versioning control and you can easily make small changes and perform updates to a site via the command line, without needing to go through the entire FTP login process. It is especially faster if you save the SSH key. That way you don’t have to enter your password everytime you push your code.

Here are the step-by-step instructions assuming the project name to be ‘rainbows’:

  • Update the robots.txt:

    User-agent: *
    Disallow: /relative-path-to-rainbows
    
  • If your site uses a database, create the database and other dependencies on the server.
  • Login via SSH on server: username@domain.com. Navigate to where you want to deploy your website. Execute the following:

    mkdir rainbows
    cd rainbows
    git init
    git config receive.denyCurrentBranch ignore
    vim .git/hooks/post-update
    # paste this script: http://utsl.gen.nz/git/post-update
    chmod +x .git/hooks/post-update
    
  • In your local repository, add the remote for the live site:

    git remote add live ssh://username@domain.com/path-to-rainbows
    
  • In local copy, push to remote repository:

    git push live master
    # On the remote repository, you may or may not need to
    # do 'git checkout master' to see the changes.
    
  • That’s it! Whenever you need to push code, just do:

    git push live
    
  • To make the process a lot faster, set up SSH Keys to avoid having to enter the password everytime. Instructions for that coming up later.

Reference:

http://stackoverflow.com/questions/279169/deploy-php-using-git

git Cheatsheet

February 1, 2010 1 comment

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 and 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 branch --track 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 -am "v1.0" 98eda02
    
  • Push tags to remote repo
    git push --tags
  • Delete a local tag

    git tag -d v1.0
  • Rename a local tag

    	git tag NEW_TAG OLD_TAG
    	git tag -d OLD_TAG
  • Delete a remote tag

    git push origin :refs/tags/v1.0

Useful Git References

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:

Open the RSS feed of the current page in Google Reader so that you can easily subscribe to it

!rss

Share current page through mail, gmail, facebook, twitter, etc.

!share m / g / fb / t / ...

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 or quix commands preceded by

:

A couple of examples are:

Search twitter for gleeBox

:tw gleebox

Search IMDb for avatar

:imdb avatar

Scraper commands:

Select Linked Images

?img

You can also define custom scrapers. Example: This will select all shared links on twitter.com

?t - a.web 

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 51 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”. Example:
      <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

      Example:

      <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 and 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.

Next Page »