Skip to content

Instantly share code, notes, and snippets.

View cstrahan's full-sized avatar

Charles Strahan cstrahan

  • Backtrace
  • Dallas, TX
View GitHub Profile
@danlucraft
danlucraft / enter_the_matrix.rb
Created April 21, 2011 22:33
Bot for playing rdrc2 Enter the Matrix game
require 'pp'
require 'rubygems'
require 'mechanize'
class MatrixInterface
CREDS = File.read("creds.txt").split(",")
def initialize
login_page = agent.get("http://reddirtrubyconf.com/login")
@otac0n
otac0n / SplayTree`2.cs
Last active December 5, 2019 09:55
A splay tree in C# for .NET, fully implementing IDictionary<TKey, TValue>.
/* ---- MIT LICENSE ----
Copyright (c) 2011 John Gietzen
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
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@toamitkumar
toamitkumar / gist:952211
Created May 2, 2011 19:35
Inspect and test routes on console (Rails 3)
$ rails console
Loading development environment (Rails 3.0.6)
ruby-1.8.7-p334 :001 > r = Rails.application.routes
Gives you a handle of all the routes (config/routes.rb)
#Inspect a named route:
ruby-1.8.7-p334 :005 > r.recognize_path(app.destroy_user_session_path)
=> {:action=>"destroy", :controller=>"sessions"}
{-#LANGUAGE GADTs #-}
module Calculator where
import Text.Parsec
import qualified Text.Parsec.Expr as PE
import qualified Text.Parsec.Token as PT
import qualified Text.Parsec.Language as PL
import Control.Applicative hiding ((<|>))
let inline name (x : ^T) = (^T : (member Name : string) (x))
let inline age (x : ^T) = (^T : (member Age : int) (x))
let inline nameAndAge x = (name x, age x)
type Person(name : string, age : int) =
member __.Name = name
member __.Age = age
type Employee(name : string, age : int, employeeId : string) =
member __.Name = name
@jpantuso
jpantuso / README.md
Created June 17, 2011 18:18 — forked from jondkinney/README.md
Deploying Rails to Linode

Deploying Rails to Linode

Installing Ruby Enterprise Edition, Apache, MySQL, and Passenger for deploying Rails 3.0 applications.

Get a Linode, and set it up with Ubuntu 10.04 LTS so that you have till April 2013 to get updates. Once the Linode is formatted, boot it and continue on.

Set up an 'A' record in your DNS, pointing to the IP of your Linode. I'm using demo.napcs.com here.

Initial setup

@txus
txus / capybara_uoc.rb
Created June 26, 2011 15:05
UOC scraping with standalone Capybara
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'akephalos'
Capybara.run_server = false
Capybara.current_driver = :akephalos
Capybara.app_host = 'http://cv.uoc.edu'
module MyCapybaraTest
@mattflo
mattflo / MapKata.txt
Created June 28, 2011 18:08
Map Kata
Map Kata
========
* Given a simple grid, e.g. 10x10
* Given a game piece is placed somewhere on the grid, e.g. 5,5
* Given the piece canNOT be moved diagonally, e.g. one up, one left...
* Find all available squares to which the piece can move
** 1 move
** 2 moves
** etc...
** until you are thrilled with your solution or ready for something new
@TooTallNate
TooTallNate / .gitignore
Created July 9, 2011 04:05
low-level objc runtime apis
*
!*.m
!Makefile
@jcasimir
jcasimir / filters.markdown
Created July 22, 2011 18:14
Controller Filters

Controller Filters

The Rails REST implementation dictates the default seven actions for your controllers, but frequently we want to share functionality across multiple actions or even across controllers. Controller filters are the easiest way to do that.

Before, After, and Around

There are three types of filters implemented in Rails:

  • a before_filter runs before the controller action
  • an after_filter runs after the controller action