Skip to content

Instantly share code, notes, and snippets.

View felipeelias's full-sized avatar
💭
I may be slow to respond.

Felipe Elias felipeelias

💭
I may be slow to respond.
View GitHub Profile
@ideaoforder
ideaoforder / doorkeeper-cancan-hack.rb
Created May 3, 2012 17:19
Doorkeeper/CanCan scope hack--restrict Oauth applications to user who created them
admin_authenticator do |routes|
# Put your admin authentication logic here.
# If you want to use named routes from your app you need
# to call them on routes object eg.
# routes.new_admin_session_path
# Admin.find_by_id(session[:admin_id]) || redirect_to(routes.new_admin_session_path)
if current_user
if session[:customer_id]
current_customer = Customer.find_by_id(session[:customer_id])
redirect_to(routes.customers_path) if !current_customer
@Diggz
Diggz / lyrics.txt
Created April 22, 2012 18:43 — forked from pjg/lyrics.txt
Piano Man by Johnny Diggz @ Railsberry
It's 8:00 o'clock on a Friday
The regular crowd shuffles in
there's an old man sitting next to me
making love to his beer
la la di di da
la la di di da
Sing us a song, you're the piano man!
sing us a song tonight
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@coreyhaines
coreyhaines / .rspec
Last active August 15, 2024 15:13
Active Record Spec Helper - Loading just active record
--colour
-I app
@netmute
netmute / README.md
Last active May 10, 2025 11:03
Game of Life in 140 chars of Ruby

Game of Life

An implementation of Conway's Game of Life in 140 characters of Ruby.

Author

Created by Simon Ernst (@sier).

@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

require "money"
class Decorator < BasicObject
undef_method :==
def initialize(component)
@component = component
end
def method_missing(name, *args, &block)
@rahul100885
rahul100885 / nginx.conf
Created October 14, 2011 08:33
Sample nginx file for web application with gzip and cache
user www-user;
worker_processes 1;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
pid logs/nginx.pid;
@fennb
fennb / gist:1283573
Created October 13, 2011 06:35
nginx microcaching config example
# Set cache dir
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=microcache:5m max_size=1000m;
# Virtualhost/server configuration
server {
listen 80;
server_name yourhost.domain.com;
# Define cached location (may not be whole site)
class Monopoly
constructor: (serverSide, popupsManager) ->
player = new Player(PlayerAttributes)
playerView = new PlayerView
playerController = new PlayerController(player, playerView)
(..)
class PlayerView
update: (player) ->
$("#player_score").text(player.points)