Skip to content

Instantly share code, notes, and snippets.

View phillipoertel's full-sized avatar

Phillip Oertel phillipoertel

View GitHub Profile
Scaling RoR MUC
Roles
- "big decisions" group
- Examples:
- do we take on non-refugees
- when do we start the weekly course
- do students have to qualify for the weekly course
- which volunteers do we take on
@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 / 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) {
require 'test/unit'
require 'mocha/setup'
require 'fileutils'
class MyClass
def do_it
file = "/tmp/foo"
FileUtils.touch(file)
FileUtils.chmod(0777, file)
end
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
@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
@phillipoertel
phillipoertel / .irbrc
Created October 12, 2012 06:48
Config for a silent, non-distracting IRB.
IRB.conf[:PROMPT_MODE] = :SIMPLE
IRB.conf[:ECHO] = false
@phillipoertel
phillipoertel / gist:3312805
Created August 10, 2012 09:14
Here's what I needed to teach Sublime Text some TextMate keyboard shortcuts I use frequently -- Shift-Ctrl-T to show all methods in a file, and Cmd-L to go to a line in a file.
[
// goto line
{ "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
// goto method
{ "keys": ["super+shift+t"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} }
]
describe "#visible_for_user?" do
let(:owner) { FactoryGirl.create(:user) }
let(:other_user) { FactoryGirl.create(:user) }
let(:private_content) { FactoryGirl.build(:private_content, :project => owner.default_project) }
let(:public_content) { FactoryGirl.build(:public_content, :project => owner.default_project) }
specify { private_content.should be_visible_for_user(owner) }
specify { private_content.should_not be_visible_for_user(other_user) }
specify { public_content.should be_visible_for_user(owner) }
specify { public_content.should be_visible_for_user(other_user) }
end
@phillipoertel
phillipoertel / gist:2170042
Created March 23, 2012 12:02
passenger 3 "zero-downtime" restarts
# loop do
# start = Time.now
# `curl -s http://staging.torial.com`
# puts "Requested in #{Time.now - start}s"
# end
[...]
Requested in 0.148879s
Requested in 0.137547s
Requested in 0.165125s