Skip to content

Instantly share code, notes, and snippets.

View telent's full-sized avatar

Daniel Barlow telent

View GitHub Profile
@telent
telent / rackup.rb
Created May 28, 2011 21:16
Thin-Prefork - a real-world example
#!/usr/bin/env ruby
require 'rticulate'
require 'thin/prefork'
require 'thin/prefork/project'
require 'projectr/watch_changes'
debugging = ARGV.member?("-d")
if debugging then
stderr=$stderr.dup
@telent
telent / gist:1006328
Created June 3, 2011 13:22
rvm installer failure
stargreen@lsip:~$ /usr/local/bin/rvm-installer --version 1.2.0
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 703k 100 703k 0 0 250k 0 0:00:02 0:00:02 --:--:-- 280k
Unrecognized option: --path
Usage:
./scripts/install [options]
@telent
telent / Makefile
Created June 6, 2011 20:47
All that glitters
TARGET_HOSTNAME=golden
TEMPLATE=template
RELEASE=squeeze
PROXY=http://lsip.4a.telent.net:3142
MIRROR=$(PROXY)/ftp.debian.org/debian
# this must be in a format that works as input to sfdisk
PARTITIONS='1,1044,L,*\n1045,243\n1288,\n;'
all: checkuid0 disk.img
@telent
telent / gist:1119996
Created August 2, 2011 10:48
Puppetised redmine on Debian, first pass
# gist has no puppet syntax highlighting? shurely shome mishtake
# Faced with the choice of writing down in English how I installed redmine so that
# A N Other admin could repeat it at a later date, or writing down in Puppet
# syntax how I would propose to install it, I went for the latter option and
# now I can repeat it at any date I like. Oh, let's run it again!
# This works for me. If you have the Debian Squeeze versions of ruby and puppet,
# it may also work for you. If it breaks, you get to keep both halves. I used
wsrv() { ruby -r sinatra -e "a=ARGV;;enable :run; set :port, ((i=a.index('-p') and a.slice!(i,2)[1].to_i)||8000); set :public, File.join(Dir.pwd,a[0]||'.'); get '/' do Sinatra::VERSION ; end;" -- $* ;}
:; export PATH=/usr/local/rbx/bin/:/home/dan/scripts:/home/dan/bin:/usr/local/lib/android/tools:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin
:; type ruby
ruby is /usr/local/rbx/bin/ruby
:; echo $GEM_HOME
/home/dan/gem
:; rm Gemfile.lock
:; bundle install
Fetching source index for http://rubygems.org/
Using rake (0.9.2.2)
Using log4r (1.1.9)
@telent
telent / gist:1514041
Created December 23, 2011 12:17
fun with method aliases
irb(main):025:0> class Foo; def foo; 42 ;end ; alias :bar :foo ;end
=> nil
irb(main):026:0> Foo.instance_method(:foo)
=> #<UnboundMethod: Foo#foo>
irb(main):027:0> Foo.instance_method(:bar)
=> #<UnboundMethod: Foo#foo>
irb(main):028:0> Foo.instance_method(:foo).name
=> :foo
irb(main):029:0> Foo.instance_method(:bar).name
=> :bar
@telent
telent / core.clj
Created March 3, 2012 22:03
Audio (mp3/flac/etc) tag support for Clojure via JAudiotagger
(ns onelouder.core
(:import [org.jaudiotagger.audio AudioFileIO]
[org.jaudiotagger.tag FieldKey]))
(defn tags [file]
(let [fields (apply conj {} (map (fn [n] [(keyword (. (. n toString) toLowerCase)) n]) (. FieldKey values)))
tag (. file (getTag))]
(apply conj {}
(filter (fn [[name val]] (and val (not (empty? val))))
(map (fn [[name val]]
$ cat connectivity.pl
#!/usr/bin/perl
open(P,"ping dean.stargreen.com|");
my $verbose=grep(@ARGV,"-v");
#warn $verbose;
$|++; while(<P>){
my($seq)=/icmp_req=(\d+)/ ;
print $_ if $verbose;
while($seq>$expected){
print ((scalar gmtime)." missed $expected\n");
DIRS=SOURCES SPECS BUILD BUILDROOT RPMS SRPMS workarea
SPEC=mongodb.spec
VERSION=2.2.1
UPSTREAM=http://downloads.mongodb.org/src/mongodb-src-r$(VERSION).tar.gz
TARBALL=$(shell basename $(UPSTREAM))
all: $(DIRS)
@echo "ready"
distclean: