Skip to content

Instantly share code, notes, and snippets.

View shanechin's full-sized avatar

Shane Chin shanechin

  • Columbia University
  • New York, New York
View GitHub Profile
@shanechin
shanechin / trypy
Last active August 29, 2015 14:19 — forked from naftaliharris/trypy
#!/bin/bash
# An enhancement to the "python" executable that automatically launches you into the python debugger on error.
#
# Use it like you would the "python" executable, for example:
# $ trypy somefile.py
# or
# $ trypy somefile.py arg1 arg2
#
# EXAMPLE:
@shanechin
shanechin / gist:ca86b771ab3802d7ad0d
Created April 10, 2015 07:20
Strace output for Copyq
execve("/usr/local/bin/copyq", ["copyq", "-s", "zsh", "show"], [/* 67 vars */]) = 0
brk(0) = 0x21b6000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9593757000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=151268, ...}) = 0
mmap(NULL, 151268, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9593732000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
@shanechin
shanechin / OAuth.cls
Last active August 29, 2015 14:17 — forked from surjikal/OAuth.cls
public class OAuth {
public static HttpRequest signRequest(HttpRequest req, String consumerKey, String consumerSecret) {
String nonce = String.valueOf(Crypto.getRandomLong());
String timestamp = String.valueOf(DateTime.now().getTime() / 1000);
Map<String,String> parameters = new Map<String,String>();
parameters.put('oauth_signature_method','HMAC-SHA1');
parameters.put('oauth_consumer_key', consumerKey);
parameters.put('oauth_timestamp', timestamp);
# After spending too much time away from Python on Javascript, I gave this a shot. To my surprise, it worked!
# Since Python doesn't bind "self" explicitly in classes, this looks almost exactly like Python classes.
# The only visible difference is that you cannot simply access the members using the dot syntax (cat.sayHi).
# It must be accessed as a dictionary.
def Cat(legs, colorId, name):
def sayHi():
print 'Hi, my name is %s. I have %s legs and am %s.' % (this['name'], this['legs'], this['color'])
this = {
@shanechin
shanechin / gist:f97b1f7b766bbffeeddd
Created March 16, 2015 02:39
playing around with kamon-dashboard
while true
do
echo -n "stats.timers.kamon.localhost.system-metric.cpu.cpu-user.mean_99:$(((RANDOM % 10) + 1))|c" | nc -w 1 -u localhost 8125
done
import multiprocessing as mp
import os
import time, random
def f(x):
b = x*x
time.sleep(random.choice([5,8,10,14,20]))
print "{0} procces id {1} with parent {2} doing {3}".format(mp.current_process(), os.getpid(), os.getppid(), x)
return b
# source this code in a Bash shell ($ . django-csrftoken-login-demo.bash),
# and run with a DB name as parameter (e.g. $ django-csrftoken-login-demo demo)
django-csrftoken-login-demo() {
# -- CHANGE THESE VALUES TO MATCH YOUR ACCOUNT --
local HOSTING_USERID=9988
local HOSTING_PANEL_USER='customer@email.address'
local HOSTING_PANEL_PASS='my secret login password'
local HOSTING_DB_PREFIX='username_'
local DB_NAME=$HOSTING_DB_PREFIX$1
These two symbols look correct in my terminal, before I was seeing > and <
" My own hack for the seperator
let g:airline_left_sep = ''
let g:airline_right_sep = ''
@shanechin
shanechin / gist:6084025
Created July 25, 2013 21:39
Noir installation
When using Noir, you must install the newer version of leiningen, you may place it on path within the /bin/ folder.
verify correct usage with which lein.
https://raw.github.com/technomancy/leiningen/stable/bin/lein
// ==UserScript==
// @name PissApOff
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description enter something useful
// @include http://fifa1404.herokuapp.com/view/1
// @include http://fifa1404.herokuapp.com/
// @copyright 2012+, You
// ==/UserScript==