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 "net/http" | |
require "enumerator" | |
# Example Usage: | |
# | |
# use Rack::Proxy do |req| | |
# if req.path =~ %r{^/remote/service.php$} | |
# URI.parse("http://remote-service-provider.com/service-end-point.php?#{req.query}") | |
# 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 "net/http" | |
# Example Usage: | |
# | |
# use Rack::Proxy do |req| | |
# if req.path =~ %r{^/remote/service.php$} | |
# URI.parse("http://remote-service-provider.com/service-end-point.php?#{req.query}") | |
# 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
class Rack::ProcTitle | |
F = ::File | |
PROGNAME = F.basename($0) | |
def initialize(app) | |
@app = app | |
@appname = Dir.pwd.split('/').reverse. | |
find { |name| name !~ /^(\d+|current|releases)$/ } || PROGNAME | |
@requests = 0 | |
$0 = "#{PROGNAME} [#{@appname}] init ..." |
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 _hero_getRemoteNames(){ | |
git config --get-regexp remote.*.url heroku.com | | |
sed -E 's/^remote\.([^\.]*)\.url .*$/\1/' | |
} | |
function _hero_herokuAppFor(){ | |
git config --get remote.$1.url | | |
sed -E 's/^git@heroku.com:([^.]*)\.git/\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
# Introduction: | |
We need to select large numbers of items (300k or more), based on active record associations (and selectors, and all that faff), but we only care about the ids. | |
This is easily solved by bla_bla_bla_scope.map(&:id). This however takes about 16s of CPU grinding ruby to get to the final answer via AR objects. AR objects that contain only an ID. | |
Why not just use the SQL generated by the scopes and other voodoo to just pump the SQL through? That's what this does, in the most complex way imaginable! | |
# Usage: |
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
rm -R $HOME/Desktop/server-{1,2} | |
mkdir -p $HOME/Desktop/server-{1,2} | |
mysql_install_db --datadir=$HOME/Desktop/server-1 && mysqld --server-id 1 -h ~/Desktop/server-1 --socket ~/Desktop/server-1/mysql.sock -P 10001 --log-bin & | |
mysql_install_db --datadir=$HOME/Desktop/server-2 && mysqld --server-id 2 -h ~/Desktop/server-2 --socket ~/Desktop/server-2/mysql.sock -P 10002 --master-port=10001 --master-host=127.0.0.1 --master-user=root & | |
alias sql-master="mysql -h127.0.0.1 -P10001 -uroot" | |
alias sql-slave="mysql -h127.0.0.1 -P10002 -uroot" | |
alias sql-master-admin="mysqladmin -h127.0.0.1 -P10001 -uroot" |
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
javascript: | |
if( !window.goviasGrid ){ | |
window.goviasGrid = document.createElement("div"); | |
document.getElementsByTagName("body")[0].appendChild(window.goviasGrid); | |
window.goviasGrid.style.background = "url(http://tomlea.co.uk/assets/the-grid.png) repeat-y 50% 0"; | |
window.goviasGrid.style.width = "100%"; | |
window.goviasGrid.style.height = "100%"; | |
window.goviasGrid.style.position = "fixed"; | |
window.goviasGrid.style.top = "0"; | |
window.goviasGrid.style.bottom = "0"; |
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
AU-Colleen | |
AU-Jon | |
BE-Hendrik | |
BE-Minna | |
BE-Sofie | |
BR-Lygia | |
CA-Antonine | |
CA-Felix | |
CN-Pan | |
CZ-Zdenech |
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
# A secure S3 storage engine for Paperclip. | |
# Usage: | |
# | |
# require "paperclip/storage/s3secure" | |
# has_attached_file :image, :storage => :S3secure, … | |
module Paperclip::Storage::S3secure | |
def self.extended base | |
base.extend(Paperclip::Storage::S3) | |
base.options[:s3_permissions] = :private |
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 sort_order | |
# Google was indexing "random" search orders, it parsed our javascript, badly. | |
SORT_METHODS[params[:sort_order]] or raise_redirect_to(@product, :status => 301) | |
end | |
def segment | |
segment = params[:segment] | |
segment = segment.to_sym if %w[all other].include?(segment) | |
segment = nil if segment == :all | |
# Bad or expired segments need 301ing |
NewerOlder