`quickie` and `loud Mouth`

| Comments

I’ve started two new categories. loud mouth and quickie. I am doing a new experiment of writing a blog post of every new or old (which I haven’t documented) I do while I am working on some project. loud mouth is for that. But I don’t always like to explain things deep. For those times I am starting quickie, which represents posts which just get stuff done, without explaining much; basically just a dump of the steps I took to solve something. Here’s first post that belongs to both these categories.

Find Which Application Is Running on a Particular Port

| Comments

I tried a Chrome extension I ran into on reddit. It runs mitm proxy behind the screen. Then at an occasion, I had to run a proxy for my work purposes, but I found port 8080 is already taken. It turned out tamper keep mitm proxy running even when it’s disabled (not the extension but through the switch given in tamper). This is how I found out which application was using port 8080.

The Awesome of Web Browsing With Emacs

| Comments

Emacs is awesome. There is a kinda steep learning curve for new comers, which I think is the reason it’s not popular among most new-techies. But once you’ve got over that, it’s all hugs and kisses.

Emacs is addictive. You get addicted to it. Addicted to its power, to its flexibility, and if nothing else, it’s keyboard shortcuts. This addiction result in browser extensions like firemacs ), (you should definitely try it if you are an emacs user), which adds emacs shortcuts to Firefox (another awesome piece of technology).

My Setup for Using Emacs as Web Browser

| Comments

This post was actually a part of the last one, but the node was long enough so I broke it into two. Why? Well, why making it one post when I can make them two? To save users a click and a page load (I know some UX) of course, but I also have to convince ever self-criticizing brain that I am justifying with my blog and not slacking off.

So here’s my setup for using Emacs as a web browser.

Some Tips for Developing Firefox Extensions in Emacs

| Comments

I used addon-sdk to create my simple firefox addon. It makes really easy to create firefox addon by avoiding writing boilerplate code and provides a simple Javascript api for some functionality of Firefox.



Addon-sdk do makes things easier but the workflow is still not as  straightforward as that of developing Chrome extensions. In chrome, we can load unpackaged extensions which are just folders containing a simple HTML app and a manifest.json. In case of Firefox addons, we need to first
  • build a firefox extension from within the folder containing the code with ‘cfx xpi’ (command provided by addon-sdk)
  • then run a Firefox instance with ‘cfx run’
We need to do this every time we make any change in the addon code. Sounds
gross right? It is indeed gross.

To make things simpler, there’s an addon in Firefox marketplace called ’auto-installer’ which allow us to install addons on the fly. This is highly recommended if you are going to develop a firefox addon.
Here’s a great tutorial on Firefox Developers Network for installing and using addon-sdk.
So when developing a new Firefox addon, things should go in a flow similar to this.

Install Auto-installer addon in Firefox

This addon allow pushing the addon we are developing to Firefox on the fly, without the need to do something like ‘cfx run’ over and over again.
  • It need us to build the addon (cfx xpi), and send it inside a HTTP POST request to localhost:8888
  • It then reinstall the addon on the running Firefox instance
  • It identifies the addon by its ‘id’ we define in ‘package.json’ file. So if we change the ‘id’ there, a new copy of our addon will get installed along with previously installed file.
This make things specially easy with Emacs, see next point.

How to use

  • Install auto-installer on a Firefox instance (may be with a different profile than your default profile (firefox -ProfileManager))
  • Build the addon
    cfx xpi
  • Post it to localhost:8888. e.g with
    wget –post-file=myAddon.xpi http://localhost:8888/
  • Done
In the article on Firefox developers hub, they suggest following command which I found not very good.
while true ; do cfx xpi ; wget –post-file=codesy.xpi http://localhost:8888/ ; sleep 5 ; done
Above command builds a Firefox xpi addon from our source code every 5 seconds, and push it to the Firefox instance. It’s annoying in its own right.

Install ’compile-bookmarks’ in Emacs

This package allow keeping ‘compile’ commands like bookmarks, and executing them with keyboard shortcuts. It’s more useful than one might think at first. I do all sort of tasks as compile-commands in Emacs like running unit-tests.

