Skip to content

Instantly share code, notes, and snippets.

#import <Cocoa/Cocoa.h>
@interface RBAppDelegate : NSObject <NSApplicationDelegate>
{
NSStatusItem *systemStatusItem;
}
@end
@runeb
runeb / loadAd.js
Created January 30, 2012 15:24
document.write ad voodoo
function loadAd(url, div) {
function makeAdParser(el, cb) {
var inNoScriptTag = false;
var parser = function(txt) {
txt = txt.trim();
if(txt === '</noscript>') { inNoScriptTag = false; return; }
if(txt === '<noscript>') { inNoScriptTag = true; return; }
if(inNoScriptTag) { return; }
@runeb
runeb / finn.rb
Created December 20, 2011 10:00
Finn.no real estate pages as JSON data
# encoding: UTF-8
require 'open-uri'
require 'uri'
def finn(id)
doc = open("http://www.finn.no/finn/realestate/homes/object?finnkode=#{id}").read
doc =~ /helios_parameters\s?:\s?'(.*)'/
attrs = $1.split(';').inject({}) do |mem, e|
key, value = e.split "="
@runeb
runeb / backbone.namespace.js
Created November 23, 2011 15:55
Backbone support for (railsy) namespaces in model/collection json representations
// Extend Backbone.Model to support setting a namespace
// for models. Example response from server:
// {
// 'modelname' : {
// ... attributes ...
// }
// We dont want the attributes to be scoped by the model name
// in the models attributes property. This new parse function
// will drop the namespace if it is defined on the model.
// Example:
@runeb
runeb / paper.SVG.js
Created August 25, 2011 14:34
Export the paper.js view as SVG by rendering to http://svgkit.sourceforge.net/web/SVGCanvas.html
// SVGCanvas.prototype.transform = SVGCanvas.prototype.translate;
// SVGCanvas.prototype.fillText = SVGCanvas.prototype.text;
paper.View.prototype.toSVG = function() {
var svgContext = new SVGCanvas(this.canvas.width, this.canvas.height);
var oldCtx = this._context;
this._context = svgContext;
this.draw(false);
@runeb
runeb / provisioning_protal.rb
Created May 6, 2011 12:06
A script for accessing the iOS provisioning portal programmatically. Probably a bit outdated now, and assumes you are part of several teams. CUD of CRUD not impl.
require 'bundler/setup'
require 'mechanize'
class Device
attr_accessor :name, :uuid, :id
end
class ProvisioningPortal
attr_reader :connection
@runeb
runeb / mls.rb
Created April 23, 2011 15:10 — forked from judofyr/mls.rb
Conversions between latitude, longitude and Maidenhead Locator System
module MLS
extend self
GRID = ("A".."R").to_a
SQUARE = ("0".."9").to_a
SUB = ("a".."x").to_a
deg = 180.0
PARTS = [[18, GRID], [10, SQUARE], [24, SUB], [10, SQUARE]]
PARTS.map! { |div, part| [deg = deg / div, part] }
# An attempt at visualising classbox local rebinding as described in
# http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.3.4133&rep=rep1&type=pdf
#
# Suppose a classbox ClassBox1 defines a class C with two methods, m callin n, and
# classbox ClassBox2 imports C from ClassBox1 and replaces n. We say that…
class C;end
module ClassBox1
refine C do
@runeb
runeb / db.no.clean.css
Created September 1, 2010 14:29
Cleaning up db.no
/* Generell plagsomhet */
.skattesok2009 {display: none!important;}
#solBox {display: none!important;}
#header {display:none!important;}
div.ad {display: none!important;}
#ad-top {display: none!important;}
div#topp-ad {display: none!important;}
#tvguide .head {display: none!important; }
iframe {display: none!important;}
#footerwrapper {display: none!important;}
@runeb
runeb / mongoid.nb.yml
Created August 30, 2010 20:12
Norwegian translation for Mongoid
nb:
activemodel:
errors:
messages:
taken: er allerede i bruk
mongoid:
errors:
messages:
document_not_found: