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
Rails::Initializer.run do |config| | |
# Read from config/memcached.yml to setup Memcache instance | |
# Individual caching mechanisms are enabled in environment specific configs | |
require 'memcache' | |
mservers = if (File.exist?(mconfig = Rails.root+'config'+'memcached.yml')) | |
YAML.load_file(mconfig)[RAILS_ENV].delete('servers') | |
end | |
MemCacheConnection = MemCache.new(mservers || 'localhost:11211', :namespace => "_myapp") | |
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'thor' | |
require 'twitter' | |
class TNT < Thor | |
map "MESSAGE" => :post | |
desc "post \"message\"", "Post a message to Twitter" |
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
Bluepill.define_process_condition(:running_time) do | |
def initialize(options = {}) | |
@below = options[:below] | |
end | |
def run(pid) | |
started = `ps -p #{pid} -o command`.match(/since (\d+)/)[1].to_i | |
Time.now - Time.at(started) | |
rescue | |
0 |
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
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', 'UA-XXXXX-X']); | |
_gaq.push(['_trackPageview']); | |
(function() { | |
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; | |
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga); | |
})(); |
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
namespace :deploy do | |
namespace :crontab do | |
def update_cmd_for(role) | |
load_file = "config/whenever/#{fetch(:environment)}.#{role}.rb" | |
[ "cd #{fetch(:current_path)} &&", | |
"if [ -f #{load_file} ] ; then", | |
"bin/whenever", | |
"--update-crontab #{fetch(:application)}.#{fetch(:environment)}.#{role}", | |
"--load-file #{load_file}", |
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
mysql> EXPLAIN SELECT count(DISTINCT `competition_entries`.id) AS count_all FROM `competition_entries` LEFT OUTER JOIN `videos` ON `videos`.attachable_id = `competition_entries`.id AND `videos`.attachable_type = 'CompetitionEntry' LEFT OUTER JOIN `moderations` ON `moderations`.moderated_id = `competition_entries`.id AND `moderations`.moderated_type = 'CompetitionEntry' LEFT OUTER JOIN `users` ON `users`.id = `competition_entries`.user_id INNER JOIN `images` ON `images`.attachable_id = `competition_entries`.id AND `images`.attachable_type = 'CompetitionEntry' WHERE (moderations.state = 0) ; | |
+----+-------------+---------------------+--------+-----------------------------------------------------------------------+-----------------------------------+---------+--------------------------------------------------+------+-------------+ | |
| id | select_type | table | type | possible_keys | key | key_len | ref |
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
I'm trying to run the chef::bootstrap_server recipe from the | |
HEAD of '09beta' branch of opscode/cookbooks and seeing | |
weirdness with attribute lookup. | |
chef v0.9.0.b02 via `chef-solo -j dna.json -c solo.rb` | |
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
# chef-client - Chef Configuration Management Client | |
# | |
# Chef Client provides the Chef configuration management daemon | |
description "Chef Client" | |
start on filesystem | |
stop on runlevel S | |
respawn |
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
# see http://github.com/opscode/cookbooks/blob/master/chef/attributes/default.rb |
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
#!/usr/bin/python | |
""" | |
Splits an input pdf file into many files, one per page | |
""" | |
import sys | |
import os | |
from CoreGraphics import * |