Skip navigation

Category Archives: coding

node-waf is a tool shipped with Node.js to help build C++ files into a node.js compatible library or tool. It is only available if you installed node.js from source. 


The path to node-waf is usually in /usr/local/bin


If you see that node is installed in /usr/bin but not /usr/local/bin then you did not install node.js from source.

$ git clone

$ ./configure

$ make

$ sudo make install

And now you should see node-waf in /usr/local/bin

If you simply try to use node-waf without installing node you’ll see this error:

“ImportError: No module named Scripting”

Do not do this, instead install node.js.


The imperative implementation of the algorithm is well known. Let’s arrange the input sequence (e1, e2, …en) into an array ‘a’ so that initially a[i] = ei, i=1..n. At step 1, we choose a random number r1 uniformly from [0..n-1]. Thus a[1+r1] will be the first element of the permuted sample, b1. We swap a[1+r1] and a[1]. Thus a[1] will contain b1. At step 2, we choose a random number r2 uniformly from [0..n-2]. a[2+r2] will be a uniform sample from {e1..en} – {b1}. After we swap a[2] and a[2+r2], a[2] will be b2, and a[3..n] will contain the remaining elements of the original sequence, {e1..en} – {b1,b2}. After n-1 steps, we’re done. The imperative algorithm in OCaml has been already posted on this thread.

Includes an implementation example and a critique of sort-based algorithms.

To make option left (⌥←) move to previous word you only need to add a new key binding entry like the following:

Terminal Key Editing

To insert 33b you need to hit the escape key (which inserts 33) and then press b.

You want to do the same for option cursor right. You can also bind control left/right to begin/end of paragraph. The shell keys for these two actions are ⌃A and ⌃E. In the key bindings editor you press ⌃A (control A) and it will insert 01 as the string value:

Terminal Key Editing

I don’t get why this has to be done or what is wrong with the default settings. Really bizarre.

Posted via web from Apphacker’s learning curve

Official Google Blog: The Google design, turned up a notch.

I like the new logo better, but unfortunately I can’t see it since I use their keyboard shortcut experiment (and have been for like the last three years). I see some Google Experimental logo and I don’t see the new side bar either. I’d rather have the keyboard shortcuts than the pretty new logo any day though.

This one is pretty easy, but for the fact that the built-in help doesn’t mention git ls-files.

To view deleted files use git ls-files –deleted

To restore deted files just use git checkout – <deleted_file>

Too easy.

In svn you’d simply type ‘svn up’ and deleted files would be restored. A little bit more involved with git.

Posted via web from Apphacker’s learning curve

$du -ah /path/to/dir

The ‘ls’ program will show you file sizes but only 4k for directories (depending on machine, platform and other variables). Use ‘du’ as shown above to get the folder size.

Posted via web from Apphacker’s learning curve

sudo dpkg -L packagename

for example:

bjorn@bjorn-ubuntu:/usr/lib$ sudo dpkg -L libmemcache0

Posted via web from Apphacker’s learning curve

For a few years now there has been a steady trend toward more powerful websites. Websites with more features, new interactions, beginning to resemble desktop applications. Google is a known proponent of this approach, and they’ve come up with an operating system that is basically a browser running client side applications.

Definition of a client side app
A client side app, sometimes also referred to as an RIA or rich internet application, is a website that launches a powerful front-end application usually written in JavaScript.

Benefits of client side app
A powerful, fast, responsive and dynamic UI. Desktop UI metaphors such as context menus, interactive visuals, drag and drop and others that allow for complex and intuitive user interaction. A comprehensive user interface experience where all aspects and features are contained within a unified application. Less reliance on links and standard web elements adhering to a hyperlink document metaphor. Dynamically updated interface immediately connected to a back end service – think instant messaging or Google Wave instead of a forum as an example.

Proponents of client side app
Google, a vast horde of Silicon Valley startups, tech reporters such as TechCrunch, and even Microsoft, Apple and Adobe are making noticeable impact in client side applications. The new HTML 5 specification. JavaScript libraries such as Google Closure, Dojo, and jQuery.

How to think about a client side app in the implementation
The danger is to think that some use of AJAX and dynamic UI elements is enough but it isn’t. The common refrain is the comparison to a desktop application, so let’s pursue that analogy.

Desktop analogy
There is a benefit to be realized from drawing a connection between a client side application in a browser and a desktop application. Desktop applications don’t download parts of its UI from a remote server. For example, some web sites may use XMLHTTPRequests to grab server side generated HTML from the backend. Desktop apps don’t do this, they can’t (unless they use something like a WebView), and neither should your client side application. Grab your data from the backend as a desktop application could handle it, as JSON or XML, and allow the client side application to determine how to display this information to the user. From launch until close, your client side application should render the UI, not the backend.

Desktop applications do not display an inordinate amount of buttons that send you to other desktop applications. In fact most desktop apps never send you to another application. In a client side application links to other sites take you out of the application to some other place: a link closes your application if it does not open a new tab or window. How many desktop applications have interface features that simultaneously send the user to a different desktop app and then closes itself?

The initial HTML is really an application download
The best way to think about a client side app is to imagine that the initial HTML download is an application download. Allow the client side application to perform the rendering of information and UI elements. Don’t utilize back end generated HTML, even if there is a small performance hit: you’re loading an application, not a website document. The first time a user downloads your application it is also an installation. You prepare the client side database/storage mechanism, you obtain user preferences, you explain your application. Smart use of browser caching can help prevent new downloads of your application on subsequent visits. Updates are actually new versions of your application that will require a new download via cache busting techniques.

Compile your application
Make use of tools such as Google Closure’s comiler. Make use of sprites and condense your CSS into a single file. Think of using tools such as buildbot and scons to generate the application that will reside in production to help you with these steps.

The desktop analogy can go a long way to help you develop a more powerful experience for your website. I know this is probably a horse that seems beaten to death but there is still confusion and often optimal designs are not implemented. Developers or product managers imagine that their one little AJAX jQuery slider feature on an otherwise static page means they’ve marked that “I have a client side app” check box, when the entire approach may be wrong. As a developer who in some ways specializes in writing JavaScript as rich internet applications it strikes me when speaking to potential employers when they are not sure what to do with someone like me. Often people may pay lib service to the idea of a client side application with a “we want that” but then can’t find a place for it yet. They want it, because it is a great thing to have. To get it, a little shift in thinking may be required.

One of my biggest problems with vim has been figuring out how to edit normal text. Vim seems suited best for code, small lines with hard new line carriage returns at the end. Well I just discovered this bit below which may lead to me using Vim for all text editing, even non-coding for now on!

10.6. How do I jump to beginning or end of a sentence, paragraph or a

You can use the following motion commands to jump to the beginning or end
of a sentence or a paragraph or a section:

      motion  position    where
      (       beginning   current sentence
      )       end         current sentence
      {       beginning   current paragraph
      }       end         current paragraph
      []      end         previous section
      [[      beginning   current section
      ][      end         current section
      ]]      beginning   next section

Each of these motions can be preceded by a number which will extend the
jump forward (or backward).

For more information, read

    :help object-motions

Posted via email from Apphacker’s learning curve

Move to the top or bottom of the viewable buffer (current file open and focused for editing) via H to go the top (think H for High), M to go to the middle, and L for the bottom (L for low).

Posted via email from Apphacker’s learning curve