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
# 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
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
@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
# 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 / 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);
@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 / 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:
I was visited by the gains fairy this week.
There's this massive bald black dude who works out early in the morning. There's no way he isn't juicing. His tank top looks like a g string on him, he's got veins popping out everywhere. I swear this dude has visible capillaries, it's unreal. He sweats like he's in a sauna the whole time, just dripping. Carries 2 towels around. Yells on the way up when he squats. Talks to himself in the mirror shrugging. I was embarrassed to ask him for a spot the first time, just because my 2 plate bench seemed so feeble next to this monster of a man. But it was 5:30 AM, and it was him or the fat guy doing curls with kettlebells.
Anyways, so I'm only looking for 1 rep on this set (5/3/1) but hoping for 2. He doesn't touch the bar, thank god. I Get the first rep with great form, then struggle to get the second rep up. He leans over me and yells, "YOU'VE GOT 3!" I'm startled, but what the hell, he can bail me out if I fail. So I pause at the top and try 3. On my way up, he's still
@shanechin
shanechin / example-vimrc.py
Last active October 10, 2015 21:31
Some python .vimrc examples
from snake import *
import pyperclip
from sh import xdotool
import random
import string
@key_map("<leader>l")
def log():
'''
@shanechin
shanechin / gulpfile.js
Created November 7, 2015 12:24 — forked from soin08/gulpfile.js
Gulpfile.js to use with Django projects. Based on gulpfile.js from Google Web Starter Kit.
//Based on gulpfile.js from Google Web Starter Kit.
//https://github.com/google/web-starter-kit
'use strict';
// Include Gulp & Tools We'll Use
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');