Skip to content

Instantly share code, notes, and snippets.

View pglombardo's full-sized avatar
🕶️

Peter Giacomo Lombardo pglombardo

🕶️
View GitHub Profile
@pglombardo
pglombardo / gist:1005825
Created June 3, 2011 03:31
Regnum Online Mac Client Crash with Trackpad Multi-touch (reproduceable)
Process: ROClientGame [4953]
Path: /Users/pglombardo/Applications/Realms Online/live/./ROClientGame.app/Contents/MacOS/ROClientGame
Identifier: ???
Version: ()
Code Type: X86 (Native)
Parent Process: ??? [1]
Date/Time: 2011-06-02 23:27:29.648 -0400
OS Version: Mac OS X 10.6.7 (10J869)
Report Version: 6
@pglombardo
pglombardo / gist:1020074
Created June 11, 2011 00:21
Mac Realms Online Crash with Two Finger Trackpad Drag
Process: ROClientGame [92712]
Path: /Users/pglombardo/Applications/Realms Online/live/./ROClientGame.app/Contents/MacOS/ROClientGame
Identifier: ???
Version: ()
Code Type: X86 (Native)
Parent Process: ??? [1]
Date/Time: 2011-06-10 20:20:17.983 -0400
OS Version: Mac OS X 10.6.7 (10J869)
Report Version: 6
@pglombardo
pglombardo / capistrano_database_yml.rb
Created February 13, 2012 23:09 — forked from weppos/capistrano_database_yml.rb
Provides a couple of tasks for creating the database.yml configuration file dynamically when deploy:setup is run.
#
# = Capistrano database.yml task
#
# Provides a couple of tasks for creating the database.yml
# configuration file dynamically when deploy:setup is run.
#
# Category:: Capistrano
# Package:: Database
# Author:: Simone Carletti <weppos@weppos.net>
# Copyright:: 2007-2010 The Authors
@pglombardo
pglombardo / gist:1894853
Created February 23, 2012 20:16
Block versus String With Incrementing Var Showdown
require 'benchmark'
require 'logger'
logger = Logger.new("/dev/null")
logger.level = Logger::INFO
puts "Simple Strings"
Benchmark.bmbm do |x|
x.report("string form") {
x = 0
@pglombardo
pglombardo / default.vcl.pl
Created July 11, 2012 22:05 — forked from bmarini/default.vcl.pl
A good varnish config for a Rails app
# https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html
# https://www.varnish-cache.org/trac/wiki/VCLExamples
# Summary
# 1. Varnish will poll the backend at /health_check to make sure it is
# healthy. If the backend goes down, varnish will server stale content
# from the cache for up to 1 hour.
# 2. Varnish will pass X-Forwarded-For headers through to the backend
# 3. Varnish will remove cookies from urls that match static content file
# extensions (jpg, gif, ...)
@pglombardo
pglombardo / gist:3105378
Created July 13, 2012 15:07
Varnish check for existing cookie
# Don't serve cached pages for logged in users
if (req.http.Cookie ~ "logged_in_cookie=") {
return(pass);
}
@pglombardo
pglombardo / gist:3105433
Created July 13, 2012 15:16
Overriding Devise Sessions Controller and Setting a Cookie
# config/routes.rb
devise_for :users, :controllers => { :registrations => :sessions => "sessions" }
# app/controllers/sessions_controller.rb
class SessionsController < Devise::SessionsController
# POST /resource/sign_in
def create
cookies[:logged_in_cookie] = "#{SecureRandom.hex(16)}"
super
end
@pglombardo
pglombardo / gist:3105491
Created July 13, 2012 15:30
Rails expires_in unless logged in
# Set cache headers unless this user is logged in
expires_in 1.hour, :public => true, 'max-stale' => 0 unless current_user
@pglombardo
pglombardo / gist:3139254
Created July 18, 2012 22:12
Getting gchartrb to work in your Rails app
gem 'gchartrb'
gem 'google_charts'
@pglombardo
pglombardo / gist:3139281
Created July 18, 2012 22:15
Rails Charts Controller for gchartrb
class ChartsController < ApplicationController
def index
GoogleChart::PieChart.new('320x200', "Pie Chart",false) do |pc|
pc.data "Apples", 40
pc.data "Banana", 20
pc.data "Peach", 30
pc.data "Orange", 60
@chart_url = pc.to_url
end
end