This Presentation was built to be viewed with GistDeck
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 ImageHelpers | |
def image_path(size) | |
case size | |
when "thumbnail" | |
File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "fixtures", "adam_mint.jpg")) | |
# NOTE: I created a sub dir of "support" called "fixtures" in which to place test files. | |
else | |
raise "don't know where to find a #{size} image" | |
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
# Using bundler 1.0.0.beta.2 now. | |
source :gemcutter | |
gem "rack", "1.1.0" | |
gem "rails", "2.3.8" | |
# ... | |
gem "redis", "2.0.3" | |
gem "redis-store", "1.0.0.beta2" | |
# ... |
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
Ever wondered how to login as another user within Devise? | |
Recently we had a feature request that would provide Admins with the ability | |
to sign is as another user. You could imagine live demonstrations or even production | |
support calls where you would like to be signed in as another user, yet not | |
have to ask for or decrypt their current password. After stewing for a bit, we found a | |
pretty nice solution with Devise. | |
Here's the Cucumber feature... |
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
#!/bin/sh | |
DEST_DIR="/some/other/dir" | |
function linker() { # create simlink to downloaded files, rather than copy to final directory | |
if [ ! -d "$DEST_DIR/$1" ]; then mkdir "$DEST_DIR/$1"; fi | |
cd "$1" | |
for F in *; do | |
if [ -d "$F" ]; then linker "$1/$F"; fi | |
ln -s "$TR_TORRENT_DIR/$1/$F" "$DEST_DIR/$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
:+1: | |
:-1: | |
:airplane: | |
:art: | |
:bear: | |
:beer: | |
:bike: | |
:bomb: | |
:book: | |
:bulb: |
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
mkdir heroku | |
cd heroku/ | |
virtualenv --no-site-packages env | |
source env/bin/activate | |
pip install bottle gevent | |
pip freeze > requirements.txt | |
cat >app.py <<EOF | |
import bottle | |
import os |
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
num_processes = 2 | |
batch_size = 1000 | |
threads_per_process = 10 | |
Parallel.map(0...num_processes, :in_processes => num_processes) do |i|· | |
User.connection.reconnect! | |
User.find_in_batches(:batch_size => batch_size,· | |
:start => (User.count/num_processes) * i,· | |
:conditions => ["id <= ?", (User.count/num_processes)*(i+1)]) do |batch|· | |
Parallel.map(batch, :in_threads => threads_per_process) do |record| |
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 Retriable | |
# This will catch any exception and retry twice (three tries total): | |
# with_retries { ... } | |
# | |
# This will catch any exception and retry four times (five tries total): | |
# with_retries(:limit => 5) { ... } | |
# | |
# This will catch a specific exception and retry once (two tries total): | |
# with_retries(Some::Error, :limit => 2) { ... } | |
# |
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.application.config.compass.line_comments = false | |
sass_compiler = Compass::Compiler.new(Rails.root, Compass.configuration.sass_path, Compass.configuration.css_path, sass: Compass.sass_engine_options) | |
engine = sass_compiler.engine(sass_filepath, File.join(Compass.configuration.css_path, "dummy.css")) | |
css_string = engine.render |
OlderNewer