Skip to content

Instantly share code, notes, and snippets.

View andrewheiss's full-sized avatar
👨‍💻
#rstats-ing all the things

Andrew Heiss andrewheiss

👨‍💻
#rstats-ing all the things
View GitHub Profile
@andrewheiss
andrewheiss / DataframeSummary.R
Created May 14, 2012 18:52
Dataframe Summary
DataframeSummary <- function(x) {
if (class(x) != "data.frame")
stop("must supply a dataframe")
#-------------------------------------
# Continuous, numeric data summaries
x.continuous <- x[ , sapply(x, is.numeric)]
if (ncol(x.continuous) > 0) {
x.min <- apply(x.continuous, 2, min, na.rm=TRUE)
x.max <- apply(x.continuous, 2, max, na.rm=TRUE)
#!/usr/bin/perl -w
# Modified from Dr. Drang's original script at http://www.leancrew.com/all-this/2011/02/dissociated-darwin/
use Games::Dissociate;
# Choose the corpus file
if ($#ARGV == -1) {
$corpus = "totc.txt";
} else {
$corpus = $ARGV[0];
@andrewheiss
andrewheiss / backupify.py
Created July 8, 2012 05:29
Backupify Tweets to Markdown
#!/usr/bin/env python
import os
import glob
import json
from datetime import datetime
import dateutil.parser
# Handle Unicode
import sys
@andrewheiss
andrewheiss / R.sublime-settings
Created July 10, 2012 04:49
R word_separators
{
"word_separators": "/\\()\"'-:,;<>~!@#$%^&*|+=[]{}`~?"
}
@andrewheiss
andrewheiss / gist:3081235
Created July 10, 2012 05:13
Language-specific keybindings
// Executes line(s) of text in REPL terminal, latter only displays code and does not execute
{ "keys": ["super+shift+r"], "command": "repl_transfer_current", "args": {"scope": "lines"}, "context":
[
{ "operand": "source.r", "operator": "equal", "match_all": true, "key": "selector" }
]
},
@andrewheiss
andrewheiss / algorithm.py
Created July 12, 2012 00:40
Excerpt from basic algorithm
def a_ask_b_to_join():
print "Inviting B"
if b_delta_if_move >= 0 and b_delta_if_move > b_delta_if_stay:
print "This is the ideal situation; {0} will gain {1} points and {2} will gain {3}. Permission granted.".format(player_a.name, a_delta_if_stay, player_b.name, b_delta_if_move)
player_b.joinTeam(team_a)
return True
elif b_delta_if_stay >= 0 and b_delta_if_stay > b_delta_if_move:
print "It's better if B stays... but why not... join!" # TODO: Maybe base this on a percentage?
player_b.joinTeam(team_a)
return True
@andrewheiss
andrewheiss / Open_hide_dock.scpt
Created August 5, 2012 22:45
Open and hide all dock programs
repeat with bundleID in paragraphs of (do shell script "defaults read com.apple.dock persistent-apps | sed -E -n 's/.*\"bundle-identifier\" = \"(.*)\";/\\1/p'")
launch application id bundleID
set programName to name of application id bundleID
tell application "Finder"
set visible of process programName to false
end tell
end repeat
@andrewheiss
andrewheiss / tex2docx.sh
Created December 3, 2012 04:28
tex2docx
#!/usr/bin/env bash
filename="${1}"
no_extension=${filename%.*}
# echo "Converting Markdown to LaTeX..."
# multimarkdown -t latex ${no_extension}.md > ${no_extension}.tex
echo "Running LaTeX..."
latex -interaction=nonstopmode ${no_extension} > /dev/null
@andrewheiss
andrewheiss / gist:5667322
Created May 29, 2013 01:13
Toggle Bluetooth menu item
tell application "System Preferences"
activate
set the current pane to pane "Bluetooth"
delay 1
end tell
tell application "System Events"
tell process "System Preferences"
set toggleBluetooth to the checkbox "Show Bluetooth in menu bar" of the window "Bluetooth"
click toggleBluetooth
@article{econ-egypt-politics:2013,
Date-Added = {2013-04-04 23:27:11 +0000},
Date-Modified = {2013-04-04 23:28:31 +0000},
Day = {30},
Entrysubtype = {magazine},
Journal = {The Economist},
Keywords = {790 Report},
Month = {3},
Title = {Egypt: It's the politics, stupid},
Url = {http://www.economist.com/news/leaders/21574495-economy-faces-collapse-broader-based-government-needed-take-tough-decisions-its},