Skip to content

Instantly share code, notes, and snippets.

def punch_asshole
shots_away = Shot.where("cup != 0 and round_id = ? and team_id = ?", round.id, game.away.id)
shots_home = Shot.where("cup != 0 and round_id = ? and team_id = ?", round.id, game.home.id)
if shots_away.count == 2
Player.includes(:shots).where("shots.cup == 0 and shots.round_id = ? and shots.team_id = ?", round.id, game.away.id).assholes += 1
end
if shots_home.count == 2
Player.includes(:shots).where("shots.cup == 0 and shots.round_id = ? and shots.team_id = ?", round.id, game.home.id).assholes += 1
end
CREATE OR REPLACE FUNCTION clone_schema_data(source_schema text, dest_schema text) RETURNS void AS
$BODY$
DECLARE
objeto text;
BEGIN
FOR objeto IN
SELECT table_name::text FROM information_schema.TABLES WHERE table_schema = source_schema
LOOP
IF objeto != 'schema_migrations' THEN
EXECUTE 'INSERT INTO ' || dest_schema || '.' || objeto || '(SELECT * FROM ' || source_schema || '.' || objeto || ')';
def current_site_stylesheet_files_tag
if current_site
css_files = current_site.stylesheet_files
if css_files.empty?
nil
else
a = []
css_files.each do |css|
a << css.file.url
Started POST "/admin/images.js?subdomain_name=get" for 127.0.0.1 at Tue Nov 16 00:21:37 +0800 2010
Processing by Admin::ImagesController#create as JS
Parameters: {"authenticity_token"=>"Rf47eL6W+rbeE6qEgnHcn9hZci0CvfNFhHXqRoBKpJE=", "utf8"=>"✓", "to"=>"/admin/pages/home/edit?subdomain_name=get#fragment-3", "imageable_type"=>"Page", "upload_id"=>"upload_id_1289838097073", "imageable_id"=>"24", "subdomain_name"=>"get", "image"=>{"file"=>#<File:/tmp/RackMultipart20101116-26840-1ndwdte-0>}}
$ cap deploy DEPLOY=production
*** Deploying to the PRODUCTION server!
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote [email protected]:tayag/salcedo-auctions.git master"
* executing "if [ -d /var/www/salcedoauctions/shared/cached-copy ]; then cd /var/www/salcedoauctions/shared/cached-copy && git fetch -q origin && git reset -q --hard 0c974279004fe0d02ce1bdc015e7b55d60df2397 && git clean -q -d -x -f; else git clone -q --depth 1 [email protected]:tayag/salcedo-auctions.git /var/www/salcedoauctions/shared/cached-copy && cd /var/www/salcedoauctions/shared/cached-copy && git checkout -q -b deploy 0c974279004fe0d02ce1bdc015e7b55d60df2397; fi"
servers: ["64.120.145.48"]
... # ...
And I should see "You have requested for a condition report, and will be emailed one as soon as we are able to process your request." # features/step_definitions/web_steps.rb:107
And I should receive an email # features/step_definitions/email_steps.rb:51
expected: 1,
got: 0 (using ==) (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/email_steps.rb:52:in `/^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/'
features/request_for_condition_reports.feature:18:in `And I should receive an email'
When I open the email # features/step_definitions/email_steps.rb:72
Then I should see "Ramon ([email protected]) wants a conditio
Then /^the page "([^"]*)" should be the child of "([^"]*)"$/ do |page_name, parent_name|
child = @current_site.pages.find_by_name(page_name)
parent = @current_site.pages.find_by_name(parent_name)
parent.children.should include(child)
end
@ramontayag
ramontayag / gist:731607
Created December 7, 2010 09:15
How to 'send' this data?
Given this string {{images["220"]["x20"]["grayscale"]["something else"]}}
Using regex, how can I extract the following args?
1. 220
2. x20
3. grayscale
4. something else
But allow for unlimited args. For ex, given this regex {{images["220"]["x20"]["grayscale"]["something else"]["yet another thing"]}}
it'll get these args:
module LiquidTemplatingHelper
def liquidize(content, args)
Liquid::Template.parse(content).render(args, :filters => [LiquidFilters])
end
def liquidize_snippets(snippettable)
text = ""
snippettable.scheme.snippets.each do |snippet|
s = div_for(snippet) { liquidize(snippet.content, 'object' => snippettable, 'images' => current_site.images.all) }
text << s
# Used to parse through an scss stylesheet to make editing of that stylesheet simpler
# Ex. Given a file called style.scss
#
# // @name Masthead Background Color
# // @type color
# // @description Background color of the masthead.
# $masthead_bg_color: #444;
#
# sp = StyleParser.new(contents of style.scss)
#