Skip to main content


Showing posts from July, 2009

Git supports commiting specific parts of a file

While working on my web based learning project, I made a lot of changes to a Django view file without committing them. When I actually decided to commit, I realized that the changes in my view file should go into separate commits. I knew it was possible to commit parts of a file in Git, but I was not sure exactly how it could be done. I asked the question on StackOverflow and got an answer within minutes :-) Anyways here's how I did it. I had 3 files in my index: app/courses/templates/course/show.html app/courses/ The first 2 files were fine, but I did not want to commit the entire view file with the first two, I wanted only one change in that file to go in this commit. Since I had already added the view file to the index, I first had to unstage it with: git reset app/courses/ Then I did an interactive add to add only one hunk from the view file: git add --patch apps/courses/ Running this command showed me the first hunk from the file and an option ask

JQuery selectors and future elements

I am using JQuery for the AJAX and dynamic aspects of my web based learning platform. I like the fact that JQuery allows us to use CSS type selectors to select elements on the page to either manipulate them, add event handlers, or a host of other things. So, the code below intercepts clicks on all links and dynamically adds a new link when a link is clicked. <html> <head> <link rel="stylesheet" type="text/css" href="/site-media/al/style.css" /> <script type="text/javascript" src="./jquery-1.3.2.min.js"></script> </head> <body> <script type="text/javascript"> $(document).ready(function() { $("a").click(function() { $("ul#questions").append("<li><a href='#'>click me</a></li>"); }); }); </script> <div> <

Refreshing iptables

The last time I played around with IPTables was about 6 - 7 years back. I have been working with a Linux box again from the last few months and I am absolutely thrilled about it. Nevertheless, I have also been meaning to set up a simple IPTables firewall on my machine. Since I had forgotten all my IPTables concepts, I decided to hunt the Internet for some good articles. I found some really nice resources to refresh my memory as well as learn new things. Here is a nice 3 part video series from Linux Journal . iptables part 1 iptables part 2 iptables part 3 The entire series takes less than a half hour and is a good refresher or introduction to IPTables. Here is a nice picture which explains how a packet is routed through various chains in the ip tables. If you are looking for a quick refresher, this might help you out. If you want more details, here is a tutoria l, and yet another tutorial , and Netfilter's excellent documentation on IPTables. So now there is no excuse for not se