Skip to content

Instantly share code, notes, and snippets.

@anirudhjoshi
anirudhjoshi / htmlcharacterconvertor.py
Created December 16, 2009 03:50
htmlcharacterconvertor.py
#!/usr/bin/python
# HTML Character Convertor
# Replaces HTML entities in a given string - with their correct character.
def extractKeyValueToDictionary(fileName):
allLines = open(fileName, 'r').readlines()
dictionary = {}
for line in allLines:
key,value=line.split(':')
# Variation on Hashrocket's script for managing the git process
# as documented here: http://reinh.com/blog/2008/08/27/hack-and-and-ship.html
# Create shell scripts out of each of these, put them in your path (~/bin for example)
# chmod 755 them and use like this:
#
# This version of hack is totally different than Hackrockets. I feel that hack implies
# that you are getting started, not finishing up. sink is Hashrockets hack.
#
# $ hack branch_name
# Test and Implement until done
@anirudhjoshi
anirudhjoshi / node-and-npm-in-30-seconds.sh
Created August 14, 2011 02:15 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@anirudhjoshi
anirudhjoshi / angel_sim.py
Created September 14, 2011 04:32 — forked from jmillerinc/angel_sim.py
Monte Carlo simulation of the payoffs to angel investing
#!/usr/bin/python
#
# Monte Carlo simulation of the payoffs to angel investing.
#
# Assume a pool of N different investors, each investing in D deals,
# with a fixed time horizon and a fixed distribution of payoffs.
# Randomly simulate each investor's total payoff, then compute the
# mean and std dev of all IRRs in the overall pool.
#
# This gives an individual angel an idea of what kind of payoff &
@anirudhjoshi
anirudhjoshi / latency.txt
Created October 20, 2012 11:41 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
import java.lang.Exception;
import java.util.Scanner;
import java.util.StringTokenizer;
public class DateParser {
public static void main(String[] args) throws Exception {
while (true) {
@anirudhjoshi
anirudhjoshi / CircleTest2.java
Created November 1, 2012 01:50
CircleTest2.java
public class CircleTest2 {
public static class Circle_1 {
public float r = 100;
public float getR(){ return r;}
}
public static class GraphicCircle_1 extends Circle_1 {
public float r = 10;
public float getR(){ return r;}
@anirudhjoshi
anirudhjoshi / Employee.java
Created November 5, 2012 05:23
Employee.java
public class Employee implements Comparable {
private String id;
private String name;
public Employee(String id, String name){
setId(id);
setName(name);
}