This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Rack | |
# | |
# RefererControl is a Rack middleware app which restricts access to paths | |
# based on the Referer header. Using RefererControl you can make sure | |
# users follow the intended flow of a website. If a controlled path is | |
# visited with an unacceptable Referer URI, then a simple 307 Redirect | |
# response is returned. | |
# | |
# RefererControl should also make Cross Site Request Forgery (CSRF) a | |
# little more difficult to exploit; but not impossible using JavaScript. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get "/about" => 'info#about', :as => 'about' | |
get "/privacy" => 'info#privacy', :as => 'privacy' | |
get "/license" => 'info#license', :as => 'license' | |
get "/mission" => 'info#mission', :as => 'mission' | |
get "/contact" => 'info#contact', :as => 'contact' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Paperclip | |
module ClassMethods | |
def has_attached_file name, options = {} | |
include InstanceMethods | |
write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil? | |
attachment_definitions[name] = {:validations => []}.merge(options) | |
after_save :save_attached_files | |
before_destroy :destroy_attached_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Account | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
field :subdomain, :type => String | |
embeds_many :users | |
accepts_nested_attributes_for :users | |
validates_presence_of :name, :subdomain | |
validates_uniqueness_of :subdomain, :case_sensitive => false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rake task to launch multiple Resque workers in development/production with simple management included | |
require 'resque/tasks' # Require Resque tasks | |
namespace :workers do | |
# = $ rake workers:start | |
# | |
# Launch multiple Resque workers with the Rails environment loaded, | |
# so they have access to your models, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Migrating my old .gitconfig blog post from 2007 to here so I can update it easier. | |
# Original URL: | |
# https://www.susanpotter.net/snippets/my-.gitconfig-.tigrc-files/ | |
[user] | |
name = Susan Potter # make sure you change this | |
email = [email protected] # make sure you change this | |
[color] | |
diff = auto | |
status = auto | |
branch = auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Devise | |
module Orm | |
module MongoMapper | |
module Hook | |
def devise_modules_hook! | |
extend Schema | |
include Compatibility | |
yield | |
return unless Devise.apply_schema | |
devise_modules.each { |m| send(m) if respond_to?(m, true) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait RestHelper extends LiftRules.DispatchPF { | |
... | |
/** | |
* A function that chooses JSON or XML based on the request.. | |
* Use with serveType | |
*/ | |
implicit def jxSel(req: Req): Box[JsonXmlSelect] = | |
if (jsonResponse_?(req)) Full(JsonSelect) | |
else if (xmlResponse_?(req)) Full(XmlSelect) | |
else None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Fabrizio Calderan, twitter @fcalderan, 2010.11.02 | |
* I had an idea: could Inception movie be explained by a few javascript closures | |
* and variable resolution scope (just for fun)? | |
* | |
* Activate javascript console =) | |
*/ | |
<script> | |
console.group("inception movie"); |
OlderNewer