This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fortune -s -n 100 | cowsay -f `ls -1 /usr/share/cowsay/cows/ | replace ".cow" "" | tail -n +\`echo $(( 1 + (\\\`od -An -N2 -i /dev/random\\\`) % (\\\`ls -1 /usr/share/cowsay/cows/ | wc -l\\\`) ))\` | head -1` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
from flask import Flask, request, Response | |
app = Flask(__name__) | |
def check_auth(username, password): | |
"""This function is called to check if a username / | |
password combination is valid. | |
""" | |
return username == 'username' and password == 'pass' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Tree a = NullNode | Node a (Tree a) (Tree a) | |
instance (Show a) => Show (Tree a) where | |
show NullNode = "" | |
show (Node x NullNode NullNode) = show x | |
show (Node x l r) = show x ++ "(" ++ show l ++ " " ++ show r ++ ")" | |
preOrder :: Tree a -> [a] | |
preOrder NullNode = [] | |
preOrder (Node x l r) = x : (preOrder l ++ preOrder r) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|de| | f|Cl|nf|ed|au| i|ti| |ma|ha|or|nn|ou| S|on|nd|on| | |
|ry| |is|th|is| b|eo|as| | |f |wh| o|ic| t|, | |he|h | | |
|ab| |la|pr|od|ge|ob| m|an| |s |is|el|ti|ng|il|d |ua|c | | |
|he| |ea|of|ho| m| t|et|ha| | t|od|ds|e |ki| c|t |ng|br| | |
|wo|m,|to|yo|hi|ve|u | t|ob| |pr|d |s |us| s|ul|le|ol|e | | |
| t|ca| t|wi| M|d |th|"A|ma|l |he| p|at|ap|it|he|ti|le|er| | |
|ry|d |un|Th|" |io|eo|n,|is| |bl|f |pu|Co|ic| o|he|at|mm| | |
|hi| | |in| | | t| | | | |ye| |ar| |s | | |. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Tree a = NullNode | Node a (Tree a) (Tree a) | |
instance (Show a) => Show (Tree a) where | |
show NullNode = "" | |
show (Node x NullNode NullNode) = show x | |
show (Node x l r) = show x ++ "(" ++ show l ++ " " ++ show r ++ ")" | |
sumtree :: Int -> Int -> Tree Int | |
sumtree rootVal depth |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- You are given n strings w1, w2, ..., wn. Let Si denote the set of strings formed by | |
-- considering all unique substrings of the string wi. Let S = {S1 U S2 U .... Sn} i.e. | |
-- S is a set of strings formed by considering all the unique strings in all sets | |
-- S1, S2, ..., Sn. You will be given many queries and for each query, you will be given | |
-- an integer k. Your task is to output the lexicographically kth smallest string from | |
-- the set S. | |
import Data.List | |
import Control.Monad | |
import Control.Exception |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
from urlparse import urlparse | |
import sys | |
if len(sys.argv) != 3: | |
print "Usage: python CoderWeeklyToInstapaper.py <instapaper_username> <instapaper_password>" | |
sys.exit() | |
else: | |
(_, username, password) = sys.argv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
import sys | |
if len(sys.argv) != 3: | |
print "Usage: python HackerMonthlyToInstapaper.py <instapaper_username> <instapaper_password>" | |
sys.exit() | |
else: | |
(_, username, password) = sys.argv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A point A is said to be dominating another point B | |
# iff A.x > B.x and A.y > B.y. | |
# Given a set of points, find all the points which are | |
# not dominated by any other point. | |
# | |
# This program used a Quad Tree to solve this problem | |
# in O(kn) time where n is number of input points and | |
# k = max(log2(x_range/min_x_dist), log2(y_range/min_y_dist)) where | |
# x_range = range of x coordinates of the points, | |
# y_range = range of y coordinates of the points, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: python HaskellCC.py (Ctrl-C for exit) | |
import time | |
from datetime import datetime | |
import subprocess | |
from watchdog.observers import Observer | |
from watchdog.events import PatternMatchingEventHandler | |
class HaskellContinuousCompiler(PatternMatchingEventHandler): |