Skip to content

Instantly share code, notes, and snippets.

View kevinwang's full-sized avatar

Kevin Wang kevinwang

View GitHub Profile
@kevinwang
kevinwang / manifest.json
Last active November 6, 2015 09:20
Chrome extension to redirect Wikipedia to mobile version
{
"manifest_version": 2,
"name": "Wikipedia Mobile",
"description": "Redirects Wikipedia articles to mobile version",
"version": "0.0.1",
"background": {
"scripts": ["request.js"]
},
"permissions": [
"webRequest",
#!/usr/bin/env bash
# Post-commit hook to amend commit author if author is prog694.
# Save as .git/hooks/post-commit from repo root.
#
# Author: Kevin Wang <kevin@kevinwang.com>
# Force tty input
exec < /dev/tty
git log -1 HEAD --pretty="format:%ae" | grep prog694@gmail.com > /dev/null

Keybase proof

I hereby claim:

  • I am kevinwang on github.
  • I am kevinwang (https://keybase.io/kevinwang) on keybase.
  • I have a public key whose fingerprint is FDD6 D5F1 4329 E147 BBE2 053F 7EFA DD76 7646 072D

To claim this, I am signing this object:

@kevinwang
kevinwang / grader.py
Created September 7, 2014 23:07
CS 225 HW0 grader
with open('out.csv', 'a', 0) as out:
while True:
grade = 0
netid = raw_input('NetID: ')
for i in xrange(21):
grade += float(raw_input())
print 'Grade: %.1f' % grade
out.write('%s,%.1f\n' % (netid, grade))
@kevinwang
kevinwang / app.js
Created August 7, 2014 21:52
Khan Academy Intern Sentry
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.json());
var Hipchatter = require('hipchatter');
var hipchatter = new Hipchatter('<API token>');
var interns = [
@kevinwang
kevinwang / resample-dpi.sh
Created July 15, 2014 07:15
Amazon S3 + CloudFront screenshot tool
#!/usr/bin/env bash
if [[ ! "$1" || "$1" == "-h" || "$1" == "--help" ]]; then cat <<HELP
Resample specified images to 72 DPI
http://benalman.com/
Usage: $(basename "$0") [img [img ...]]
The new MacBook Pro retina display is amazing, but screengrabs taken on
one using the screencapture utility aren't scaled to 72 DPI by default.
@kevinwang
kevinwang / TimeDilation.java
Last active December 16, 2015 04:29
Solutions to several problems from the St. Joseph's College high school programming competition.
import java.io.*;
import java.util.*;
public class TimeDilation {
public static double na(double nj, double vRatio) {
return nj * Math.sqrt(1 - vRatio*vRatio);
}
public static double round(double d, int precision) {
d *= Math.pow(10, precision);
@kevinwang
kevinwang / timenow.rb
Created August 3, 2012 14:22
Benchmarks how often Ruby is fast enough that two consecutive Time.now calls return identical Time objects.
#!/usr/bin/env ruby
total = 0
trues = 0
while true
if Time.now == Time.now
trues += 1
end
total += 1
@kevinwang
kevinwang / db_shuffle.rb
Created June 24, 2012 05:29
Deck shuffling
require 'mongo'
db = Mongo::Connection.new.db('deckdb')
db.drop_collection('decks')
decks = db['decks']
decks.create_index('deck', unique: true)
i = 0
while true
puts i += 1