Public Gists by pjb3

Gravatar
Mon Jun 08 20:14:46 -0700 2009
1
2
3
Prelude> let numberOfAttendeesToAnyGivenLanguageGroup totalNumberOfAttendeesAtTheFirstMeeting meetingNumber = round $ totalNumberOfAttendeesAtTheFirstMeeting ** (1/meetingNumber)
Prelude> map (numberOfAttendeesToAnyGivenLanguageGroup 16) [1..12]
[16,4,3,2,2,2,1,1,1,1,1,1]
Gravatar
Mon Jun 08 19:27:08 -0700 2009
1
2
3
Array.prototype.each = function(f) {
  for(var i = 0; i < this.length; i++) {
    f(this[i])
Gravatar
Mon May 11 11:04:24 -0700 2009
1
2
3
function each(f, arr) {
  for(var i=0; i < arr.length; i++) {
    f.apply(null, [arr[i]])
Gravatar
Thu May 07 05:21:56 -0700 2009
1
2
3
#!/usr/local/bin/ruby
require 'rubygems'
require 'hpricot'
Gravatar
Thu Apr 16 21:43:36 -0700 2009
1
2
3
(defn foldr [f acc coll]
  (if (first coll)
    (f (first coll) (foldr f acc (rest coll)))
Gravatar
Tue Apr 07 07:32:59 -0700 2009
1
2
3
class Whatever
  def foo
    @@foo = 42
Gravatar
Wed Feb 18 21:11:46 -0800 2009
1
2
3
; HTTP query string parser, Clojure
 
(defn parse-query-string
Gravatar
Wed Jan 28 19:58:43 -0800 2009
1
2
3
$ mkdir -p src/ex
$ echo "(ns ex.Foo (:gen-class :extends Exception))" > src/ex/Foo.clj
$ mkdir classes
Gravatar
Wed Jan 21 15:27:48 -0800 2009
1
2
3
  # true if any fields of this object match any of the values
  def any_field_matches_any_value?(fields, values)
    re = Regexp.new(values.join("|"), Regexp::IGNORECASE)
Gravatar
Wed Jan 21 15:26:44 -0800 2009
1
2
3
  # true if any fields of this object match any of the values
  def any_field_matches_any_value?(fields, values)
    re = Regexp.new(values.join("|"), Regexp::IGNORECASE)
Gravatar
Tue Jan 13 14:52:14 -0800 2009
1
2
3
import clojure.lang.Compiler;
import clojure.lang.PersistentList;
import clojure.lang.Symbol;
Gravatar
Wed Dec 31 12:45:43 -0800 2008
1
2
3
R = 3963.1676
 
def miles_to_lat(x)
Gravatar
Mon Dec 22 06:42:06 -0800 2008
1
2
3
(defn move-to [shape x y] (merge shape {:x x :y y}))
(defn r-move-to [shape x y] (move-to shape (+ (shape :x) x) (+ (shape :y) y)))
(derive ::rectangle ::shape)
Gravatar
Fri Dec 12 12:21:06 -0800 2008
1
2
3
<html>
  <head>
    <title>JavaScript</title>
Gravatar
Sun Nov 16 15:08:33 -0800 2008
1
2
3
(defn detect [pred coll]
  (if (empty? coll) nil
    (if (pred (first coll))
Gravatar
Tue Oct 14 19:44:49 -0700 2008
1
2
3
package clojure.velocity;
 
import org.apache.velocity.util.introspection.UberspectImpl;
Gravatar
Sun Oct 12 13:19:31 -0700 2008
1
2
3
require 'uri'
module Http
  DEFAULT_TIMEOUT = 30
Gravatar
Tue Sep 30 10:34:20 -0700 2008
1
2
3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
Gravatar
Wed Sep 24 04:48:38 -0700 2008
1
2
3
require 'email_re'
 
#I assume this is monkey patching a BasicBackend class
gist: 11156 acts_as_paranoid for Rails 2.1
Gravatar
Tue Sep 16 15:51:49 -0700 2008
1
2
3
module Acts
  module Paranoid
    def acts_as_paranoid