This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run as `ruby swedish_chef.rb` | |
# Source: unknown, e.g. copied somewhere from the interwebs | |
class SwedishChef | |
def self.call(string) | |
@string = string | |
@string.gsub!(/an/, "un") | |
@string.gsub!(/An/, "Un") | |
@string.gsub!(/au/, "oo") | |
@string.gsub!(/Au/, "Oo") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from https://thoughtbot.com/blog/how-to-stub-external-services-in-tests | |
require 'sinatra/base' | |
class FakeMuxApi < Sinatra::Base | |
configure :production, :development do | |
enable :logging | |
end | |
post '/video/v1/assets' do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import EmberRouter from '@ember/routing/router'; | |
import { computed } from '@ember/object'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle!', | |
myRoutes: computed('isInitialized', function(){ | |
let owner = Ember.getOwner(this); | |
let router = owner.lookup('router:main'); | |
let routes = router._routerMicrolib.recognizer.names; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def capture(*streams) | |
require 'stringio' | |
streams.map! { |stream| stream.to_s } | |
begin | |
result = StringIO.new | |
streams.each { |stream| eval "$#{stream} = result" } | |
yield | |
ensure | |
streams.each { |stream| eval("$#{stream} = #{stream.upcase}") } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In 1.9 the Time#to_s method doesn't return in the format as outlined in the pickaxe book (PDF page 747): | |
it "ouput of #to_s is different in 1.8 and 1.9" do | |
time = Time.at(1289349987) | |
time.strftime("%a %b %d %H:%M:%S %z %Y").should eql('Wed Nov 10 01:46:27 +0100 2010') # passes | |
time.to_s.should eql('Wed Nov 10 01:46:27 +0100 2010') # fails | |
end | |
# Failure/Error: time.to_s.should eql('Wed Nov 10 01:46:27 +0100 2010') | |
# expected "Wed Nov 10 01:46:27 +0100 2010" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MyAccessors | |
@@my_accessors = [] | |
def my_accessor var | |
attr_accessor var | |
@@my_accessors << var | |
end | |
def my_attributes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppServer | |
attr_accessor :admin_password, :port | |
end | |
class Configuration | |
attr_accessor :tail_logs, :max_connections, :admin_password | |
def app_server | |
@app_server ||= AppServer.new | |
yield @app_server if block_given? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File Pattern: | |
!(/\.(?!htaccess)[^/]*|(swf|mp3|jpeg|gif|png|psd|log|pdf|sql|bz2)|\.(tmproj|o|pyc)|/Icon\r|/svn-commit(\.[2-9])?\.tmp)$ | |
Folder Pattern: | |
!.*/(\.[^/]*|public/system|server/gems|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= image_submit_tag "button_volgende_stap.gif", :title=> t('form.submit'), :onclick => "needToConfirm = false;" %> | |
<% content_for :page_js do %> | |
<script> | |
var needToConfirm = false; | |
window.onbeforeunload = confirmExit; | |
function confirmExit() { | |
if (needToConfirm) { | |
return "U heeft onbewaarde wijzigingen. Doorgaan?"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# Tracklisting: (c) 2010 KinkFM.com and their listeners | |
# Code: (c) 2010 Leon Berenschot, Wendbaar.nl | |
# | |
# Find the tracks of the Kink1500 in your iTunes library | |
# Usage: | |
# - First create a playlist called "Kink 1500-2010" | |
# - From the commandline execute 'ruby ./find_1500.rb' | |
# |
NewerOlder