Skip to content

Instantly share code, notes, and snippets.

View wchargin's full-sized avatar

wchargin wchargin

View GitHub Profile
#!/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
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 February 18, 2014 15:29
Sample data for Quora challenge #1
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
8 0.887978406291 0.332721916227
@wchargin
wchargin / gist:9753838
Created March 25, 2014 01:47
vim, pdflatex, evince
# 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 August 29, 2015 13:57
clean TeX auxiliary files
#!/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 August 29, 2015 14:01
script to answer Quora question
/* 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 June 2, 2014 04:24
install Solarized in gnome-terminal
#!/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 August 29, 2015 14:03
Format obj, tri, phi files, and push to an Android device
#!/bin/bash
# Set these up!
FORMATOBJ=
OBJ2TRI=
TRI2PHI=
PREFIX="/sdcard/car"
ADB="$(which adb)"
if [ -z "$1" ]; then
@wchargin
wchargin / histfreq.sh
Created July 31, 2014 05:03
most frequent commands under bash_eternal_history configuration
# 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 July 6, 2015 18:20
source for gae-sandbox-997.appspot.com
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /_ah/pipeline(/.*)?
script: pipeline.handlers._APP
- url: /.*
script: main.application