Skip to content

Instantly share code, notes, and snippets.

@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
#!/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
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;}
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
#
# 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
@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
@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 / LICENSE.txt
Created May 18, 2011 14:31 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
Copyright (c) 2011 YOUR_NAME_HERE, YOUR_URL_HERE
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@yortz
yortz / post-receive
Created June 26, 2011 00:28 — forked from carlosantoniodasilva/post-receive
Basic git post-receive hook file to deploy a Rails app.
#!/bin/bash
APP_NAME="your-app-name-goes-here"
APP_PATH=/home/deploy/${APP_NAME}
# Production environment
export RAILS_ENV="production"
# This loads RVM into a shell session. Uncomment if you're using RVM system wide.
# [[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm"
@yortz
yortz / gist:1128473
Created August 5, 2011 20:43 — forked from crosebrugh/gist:1128448
Using nested_for_for with rails_admin
class Product < ActiveRecord::Base
has_many :material_product_mappings, :dependent => :destroy, :inverse_of => :product
has_many :materials, :through => :material_product_mappings, :autosave => true
#...
rails_admin do
list do
field :material_product_mappings do