Skip to content

Instantly share code, notes, and snippets.

View zmalltalker's full-sized avatar

Marius Mathiesen zmalltalker

View GitHub Profile
class Foo
class Bar
end
end
#import "AppController.h"
#import "Person.h"
@implementation AppController
-(id)init
{
NSLog(@"Initializing");
people = [Person findAll];
return self;
}
@zmalltalker
zmalltalker / gist:3265
Created July 30, 2008 14:06
Spike for getting weather forecasts from Yr
def openAnything(source):
"""URI, filename, or string --> stream
This function lets you define parsers that take any input source
(URL, pathname to local or network file, or actual data as a string)
and deal with it in a uniform manner. Returned object is guaranteed
to have all the basic stdio read methods (read, readline, readlines).
Just .close() the object when you're done with it.
Examples:
require 'rubygems'
require 'hpricot'
require 'open-uri'
class Gist
attr_accessor :gist_id, :title, :author
def self.find_all(author="zmalltalker")
result = []
doc = Hpricot(open("http://gist.github.com/#{author}"))
(doc/"div.file").each do |file|
link = (file/"div.info/span/a").first
# encoding: utf-8
alias :"✎" :puts
class Person
attr_accessor :name
def initialize(a_name)
self.name = a_name
end
def ☺(someone)
✎ "#{self} loves #{someone}"
end
end
end
end
end
end
items << item
end
end
end
end
class="active"
<%
else
end
%>
>
class FalseClass
def ifTrue(blk, options)
options[:ifFalse].call
end
end
class TrueClass
def ifTrue(blk, options)
blk.call
end
module Modulus11
def modulus_11_ok?
sum = 0
weights = [5,4,3,2,7,6,5,4,3,2]
digits = cdv_string.split(//)
10.times do |n|
num = digits[n].to_i
sum += num.to_i * weights[n].to_i
end
rest = sum % 11
# A small script that collects details about matches in the Norwegian eliteserien and returns these as Ruby objects
# If you run this file itself, will return a list with details for the teams
require 'rubygems'
require 'open-uri'
require 'hpricot'
class Team
include Comparable
attr_accessor :team_name, :matches, :wins, :losses, :draws, :plus, :minus, :points