Skip to content

Instantly share code, notes, and snippets.

View phillipoertel's full-sized avatar

Phillip Oertel phillipoertel

View GitHub Profile
@phillipoertel
phillipoertel / gist:4114704
Created November 19, 2012 23:08
Dragonfly FTW
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
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
require 'test/unit'
require 'mocha/setup'
require 'fileutils'
class MyClass
def do_it
file = "/tmp/foo"
FileUtils.touch(file)
FileUtils.chmod(0777, file)
end
@phillipoertel
phillipoertel / torial_group_members.php
Last active December 16, 2015 08:28
Beispiel für das Auslesen der DMW-Gruppenmitglieder in PHP.
<?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) {
@phillipoertel
phillipoertel / reducer.rb
Last active January 2, 2016 19:29
Reduce a hash with arrays as values to a maximum number of array entries.
#
# 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"
@phillipoertel
phillipoertel / gist:8997250
Created February 14, 2014 07:45
Aufgabe 1
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
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
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)
class Account
def initialize(id)
@balance = 0
@id = id
end
def decrease_balance(amount)
@balance -= amount
end
require 'test/unit'
class StringCalculator
def add(string)
string.split(',').map(&:to_i).inject(:+) || 0
end
end
class TestStringCalculator < Test::Unit::TestCase