Skip to content

Instantly share code, notes, and snippets.

View BinRoot's full-sized avatar

Nishant Shukla BinRoot

View GitHub Profile
@BinRoot
BinRoot / camus-winter.quote
Created February 10, 2013 16:22
Camus Winter
In The Midst Of Winter, I Found There Was, Within Me, An Invincible Summer.
- Albert Camus
@BinRoot
BinRoot / cipher.hs
Created February 5, 2013 00:59
Caesar Cipher Example
-- this is the original cipher function you will run
cipher [] _ = []
cipher a b = rot (head a) b : cipher (tail a) b
-- Take a look at this 'rotate' function.
-- Rotate will convert a Char into another Char.
-- This almost works. But it doesn't loop around z-->a.
rotate :: Char -> Int -> Char
rotate c n = if n==0
then c
@BinRoot
BinRoot / problemsolving.quote
Created January 28, 2013 04:18
Problem Solving
And how will you inquire, Socrates,
into that which you know not? What will you
put forth as the subject of inquiry? And if you
find what you want, how will you ever know that
this is what you did not know?
- Meno
class IntersectionFound(Exception):
def __init__(self, user_id):
self.user_id = user_id
def get_friends(user_id):
"""Returns a set of ids representing the friends of the given user."""
def update_shortest_path(shortest_paths, user_id, to_user_id, via_user_id, distance):
"""Update the shortest path for one user."""
if shortest_paths.has_key(user_id):
@BinRoot
BinRoot / gist:4577287
Created January 20, 2013 08:28
Sample Snapgraph /link out
[
"vivekb",
"octopi",
"binroot"
]
db.codes.findAndModify(
{
query: {type:"hi"},
update: {desc:"stuff"}
}
);
@BinRoot
BinRoot / gist:4491117
Created January 9, 2013 06:27
MongoDB: groups a search by type with number of results
db.codes.group({key:{'type':1}, cond:{type:{$regex:'.*hi.*'}}, initial:{sum:0}, reduce:function(doc, prev){prev.sum++}})
quicksort :: Ord a => [a] -> [a]
quicksort [] = []
quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater)
where
lesser = filter (< p) xs
greater = filter (>= p) xs
@BinRoot
BinRoot / gist:4287431
Created December 14, 2012 18:20
Linux 1
cd ~
rm -rf Pictures Photos Videos Public
PS1="\e[0;37m┌──\e[0m[\e[0;33m\u\e[0m@\e[0;34m\h\e[0m]─[\e[2;37m\w\e[0m]\n\e[0;\
37m└─\e[0m\$ "