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 / backbone.rails.js
Created April 23, 2011 04:51 — forked from trydionel/backbone.rails.js
Makes Backbone.js play nicely with default Rails setup
//
// Backbone.Rails.js
//
// Makes Backbone.js play nicely with the default Rails setup, i.e.,
// no need to set
// ActiveRecord::Base.include_root_in_json = false
// and build all of your models directly from `params` rather than
// `params[:model]`.
//
// Load this file after backbone.js and before your application JS.
@tors
tors / stack.sh
Created May 1, 2011 07:02
Automated VPS Setup for Ubuntu 10.04 LTS (Lucid) - Rails with Nginx
#!/bin/bash
echo "Automated VPS Setup for Ubuntu 10.04 LTS (Lucid) - Rails with Nginx"
echo "chmod +x stack.sh"
echo "./stack.sh yourdomain.com"
echo "-------------------------------------------------------------------"
echo "Set Hostname"
echo "------------"
@tors
tors / Overlay.Mask.js
Created May 13, 2011 14:31 — forked from jiggliemon/Overlay.Mask.js
a simple Overlay class
if(!window.Overlay){
throw new Error('the Class "Overlay" doesn\'t appear to be present');
}
/*
* Overlay Mask
*/
(function($){
var Mask = {
@tors
tors / .bash_profile
Created May 27, 2011 08:45
new bash profile script
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
export CLICOLOR=1
# Colors ----------------------------------------------------------
export TERM=xterm-color
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
export CLICOLOR=1
@tors
tors / application.html.erb
Created June 29, 2011 16:37 — forked from miles/application.html.erb
RyanB's super simple Rails authentication example
<!-- layout file -->
<% if current_user %>
Welcome <%= current_user.username %>. Not you? <%= link_to "Log out", logout_path %>
<% else %>
<%= link_to "Sign up", signup_path %> or <%= link_to "log in", login_path %>.
<% end %>
@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
@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); })
# Colors ----------------------------------------------------------
export TERM=xterm-color
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
export CLICOLOR=1
alias ls='ls -G' # OS-X SPECIFIC - the -G command in OS-X is for colors, in Linux it's no groups
#alias ls='ls --color=auto' # For linux, etc
@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 / 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';