This file contains hidden or 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
require 'test/unit' | |
class StringCalculator | |
def add(string) | |
string.split(',').map(&:to_i).inject(:+) || 0 | |
end | |
end | |
class TestStringCalculator < Test::Unit::TestCase |
This file contains hidden or 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 Account | |
def initialize(id) | |
@balance = 0 | |
@id = id | |
end | |
def decrease_balance(amount) | |
@balance -= amount | |
end |
This file contains hidden or 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
require 'embedly' | |
key = ENV['KEY'] | |
timeout = 60 | |
client = Embedly::API.new(key: key, timeout: timeout) | |
url = 'http://de.qantara.de/inhalt/zivilgesellschaftliche-initiativen-im-libanon-ich-bin-kein-maertyrer' | |
p client.extract(url: url) |
This file contains hidden or 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
require_relative '../features_helper' | |
require_relative 'registration_spec_helper' | |
feature "Registering as new user", :js do | |
include RegistrationSpecHelper | |
background do | |
visit root_path | |
click_on("Registrieren") | |
end |
This file contains hidden or 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
contents = { | |
user1: [1, 2, 4, 5, 6], | |
user2: [7, 8, 9], | |
user3: [10, 11, 12, 13] | |
} | |
# regeln: | |
- höchstens 6 elemente zurückgeben | |
- von möglichst vielen usern | |
- gleichmaessig |
This file contains hidden or 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 like this: | |
# | |
# > git clone https://gist.github.com/8350277.git reducer | |
# > cd reducer | |
# > gem install rspec -v 2.14.1 | |
# > rspec reducer.rb | |
# | |
require "rspec" |
This file contains hidden or 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
<?php | |
$url = "https://www.torial.com/groups/dmw/members.json"; | |
$response = file_get_contents($url); | |
$members = json_decode($response); | |
# wir liefern noch mehr daten als in der folge ausgegeben werden, für die vollständige liste folgendes ausgeben: | |
# var_dump($members); | |
foreach ($members as $member) { |
This file contains hidden or 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
require 'test/unit' | |
require 'mocha/setup' | |
require 'fileutils' | |
class MyClass | |
def do_it | |
file = "/tmp/foo" | |
FileUtils.touch(file) | |
FileUtils.chmod(0777, file) | |
end |
This file contains hidden or 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
I've tried spring with Ruby 1.9.3/p327 (installed via rvm), running Rails 2.3.6. | |
* The server starts up twice (I had killed all instances before): | |
Maybe these are for test and dev env. But I've already seen three server.rb instances so I doubt that. | |
> ps aux|grep spring | |
phillip 17877 13,5 3,1 3164768 131244 s000 S 4:57pm 0:18.12 /Users/phillip/.rvm/rubies/ruby-1.9.3-p327-turbo/bin/ruby -r bundler/setup /Users/phillip/.rvm/gems/ruby-1.9.3-p327-turbo@torial/gems/spring-0.0.2/lib/spring/server.rb | |
phillip 18036 0,0 0,0 2434892 540 s007 R+ 4:59pm 0:00.00 grep --color=auto spring |
This file contains hidden or 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
require 'transcoder/base' | |
require 'transcoder/video' | |
class Content < ActiveRecord::Base | |
image_accessor :cover_image do | |
after_assign :make_preview_video | |
end | |
image_accessor :preview_video | |