Skip to content

Instantly share code, notes, and snippets.

View tors's full-sized avatar
:octocat:

Tors tors

:octocat:
  • Vim
View GitHub Profile
@tors
tors / README.md
Created June 11, 2012 08:04 — forked from keikubo/README.md
Nginx + Unicorn for Rails on Rackhub

Nginx + Unicorn for Rails on Rackhub

Description:

This script enables you to launch your Rails application in production environment (port:80) with Nginx and Unicorn.

Installation:

Please make sure that your Gemfile in your rails application includes unicorn.

@tors
tors / configuration.rb
Created June 5, 2012 10:36 — forked from youngbrioche/configuration.rb
Small configuration DSL
module Foo
module Configuration
require 'ostruct'
extend ActiveSupport::Concern
included do
#
end
module ClassMethods
@tors
tors / capybara.md
Created June 5, 2012 05:54 — forked from steveclarke/capybara.md
RSpec Matchers

Capybara

Matchers

have_button(locator)

have_checked_field(locator)
@tors
tors / auth_in_a_box.rb
Created May 31, 2012 09:17 — forked from canton7/Sample DataMapper model.rb
Sinatra Auth in a Box
# Adapted from https://gist.github.com/1444494
# Things you need to do before using this lib:
# require 'sinatra/flash' (gem sinatra-flash)
# register Sinatra::Flash
# register Sinatra::AuthInABox
# enable :sessions optionally configuring your favourite sessions settings
# Have a User model, which has the methods self.authenticate(user, pass) and is_admin?
# In your forms (login, signup, etc) make sure you display flash[:errors]
@tors
tors / .gitignore
Created April 4, 2012 06:06 — forked from nulltask/.gitignore
cluster-io
.DS_Store
._*
node_modules/
@tors
tors / application_controller.rb
Created March 27, 2012 07:42
Rails 3.1 - Adding custom 404 and 500 error pages
class ApplicationController < ActionController::Base
# ...
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, with: :render_500
rescue_from ActionController::RoutingError, with: :render_404
rescue_from ActionController::UnknownController, with: :render_404
rescue_from ActionController::UnknownAction, with: :render_404
rescue_from ActiveRecord::RecordNotFound, with: :render_404
end
@tors
tors / pocketfm.js
Created March 5, 2012 03:11 — forked from chjj/pocketfm.js
pocket-sized file manager/sharing so i dont have to start up samba
/**
* pocketfm
* Pocket-sized File Manager
* Uses plain html to be as simple as possible
* Code is messy, needs revision and needs
* native mv, rm, cp implementations
* Copyright (c) 2011, Christopher Jeffrey (MIT License)
*/
process.title = 'pocketfm';
@tors
tors / add_attachment_data_to_wrapper.rb
Created February 26, 2012 06:06 — forked from Traz/add_attachment_data_to_wrapper.rb
Small tips for building a polymorphic usage of Paperclip, with video to flv, video thumbnail, mp3 tag extraction, zip file listing processors.
class AddAttachmentsDataToWrapper < ActiveRecord::Migration
def self.up
add_column :wrappers, :data_file_name, :string
add_column :wrappers, :data_content_type, :string
add_column :wrappers, :data_file_size, :integer
add_column :wrappers, :data_updated_at, :datetime
end
def self.down
remove_column :wrappers, :data_file_name
@tors
tors / gist:1133533
Created August 9, 2011 06:59 — forked from theflowglenn/gist:1040942
Snippet from Rails 3 Client Side Validations JS to allow for AJAX spinner
// Set up the events for the form
form
.submit(function() { return form.isValid(settings.validators); })
// added loading toggle to handle the feedback spinner image (and changed 'beforeSend' to just 'before')
.bind('ajax:before', function() { $("#loading").toggle(); return form.isValid(settings.validators); })
.bind('ajax:success', function() { $("#loading").toggle(); })
// Callbacks
.bind('form:validate:after', function(eventData) { clientSideValidations.callbacks.form.after( form, eventData); })
.bind('form:validate:before', function(eventData) { clientSideValidations.callbacks.form.before(form, eventData); })
@tors
tors / carrierwave.rb
Created August 4, 2011 13:59 — forked from yortz/carrierwave.rb
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