Skip to content

Instantly share code, notes, and snippets.

View mikebridge's full-sized avatar
🤔
Thinking

Mike Bridge mikebridge

🤔
Thinking
View GitHub Profile
@mikebridge
mikebridge / rspec_formatter_for_emacs.rb
Created October 18, 2011 23:05 — forked from kiyoka/rspec_formatter_for_emacs.rb
RSpec formatter for Emacs E-x compile feature
require 'rspec/core/formatters/progress_formatter'
# Example of a formatter with custom bactrace printing. Run me with:
# ruby bin/spec xxxxx.rb -r ./test/rspec_formatter_for_emacs.rb -f CustomFormatter
class CustomFormatter < RSpec::Core::Formatters::ProgressFormatter
def backtrace_line(line)
return nil if configuration.cleaned_from_backtrace?(line)
str = line.gsub(/([^:]*\.rb):([0-9]+):in /) do
path = "#{$1}"
lineno = "#{$2}"
@mikebridge
mikebridge / pandora.coffee
Created February 17, 2012 06:36
Adapter from hubot to an A.L.I.C.E pandorabot
# Chat with hubie.
#
# hubie <anything>
#
# don't forget to set HUBOT_PANDORA_BOTID = <botid>
QS = require "querystring"
module.exports = (robot) ->
@mikebridge
mikebridge / assignment_1.clj
Created March 14, 2012 02:25
Codelesson Clojure Assignment 1
(ns codelesson.assignment-1)
;; Write a function called map-while which accepts a function f, a sequence s, and a predicate pred. When applied, it collects the results of applying f to s as long as applying pred to elements returns true.
(defn map-while [f s pred]
(map f (take-while pred s)))
@mikebridge
mikebridge / assignment_2.clj
Created March 17, 2012 19:32
Codelesson Clojure Assignment 2
;; ... Given a bunch of dollar bills, in how many ways can they be broken into coins?
;;
;; ======================
;; Algorithm
;;
;; For each coin, calculate a set of multiples from zero to the largest
;; number which is less than or equal to the dollar-value goal. Find
;; the combinations, choosing one multiple from each set, which total to
;; the goal.
;;
@mikebridge
mikebridge / assignment_3.clj
Created March 18, 2012 04:12
Codelesson Clojure Assignment 3
(ns codelesson.assignment-3)
(defn match-element
[pattern-el data-el]
{:pre [(not (coll? pattern-el)) ]
:post [(or (true? %) (false? %))] }
(or
(= pattern-el data-el)
(= '? pattern-el)))
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {
@mikebridge
mikebridge / assignment_4.clj
Created March 29, 2012 04:37
Codelesson Clojure Assignment 4
(ns codelesson.assignment-4
(:require [clojure.string :as str]))
(defn rotate-left [current-dir]
{:pre [(char? current-dir)]}
((apply hash-map (seq "NWWSSEEN")) current-dir))
(defn rotate-right [current-dir]
{:pre [(char? current-dir)]}
((apply hash-map (seq "NEESSWWN")) current-dir))
@mikebridge
mikebridge / assignment_5.clj
Created April 3, 2012 01:17
Codelesson Clojure Assignment 5
(ns codelesson.assignment-5
(:require [clojure.string :as str]))
;; util
(defn log [s]
(println s))
;; delay a function for a random number of milliseconds
(defn wait-and-call [f]
@mikebridge
mikebridge / assignment_6.clj
Created April 10, 2012 03:23
Codelesson Clojure Assignment 6
(ns codelesson.assignment-6
(:require [clojure.string :as str])
(:import [org.joda.time Years DateTime])
(:import [java.text NumberFormat]))
;; utils
(defn account-logger [key ref old new]
;; (println (str "ACCOUNTS " key "\n WAS:" old "\n NOW:" new "END"))
)
@mikebridge
mikebridge / JAccount.java
Created April 20, 2012 04:09
Codelesson Clojure Assignment 7 & 8
package codelesson.assignment8;
import java.math.BigDecimal;
import org.joda.time.DateTime;
public class JAccount {
public enum JAccountType { CHEQUING, SAVINGS, MONEYMARKET };
private DateTime _dateCreated;