Skip to content

Instantly share code, notes, and snippets.

View relnum-toggle.vim
" 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 Jun 4, 2013
Language for working with bid data
View bid-dsl.rb
# 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 Jun 4, 2013
Cleans up CSV files
View clean-csv.rb
#!/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 Jun 4, 2013
Remove security from a PDF file using Ghostscript. Bring your own Ghostscript install!
View unlock-pdf
#!/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 Aug 8, 2018
Net::SFTP test script. Fails when downloading files larger than 4 GB
View 000-sftp.rb
#!/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'
View ab-grapher.rb
#!/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 Dec 16, 2015
Install script for Tabula
View install-tabula.sh
# 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.
View BrainHoney Technical Solution Outline.md

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 Feb 25, 2013
Outputs memory stats on the command line for OS X. Similar to (but way different than) free on Linux.
View free.sh
#!/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]
View trans.rb
# encoding: UTF-8
require 'rubygems'
require 'bundler/setup'
require 'active_support/inflector'
require 'iconv'
puts %[
This is why String#encode does not replace Iconv, and neither
does ActiveSupport::Inflector#transliterate: