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
source :gemcutter | |
gem 'sinatra', '1.1.0', :git => 'http://github.com/sinatra/sinatra.git' | |
gem 'RedCloth', '4.2.3' |
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
function mkgemset() { | |
mkdir $1 | |
echo 'source :gemcutter' > $1/Gemfile | |
touch $1/Rakefile | |
echo 'rvm_gemset_create_on_use_flag=1\nrvm gemset use' $1 > $1/.rvmrc | |
cd $1 | |
git init | |
mate . | |
} |
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
private static IEnumerable<AuditParameter> GetParametersFromEnumeration(IEnumerable args) | |
{ | |
var parameters = new List<AuditParameter>(); | |
foreach(var arg in args) | |
{ | |
var iaudit = arg as IAuditableParameter; | |
if(iaudit != null) | |
{ | |
parameters.Add(new AuditParameter {Value = iaudit.AuditParameter}); | |
continue; |
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
public class BaseClass | |
{ | |
public string STRING { get { return "Base"; } } | |
} | |
public class ChildClass : BaseClass | |
{ | |
public new string STRING { get { return "Child"; } } | |
} |
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 friendly_name(user) | |
temp_name = if user.first_name.blank? && user.last_name.blank? | |
user.email | |
elsif user.first_name.blank? | |
user.last_name | |
elsif user.last_name.blank? | |
user.first_name | |
else | |
"#{user.first_name} #{user.last_name}" |
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 PostsController < ApplicationController | |
def index | |
cookies[:index] = "INDEX" | |
session[:index] = "INDEX" | |
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
require 'resque/server' | |
class SecureResqueServer < Resque::Server | |
before do | |
redirect '/' unless some_condition_is_met! | |
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
Site.joins(:user).select('sites.user_id, count(*) as count').group('sites.user_id') | |
<Site user_id: 1> #should have a count of 2 | |
# returns only the user_id. If I cheat and name the 'count' column the same name as another column on my model it returned. | |
Site.joins(:user).select('sites.user_id, count(*) as id').group('sites.user_id') #BAD! | |
<Site id: 2, user_id: 1> #id == count in this result |
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 MailQueue | |
extend self | |
def queue | |
:default | |
end | |
def perform(options = {}) | |
options = options.with_indifferent_access |
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
# Restart a rack app running under pow | |
# http://pow.cx/ | |
# | |
# Adds a kapow command that will restart an app | |
# | |
# $ kapow myapp | |
# $ kapow # defaults to current directory | |
# | |
# Supports command completion. | |
# |