Skip to content

Instantly share code, notes, and snippets.

View cstrahan's full-sized avatar

Charles Strahan cstrahan

  • Backtrace
  • Dallas, TX
View GitHub Profile
require 'openid/store/interface'
module OpenID::Store
class Association
include Mongoid::Document
field :secret, :type => Binary
def from_record
OpenID::Association.new(handle, secret.to_s, issued, lifetime, assoc_type)
end
@bryanl
bryanl / tmux.conf
Created November 30, 2010 05:17
I copied this from somewhere. It is a good start, though
# ~/.tmux.conf
#
# See the following files:
#
# /opt/local/share/doc/tmux/t-williams.conf
# /opt/local/share/doc/tmux/screen-keys.conf
# /opt/local/share/doc/tmux/vim-keys.conf
#
# URLs to read:
#
import io.Source
import scala.util.control.Breaks._
/**
* Scala TicTacToe game without any side effects
*
* Written in response to following post (which also contains task description):
* http://blog.tmorris.net/scala-exercise-with-types-and-abstraction/
*/
object TicTacToe {
public abstract class ExpressionVisitorBase<TState>
{
public class ExpressionNotSupportedException : Exception
{
public ExpressionNotSupportedException(Expression expression) :
base(string.Format("Expression {0} not supported.", expression.GetType().Name)) { }
}
public virtual TState Visit(Expression node)
{
(defn reverse*-cps [x k]
(cond
(nil? (seq x)) (apply-cont k [])
(seq? (first x))
(recur (rest x) ; <-- HERE
(fn [new-tail]
(reverse*-cps (first x)
(fn [new-head]
(snoc-cps new-tail new-head k)))))
:else (recur (rest x) ; <-- AND HERE
(defn reverse*-cps [x k]
(cond
(nil? (seq x))
(trampoline #(apply-cont k '[])) ; <-- HERE
(seq? (first x))
(recur (rest x)
(fn [new-tail]
(reverse*-cps (first x)
(fn [new-head]
(snoc-cps new-tail new-head k)))))
(defn reverse*-cps [x k]
(cond
(nil? (seq x))
(trampoline #(apply-cont k '[]))
(seq? (first x))
(recur (rest x)
(fn [new-tail]
#(reverse*-cps (first x) ; <-- HERE
(fn [new-head]
(snoc-cps new-tail new-head k)))))
@skorks
skorks / subset_sum_dynamic.rb
Created February 26, 2011 14:32
Solving the subset sum problem via dynamic programming
require 'terminal-table/import'
class SubsetSumMatrix
class << self
def create_empty_for(array)
matrix = []
header = [nil] + build_header_from(array)
matrix << header
array.each_with_index do |element,i|
row = header.collect{|value| 'F'}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Reflection.Emit;
using System.Collections.Concurrent;
using System.Data;
using System.Reflection;
@cowboy
cowboy / finder-open-iterm-here.scpt
Created April 6, 2011 12:10
Finder Open iTerm Here: Drop a folder on this script (or just run it) to open a new iTerm window there. If the selected item isn't a folder, it will open the item's parent folder. Great when bound to a hotkey in FastScripts or added to the Finder Sidebar
(*
* Finder Open iTerm Here - v1.0.2 - 4/14/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*)
tell application "Finder"