Have you ever wondered how does look the computation of Fibonnaci number in assembly?

Have you ever wondered how does look the computation of Fibonnaci number in assembly?

For sake of curiosity I chose Pep/8 Assembler and Simulator which could be found on http://code.google.com

The original C uncached version looks as following:


#include <iostream>
using namespace std;
int fib (int n)
{
    if (n == 0)
    {
        return 0; 
    }
    else if (n == 1)
    {
        return 1;
    }
    else
    {
       return fib (n - 1) + fib (n - 2);
    }
}
int main ()
{
    int num;
    cout << "Which Fibonacci number? ";
    cin >> num;
    cout << "The number is " << fib (num) << endl; 
    return 0;
}


The Pep/8 implementation:


( Read more )

Removing dangling commits and those reachable from the reflogs

If you see something like that:
$ git fsck --lost-found
dangling commit 9dbd85d427b32773aee016efc7912f9d1c39aac4
dangling commit 604948146be1bdc2181962543cca039c18cc06b4


You might want to get rid of those dangling commits, in order to accomplish it, do following:
git reflog expire --expire=now --all #Dangerous command, it will be very difficult to recover stuff later on, if you execute it
git gc --prune=now

Update locate database on OS X (updatedb)

In order to update "locate" database on OS X, some people suggest to create a symlink:


sudo ln -s /usr/libexec/locate.updatedb /usr/local/bin/updatedb

However, this method can create an erroneous output if you are in directory with a specific permission e.g.

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
find: .: Permission denied


The better method would be to create a bash script /usr/local/bin/updatedb:

  #!/bin/bash
  pushd . > /dev/null
  cd /usr/libexec
  echo "Updating locate database..."
  sudo ./locate.updatedb
  echo "Updating complete!"
  popd > /dev/null


Make it executable: sudo chmod +x /usr/local/bin/updatedb

Now you can just run «sudo updatedb», in order to update «locate» database.

Top 50 Programming Quotes of All Time


50. «Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning.»
— Rick Cook

49. «Lisp isn't a language, it's a building material.»
— Alan Kay.

48. «Walking on water and developing software from a specification are easy if both are frozen.»
— Edward V Berard

47. «They don't make bugs like Bunny anymore.»
— Olav Mjelde.

46. «A programming language is low level when its programs require attention to the irrelevant.»
— Alan J. Perlis.

45. «A C program is like a fast dance on a newly waxed dance floor by people carrying razors.»
— Waldi Ravens.

44. «I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone.»
— Bjarne Stroustrup

43. “Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter.”
— Eric S. Raymond

42. “Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.”
— Mosher’s Law of Software Engineering

41. “I think Microsoft named .Net so it wouldn’t show up in a Unix directory listing.”
— Oktal


( Read more )

Insertion sort implemented in Javascript


   function insertSort(array){
	   for(i=1, n=array.length; i<n; i++){
   	        key = array[i];
                j=i-1;
                while(j > -1 && key < array[j]){
                     array[j+1]=array[j];
                     j--;
                }
                array[j+1]=key;
	   }
          return array;
   }


Insertion sort on Wikipedia

Create a task in Windows XP/7 Task Scheduler using batch file

In my current job we needed to automatize some processes by using Windows Task Scheduler; I wrote a batch file, which you may find useful,
especially when you don't have direct/remote access to user's desktop.

The main problem of implementation this task was Windows Vista/7 with its UAC, I had to use powershell to get Admin privileges by popping a window prompt to user directly to accept rather than have the user type the password manually upon the request.


( Read more )

[cfwheels] Apache with Tomcat and url rewriting

Hell YES. This ^&(%^989&^%*(% Tomcat is now working for me like a bleeding
pig. Hell YES!!! 12 hours of making this shit working. I am dying :F

I haven't found anywhere instruction so I put this in here

Assumption data:

— site folder is f:/usr/htdocs/cfpages/site
— site folder is accessible by the Apache
— our site is localFirstCFWheels
— no mod_jk no mod URLFilter or how this shit is called
— pure apache rewrite rules
— Apache Tomcat 6.0.26 Server
— Apache 2.2.13 (and later)
— Railo 3.1.2.001
— Apache Tomcat is configured to listen on 8100 port



( Read more )

Guest machine for Virtualbox with preinstalled Django, Pylons and Ruby On Rails

This weekend I have devoted my time for playing with the new and famous frameworks Django, Pylons, and Ruby On Rails.
Almost 80% of the weekend I spent on installing them, if you don't wanna spend time by installing these frameworks and want start playing with them immediately, you are welcome to use my already configured virtual machine for Virtualbox.

First of all you will need Virtualbox, then download image of my virtual machine:
Server 1
Server 2

Extract the archive and import the virtual appliance to Virtualbox
Importing Guest Machine



( Read more )

CSS hacks

/***** Selector Hacks ******/
 
/* IE6 and below */
* html #uno { color: red }
 
/* IE7 */
*:first-child+html #dos { color: red }
 
/* IE7, FF, Saf, Opera */
html>body #tres { color: red }
 
/* IE8, FF, Saf, Opera (Everything but IE 6,7) */
html>/**/body #cuatro { color: red }
 
/* Opera 9.27 and below, safari 2 */
html:first-child #cinco { color: red }
 


( Read more )