gem install rails --pre
rails new my_app -T
| 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. |
| # JRuby version of ImageScience (other image toolkits are available) | |
| require 'image_voodoo' | |
| class ImageSizer | |
| def initialize(app, mime_types=%w[image/jpeg image/png image/gif]) | |
| @app = app | |
| @mime_types = mime_types | |
| end | |
| def call(env) |
| # See also http://github.com/simonjefford/rack_firebug_logger | |
| # for this middleware + tests + a rails plugin | |
| class FirebugLogger | |
| def initialize(app, options = {}) | |
| @app = app | |
| @options = options | |
| end | |
| def call(env) | |
| dup._call(env) |
| module Mongoid | |
| # Caches the entire document in a Marshall and Redis. | |
| # Defines Document#get(id), adds methods to recache document after a save. | |
| # Add `include Mongoid::CachedDocument` in your model to enable the feature. | |
| module CachedDocument | |
| def self.included(base) | |
| base.class_eval do | |
| include InstanceMethods | |
| extend ClassMethods | |
| before_save :refresh_cache |
| #!/bin/bash | |
| # User data to configure a vanilla Ubuntu EC2 instance. | |
| # Installs chef-client (with minimal dependencies), | |
| # configures chef, and adds roles | |
| test $UID == 0 || (echo "Error: must run as root"; exit 1) | |
| ######### STEP 1: OPERATING SYSTEM CONFIGURATION | |
| BOOTLOG="/var/log/bootstrap.log" |
# This example does an AJAX lookup and is in CoffeeScript
$('.typeahead').typeahead(
# source can be a function
source: (typeahead, query) ->
# this function receives the typeahead object and the query string| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>OnDemand</key> | |
| <false/> | |
| <key>KeepAlive</key> | |
| <true/> | |
| // Photoshop Script to Create iPhone Icons from iTunesArtwork | |
| // | |
| // WARNING!!! In the rare case that there are name collisions, this script will | |
| // overwrite (delete perminently) files in the same folder in which the selected | |
| // iTunesArtwork file is located. Therefore, to be safe, before running the | |
| // script, it's best to make sure the selected iTuensArtwork file is the only | |
| // file in its containing folder. | |
| // | |
| // Copyright (c) 2010 Matt Di Pasquale | |
| // Added tweaks Copyright (c) 2012 by Josh Jones http://www.appsbynight.com |
One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.
Most workflows make the following compromises:
Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.
Use production SSL certificates locally. This is annoying