Skip to content

Instantly share code, notes, and snippets.

View rab's full-sized avatar
👨‍💻
Home Office is a mess (as usual)

Rob Biedenharn rab

👨‍💻
Home Office is a mess (as usual)
View GitHub Profile
@rab
rab / .gitconfig
Last active May 14, 2024 07:05
A good starting point for ~/.gitconfig
# -*- Conf -*-
[color]
branch = auto
diff = auto
status = auto
showbranch = auto
ui = true
# color.branch
# A boolean to enable/disable color in the output of git-branch(1). May be set to always, false (or
@rab
rab / gist:2938025
Created June 15, 2012 18:27 — forked from st23am/gist:2937073
Git branch parsing
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
@rab
rab / hello.clj
Created May 8, 2012 22:14 — forked from gigasquid/swarmcoding
Swarm coding instructions
(ns cincyfp.hello)
(+ 1 1)
;; given 3 integers in a sequence
;; generate the number of lights that are on in a berlin clock,
;; returning 5 rows
(defn make-counts [[hours minutes seconds]]
[
(- 1 (mod seconds 2))
@rab
rab / output
Created October 10, 2011 13:48
Testing a die for bias
ruby randomness.rb rob_d20.txt
500 rolls from 1 to 20
Expected per bucket: 25.0 (σ ≈ 5.00)
10: ( 1)
11:
12:
13:
14:
15: (20)
@rab
rab / xferlist.rb
Created May 28, 2011 21:35
Ruby script to xfer a set of directories to an sftp location
#!/usr/bin/env ruby -w
# Expected to be found at ~/code/ruby/xferlist.rb
# Move all files newer than the 'sentinel' to the web site
# skip all .doc files (MS-Word)
# skip all files containing a tilde (~) (local backup or archival copies)
# skip anything in 'old-notices'
#
# Deals with spaces in file/directory names by using the '?' shell wildcard
@rab
rab / with_log_level.rb
Created March 31, 2011 13:48
temporarily change the logging level for the duration of a block
require 'logger'
module WithLogLevel
def with_log_level(level=Logger::INFO)
if logger
begin
original_level = logger.level
logger.level = level
yield
ensure
@rab
rab / gist:874985
Created March 17, 2011 19:44
Steps for getting the 500Gb drives into the old server
  • Receive the pair of 500Gb drives for the old server.
  • REMOTE
    • turn off all datafeeds (done)
    • StylePath is DOWN (Thu 18:45)
    • do a full backup [A] (done at Thu 19:41)
    • StylePath is UP (~1hr downtime) (Thu 19:52, actual down 1:07)
  • copy the backup to new server and to a USB drive
@rab
rab / .git-completion.sh
Created January 12, 2011 15:31
Colorful bash prompt with rvm and git goodness
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
class Person
include ActiveModel::MassAssignmentSecurity
attr_accessor :name, :birthday, :handsomeness
attr_protected :handsomeness
def initialize(params = {})
self.attributes = params
end
@rab
rab / README.md
Created August 18, 2010 20:48
Simulating Vehicle traffic for Bruce Wayner <winshocker@gmail.com>

run with:

ruby simulating_vehicles.rb

or to see each vehicle:

ruby -v simulating_vehicles.rb

You'll have to tally the results yourself across many runs, but this is way more than you deserve. (And you really need to understand it before you turn it in.)