Skip to content

Instantly share code, notes, and snippets.

@bradland
bradland / ssh-copy-id
Created August 14, 2013 13:34
ssh-copy-id script for OS X
#!/bin/sh
# Shell script to install your public key on a remote machine
# Takes the remote machine name as an argument.
# Obviously, the remote machine must accept password authentication,
# or one of the other keys in your ssh-agent, for this to work.
ID_FILE="${HOME}/.ssh/id_rsa.pub"
if [ "-i" = "$1" ]; then
" C-n to toggle relative/normal line numbers
function! NumberToggle()
if(&relativenumber == 1)
set number
else
set relativenumber
endif
endfunc
nnoremap <C-n> :call NumberToggle()<cr>
@bradland
bradland / bid-dsl.rb
Created June 4, 2013 23:09
Language for working with bid data
# The only operators available would be basic arithmetic (+, -, /, *), modulo,
# and parenthesis for grouping. The variables bid, weight, and adjustment
# would be passed in to the DSL scope. Users can define and assign their own
# variables, but these would be limited to local scope within the DSL only.
# Percentage weighting
bid * (weight * 0.01)
# Percentage weighting with adjustment
(bid * (weight * 0.01)) + adjustment
@bradland
bradland / clean-csv.rb
Created June 4, 2013 19:31
Cleans up CSV files
#!/usr/bin/env ruby
require 'csv'
require 'iconv'
def clean(string)
# Tranlit to ASCII
string = Iconv.new('ASCII//TRANSLIT', 'UTF-8').iconv(string)
# Trim whitepsace
string = string.chomp
@bradland
bradland / unlock-pdf
Created June 4, 2013 18:05
Remove security from a PDF file using Ghostscript. Bring your own Ghostscript install!
#!/usr/bin/env bash
if [ $# -lt 2 ] ; then
echo "Usage: unlock-pdf input.pdf output.pdf"
exit 1
elif [ ! -f "$1" ] ; then
echo "File $1 does not exist"
exit 1
elif [ ! -f "$2" ] ; then
echo "File $2 does not exist"
@bradland
bradland / 000-sftp.rb
Last active August 8, 2018 02:33
Net::SFTP test script. Fails when downloading files larger than 4 GB
#!/usr/bin/env ruby
require 'net/sftp'
@host = 'localhost'
@user = 'username'
@password = 'password'
@remote_dir = '/source/path/goes/here'
@remote_file_name = 'test-data.txt'
@tmp_dir = '/destination/path/goes/here'
#!/usr/bin/env ruby
require 'fileutils'
require 'open3'
class App
def start
data_files = Dir.glob('data/*.tsv')
data_files.each do |data_file|
@bradland
bradland / install-tabula.sh
Last active December 16, 2015 02:09
Install script for Tabula
# Tabula installer for Ubuntu 12.10
# This script will build a working install of Tabula in your cwd. I run this
# entire script as root because of the number of software installs. If you're
# not comfortable with that, you're probably able to figure out how to do this
# as a regular user.
# These scripts prefer apt packages that are available by default under Ubuntu
# 12.10, but will fall back to using source distributions where packages are not
# available in the default Ubuntu repositories.

BrainHoney Technical Solution Outline

Goal

Provide customers with a solution that can run on their own servers without the requirement for an active internet connection.

Solution Strategy

BrainHoney will host both the content and assessments for ERR items, eliminating the need for ERR to run on customer's equipment.

@bradland
bradland / free.sh
Created February 25, 2013 21:27
Outputs memory stats on the command line for OS X. Similar to (but way different than) free on Linux.
#!/usr/bin/python
# Credit to drfrogsplat from here:
# http://apple.stackexchange.com/questions/4286/is-there-a-mac-os-x-terminal-version-of-the-free-command-in-linux-systems
import subprocess
import re
# Get process info
ps = subprocess.Popen(['ps', '-caxm', '-orss,comm'], stdout=subprocess.PIPE).communicate()[0]