Skip to content

Instantly share code, notes, and snippets.

View osteele's full-sized avatar

Oliver Steele osteele

View GitHub Profile
puts (1..100).map { |n| '1'*n+":#{n}\n" }.join.
gsub(/^(1{5})*:/,'\0Buzz').gsub(/^(1{3})*:/,'Fizz').gsub(/.*:|(z)\d+/,'\1')
puts (1..100).map { |n| 'x'*n+"#{n}\n" }.join.
gsub(/^(xxx)*\d/,'Fizz').gsub(/[05]$/,'Buzz').gsub(/^x*|\d*(.+?)\d*/,'\1')
@osteele
osteele / openlaszlo-template.rb
Created March 23, 2009 21:51
Rails template to install the OpenLaszlo plugin
# This application template for Rails >= 2.3 installs the OpenLaszlo
# plugin and its dependencies. It offers to download the OpenLaszlo
# SDK and set the OPENLASZLO_HOME environment variable, and it updates
# .gitignore.
#
# To create a new Rails app:
# rails webapp -m http://gist.github.com/83809.txt
#
# To upgrade an existing app:
# rake rails:template LOCATION=http://gist.github.com/83809.txt

Keybase proof

I hereby claim:

  • I am osteele on github.
  • I am osteele (https://keybase.io/osteele) on keybase.
  • I have a public key whose fingerprint is C498 49BE 5DEA 5871 3D3B 9EBD 6410 7EDA 1D58 E869

To claim this, I am signing this object:

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [AnyObject]) {
let location = locations.lastObject as! CLLocation
if let lastLocation = lastGeocodedLocation {
if lastLocation.distanceFromLocation(location) < distanceFilter {
NSLog("current location is within \(round(distanceFilter))m of previous location")
return
}
if abs(location.coordinate.latitude - lastLocation.coordinate.latitude) < lastLocation.horizontalAccuracy &&
abs(location.coordinate.longitude - lastLocation.coordinate.longitude) < lastLocation.verticalAccuracy {
var distance = sqrt(pow(lastLocation.horizontalAccuracy,2) + pow(lastLocation.verticalAccuracy,2))
@osteele
osteele / get_file_forks.py
Created January 20, 2016 00:54
Print a file's forks
#!/usr/bin/env python
# INSTALL: pip install github3.py
# USAGE: ./get_file_forks.py AllenDowney/DataScience age_lm.py
# Set HOMEBREW_GITHUB_API_TOKEN to avoid Github's rate limit.
import os
import sys
import github3
@osteele
osteele / install-sublime.sh
Last active January 21, 2016 15:36
Install Sublime Text 3 and recommended packages for SoftDes2015.
#!/bin/bash -eu
# Usage: wget https://gist.githubusercontent.com/osteele/7f53dce67ce2925f55e2/raw/install-sublime.sh | bash
# Add the Sublime Text 3 (ST3) repository
sudo add-apt-repository ppa:webupd8team/sublime-text-3
# Update and upgrade your system:
sudo apt-get update
sudo apt-get upgrade
# Install Package Control package manager for ST3
ST3_CONFIG=~/.config/sublime-text-3
PC_DIR=$ST3_CONFIG/Installed\ Packages/Package\ Control.sublime-package
PC_FNAME=Package%20Control.sublime-package
mkdir -p "$PC_DIR"
curl -O https://sublime.wbond.net/$PC_FNAME
unzip -u $PC_FNAME -d "$PC_DIR"
rm $PC_FNAME
# Add the Anaconda and Floobits packages. When ST3 is launched, Package Control will install these.
@osteele
osteele / install-jupyter-launchagent.sh
Created January 22, 2016 15:04
install-jupyter-launchagent.sh
#!/bin/bash -eu
die() { echo "$@" 1>&2 ; exit 1; }
LAUNCH_AGENTS_DIR=~/Library/LaunchAgents
[[ -d $LAUNCH_AGENTS_DIR ]] || die "Missing directory: $LAUNCH_AGENTS_DIR. Are you sure you're on a Mac?"
NOTEBOOK_DIR=~/code/notebooks
[[ -d $NOTEBOOK_DIR ]] || die "Missing directory: $NOTEBOOK_DIR"
@osteele
osteele / nagbot.py
Last active March 11, 2016 23:04
Synthesize reminder messages for students who haven't submitted pull requests for the required number of toolbox projects.
# -*- coding: utf-8 -*-
"""Print email nags regarding toolbox pull requests.
The current directory should contain a file `Master Grades.xlsx` with two sheets, and columns
`First Name`, `Last Name`, `E-mail`, and `GitHub`.
Author: Oliver Steele <oliver.steele@olin.edu>
"""
import os