Skip to content

Instantly share code, notes, and snippets.

View kfaustino's full-sized avatar

Kevin Faustino kfaustino

View GitHub Profile
@kfaustino
kfaustino / gist:3090934
Created July 11, 2012 14:55
Toronto Ruby Brigade Notes for July 10th, 2012 by David Andrews
SOA
=====================================
Pitr
works at Uken Games (team of about 20 people) doing MMO mobile games
been there for about a year
Noticed things were not DRY
refactored common elements from existing games:
authentication
payments
@kfaustino
kfaustino / gist:1002201
Created June 1, 2011 12:27
Disqus in Haml
:plain
<div id="disqus_thread"></div>
<script type="text/javascript">
/**
* var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread]
*/
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '<SOURCE.JS>';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
@kfaustino
kfaustino / Nu Ideas - each_with_object
Created January 21, 2011 01:51
Example: Creating a hash of HTML status codes from an Array
status_codes = [['OK',200], ['Created', 201],
['Accepted', 202], ['Moved Permanently', 301],
['Found', 302], ['Not Modified', 304]]
# Create Hash via inject
status_codes.inject({}) do |result, (description, value)|
key = description.downcase.gsub(' ','_')
result[key] = value
result # Explicit return of the hash
end
Current edit.html.erb:
<h2>Editing a ticket in <%= @project.name %></h2>
<%= form_for [@project, @ticket] do |f| %>
<%= render "form" %>
<% end %>
Proposed change:
<h2>Editing a ticket in <%= @project.name %></h2>
<%= render "form" %>
# How to give your devise controllers all the same layout (e.g. "authentication" below)
class ApplicationController < ActionController::Base
layout :setup_layout
protected
def setup_layout
devise_controller? ? "authentication" : "application"
end
end
@kfaustino
kfaustino / nginx_rails_public_cache_rewrite
Created March 2, 2010 03:16
nginx rewrite rules for rails page cache in public/cache
# Place the following in the server block
if (-f $request_filename) {
break;
}
if (-f $document_root/cache/$uri/index.html) {
rewrite (.*) /cache/$1/index.html break;
}
desc "Generate and deploy assets"
task :deploy_assets, :roles => :app do
# get the previous timestamp
old_timestamp = File.read("config/deploy_timestamp").to_i rescue 0
# generate timestamp into config/deploy_timestamp
timestamp = Time.now.to_i
File.open("config/deploy_timestamp", 'w') do |f|
f.write(timestamp)
end
require "integrity"
Integrity.new(File.dirname(__FILE__) + "/config.yml")
project = Integrity::Project.first(:name => "Project Foo")
unless `git ls-remote #{project.uri}`.include?(project.commits.last)
project.build
end
# sexy_template.rb
# by Kevin Faustino
# Delete all unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/robots.txt"
run "rm -f public/images/*"
run "rm -f public/javascripts/*"