Skip to content

Instantly share code, notes, and snippets.

@kylebragger
kylebragger / force-ssl.rb
Created November 10, 2011 06:02 — forked from mrrooijen/force-ssl.rb
Secure with SSL (Subdomain and Protocol) in Rails 3.1
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :secure_with_ssl
private
def secure_with_ssl
if request.subdomain != 'secure' or request.protocol != 'https'
redirect_to :subdomain => 'secure', :protocol => 'https'
/*
---
name: guilloche
script: guilloche.js
description: guilloche
provides: [Guilloche]
...
*/
/*
This would have to be modified obviously, but it proves the concept.
*/
$('.code').hide()
.clone()
.appendTo('html')
.css('position', 'absolute')
.css('top', '2.5%')
.css('left', '2.5%')
.css('width', '95%')
module Paperclip
class AutoOrient < Paperclip::Processor
def initialize(file, options = {}, *args)
@file = file
end
def make( *args )
dst = Tempfile.new([@basename, @format].compact.join("."))
dst.binmode
after running:
- sudo gem install rails --no-ri --no-rdoc
- mkdir -p /var/www
- set up nginx and virtual host
require 'net/http'
require 'uri'
# /api/v1/:format/new
# /api/v1/:format/gists/:user
# /api/v1/:format/:gist_id
res = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/xml/new'),
{ 'files[file1.ab]' => 'CONTNETS',
'files[file2.ab]' => 'contents' })
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db

Rails 2.3.5 on App Engine

We assumed Rails 2 would never work without rubygems, and we committed to gem bunlder for JRuby on App Engine, so we were waiting for Rails 3. Fortunately, Takeru Sasaki was able to patch the Rails 2.3.5 calls to rubygems, and now we have it working. Rails 2.3.5 currently spins up several seconds faster than Rails 3, and just a few seconds behind Sinatra.

Install the Development Environment

The gems for the development environment include a pre-release appengine-tools gem that provides a pre-release version of jruby-rack.

sudo gem install google-appengine
sudo gem install appengine-tools --pre
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json