Skip to content

Instantly share code, notes, and snippets.

# Get the drive identifier
# returns something like sata0/0
$ cfgadm | grep c2t0d0
sata0/0::dsk/c2t0d0 disk connected configured ok
# Power off
# Pull old drive, replace in same position w/ new drive
# Check that the new drive is configured
$ cfgadm | grep c2t0d
sata0/0::dsk/c2t0d0 disk connected configured ok
@pauladam
pauladam / readernaut-export.coffee
Created December 1, 2012 23:28
Readernaut library export. Export your readernaut library to csv for import to other services (Goodreads, LibraryThing etc)
args = require('system').args
if args.length != 3
console.log 'Usage: phantomjs readernaut-export.coffee user pass > export.csv'
phantom.exit()
user = args[1]
pass = args[2]
loginPage = require('webpage').create()
@pauladam
pauladam / gif-it.rb
Created September 22, 2012 20:14
movie -> gif89a
#!/usr/bin/ruby
# gif-it
if ARGV.length < 3
puts "usage: gif-it <filename> <start-time> <duration>"
end
fn = ARGV.shift
start_time = ARGV.shift
duration = ARGV.shift
[12] pry(main)> class Fixnum
[12] pry(main)* def in(l)
[12] pry(main)* l.include? self
[12] pry(main)* end
[12] pry(main)* end
=> nil
[13] pry(main)> 1.in [1,2,3]
=> true
@pauladam
pauladam / ripit.sh
Created February 11, 2012 22:53
Barebones cd -> mp3 bash script
#!/bin/bash
cdparanoia -B
ls | while read fn; do lame $fn; done;
mp3wrap -v album.mp3 *.mp3
mp3val album_MP3WRAP.mp3 -f -nb
mv album_MP3WRAP.mp3 album.mp3
cp album.mp3 ~/Dropbox/Public/
@pauladam
pauladam / copy-safari-tabs.rb
Created November 21, 2011 19:54
Copy open safari tabs to Chrome
#!/usr/local/bin/macruby
framework "ScriptingBridge"
safari = SBApplication.applicationWithBundleIdentifier("com.apple.Safari")
safari.windows.each {|window|
window.tabs.each { |tab|
cmd = "open -a '/Applications/Google\ Chrome.app/' #{tab.URL}"
`#{cmd}`
}
@pauladam
pauladam / reckon seconds till next tuesday.coffee
Created October 20, 2011 00:32
Seconds till next tuesday (coffeescript)
# returns seconds till next tuesday @ noon - 5 minutes
exports.reckonTimeoutValue = ()->
# num days till next tuesday
tuesOffset =
2 : 7
3 : 6
4 : 5
5 : 4
6 : 3
@pauladam
pauladam / partial_function_application.js
Created March 10, 2011 01:29
Practical example of function currying in JS
// I have some code that needs to use the following
// construct repeatedly
for(i=0;i<classes.length;i++){
var c = classes[i];
for(j=0;j<centers.length;j++){
var k = centers[k];
// do something with [c,k], like,
// demand[[c,k]] = expression;
# Bulk add a bunch of urls to your Instapaper account
$ for link in `cat links.txt`; do curl --basic --user username:password --data url=$link http://www.instapaper.com/api/add; done