Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View lukewendling's full-sized avatar

Luke Wendling lukewendling

View GitHub Profile
@lukewendling
lukewendling / gist:7027680
Last active December 25, 2015 19:29
Basic structure of a Rails API with Backbone frontend
###
# Rails Controller to manage an NFL team's fans
# from a email signup form
###
class FansController < ActionController::Base
def create
@fan = Fan.new(fan_params)
respond_to do |format|
def combine_anagrams(words)
h = {}
words.map do |word|
sort_key = word.each_char.sort.join
h[sort_key] ||= []
h[sort_key] << word
end
h.values
end
def ApplicationController
# perhaps in a mixin
def permanent_redirect_to(options)
url = case options
when String
options
else
url_for(options)
end
head :moved_permanently, :location => url
@lukewendling
lukewendling / gist:1621689
Created January 16, 2012 16:37 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p0 and Bundler
# Install with:
# bash < <(curl -L https://raw.github.com/gist/1621689)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
#
# > bundle -v
# > Bundler version 1.0.21
echo "Installing ruby-debug with ruby-1.9.3-p0 and Bundler ..."
@lukewendling
lukewendling / gist:92548
Created April 9, 2009 16:05
add a blueprintcss-based 'to_html' method to Ruby's Array
class Array
# wrap elements in blueprintcss-oriented div tags
# ex. results.to_blueprint_html('span', 2, 10, 4, 8)
def to_blueprint_html(css_class, *args)
raise ArgumentError, "args count doesn't match number of elements" if args.size != self.size
output = []
each_with_index do |item, index|
output << "<div class='#{css_class}-#{args[index]}'>#{item}</div>"
end
output.last.gsub!(/'>/, " last'>") # last element should have 'last' class assigned
<!--//
RubyRobot
Copyright (c) 2008 Fabio Zendhi Nagao <http://zend.lojcomm.com.br/>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
<?xml version="1.0"?>
<settings>
<console change_refresh="10" refresh="100" rows="40" columns="120" buffer_rows="999" buffer_columns="120" shell="" init_dir="c:\applications" save_size="0">
<colors>
<color id="0" r="0" g="0" b="0"/>
<color id="1" r="0" g="0" b="128"/>
<color id="2" r="0" g="150" b="0"/>
<color id="3" r="0" g="150" b="150"/>
<color id="4" r="170" g="25" b="25"/>
<color id="5" r="128" g="0" b="128"/>