Skip to content

Instantly share code, notes, and snippets.

View wchargin's full-sized avatar

Willow Chargin wchargin

View GitHub Profile
@wchargin
wchargin / gxwhich
Created January 14, 2014 05:04
Identify process by X window (like xkill but for info)
#!/bin/sh
xprop | awk '($1=="_NET_WM_PID(CARDINAL)") {print $3}' | xargs ps h -o pid,cmd | xargs notify-send
package edge;
import java.awt.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class Repeated {
public static void main(String[] args) throws Exception {
#!/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
@wchargin
wchargin / words
Created February 11, 2014 01:14
/usr/share/dict/words
This file has been truncated, but you can view the full file.
A
A's
AA's
AB's
ABM's
AC's
ACTH's
AI's
AIDS's
AM's
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"