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 index | |
@users = User.latest.with_avatar | |
end | |
def random | |
@users = User.random.with_avatar.limit(21) | |
end | |
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 ActiveRecord | |
class TablelessBase < ActiveRecord::Base | |
def self.columns() @columns ||= []; end | |
def self.column(name, sql_type = nil, default = nil, null = true) | |
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) | |
end | |
end | |
end |
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 recalculate! | |
self.number_of_questions = Match.connection.select_value("SELECT count(*) as c | |
FROM | |
responses as my_responses | |
LEFT JOIN | |
responses as their_responses | |
ON their_responses.user_id = #{user_b.id} | |
AND my_responses.question_id = their_responses.question_id | |
WHERE | |
my_responses.user_id = #{user_a.id} |
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
# awesome git-enabled prompt | |
function parse_git_branch { | |
ref=$(git-symbolic-ref HEAD 2> /dev/null) || return | |
echo "("${ref#refs/heads/}")" | |
} | |
export PS1='\[\033[00;32m\]\u \[\033[00;35m\]\w\[\033[00m\]\[\033[00;33m\]`git branch 2>/dev/null|cut -f2 -d\* -s` \[\033[00m\]\$ ' |
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
require "rubygems" | |
require "ap" | |
unless IRB.version.include?('DietRB') | |
IRB::Irb.class_eval do | |
def output_value | |
ap @context.last_value | |
end | |
end | |
else # MacRuby |
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
require 'acceptance_helper' | |
feature "Welcome Page" do | |
background do | |
50.times { Factory(:user) } | |
end | |
scenario "when user is not logged in" do | |
visit '/' | |
page.should have_content('Welcome! :)') |
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
# User information. Replace with your own data, obviously. | |
# | |
[user] | |
name = Hendrik Mans | |
email = hendrik@mans.de | |
# Automatically track branches with the same name | |
# | |
[branch] | |
autosetupmerge = true |
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 Fleximage::Operator::Polaroid < Fleximage::Operator::Base | |
def operate(angle_range = 10, border_width = 10) | |
@image.border!(border_width, border_width, "#f0f0ff") | |
# Bend the image | |
@image.background_color = "none" | |
amplitude = @image.columns * 0.01 # vary according to taste | |
wavelength = @image.rows * 2 |
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
# So here's the new rbfu invocation style I'm tinkering with. | |
# If you want to play around with it, you can get it from the | |
# 'rbfu-exec' branch in rbfu: | |
# | |
# https://github.com/hmans/rbfu/tree/rbfu-exec | |
# | |
# The overall syntax is: | |
# | |
# rbfu [@<version>] <command> | |
# |
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
$listenerOptions = new Zend\Module\Listener\ListenerOptions($appConfig['module_listener_options']); | |
$defaultListeners = new Zend\Module\Listener\DefaultListenerAggregate($listenerOptions); | |
$defaultListeners->getConfigListener()->addConfigGlobPath('config/autoload/*.config.php'); |