✪ rqworker --db 10 default high
16:06:30 RQ worker started, version 0.3.7
16:06:30
16:06:30 *** Listening on default, high...
16:06:49 high: jobs.multiply(5, 2) (2df52ba2-bd32-4849-a8e1-c5241c78b542)
16:06:49 Job OK, result = 10
This file contains hidden or 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
# Amount should be a decimal between 0 and 1. Lower means darker | |
def darken_color(hex_color, amount=0.4) | |
hex_color = hex_color.gsub('#','') | |
rgb = hex_color.scan(/../).map {|color| color.hex} | |
rgb[0] = (rgb[0].to_i * amount).round | |
rgb[1] = (rgb[1].to_i * amount).round | |
rgb[2] = (rgb[2].to_i * amount).round | |
"#%02x%02x%02x" % rgb | |
end | |
This file contains hidden or 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
#!/bin/bash | |
# Restarts Pow when DNS fails to resolve | |
lsof | grep 20560 | awk '{print $2}' | xargs kill -9 | |
launchctl unload ~/Library/LaunchAgents/cx.pow.powd.plist | |
launchctl load ~/Library/LaunchAgents/cx.pow.powd.plist |
This file contains hidden or 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
config.model Merchant do | |
create do | |
field :merchant_level do | |
render do | |
bindings[:view].render :partial => "admin/fields/merchant_level", :locals => {:field => self, :form => bindings[:form]} | |
end | |
end | |
end | |
end |
This file contains hidden or 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 add_product(product) | |
current_item = line_items.find_by_mnetid(product[:mnetid]) | |
if current_item | |
current_item.errors[:base] << "This is already in your cart" | |
#raise "This is already in your cart" | |
return false | |
else | |
current_item = line_items.build( | |
:mnetid => product[:mnetid], | |
:title => product[:title], |
This file contains hidden or 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 location | |
@genre = Genre.find_by_slug(params[:slug]) | |
if @genre.nil? | |
render :template => 'site/not_found', :status => '404' | |
end | |
@title = "#{params[:city] + ',' if params[:city]} #{params[:state]} #{@genre.name}" | |
@results = [] | |
@bands = Band.near( | |
[params[:city], params[:state]].join(" "), | |
3000, |
This file contains hidden or 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
total = 0 | |
(0...1000).each do |i| | |
total += i if (i%3 == 0 || i%5 == 0) | |
end | |
puts total |
This file contains hidden or 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
<?php | |
$docs = get_posts('numberposts=-1&post_type=page&post_parent=36&orderby=title&order=ASC'); | |
$faculty = array(); | |
foreach ($docs as $doc) { | |
array_push($faculty, $doc->ID); | |
} | |
$currentElement = array_search($post->ID, $faculty); | |
$next = isset( $faculty[$currentElement+1] ) ? $faculty[$currentElement+1] : null; | |
$prev = isset($faculty[$currentElement-1]) ? $faculty[$currentElement-1] : null; | |
if ( !is_null($prev) ) { |
This file contains hidden or 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
<?php | |
$show = 10; # The number of posts to display on this page | |
if (isset($_GET['pageID'])) | |
{ | |
$pageID = $_GET['pageID']; | |
} else { | |
$pageID = 1; | |
} |
This file contains hidden or 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
$text = $tweet->title; | |
$text = preg_replace("#(^|[\n ])@([^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://www.twitter.com/\\2\" >@\\2</a>'", $text); | |
$text = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#ise", "'\\1<a href=\"\\2\" >\\2</a>'", $text); | |
$text = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://\\2\" >\\2</a>'", $text); |
NewerOlder