Create a bookmark with a compile command like following:
/path/to/firefox-addon-sdk/bin/cfx xpi && wget –post-file=myAddon.xpi http://localhost:8888/
When we provide complete path of the ‘cfx’ command, we don’t need to activate the ‘virtualenv’.

You can do this by
  • run ‘compile’ function (M-x compile)
  • execute above mentioned command from mini-buffer
     
  • Select ‘add’ from ‘compile’ menu. The command you used previously for compiling will appear there, select it
  • It will then prompt in mini-buffer for a key to use for compiling with above command
  • Choose whichever seem right to you. I have chosen ‘f’ for this.
You can now run build and install your extension in firefox with keys ‘C-` f’.

This was the workflow I came up with developing my one firefox addon. I would love to hear how experts do things. If you have time, please tell in comments your way of doing things.

Differnet Ways of Accessing a Commit in Git

| Comments

Ok, so it’s been quite long since I wrote anything for this blog. I made a resolution earlier about ‘a post a day’ which is apparently shattered. So here’s a quick and dirty posts straight from my notes to help bringing me back on track. Any help it does to anyone else is a bonus :)

So as we discussed in a previous post, there are many names for a commit (noun) in git. We may call it a branch, a tag, or just a commit, they are just different ways of accessing a commit.

So, here’s an incomplete list of different ways in which we can access a commit in git.

“To Know Me Better, Try Walk in My Boots”, Said GNU/Linux

| Comments

A quick go through to the GNU/Linux boot process

This post talks (quickly) about how a typical Linux (PC) system boots. I’ll try avoiding much technical terms. It’ll be a quick walk without diving much deeper.

The booting process of a system involves several steps.
When the computer first powers up, the code in its ROM is executed. This code generally called the firmware has some knowledge of the system hardware. On PCs this initial boot code is generally called the BIOS (Basic Input/Output System). A PC can have several BIOS levels for machine itself, graphic cards, network cards etc. In the context of booting, the BIOS generally perform two operations:
  • It figures out which device to boot from
  • And loads a program from the bootable sector from bootable device which tell the secondary boot loader to load

Git Commit Illustrated: Simplicity Revealed by a Complex Exercise for Simplest Git Task

| Comments

In this post I will try to explain the underlying commands and to a level the internal working of the git system involved when making a ‘commit’.
This post is actually the by-product of my research for another post about git (.git/ actually). I was so much astonished by the amount of myths about complexity of git system removed from my mind, that I decided to make it the today’s post itself. To me the git system appears much simple now than yesterday.

Commit

Commit is the central piece of the git system. The git world is simply a collection of commit objects, each of which hold a tree, which hold references to other trees and blobs. The branches, the tags, the HEAD are just fancy aliases for commits (more on these in some other post (next may be)).
A commit is basically the snapshot of present working tree. I will spare the details for a future post (it’s worth it).

Let’s now discuss what this post is about. Revealing the secrets involved in every git users ritual of ‘commit’ing, and performing a commit manually.

5 Cool Things to Do With `netcat’

| Comments

I heard somewhere about ‘netcat’ being the swiss-army-knife for networking. Looking through its man pages I tried many commands as I could understand them, but still remained unimpressed. But so many wise people calling netcat ‘the awesome’ can’t be wrong, right! So I went through lengths and surfed  the Internets, grep’d some ebooks on networking, re-read its man pages and forced myself to get impressed.
Here is a list of cool things I could figure out to be done with netcat. I am sure there are more my puny brain couldn’t discover. Hugs and kisses for all (females) who will tell ‘em in comments.

5 Things I Frequently Do and Forget With Git

| Comments

Here are few things I used to do a lot in my starting days with git and then forgot to re-search them when needed next time. These tips are from my notes.

How to undo the last Git commit?

There are two scenarios in this case, and hence two ways to achieve our goal.

Hard Reset - Completely undo the last commit and all the changes it made.

git reset –hard HEAD~1
Imagine the state of the tree is as following:

   (F)
A-B-C
       ↑
  master