it's my (old) blog

by simon baird

Monday, November 22, 2010

A fork appears in the road...

This blog is closing down.

[Pause for gasps and murmurs].

Dry your eyes internet. I would not leave you out in the cold like that!

I am splitting this blog into two blogs. Like a primordial amoeba. What was one is now two.

Blog #1:
Bookmark or subscribe to this for my pointless photos, sporadic musings and occasional half-hearted music review.

Blog #2:
Bookmark or subscribe to this for posts about programming, code snippets and other geek stuff.
(Ps, sorry about the recycled content. Just needed something to kick start things over there).

Now you must choose. The left path or the right. Or you could follow both, like some kind of bad Harry Potter plot device. (Or you could find a bus and get the hell out of here).

Now, if you please, I would like to take a moment to fondly remember...

"it's my blog"
http://glosoli.blogspot.com/
13 Sep, 2005 - 22 Nov, 2010

And don't forget, you can come back any time to browse the archives and relive some of those sweet memories. (I know that's what I will be doing).

Sunday, November 21, 2010

Thursday, November 18, 2010

do you guys know about die antwoord?

kind of like a next level south african ali-g

perhaps boing boing get credit for introducing them to the world. at that point no-one really knew they were "fake"

here is an awesome yolandi halloween costume...

Wednesday, November 17, 2010

hamrbl - a cute haml hack to let you write ruby with python-esque whitespace

Did you ever wish your code looked more like your haml?

Did you ever wonder what ruby would be like with python style significant whitespace?

Without further ado, I present hamrbl.rb

require 'rubygems'
require 'haml'
# Put a - char on each line in just the right place.
# (Need to remove blank lines too, they cause problems)
haml_source = File.read($0).gsub(/\n+/,"\n").gsub(/^\s*/,'\&-')
begin
# Run the file with haml
Haml::Engine.new(haml_source).render
rescue Exception => e
# Spit out the haml source to make it easier to find your error
puts "FAILED!\n#{haml_source}"
raise e
end
exit
# Here's a one line version :)
# Haml::Engine.new(File.read($0).gsub(/\n+/,"\n").gsub(/^\s*/,'\&-')).render; exit
view raw hamrbl.rb hosted with ❤ by GitHub
#!/usr/bin/ruby -r hamrbl
# Just a test of hamlrb.rb
module Singing
def sing(count=1)
count.times do |i|
if %w[tweety bigbird].include? @name.downcase
puts "#{@name}: 'tweet tweet #{i+1}'"
else
puts "#{@name}: 'la la la #{i+1}'"
class Singer
include Singing
def initialize(name)
@name = name
# comments are okay :)
Singer.new('Thom').sing(2)
Singer.new('Tweety').sing
view raw test.rb hosted with ❤ by GitHub
$ ls -l
total 24
-rw-r--r-- 1 simon staff 232 17 Nov 21:13 hamrbl.rb
-rwxr-xr-x 1 simon staff 433 17 Nov 21:56 test.rb
$ ./test.rb
Thom: 'la la la 1'
Thom: 'la la la 2'
Tweety: 'tweet tweet 1'
$
view raw zzoutput hosted with ❤ by GitHub

Surprisingly the syntax highlighting works fine in vim and github. :)

Disclaimer: just for fun... this is (almost certainly) a gross misuse of the wonderful haml

include_and_extend method for ruby, experiments with modules

