Skip to content

Instantly share code, notes, and snippets.

@rodreegez
rodreegez / images.rb
Created October 20, 2009 11:12
I was having trouble testing images uploads with the Cucumber && Webrat && Selenium setup. This was basically because I was not calling the file path correctly. To prevent this in future, I wrote a helper to extend the Cucumber World object and explicitly
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
# 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"
# ...
@choonkeat
choonkeat / render.rb
Created January 17, 2012 06:39
Rendering SASS programatically in Rails 3 (with compass)
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
@ankane
ankane / README.md
Last active December 14, 2015 03:39 — forked from panthomakos/benchmark.rb

Benchmark Bundler

Because loading gems can take longer than you think

Now available as a gem - get it here

@tommarshall
tommarshall / simple_form.rb
Created August 22, 2013 14:58 — forked from clyfe/simple_form.rb
Bootstrap3 compatible simple_form initializer (with consistent Bootstrap 3 classes)
# http://stackoverflow.com/questions/14972253/simpleform-default-input-class
# https://github.com/plataformatec/simple_form/issues/316
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
@jfsiii
jfsiii / .block
Last active July 20, 2016 01:49
SVG colored patterns via masks/CSS without images
license: unlicense
@bigsur0
bigsur0 / parallel_find_in_batches_start_end
Created September 23, 2011 16:53
Parallel gem and find_in_batches with start, end
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|
@defnull
defnull / gist:1224387
Created September 17, 2011 21:22
Deploy a Bottle app on Heroku
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
@bulljit
bulljit / transmissionUnRAR.sh
Created January 23, 2011 02:31
Transmission-Daemon Script: OnComplete unrar files and delete torrent
#!/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"