Skip to content

Instantly share code, notes, and snippets.

function rbdiff {
local branch
branch=$(git name-rev --name-only head)
git diff master..HEAD > "~/Desktop/${branch}.diff"
}
@al3x
al3x / gist:54290
Created January 29, 2009 00:56
MacPorts choking on texlive
[al3x@rawls ~]$ sudo port sync; sudo port upgrade outdated
Password:
---> Building texlive_base
Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_tex_texlive_base/work/texlive_base-2007" && make all " returned error 2
Command output: make[2]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all'.
make all-recursive
Making all in data
make[4]: Nothing to be done for `all'.
Making all in src
class Primary
def hello
puts "hello from Primary"
end
def call_hello
hello
end
end
[al3x@rawls spde:master]$ buildr run --trace
2009-03-04 13:45:41.456 ruby[3687:10b] RBCocoaInstallRubyThreadSchedulerHooks: couldn't find autoreleasePool ivar
(in /Users/al3x/src/third_party/scala/spde, development)
** Invoke buildr:initialize (first_time)
** Execute buildr:initialize
** Invoke spde (first_time)
** Execute spde
** Invoke /Users/al3x/.m2/repository/org/apache/ant/ant/1.7.1/ant-1.7.1.jar (first_time, not_needed)
** Invoke /Users/al3x/.m2/repository/org/apache/ant/ant-launcher/1.7.1/ant-launcher-1.7.1.jar (first_time, not_needed)
** Invoke /Users/al3x/.m2/repository/org/apache/ant/ant-trax/1.7.1/ant-trax-1.7.1.jar (first_time, not_needed)
@al3x
al3x / gist:78799
Created March 13, 2009 22:20
A part of UserSpec
"showing a nonexistant user returns 404" in {
withFormats(List("xml", "json")) { format =>
val response = User.show("jack", "asonetibaosneitb", format)
response mustNot beNull
response.code mustEqual 404
response
} mustNot beEmpty
}
@al3x
al3x / bundleup.rb
Created April 15, 2009 18:31
Brute force update of TextMate bundles, be they from Git or Subversion
#!/usr/bin/env ruby
require 'fileutils'
ENV['LC_ALL'] = nil
ENV['LC_CTYPE'] = 'en_US.UTF-8'
DEBUG = false
bundle_dir = "#{ENV['HOME']}/Library/Application\ Support/TextMate/Bundles"
@al3x
al3x / newpost.rb
Created April 22, 2009 23:50
Handy new post script for Jekyll blogs or similar
#!/usr/bin/env ruby
unless ARGV[0]
puts 'Usage: newpost "the post title"'
exit(-1)
end
date_prefix = Time.now.strftime("%Y-%m-%d")
postname = ARGV[0].strip.downcase.gsub(/ /, '-')
post = "/Users/al3x/src/al3x.github.com/_posts/#{date_prefix}-#{postname}.textile"
#!/usr/bin/ruby
# assumes the user has configured a TextMate project that
# points to the directory full of journal entry files
require 'date'
require 'fileutils'
date = Date.today
entry = "/Volumes/Personal/journal/#{date.to_s}.textile"
import java.security.MessageDigest
import scala.actors.Actor
import scala.actors.Actor._
import scala.util.Random
class DigestComparisonActor extends Actor {
val md5 = MessageDigest.getInstance("MD5")
val rand = new scala.util.Random()
var byteArray = new Array[Byte](32)
def forLineInFile(file: String)(f: String => Unit) {
val src = Source.fromFile(file)
src.getLines.foreach(f)
}