Skip to content

Instantly share code, notes, and snippets.

@yortz
yortz / items_controller.rb
Created December 1, 2010 17:57
image_uploader.rb
# encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
def store_dir
if "#{version_name}" == ""
"images/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}/#{model.name_file_name}"
else
"images/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}/#{version_name}_#{model.name_file_name}"
@yortz
yortz / carrierwave.rb
Created November 27, 2010 16:49
image_uploader.rb
#config/initializers/carrierwave.rb
CarrierWave.configure do |config|
if Rails.env.production? or Rails.env.development?
config.storage :cloud_files
config.cloud_files_username = "your_username"
config.cloud_files_api_key = "your_key"
config.cloud_files_container = "test"
config.cloud_files_cdn_host = "c0012345.cdnn.cloudfiles.rackspacecloud.com"
def store_dir
#
# node ---------------> ~/.nvm/<node-version>/bin/node
# node-libraries -----> ~/.node_libraries
# node-binaries ------> ~/.node_binaries
#
aptitude install g++ curl libssl-dev apache2-utils make
git clone git://github.com/creationix/nvm.git ~/.nvm
vi ~/.bashrc
NVM_DIR=$HOME/.nvm
. $NVM_DIR/nvm.sh
require 'test_helper'
class Shop < ActiveRecord::Base
end
class ItemDetail < ActiveRecord::Base
set_primary_key :id
data_miner do
import 'A csv file with no identifier', :url => 'http://imports.s3.amazonaws.com/products_no_id.csv', :errata => 'http://spreadsheets.google.com/pub?key=tF58sAgqkY214EFBMdYCIUw', :delimiter => ';' do
body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;background-color:#E6E0D9;}
body a{color:#336699;}
body h2{padding-bottom:12px;font-weight:bold;}
body h3{padding-bottom:10px;}
#container{width:80%;margin:20px auto;overflow:hidden;}
#header{background-color:#900209;padding:30px 10px 20px 10px;border-bottom:2px solid #EC9A94;overflow:hidden;}
#header h1{float:left;color:#ECEBC3;font-size:2.3em;font-weight:bold;}
#header ul.menu{margin-left:80px;margin-top:10px;float:left;overflow:hidden;}
#header ul.menu li{float:left;margin-right:20px;padding-bottom:5px;}
#header ul.menu li a{font-size:1.2em;color:#DFF6FC;text-decoration:none;}
#!/usr/bin/env ruby
# Written by Kieran P
# http://github.com/KieranP
# http://twitter.com/k776
# http://k776.tumblr.com
#
# Feel free to fork and modify.
# If you do, send me a message on
# Github details changes and I'll
@yortz
yortz / spec.rb
Created February 14, 2010 16:59 — forked from jnicklas/spec.rb
require 'rubygems'
require 'spec'
require 'spec/autorun'
require 'capybara'
require 'capybara/dsl'
Capybara.app = proc { |env| [200, {}, "Hello World"]}
Spec::Runner.configure do |config|
config.include Capybara
require 'rack/test'
require 'webrat'
require File.expand_path(File.dirname(__FILE__) + '/../../lib/stats')
Webrat.configure do |config|
config.mode = :rack
end
Stats::App.set :environment, 'cucumber'
Stats::App.enable :raise_errors
#!/usr/bin/env ruby
# Written by Kieran P
# http://github.com/KieranP
# http://twitter.com/k776
# http://k776.tumblr.com
#
# Feel free to fork and modify.
# If you do, send me a message on
# Github details changes and I'll
#!/usr/bin/env ruby
# Written by Kieran P
# http://github.com/KieranP
# http://twitter.com/k776
# http://k776.tumblr.com
#
# Feel free to fork and modify.
# If you do, send me a message on
# Github details changes and I'll