Skip to content

Instantly share code, notes, and snippets.

Avatar

William Chargin wchargin

View GitHub Profile
View whybig
#!/bin/sh
# whybig - determine which files/subdirectories are biggest
# usage: whybig [directory]
# directory defaults to "."
dir=$1
if [ -z $1 ]; then dir="."; fi
du $dir -d 1 | sort -rn
View qe.py
from urllib import request
import threading
def is_in_page(quiz_id):
try:
url = "http://www.quizegg.com/q/{0}".format(quiz_id)
req = request.urlopen(url)
lines = []
for line in req:
lines.append(line.decode('utf-8'))
@wchargin
wchargin / data.txt
Created Feb 18, 2014
Sample data for Quora challenge #1
View data.txt
This file has been truncated, but you can view the full file.
10000 1000 10000
0 0.69024660249 0.0114775157247
1 0.521697939172 0.961600288747
2 0.108694552949 0.868495375713
3 0.797198316646 0.511617073249
4 0.526006389407 0.713361205614
5 0.935532375017 0.0690046076888
6 0.393969231644 0.202272409872
7 0.690658903826 0.0738142387364
@wchargin
wchargin / gist:9753838
Created Mar 25, 2014
vim, pdflatex, evince
View gist:9753838
# in ~/.bashrc
vle () {
if [ -n "$1" ]; then
name=$(basename -s ".tex" "$1") # trim off ".tex" if there is one
vim ${name}.tex && pdflatex ${name}.tex && evince ${name}.pdf
fi
}
@wchargin
wchargin / cleantex.rb
Last active Aug 29, 2015
clean TeX auxiliary files
View cleantex.rb
#!/usr/bin/env ruby
# cleantex
# usage:
# cleantex [texfile1 texfile2 ... texfileN]
# where each file can be a directory (runs on every tex file in directory)
# running "cleantex" with no arguments is equivalent to "cleantex ."
# a single trailing dot or ".tex" is ignored (equivalent: a.tex a. a)
require 'set'
@wchargin
wchargin / colortest.c
Last active Aug 29, 2015
script to answer Quora question
View colortest.c
/* http://www.quora.com/Color-and-Colors/Are-there-any-colors-other-than-black-for-which-the-RGB-values-are-the-same-as-the-HSV-values */
#include <stdio.h>
#include <stdbool.h>
float MIN(float a, float b, float c) {
if (a <= b && a <= c) return a;
if (b <= a && b <= c) return b;
return c;
}
@wchargin
wchargin / mksolarized.sh
Created Jun 2, 2014
install Solarized in gnome-terminal
View mksolarized.sh
#!/bin/sh
DARK_BG='#000014141A1A'
# original: DARK_BG='#00002B2B3636'
LIGHTEST='#FFFFFBFBF0F0'
# original: LIGHTEST='#FDFDF6F6E3E3'
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_background" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_colors" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/palette" --type string "#070736364242:#D3D301010202:#858599990000:#B5B589890000:#26268B8BD2D2:#D3D336368282:#2A2AA1A19898:#EEEEE8E8D5D5:$DARK_BG:#CBCB4B4B1616:#58586E6E7575:#65657B7B8383:#838394949696:#6C6C7171C4C4:#9393A1A1A1A1:$LIGHTEST"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/background_color" --type string "$DARK_BG"
@wchargin
wchargin / obj2android.sh
Last active Aug 29, 2015
Format obj, tri, phi files, and push to an Android device
View obj2android.sh
#!/bin/bash
# Set these up!
FORMATOBJ=
OBJ2TRI=
TRI2PHI=
PREFIX="/sdcard/car"
ADB="$(which adb)"
if [ -z "$1" ]; then
@wchargin
wchargin / histfreq.sh
Created Jul 31, 2014
most frequent commands under bash_eternal_history configuration
View histfreq.sh
# histfreq
# history frequency for bash_eternal_history configuration
# see: http://stackoverflow.com/a/19533853/732016
# adapted from http://superuser.com/a/250230/121273
DEFAULT_LINE_COUNT=10
line_count=$1
if [ -z "$1" ]; then
line_count=$DEFAULT_LINE_COUNT
fi
@wchargin
wchargin / app.yaml
Created Jul 6, 2015
source for gae-sandbox-997.appspot.com
View app.yaml
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /_ah/pipeline(/.*)?
script: pipeline.handlers._APP
- url: /.*
script: main.application