Skip to content

Instantly share code, notes, and snippets.

@amcclosky
amcclosky / .bash_profile
Created February 27, 2016 19:46
A .bash_profile
source ~/bin/fancy_prompt.sh
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
alias show-hidden='defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder'
alias hide-hidden='defaults write com.apple.finder AppleShowAllFiles -boolean false ; killall Finder'
alias flushdns='sudo discoveryutil udnsflushcaches'
# Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt"
# Screenshot: http://img.gf3.ca/d54942f474256ec26a49893681c49b5a.png
# A big thanks to \amethyst on Freenode
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color
fi
if tput setaf 1 &> /dev/null; then
tput sgr0
@amcclosky
amcclosky / osx_notes.md
Last active February 27, 2016 21:04
Setup a new os x machine for development.

From fresh install to usable machine.

  1. Disable natural scrolling.
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false
  1. Install Homebrew.
@amcclosky
amcclosky / csv_import_magic.js
Created February 16, 2016 15:57 — forked from ianlewis/csv_import_magic.js
A Google Apps Script for importing CSV data into a Google Spreadsheet.
// vim: ft=javascript:
/*jslint sloppy: true, vars: true, white: true, nomen: true, browser: true */
/*global SpreadsheetApp, UiApp, UrlFetchApp, Utilities */
/*
* A script to automate requesting data from an external url that outputs CSV data.
*
* Adapted from the Google Analytics Report Automation (magic) script.
* @author nickski15@gmail.com (Nick Mihailovski)
* @author ianmlewis@gmail.com (Ian Lewis)
*/
@amcclosky
amcclosky / sign_s3.gs
Created February 10, 2016 15:29 — forked from andsens/sign_s3.gs
Google spreadsheet function for signing S3 URLs (very handy for CSV cost allocation reports when combined with the ImportData() function)
function sign_s3(access_key, private_key, bucket, object_name, validity, base_url) {
if(!base_url) {
base_url = "http://s3.amazonaws.com";
}
if(!validity) {
validity = 60;
}
expires = Math.floor((new Date()).getTime() / 1000) + validity;
object_name = encodeURIComponent(object_name);
stringToSign = "GET\n\n\n"+expires+"\n/"+bucket+"/"+object_name;

Keybase proof

I hereby claim:

  • I am amcclosky on github.
  • I am amcclosky (https://keybase.io/amcclosky) on keybase.
  • I have a public key whose fingerprint is 879B 64FD F8D4 66E1 4141 544B DB96 9549 BB9F CB5E

To claim this, I am signing this object:

# The following script scrapes ESPN's MLB Standings Grid and writes the
# standings for each American League (AL) team to a CSV file, which has the following
# format:
# Team, Opponent, Wins, Losses
from bs4 import BeautifulSoup
import urllib2
import re
import csv
@amcclosky
amcclosky / ramdisk.sh
Created January 31, 2013 21:05
Bash function for creating a ram disk in OS X 10.7+
#!/bin/sh
# usage: mkramdisk 1024 ~/scratch
function mkramdisk() {
ramfs_size_mb=$1
mount_point=$2
ramfs_size_sectors=$((${ramfs_size_mb}*1024*1024/512))
ramdisk_dev=`hdid -nomount ram://${ramfs_size_sectors}`
newfs_hfs -v 'ram disk' ${ramdisk_dev}
@amcclosky
amcclosky / active_record_raw_values.rb
Created September 7, 2012 19:56
An Extension to ActiveRecord::Relation to add a values method for pulling data outside of ActiveRecord::Models
module ActiveRecord
module RawValues
def values(options={})
relation = self
select_values = options[:select]
flat_result = options[:flat]
relation.select_values = select_values if select_values
@amcclosky
amcclosky / rack-mini-profiler-toggle.js
Created September 6, 2012 02:13
Hide rack-mini-profiler Bookmarklet
javascript:(function(){ $('.profiler-results').toggle(); })();