Skip to content

Instantly share code, notes, and snippets.

View netzpirat's full-sized avatar

Michael Kessler netzpirat

View GitHub Profile
@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 / 0_README.md
Created November 12, 2010 10:42
Continuous CoffeeScript testing with Guard and Jasmine

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@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
@netzpirat
netzpirat / gist:385727
Created April 30, 2010 20:45
Install ruby-debug on 1.9.2 head
gem install ruby-debug19 -- --with-ruby-include=~/.rvm/src/ruby-1.9.2-head/
@netzpirat
netzpirat / rubymine.rb
Created April 14, 2010 19:32
Minimal Rails 3 support for RubyMine: Creates the old Rails 2 scripts that simply executes Rails 3 'rails' command.
#!/usr/bin/env ruby
#
# Helper script to temporary fix some RubyMine 2.0.2 functionality by
# creating old-style Rails 2 scripts. This enables me actually to
# run & debug apps and use the Rails console.
#
# On my machine I have to increase the debugger timeout to connect to a
# Rails 3 app on Ruby 1.9.1. This is done for OS X by modify the Info.plist
# to increase the timeout.
#
@netzpirat
netzpirat / mass_mailer.rb
Created March 18, 2010 23:56
Send email to all email addresses from a MySQL table
#!/usr/bin/env ruby
#
# Send mass emails to the users of my small private email server
# with TLS.
#
# Queries the MySQL database for my vhost users and sends an
# email with ActionMailer to them.
#
# Install dependencies with `gem install mysql actionmailer`
#
@netzpirat
netzpirat / resize.rb
Created March 18, 2010 20:46
A simple ruby rmagick resize script
#!/usr/bin/env ruby
# A simple ruby rmagick resize script.
#
# Example: ./resize.rb /user/joe/mypics 400 533
#
# Searches /user/joe/mypics recursively for all files ending with 'jpg'; the search is case
# insensitive. The found image will be proprtinaly scaled to a max width of 400 pixesl and
# a max height of 533 pixels. The resized image will be written to a new file with the extension 'preview.jpg'
#