Skip to content

Instantly share code, notes, and snippets.

View dkua's full-sized avatar

David Kua dkua

View GitHub Profile
{
"metadata": {
"name": "pyconca"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@dkua
dkua / clever_average_student.go
Last active August 29, 2015 13:57
Go program for finding out the average number of students per section from the Clever API.
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type Response struct {
@dkua
dkua / fuck.py
Created March 18, 2014 01:36
Python script for killing processes in a funny way.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, os
if len(sys.argv) == 3 and sys.argv[1] == "you":
regular = u"abcdefghijklmnopqrstuvqxyz"
irregular = u"ɐqɔpǝɟƃɥıɾʞʃɯuodbɹsʇnʌʍxʎz"
flipped = dict(zip(regular, irregular))
print u"\n (╯°□°)╯︵ %s" % "".join(flipped[c] for c in reversed(sys.argv[2]))

Keybase proof

I hereby claim:

  • I am dkua on github.
  • I am dkua (https://keybase.io/dkua) on keybase.
  • I have a public key whose fingerprint is C0B1 FA59 DF22 4942 E70C D4FC 3884 0595 7325 33A5

To claim this, I am signing this object:

@dkua
dkua / qmd_bench.sh
Last active August 29, 2015 14:02
Test script to test exit cases in QMD
#!/bin/bash
## Sample POST request to /scripts/qmd_bench.sh
##
## {
## "args": ["1", "10"],
## "callback_url": "http://192.168.88.88:9090"
## }
MIN=$1
  1. General Background and Overview
@dkua
dkua / gist:ddf5333266b95370c808
Created March 8, 2015 06:34
SICP Exercise 1.12
#lang scheme
(define (fact n)
(fact-tail n 1))
(define (fact-tail n acc)
(if (= 0 n)
acc
(fact-tail (- n 1) (* acc n))))
export ANACONDAPATH=$HOME/anaconda;
anaconda() {
export PATH=$ANACONDAPATH/bin:$PATH;
}
alias "anaconda"="anaconda"
nanaconda() {
export PATH=$(echo $PATH | sed -e "s|$ANACONDAPATH/bin:||g");
}
alias "nanaconda"="nanaconda"
def binary_search(L, s):
'''(list) -> bool
Return True iff s is an element of L, otherwise False
REQ: L must be a sorted list
'''
# BASE CASE: If L is empty, it's not in the list
if L == []:
result = False
# RECURSIVE DECOMP: Pick the middle element, if we found
# what we're looking for, great. If not, then we've at
<!-- Bibliography data -->
{{ $numParams := len .Params }}
{{ if eq $numParams 0 }}
{{ if isset .Page.Params "bibliography" }}
{{ $.Scratch.Set "bib_source" .Page.Params.bibliography }}
{{ end }}
{{ if isset .Page.Params "bibliography_ignore" }}
{{ $.Scratch.Set "bib_ignore" .Page.Params.bibliography_ignore }}
{{ end }}
{{ else if eq $numParams 1 }}