Skip to content

Instantly share code, notes, and snippets.

Avatar

William Chargin wchargin

View GitHub Profile
@wchargin
wchargin / gxwhich
Created Jan 14, 2014
Identify process by X window (like xkill but for info)
View gxwhich
#!/bin/sh
xprop | awk '($1=="_NET_WM_PID(CARDINAL)") {print $3}' | xargs ps h -o pid,cmd | xargs notify-send
View Repeated.java
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 {
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
@wchargin
wchargin / words
Created Feb 11, 2014
/usr/share/dict/words
View 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
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"