Skip to content

Instantly share code, notes, and snippets.

View mraaroncruz's full-sized avatar

Aaron Cruz mraaroncruz

View GitHub Profile
# Part of this borrowed from a jekyll deploy script from the jekyll author.
# This assumes sprockets and juicer which will combine your js modules and yui compress them respectively
BASE = File.dirname(__FILE__)
SRC = "#{BASE}/src"
SITE = "#{BASE}/site"
JSFILE = "javascript.js"
task :default => [:js,:build]
mraaroncruz / imagefield_widget.php
Created December 3, 2010 18:54
i want my widget!
* Implementation of hook_form();
// THIS CODE DOESN'T WORK!!! well, i mean, it works, but id doesn't do what it is supposed to do...
function community_form(&$node, $form_state) {
$type = node_get_types('type', $node);
// We need to define form elements for the node's title and body.
$form['title'] = array(
mraaroncruz / gist:959148
Created May 6, 2011 15:22
fail running serve
[serve]$ serve mockups
/usr/local/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/sass_extensions/functions/urls.rb:21:in `<module:Urls>': undefined method `declare' for Sass::Script::Functions:Module (NoMethodError)
from /usr/local/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/sass_extensions/functions/urls.rb:1:in `<top (required)>'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:53:in `require'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:53:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/sass_extensions/functions.rb:9:in `block in <top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/sass_extensions/functions.rb:5:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/compass-0.11.1/lib/compass/sass_extensions/functions.rb:5:in `<top (required)>'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:53:in `require'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_
mraaroncruz / gist:1312246
Created October 25, 2011 10:42
ActiveRecord with habtm and owner
class Playlist < ActiveRecord::Base
has_and_belongs_to_many :users
belongs_to :owner, class_name: "User", inverse_of: :owned_playlist
def editable_by?(user)
self.owner == user
class User < ActiveRecord::Base
mraaroncruz / gist:1373838
Created November 17, 2011 17:32
Sample consular project
cd = "cd /Users/aaron/Sites/rails_app &&"
window do
pane do
pane "#{cd} bin/unicorn -p 3000" # I ran bundle install --binstubs
pane "#{cd} tail -f log/development.log"
pane "#{cd} bin/rails console"
tab do
run "#{cd} v."
mraaroncruz / open_in_vim.scpt
Created November 28, 2011 11:05
Open in Iterm in vim from finder window script
* Finder Open iTerm Here - v1.0.2 - 4/14/2011
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
tell application "Finder"
mraaroncruz / gist:1885356
Created February 22, 2012 14:32
class TimespanForWorkRelationship
def initialize(worker, business)
# retrieves all work assignments for relationship
work_assignments = WorkAssignment.for(worker, business)
@months = create_related_months_for(work_assignments)
def create_related_months_for(work_assignments)
# logic to pull months out of workspans
mraaroncruz / gist:1963044
Created March 3, 2012 00:44
fuck you you fucking fuck
cache: [GET /products/black_dress] miss
cache: [GET /products/green_dress] miss
cache: [GET /products/nutha_dress] miss
cache: [GET /products/purple_dress] miss
cache: [GET /products/wedding_dress] miss
cache: [GET /blog/2012/02/lovin-weddings] miss
cache: [GET /judge112233.php] miss
cache: [HEAD /] miss
cache: [GET /] miss
cache: [GET /proxyheader.php] miss
mraaroncruz / index.html.slim
Created May 19, 2012 22:04
Data attribute helper for slim templating
.posts*data(id:, url: post.permalink)
| ...
#=> <div class="post" data-id="123" data-url="/posts/kitten-tossing-banned-in-west-virginia" >...</div>
mraaroncruz / nginx.conf
Created May 23, 2012 19:11
No SSL redirects with Spree
server {
listen 80;
root /var/www/my_app/public;
passenger_enabled on;
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;