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
# my_nat_cookbook/attributes/default.rb | |
# specify your CIDR in custom JSON somewhere: { "my_nat_cookbook": { "source_cidr": "10.1.0.0/16" } } | |
default[:deliv_nat][:source_cidr] = '0.0.0.0/0' | |
default[:deliv_nat][:aws_region] = node[:opsworks][:instance][:region] | |
default[:deliv_nat][:ec2_instance_id] = node[:opsworks][:instance][:aws_instance_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
module Mongoid | |
class Criteria | |
def each_by(by, &block) | |
idx = 0 | |
total = 0 | |
set_limit = options[:limit] | |
while ((results = ordered_clone.limit(by).skip(idx)) && results.any?) | |
results.each do |result| | |
return self if set_limit and set_limit >= total |
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
# config/initializers/char_converter.rb | |
require 'uri' | |
module Support | |
class CharConverter | |
SANITIZE_ENV_KEYS = [ | |
"HTTP_COOKIE", # bad cookie encodings kill rack: https://github.com/rack/rack/issues/225 | |
"HTTP_REFERER", | |
"PATH_INFO", |
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
### | |
### Rails.root/lib/scheduler.rb | |
### | |
require 'celluloid/autostart' | |
module AwesomeRailsApp | |
class ClockworkScheduler | |
include Celluloid | |
include Clockwork | |
def run |
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
_bundler_complete() | |
{ | |
if [[ ! `which bundle` ]]; then | |
return | |
fi | |
local cur prev commands | |
commands="help install update package exec config check list show outdated console open viz init gem platform" | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
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
namespace :workers do | |
namespace :clockwork do | |
desc "Stop clockwork" | |
task :stop do | |
on roles(:app) do | |
within release_path do | |
with rails_env: fetch(:rails_env) do | |
execute :bundle, :exec, :clockworkd, "-c lib/clockwork.rb --pid-dir=#{cw_pid_dir} --log-dir=#{cw_log_dir} stop" | |
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
<?php | |
// how to run: | |
// php download_disputes.php | |
// Works on Mac OS X | |
// It will generate (and overwrite) a csv file with name disputes.csv | |
// Update your valid Live Secret Key, this is only a test key: | |
$skey = 'skey_'; | |
// Output file 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
<?php | |
// how to run: | |
// php download_refunds.php | |
// Works on Mac OS X | |
// It will generate (and overwrite) a csv file with name refunds.csv | |
// Update your valid Live Secret Key, this is only a test key: | |
$skey = 'skey_'; | |
// Output file 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
# patch for make ruby error | |
# % rbenv install 1.8.7-p375 | |
# ... | |
# ossl_pkey_ec.c:815: error: ‘EC_GROUP_new_curve_GF2m’ undeclared (first use in this function) | |
# ossl_pkey_ec.c:815: error: (Each undeclared identifier is reported only once | |
# ossl_pkey_ec.c:815: error: for each function it appears in.) | |
# make[1]: *** [ossl_pkey_ec.o] error 1 | |
# ... | |
# | |
# refs: http://forums.cpanel.net/f5/case-84173-error-installing-ruby-377831.html |
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
#app/controllers/application_controller.rb | |
class ApplicationController < ActionController::Base | |
def opensearch | |
response.headers['Content-Type'] = 'application/opensearchdescription+xml; charset=utf-8' | |
end |
OlderNewer