Skip to content

Instantly share code, notes, and snippets.

View mariovisic's full-sized avatar

Mario Visic mariovisic

View GitHub Profile
# if you blame this, you lose.
logger.debug("\e[0;31m Life is meaningful.\e[0;00m") if rand(100) == 42 # Fixed mongoid bug.
require 'spec_helper'
describe CheckoutsController do
before :all do
puts 'running'
@counter ||= 0
@counter += 1
end
def reverse_count
(1..10).reverse_each do |i|
puts i
end
end
reverse_count
10
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage :file
version :thumb do
process :resize_to_fill => [200, 150]
end
end
before :each do
get :success
end
gem 'apn_sender', :require => 'apn'
gem 'daemons'
# app/uploaders/avatar_uploader.rb
process :fix_exif_rotation
process :strip
process :resize_to_fill => [1024, 768]
process :quality => 90 # Percentage from 0 - 100
# WTF ?
product_image.url #=> TypeError Exception: can't convert nil into String
nil.to_s #=> ""
@mariovisic
mariovisic / spec_helper.rb
Created May 18, 2011 09:50
Spec Helper working with Rcov and Rspec 2.6.0
require 'rspec'
require 'rspec/rails'
require 'rspec/autorun' # Required for Rcov to run.
@mariovisic
mariovisic / random_ip_address.rb
Created June 5, 2011 14:52
Random IP Addresses
@addresses = []
10000.times do
@addresses.push Faker::Internet::ip_v4_address
end
@addresses == @addresses.uniq # => true