Skip to content

Instantly share code, notes, and snippets.

View spllr's full-sized avatar

Klaas Speller spllr

View GitHub Profile
@spllr
spllr / twitter_monitor.rb
Created October 1, 2010 12:59
Little twitter monitor
#!/usr/bin/env ruby
# Usage:
# > twitter_monitor [search terms]
#
# By spllr
require "rubygems"
require "twitter"
require "growl"
@spllr
spllr / remove_duplicate_vim_snippets.rb
Created December 29, 2010 11:18
Removes all duplicate snippets in .vim/snippets which are already defined in .vim/bundle/snipmate.vim/snippets/*.snippets
puts "Remove duplicate snippets from vim conf"
Dir.chdir(File.expand_path("~/.vim/bundle/snipmate.vim"))
puts "Moved to #{Dir.pwd}"
Dir["**/*.snippets"].each do |snippet|
snippet_lang = File.basename(snippet, '.snippets')
File.open snippet, "r" do |snippet_file|
snippet_file.read.scan(/^snippet (.+)/) do |snippet_key|
@spllr
spllr / .bash_profile
Created January 2, 2011 10:24
Bash stuff
# macport
if [ -d /opt/local/etc/macports ]; then
PATH=/opt/local/etc/macports:"${PATH}"
fi
if [ -d /opt/local/bin/ ]; then
PATH=/opt/local/bin/:"${PATH}"
fi
if [ -d ~/bin/ ]; then
@spllr
spllr / macruby_chatter.rb
Created February 7, 2011 22:21
Little POC for Distributed Object in MacRuby
#
# MacRuby distributed objects poc.
#
# Inspired by the Distributed Object chapter in "Advanced Mac Os X Programming" by Dalrymple and Hillegass
#
# Klaas Speller
# http://www.github.com/spllr
#
# Use at own risk (that's what the lisence is for).
# Its still buggy and I would love some input on good usage of the NSRunLoop with MacRuby
@spllr
spllr / batch_resize.rb
Created February 16, 2011 14:14
Quick and dirty image resizer
require "rmagick"
require "fileutils"
[
{ :path => 'medium', :max_width => 125, :max_height => 450},
{ :path => 'normal', :max_width => 200, :max_height => 200},
{ :path => 'micro', :max_width => 65, :max_height => 65}
].each do |opts|
max_height = opts[:max_height]
max_width = opts[:max_width]
@spllr
spllr / bacon_runloop.rb
Created February 25, 2011 13:57
Test code in an nsrunloop with bacon
class Bacon::Context
def runloop(duration=0.6)
Thread.new {
runloop = NSRunLoop.currentRunLoop
yield
runloop.runUntilDate(NSDate.dateWithTimeIntervalSinceNow(duration))
}.join
end
end
@spllr
spllr / mac_bacon_breaker.rb
Created February 28, 2011 10:02
Break build when test fail
module Bacon
def self.context_did_finish(context)
handle_specification_end
Counter[:context_depth] -= 1
if (@current_context_index + 1) < @contexts.size
@current_context_index += 1
run
else
# DONE
handle_summary
@spllr
spllr / MyCoreDataTests.h
Created December 18, 2011 12:05
Unit Testing Core Data Step 1
#import <SenTestingKit/SenTestingKit.h>
#import <CoreData/CoreData.h>
@interface MyCoreDataTests : SenTestCase
{
NSManagedObjectModel *managedObjectModel;
NSPersistentStoreCoordinator *persistentStoreCoordinator;
NSManagedObjectContext *managedObjectContext;
}
@end
@spllr
spllr / MyCoreDataTests.h
Created December 18, 2011 12:11
Unit Testing CoreData Example Code
#import <SenTestingKit/SenTestingKit.h>
#import <CoreData/CoreData.h>
@interface MyCoreDataTests : SenTestCase
{
NSManagedObjectModel *managedObjectModel;
NSPersistentStoreCoordinator *persistentStoreCoordinator;
NSManagedObjectContext *managedObjectContext;
}
- (void)setupCoreDataEnvironment;
@spllr
spllr / numerology.rb
Created February 5, 2012 23:06
Calculate your number according to Numerology
#
# Calculate your number according to http://www.astrology.com/what-numerology/2-d-d-66854
#
#
# HOW ARE NUMEROLOGY CALCULATIONS DONE
# In numerology, all numbers are reduced to the single digits 1 through 9 except the special master numbers 11 and 22. 1, 2, 3, 4, 5, 6, 7, 8, 9, 11 and 22 represent the major vibration rates associated with people’s characteristics.
# The numbers are reduced by simple addition. The number 15, for instance, is reduced by adding 1 + 5 to get 6. Similarly, the number 1974 can be reduced by adding 1 + 9 + 7 + 4 to get 21. The 21 can be further reduced by adding 2 + 1 to get 3.
# Letters in individuals’ names are converted to numbers and then added together. These numbers, in turn, are also reduced. The letter A, for instance, is 1; the letter B is 2; the letter C is 3, and so forth. The following table shows the numbers assigned to all 26 letters in the English alphabet.
#
# 1 2 3 4 5 6 7 8 9