As a followup to this post and inspired again by this wycats post, here is some more experimentation with extend and include in ruby, culminating in an include_and_extend method, (which I'm not suggesting is a particularly good idea), but it does work...
#
# Example 1
#
# There are two modules, one for instance methods and one for class methods
# Use 'include' and 'extend' separately
#
module Foo1Instance
def foo; "instance foo (#{self.class.name})"; end
end
module Foo1Static
def foo_static; "static foo"; end
end
class MyClass1
include Foo1Instance
extend Foo1Static
end
#
# Example 2
#
# Kinda the same except there is a container module
#
module Foo2
module InstanceMethods
def foo; "instance foo (#{self.class.name})"; end
end
module ClassMethods
def foo_static; "static foo"; end
end
end
class MyClass2
include Foo2::InstanceMethods
extend Foo2::ClassMethods
end
#
# Example 3
#
# There is one module with an inner module for the static methods.
# The module defines the include method to automatically extend
# using the inner module
#
module Foo3
def foo; "instance foo (#{self.class.name})"; end
module ClassMethods
def foo_static; "static foo"; end
end
# Make it so when this module is included it will also extend...
def self.included(base)
base.extend ClassMethods
end
end
class MyClass3
include Foo3
end
#
# Example 4
#
# Same again but in reverse (just to satisfy my curiousity)
#
# Automatically include some stuff when extending
#
module Foo4
def foo_static; "static foo"; end
module InstanceMethods
def foo; "instance foo (#{self.class.name})"; end
end
# Make it so when this module is included it will also extend
def self.extended(base)
#base.include InstanceMethods # <- private method `include' called for MyClass4:Class (NoMethodError)
# so use send..
base.send :include, InstanceMethods
end
end
class MyClass4
extend Foo4
end
#
# Example 5
#
# Since ruby can do anything, let's define an include_and_extend method
#
#
class Class
def include_and_extend_1(the_module)
include the_module
extend the_module::ClassMethods
end
end
module Foo5 # like Foo3 without the def included magic
def foo; "instance foo (#{self.class.name})"; end
module ClassMethods
def foo_static; "static foo"; end
end
end
class MyClass5
include_and_extend_1 Foo5
end
#
# Example 6
#
# Improve (?) include_and_extend using const_get
#
class Class
# Incase you want to use something other than ClassMethods, lets use an optional arg
def include_and_extend_2(the_module,class_methods=:ClassMethods)
include const_get(the_module)
extend const_get(the_module).const_get(class_methods)
end
end
class MyClass6
include_and_extend_2 :Foo5, :ClassMethods
end
#
# Example 7
#
# Improve (?) include_and_extend again by checking for existance of the inner modules...
#
class Class
def include_and_extend(the_module,options={})
options[:instance_methods] ||= :InstanceMethods
options[:class_methods] ||= :ClassMethods
# Mainly include but be flexible
main_module = const_get(the_module)
include main_module # for an extend_and_include method, change this to extend main_module
include main_module.const_get(options[:instance_methods]) if main_module.const_defined?(options[:instance_methods])
extend main_module.const_get(options[:class_methods]) if main_module.const_defined?(options[:class_methods])
end
end
class MyClass7
include_and_extend :Foo5
end
#
# Example 8
#
# Test the optional args for include_and_extend...
#
module Foo8
def foo; "instance foo (#{self.class.name})"; end
module YipInstance
def foo2; "instance foo2 (#{self.class.name})"; end
end
module YipClass
def foo_static; "static foo"; end
end
end
class MyClass8
include_and_extend :Foo8, :instance_methods => :YipInstance, :class_methods => :YipClass
end
#-------------------------------------------------------------------------------
# Does it work?
#
[MyClass1, MyClass2, MyClass3, MyClass4, MyClass5, MyClass6, MyClass7, MyClass8].each do |klass|
puts "#{klass.new.foo}, #{klass.foo_static}"
end
# The extra instance method from Foo8...
puts MyClass8.new.foo2
#
#
# Output
#
# ~> ruby include_and_extend_experiments.rb
# instance foo (MyClass1), static foo
# instance foo (MyClass2), static foo
# instance foo (MyClass3), static foo
# instance foo (MyClass4), static foo
# instance foo (MyClass5), static foo
# instance foo (MyClass6), static foo
# instance foo (MyClass7), static foo
# instance foo (MyClass8), static foo
# instance foo2 (MyClass8)
#

Monday, November 15, 2010

video test

http://www.youtube.com/watch?v=4sPJvyQWSIc&t=2m15s

(it's kyu. i skipped you ahead to the part where they start rocking out on the floor tom)

dawn

Saturday, November 13, 2010

Thursday, November 11, 2010

Tuesday, November 09, 2010

...in which i live blog the joanna newsom tour date announcement on triple j

  • 4th march tivoli, brisbane
  • 9th march, sydney
  • 15th march, melbourne
(on sale friday morning)

Update:
More details here.


Sunday, November 07, 2010

Saturday, November 06, 2010

Kyü update

Well after listening to the album and seeing them live at the Old Museum, here is my update. Moments of genius. Not quite as good overall as I might have imagined after hearing Pixiphony for the first time. Live, there was some magic. The girls have some undeniable talent and a unique sound. It will be great to see what they are doing in five years as their songwriting matures.

Some links:

my new world is breathtaking

the first two locations are quite close to home. in the third shot i was completely lost, nearly dead, trudging through snow, miles from home. i survived one night on the ice. i did not survive a second...

the texture pack is brown and bloom.

some minecraft links:
Conways' Game of Life in Minecraft (video)
Towards Dawn - A Minecraft Travel Blog

Friday, November 05, 2010

Little script to delete a git branch on local and remote

Put this in your .bashrc (or .bash_aliases):
#
# https://gist.github.com/663503
#
# Use this to clean your repo by removing old branches.
# It will remove the branch on local and on origin.
#
# Usage:
# $ nuke_branch some_old_branch_you_dont_need
#
# Note we use -d not -D for teh safety.
#
nuke_branch() {
# Loop over all given branches
for branch in $*; do
# Check for remote branch
CHECK_REMOTE_EXISTS=`git branch -r | grep -e "^..origin/$branch\$"`
if [ -n "$CHECK_REMOTE_EXISTS" ]; then
echo "** Nuking remote branch origin/$branch"
# Delete the remote branch
git branch -d -r origin/$branch
# Push to remove it from origin (or something..?)
git push origin :$branch
else
echo "** Remote branch origin/$branch not found"
fi
# Check for local branch
CHECK_LOCAL_EXISTS=`git branch | grep -e "^..$branch\$"`
if [ -n "$CHECK_LOCAL_EXISTS" ]; then
echo "** Nuking local branch $branch"
# Delete the local branch
git branch -d $branch
else
echo "** Local branch $branch not found"
fi
echo ""
done
}
view raw gistfile1.tcsh hosted with ❤ by GitHub

joanna newsom announced for 'golden plains' in march in victoria


perhaps she will tour while she is here...

Wednesday, November 03, 2010

save 3. kind of ruined...

went exploring and found this. the pre-biome and post-biome generated terrain doesn't fit together as you can see. i'm probably going to delete it and start a fresh world. :( also i concur the mob spawn rates are way too high now. (i think notch agrees with this and an update will be forthcoming).

Tuesday, November 02, 2010

cave where i died and lost stuff


save 3 (pre-biome)


mad scheme

currently i pay 6.64% interest on my mortgage. it's going up 25 points any second now, so let's say it's 6.9%. suncorp are currently offering 1.9% on balance transfers for 15 months (when you sign up for a new credit card). suppose i "balance transfer" $10,000 from my two current cards and put the proceeds on my mortgage. i'd pay 5% less interest on $10,000 for 15 months, which is a saving of $625 or $42 a month. but, the annual card fee is $120 which brings it down to $500 or $33 a month. of course, after 15 months i'd pay off the new card and cut it up. worth it? this is tax free btw. what if i repeat this scheme with a few other low introductory rate cards?

Tuesday, October 26, 2010

nooooo...! #minecraft

(warning, boring story follows).

so i have a little single player world. i haven't been there there
long. i found an amazing cave a few minutes walk away from my base. i
explored it for a while and loaded up on iron and coal, carefully
marking my path so i could find my way back up. (there was some gold
there too but i hadn't made an iron pick yet).

it was getting late (irl) so I decided to go back home. got almost
to the surface when i was ambushed by a skeleton! i noobishly
had no bacon or other means to restore health and i ended up full of
arrows and dead. when i respawned it was daylight (thankfully) so i
bolted as quick as i could back to the spot to get my loot before it
disappeared.

but i couldn't find the entrance! it was kind of hard to see; just a
flat hole in grass and i hadn't had the sense to mark it. eventually i
found it but it was too late and all my stuff was gone. this includes
a heap of glass that i had made and all my torches, my tools, my wood,
some flint. everything. :(

(the end)

holy crap (kyü)

Watch KYU and other great gigs on Moshcam.

Monday, October 25, 2010

this could be an amazing new band: kyü

listen to pixiphony on their myspace. kind of
bat-for-lashes-vs-animal-collective-y:
http://www.myspace.com/kyusounds
friday show in brisbane:
http://tickets.oztix.com.au/?Event=17821
itunes:
http://itunes.apple.com/au/album/kyu/id391988362
(i will let you know if the hype is justified)

Sunday, October 17, 2010

Benoît Mandelbrot (1924 - 2010)

ob mandelbrot video:
http://www.youtube.com/watch?v=JGxbhdr3w2I
the photo parts are a little tacky LAME but i like the way there is zooming, panning and rotation (instead of just the traditional endless zoom)

Wednesday, October 13, 2010

minecraft

i might try to explain to you how amazing this game is. but not now. now it's just these links, (which don't really explain it either):

a fan's attempt at a trailer:
crafting guide

Wednesday, October 06, 2010

fremnet manor by night


my first ever diamond

fremnet help me shore it up so i could mine it without the diamond falling into lava

beginning_of_fortnight method for Ruby on Rails

You might know that Rails provides a bunch of useful extensions to the Time class with methods like beginning_of_week, beginning_of_month, etc.

For my application (a thing with fortnightly billing periods) I wanted to define a beginning of fortnight method to consistently calculate the beginning (and end) of a fortnight. Here's how it ended up (both short and sweet):
#
# Extend ActiveSupport to provide a beginning_of_fortnight and an
# end_of_fortnight method for the Time class
#
module ActiveSupport::CoreExtensions::Time::Calculations
#
# How many weeks since the beginning_of_week before unix time zero
#
def weeks_after_epoch
((self - ::Time.at(0).beginning_of_week) / 1.week).to_i
end
#
# The beginning of the current fortnight
#
# The choice of which week should begin a fortnight is arbitrary
# If you want to flip it then change even? to odd? below
#
def beginning_of_fortnight
# If there's been an even number of weeks since epoch use beginning of this week
# If there's been an odd number of weeks since epoch use the beginning of last week
(weeks_after_epoch.even? ? self : self - 1.week).beginning_of_week
end
#
# The end of the current fortnight
#
def end_of_fortnight
(beginning_of_fortnight + 13.days).end_of_day
end
end

(Note that there's no special reason to use epoch. Any other day would work just as well probably).

Does it work?
[Development]>> puts Time.now; (-5..5).each { |w| t = Time.now + w.weeks; puts "now and #{'%2d'%w} weeks: #{t.beginning_of_fortnight} - #{t.end_of_fortnight}" }; nil
Wed Oct 06 16:29:52 +1000 2010
now and -5 weeks: Mon Aug 30 00:00:00 +1000 2010 - Sun Sep 12 23:59:59 +1000 2010
now and -4 weeks: Mon Aug 30 00:00:00 +1000 2010 - Sun Sep 12 23:59:59 +1000 2010
now and -3 weeks: Mon Sep 13 00:00:00 +1000 2010 - Sun Sep 26 23:59:59 +1000 2010
now and -2 weeks: Mon Sep 13 00:00:00 +1000 2010 - Sun Sep 26 23:59:59 +1000 2010
now and -1 weeks: Mon Sep 27 00:00:00 +1000 2010 - Sun Oct 10 23:59:59 +1000 2010
now and 0 weeks: Mon Sep 27 00:00:00 +1000 2010 - Sun Oct 10 23:59:59 +1000 2010
now and 1 weeks: Mon Oct 11 00:00:00 +1000 2010 - Sun Oct 24 23:59:59 +1000 2010
now and 2 weeks: Mon Oct 11 00:00:00 +1000 2010 - Sun Oct 24 23:59:59 +1000 2010
now and 3 weeks: Mon Oct 25 00:00:00 +1000 2010 - Sun Nov 07 23:59:59 +1000 2010
now and 4 weeks: Mon Oct 25 00:00:00 +1000 2010 - Sun Nov 07 23:59:59 +1000 2010
now and 5 weeks: Mon Nov 08 00:00:00 +1000 2010 - Sun Nov 21 23:59:59 +1000 2010
=> nil
view raw Does it work? hosted with ❤ by GitHub

Put beginning_of_fortnight.rb in config/initializers.

Note that there is already a Numeric#fortnights method in ActiveSupport so we can use things like 2.fortnights without needing any extentions.

sleigh bells!

tell 'em (track 1)
never has a song intro more effectively communicated the message "WAKE THE EFF UP AND LISTEN TO THIS! :)"

riot rhythm (track 3)
mad chromatic gee-tar riff ftw

rill rill (track 7)
delicious summery chill-out without even trying

and the rest of it is as good

check it out

Sleigh Bells
Treats (2010)
(Content owner: Liberation Music)

Monday, October 04, 2010

Saturday, October 02, 2010