Skip to content

Instantly share code, notes, and snippets.

View ianpreston's full-sized avatar

Ian Preston ianpreston

View GitHub Profile

Cask Tutorial

A quick introduction to most of Cask's features and usage patterns.

Installation

See the README for installation instructions.

Quickstart

@ianpreston
ianpreston / kernel.json
Created September 19, 2015 21:39
Jupyter configuration for gevent
{
"display_name": "IPython 2 w/gevent",
"language": "python",
"argv": [
"python",
"-c", "from gevent.monkey import patch_all; patch_all(thread=False); from IPython.kernel.zmq.kernelapp import main; main()",
"-f",
"{connection_file}"
]
}
In [1]: import lxml.html
In [2]: import requests
In [3]: x = """<?xml version="1.0" encoding="utf-8"?><sitemap><changefreq>Hello world</changefreq></sitemap>"""
In [4]: a = lxml.html.fromstring(x)
In [5]: a
Out[5]: <Element sitemap at 0x10517d050>
import threadpool, math, os
randomize()
proc setRand(k: int, vals: var seq[int]) =
vals[k] = k * 2
if k < 7:
sleep(random(1000))
vals[k+1] = k * 2
#!/bin/sh
set -e
# Build the bootloader
cd src/bootloader
nasm -f bin main.asm -o ../../build/bootloader.bin
cd ../..
# Build the kernel
cd src/kernel/asm
ian@dreadnought > virtualenv venv; . venv/bin/activate.fish
New python executable in venv/bin/python
Installing setuptools, pip...done.
(venv)ian@dreadnought > pip install urllib3
Downloading/unpacking urllib3
Downloading urllib3-1.10.2-py2-none-any.whl (77kB): 77kB downloaded
Installing collected packages: urllib3
Successfully installed urllib3
Cleaning up...
(venv)ian@dreadnought > mkdir foobar
@ianpreston
ianpreston / example0.ipy
Last active August 29, 2015 14:15
Memory leak examples
In [1]: import sys
In [2]: def test():
...: foo = "Hello, world!"
...: try:
...: raise Exception()
...: except Exception, e:
...: trace = sys.exc_info()[2]
...: return trace
...:
@ianpreston
ianpreston / hellogl.rkt
Created January 10, 2015 17:27
OpenGL Hello World
#lang racket/gui
(require sgl)
(require sgl/gl-vectors)
(define (render canvas dc)
(send canvas with-gl-context
(lambda ()
(gl-matrix-mode 'projection)
(gl-load-identity)
(gl-ortho -10 10 -10 10 -1 1)
; Assembly hello world for OSX
; So I can remember how to do basic shit in OSX
;
; $ nasm -g -f macho -o test.o test.asm
; $ ld -o a.out -e _main test.o -lSystem
bits 32
section .data
message db "Hello, world!", 10, 0
@ianpreston
ianpreston / bayes.hs
Last active August 29, 2015 14:02
Naive Bayes Classifier in Haskell. Does it work? No idea.
data FeatureVec =
FeatureVec { cls :: Int, feat :: [Bool] }
deriving (Show)
data ValueVec =
-- TODO: Need a better name for vals
ValueVec { cnt :: Int, vals :: [Int] }
deriving (Show)
type ProbVec = [Float]