Skip to content

Instantly share code, notes, and snippets.

View netzpirat's full-sized avatar

Michael Kessler netzpirat

View GitHub Profile
@netzpirat
netzpirat / USAGE.md
Created June 1, 2011 08:39 — forked from kossnocorp/USAGE.md
MacVim with Drawer compile manual

Clone & Build

curl https://gist.github.com/raw/970438/caff9a09ed2d223b1123a69ede17cb19ad352af9/build.sh | sh
@netzpirat
netzpirat / test.coffee
Created May 4, 2011 19:34
Return nothing from a CoffeeScript function
# Everything is an Expression
->
greeting = 'Hi CoffeeScripter'
# Expect it's undefined
->
greeting = 'Hi CoffeeScripter'
return undefined
@netzpirat
netzpirat / embed.rb
Created March 29, 2011 14:12
ActiveRecord embedding
module ActiveRecord
# Allows embedding of ActiveRecord models.
#
# Embedding other ActiveRecord models is a composition of the two
# and leads to the following behaviour:
#
# - Nested attributes are accepted on the parent without the _attributes suffix
# - Mass assignment security allows the embedded attributes
# - Embedded models are destroyed with the parent when not appearing in an update again
@netzpirat
netzpirat / json_helper.rb
Created March 3, 2011 21:48
The Sencha responder adds generic JSON response handling for the Ext JS framework.
require 'siren'
# The JsonHelper adds a possibility to query JSON data with a simple query language.
# Read more about the Siren JSONQuery implementation at: https://github.com/jcoglan/siren
#
# @author Michael Kessler
#
module JsonHelper
def json(query)
@netzpirat
netzpirat / widgets.rb
Created December 29, 2010 13:36
Testing apotomo widgets with RSpec
module RSpec::Rails
module WidgetExampleGroup
extend ActiveSupport::Concern
extend RSpec::Rails::ModuleInclusion
include RSpec::Rails::RailsExampleGroup
include ActionView::TestCase::Behavior
include RSpec::Rails::ViewAssigns
include RSpec::Rails::Matchers::RenderTemplate
include RSpec::Rails::BrowserSimulators
@netzpirat
netzpirat / string_call.coffee
Created November 29, 2010 21:23
String.call and Namespaces in CoffeeScript tested with JasmineBDD
#
# Calls a function that is defined as a String
#
# 'ws.extranett.subdomain_for'.call('argument1', 'argument2')
#
# Will call the function subdomain_for bound on the object extranett
# with arguments 'argument1' and 'argument2'
#
String::call = (args...) ->
@netzpirat
netzpirat / Upload your events to Flickr
Created November 25, 2010 18:55
upload.rb - Mass media upload to Flickr
#!/usr/bin/env ruby
#
# Upload events organized by year and event name to Flickr.
#
# Your directory structure must be: year/event/... and it can contain many subdirectories and media files.
#
# The script will upload all fotos from an event with a title "Event name Year". The photo will get its
# tags from the filename, except the last token, e.g.
# band_famous_concert_12.jpg will be tagged with band, famous and concert.
#
@netzpirat
netzpirat / spec_helper.coffee
Created October 18, 2010 15:27
My Jasmine matchers taken from JSpec
this.addMatchers({
toBe: (selector) -> $(@actual).is(selector)
toBeA: (clazz) -> @actual.constructor == clazz
toBeAn: (clazz) -> @actual.constructor == clazz
toBeAnimated: -> $(@actual).queue.length > 0
toBeAnInstanceOf: (instance) -> @actual instanceof instance
toBeChecked: -> $(@actual).is ':checked'
toBeDisabled: -> $(@actual).attr 'disabled'
toBeElement: (element) -> $(@actual).get(0).tagName == element.toUpperCase()
toBeEmpty: -> @actual == '' || @actual.length == 0
@netzpirat
netzpirat / jspec.rake
Created September 9, 2010 14:16
Generate jspec run configurations (dom.html, rhino.js and server.html) out of a central configuration file with file globbing!
#
# Rake task for generating the different jspec run configuration from
# a single, central configuration file that supports file globbing
#
# Author: Michael Kessler aka. netzpirat
# License: MIT
#
namespace :jspec do
desc 'Generate the run configurations for all environments'
@netzpirat
netzpirat / gist:430778
Created June 8, 2010 23:10
Ruby debug with RVM and Ruby 1.9
gem install ruby-debug19 -- --with-ruby-include=/home/michi/.rvm/src/ruby-1.9.2-preview3