Skip to content

Instantly share code, notes, and snippets.

@KWMalik
KWMalik / improved_tutorial.py
Created November 24, 2012 17:02 — forked from ipl31/improved_tutorial.py
Improved Tutorial 9 to be a little more pythonic and also track tickers with matched events
'''
(c) 2011, 2012 Georgia Tech Research Corporation
This source code is released under the New BSD license. Please see
http://wiki.quantsoftware.org/index.php?title=QSTK_License
for license details.
Created on March, 5, 2012
@author: Sourabh Bajaj
@contact: sourabhbajaj90@gmail.com
@KWMalik
KWMalik / SHITLOAD
Created November 21, 2012 19:16 — forked from supki/SHITLOAD
How to create and use filters via libstackexchange
# First, try to get question body with default filter
μ> (fmap head . askSE $ questionsOnUsers [972985] <> site "stackoverflow" ) >>= (^! field "body") :: IO String
*** Exception: user error (key "body" not present)
# Okay, create appropriate filter for this task and get its name
μ> (askSE $ createFilter ["question.body"] [] "default") >>= (^! field "items" . fields "filter") :: IO [String]
["!9hnGssGO4"]
# See
μ> (fmap head . askSE $ questionsOnUsers [972985] <> site "stackoverflow" <> filter "!9hnGssGO4") >>= (^! field "body") :: IO String
@KWMalik
KWMalik / GameDef.scala
Created November 21, 2012 19:07 — forked from supki/GameDef.scala
Functional programming course at Coursera week 7.
package streams
import common._
trait GameDef {
case class Pos(x: Int, y: Int) {
def dx(d: Int) = copy(x = x + d, y)
def dy(d: Int) = copy(x, y = y + d)
Feature: search for movies by director
As a movie buff
So that I can find movies with my favorite director
I want to include and serach on director information in movies I enter
Background: movies in database
Given the following movies exist:
| title | rating | director | release_date |
@KWMalik
KWMalik / tree.md
Created October 12, 2012 21:57
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@KWMalik
KWMalik / latency.txt
Created October 12, 2012 21:56
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns
@KWMalik
KWMalik / setup.sh
Created October 12, 2012 21:56
Create and deploy a Python/Flask "hello world" app on Heroku.
#!/bin/bash
# Create and deploy a Python/Flask "hello world" app on Heroku.
# by James Thornton, http://jamesthornton.com
# To run it, do:
# $ heroku login
# $ bash setup.sh helloworld
# $ cd helloworld
@KWMalik
KWMalik / sudoku_solver.cpp
Created October 12, 2012 21:56
Sudoku solver in C++11
#include <iterator>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <cassert>
#include <memory>
#include <future>
#include <chrono>
@KWMalik
KWMalik / py-data-science.md
Created October 12, 2012 21:56
Python packages for Data Analysis

Python packages for Data Analysis, Natural Language Processing, Machine Learning and Statistics

Forever a work in progress.

I recommend you install these from the python package manager - pip.

Keep in mind that you have to resolve the dependencies yourself(unless those dependencies are python packages), if you feel that you cannot do this then please install them from your distro's package manager.

@KWMalik
KWMalik / data-science-resources.md
Created October 12, 2012 21:55
Data Science Resources