Skip to content

Instantly share code, notes, and snippets.

View maxschulze's full-sized avatar

maxschulze maxschulze

View GitHub Profile
@maxschulze
maxschulze / Gemfile
Created July 17, 2011 20:28
Gemfile with cover_me
gem 'cover_me', '>= 1.0.0.rc6', :group => :test
@maxschulze
maxschulze / Gemfile
Created July 16, 2011 14:46
Cover me configuration for Hudson
gem 'cover_me', '>= 1.0.0.rc6', :group => :test
@maxschulze
maxschulze / html_aware_truncate_helper.rb
Created June 5, 2011 19:55
HTML Aware truncate for Ruby / Rails using nokogiri
# Source:
# http://blog.madebydna.com/all/code/2010/06/04/ruby-helper-to-cleanly-truncate-html.html
require "rubygems"
require "nokogiri"
module TextHelper
def truncate_html(text, max_length, ellipsis = "...")
ellipsis_length = ellipsis.length
@maxschulze
maxschulze / watchr_script.rb
Created May 21, 2011 12:05 — forked from markbates/watchr script
A Watchr script for rails, rspec, and cucumber
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)
growlnotify = `which growlnotify`.chomp
title = "Watchr Test Results"
puts message
image = message.match(/\s0\s(errors|failures)/) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
system %(#{growlnotify} #{options} &)
@maxschulze
maxschulze / LocationAssociation.rb
Created December 9, 2010 15:12
Proposal for Radio Locations / Stations
##
# This way a radio location/station can have many cities, countries and continents, e.g.
# for a global online radio channel.
#
# A Radio Location can have just a city or country etc.
#
class RadioStation
belongs_to :radio_location
end
@maxschulze
maxschulze / photo.rb
Created November 30, 2010 11:21 — forked from lawitschka/photo.rb
Save image size for paperclip photo
class Photo < ActiveRecord::Base
has_attached_file :image, :styles => { :thumb => ['150x150#', :png],
:normal => ['660x660', :png] },
:default_style => :normal
typed_serialize :sizes, Hash
before_save :cache_image_sizes
# Get size of this photo for specified style
#
class Linkedin::Profile < ActiveRecord::Base
set_table_name 'linkedin_profiles'
belongs_to :user, :class_name => "Linkedin::User"
has_many :positions
has_many :educations
belongs_to :industry
belongs_to :location
describe User
it "should fetch Linkedin data on create for the profile"
it "should fetch Linkedin connections after create"
it "should fetch positions after fetch"
it "must have a linked in profile"
it "must have a linked in uid"
it "should be possible to update the data from linked in"
end
@maxschulze
maxschulze / database_cleaner_config.rb
Created November 5, 2010 17:42
Database Cleaner configuration fuer cucumber mit I18n Backend Database
DatabaseCleaner.strategy = :truncation, { :except => %w[ translations ] }