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 / gist:3181690
Created July 26, 2012 12:07 — forked from willmcneilly/gist:3181555
Fabric consecutive 't' paths fix
/**
* @private
* @method _render
*/
_render: function(ctx) {
var current, // current instruction
previous = null,
x = 0, // current x
y = 0, // current y
controlX = 0, // current control point x
@overture8
overture8 / call_template.rb
Created December 1, 2011 20:04 — forked from juggy/call_template.rb
Render a complete page in rails 3 without controller
# create the template
template = PageOfflineTemplate.new
template.quote = quote
template.pages = quote.build_pages
# Here I render a template with layout to a string then a PDF
pdf = PDFKit.new template.render_to_string(:template=>"quotes/review.html.haml")
@overture8
overture8 / offline_template.rb
Created December 1, 2011 20:03 — forked from zorab47/offline_template.rb
Offline Template for Rails 2.3.x
# Public: Template to render views outside the context of a controller.
#
# Useful for rendering Rails 2.3.x views in rake tasks or background jobs when a
# controller is unavailable.
#
# Examples
#
# template = OfflineTemplate.new(:users)
# template.render("users/index", :layout => false, :locals => { :users => users })
#
@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
# 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