Skip to content

Instantly share code, notes, and snippets.

View overture8's full-sized avatar

Phil McClure overture8

  • Stora
  • Belfast, Northern Ireland
View GitHub Profile
@overture8
overture8 / rumble_template.rb
Created June 1, 2011 19:45
Rumble Labs Rails Template
# create rvmrc file
create_file ".rvmrc", "rvm 1.9.2"
gem "simple_form"
gem "devise"
gem "rake", "0.9.1"
run 'bundle install'
rake "db:create", :env => 'development'
@overture8
overture8 / remote_mysql.rb
Created May 4, 2011 12:42
Database plugin for the backup gem. Allows remote backups of MySQL databases.
require 'net/ssh'
module Backup
module Database
class SshBackup < Base
attr_accessor :name
attr_accessor :host
attr_accessor :username
attr_accessor :password
attr_accessor :host_username
@overture8
overture8 / nice_redirects.rb
Created February 25, 2011 10:42
Handy rails redirects
# Define in app controller
class ApplicationController < ActionController::Base
before_filter :require_login
# redirect somewhere that will eventually return back to here
def redirect_away(*params)
session[:original_uri] = request.request_uri
redirect_to(*params)
end
<VirtualHost *:80>
ServerName blah.localhost
ServerAlias *.blah.localhost
DocumentRoot /var/www/blah/current/public
</VirtualHost>
# Generated by NetworkManager
nameserver 127.0.0.1 # <--- ADD THIS
nameserver 8.8.4.4
nameserver 8.8.8.8
> sudo apt-get install dnsmasq
# Add domains which you want to force to an IP address here.
# The example below send any host in doubleclick.net to a local
# webserver.
address=/blah.localhost/127.0.0.1
# Or which to listen on by address (remember to include 127.0.0.1 if
# you use this.)
listen-address=127.0.0.1
> ApplicationController.allow_forgery_protection = false
> app.host! 'mysubdomain.mydomain.local:3000'
> app.post '/sessions', :username => 'phil', :password => 'somethingsecure'
$ rails c
> app.get '/uri'
> app.post '/uri', :postdata1 => "something", :postdata2 => "nothing"
> app.put '/uri', :postdata1 => "something", :postdata2 => "nothing"
> app.delete '/uri'
> app.get '/people'
> app.response.body
# You can also inspect the request with:
> app.request