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
#!/usr/bin/env bash | |
if [ "x$1" == 'xoff' ] | |
then | |
$0 turn off | |
sleep 1 | |
say yes | |
else | |
say X box $* | |
fi |
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 ActiveRecord | |
module ConnectionAdapters | |
module DatabaseStatements | |
# | |
# Run the normal transaction method; when it's done, check to see if there | |
# is exactly one open transaction. If so, that's the transactional | |
# fixtures transaction; from the model's standpoint, the completed | |
# transaction is the real deal. Send commit callbacks to models. | |
# | |
# If the transaction block raises a Rollback, we need to know, so we don't |
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/^[email protected]:([^.]*)\.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 |
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 RaisableRedirections | |
def self.included(other) | |
other.send(:around_filter, :handle_raisable_redirections) | |
end | |
protected | |
def raise_redirect_to(*args) | |
raise Redirect.new(*args) | |
end |
NewerOlder