Skip to content

Instantly share code, notes, and snippets.

@Capncavedan
Capncavedan / gist:2829773
Created May 29, 2012 18:01
Agency by Alpha search

What?! No QWERTY keyboard?

What, no QWERTY keyboard?

@Capncavedan
Capncavedan / backsimmer.rb
Created May 28, 2012 01:46
AppleScript to assist with scheduling changes in Backblaze backup speed
#!ruby
VALID_SPEED_DESCRIPTORS = %w(slow medium fast unlimited 0 10 20 30 40 50 60 70 80 90 100)
def applescript_for_speed(descriptor)
speed = case descriptor.to_s.downcase
when "slow"
"20"
when "medium"
"40"
@Capncavedan
Capncavedan / gist:2768444
Created May 22, 2012 11:21
AppleScript bits to help find UI elements
tell application "System Preferences"
activate
end tell
tell application "System Events"
tell process "System Preferences"
set visible to true
click menu item "Backblaze Backup" of the menu "View" of menu bar 1
click button "Settings..." of the first group of the window "Backblaze Backup"
--return every UI element of tab group 1 of front sheet of front window
@Capncavedan
Capncavedan / validator.rb
Created May 16, 2012 13:32
Ruby CSS validator
require 'rubygems'
require 'w3c_validators'
validator = W3CValidators::CSSValidator.new
validator.set_profile!(:css2)
fp = '/path/to/cssfile.css'
results = validator.validate_file(fp)
puts results.errors
puts results.warnings.size
@Capncavedan
Capncavedan / gist:2659724
Created May 11, 2012 13:42
ImageRight go-live checklist
- verify Fidelity Bond documents transfer to production IR server, get imported
- verify Agency documents transfer to production IR server, get imported
- verify Diary Items transfer to production IR server, get imported
- verify hyperlinks to open a file in IR work (web page open, Desktop file changes/opens)
- verify hyperlinks to open a file from IR work (Desktop file open, web page changes)
Contract Bond Factory
FactoryGirl.build(:contract_bond)
--> Principal
--> Appointed Agency
--> contract_underwriter
--> User
--> Domino User
--> Assistant
@Capncavedan
Capncavedan / Ruby script
Created April 9, 2012 15:45
Ruby script to show OS X battery info at command line
#!/usr/bin/ruby
ioreg_data = IO.popen("ioreg -w0 -l").readlines().join
ioreg_data.sub!(/.*(\+\-o AppleSmartBattery.*?\+\-o).*/m, '\\1')
ioreg_data.gsub!(/\s+\|/, "")
ioreg_data.gsub!(/\s\s+/, "\n")
battery = Hash.new
ioreg_data.split(/\n+/).each do |line|
key, value = line.split(' = ')[0..1]
next if key.nil? || value.nil?
@Capncavedan
Capncavedan / gist:2293043
Created April 3, 2012 15:45
how to install rdiscount 1.6.8 with jruby 1.6.7
Bundler command complained of not being able to find bundle1.o although I could easily locate it within /usr/lib myself.
Damn computers.
gem install rdiscount -- --with-ldflags="-L/usr/lib"
@Capncavedan
Capncavedan / gist:2223007
Created March 28, 2012 02:29
Ruby Date and Time symbol meanings
# Date and Time symbol meanings:
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
@Capncavedan
Capncavedan / gist:2170952
Created March 23, 2012 14:06
Output set of numbers as ranges
# courtesy of http://codepad.org/tBON208e
$_ = "1,2,3,8,9,12,15,17,18,19,20,21,22,23";
s/(?<!\d)(\d+)(?:,((??{$++1})))+(?!\d)/$1-$+/g;
print;