This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; generates a jar file in the pwd named cl.jar | |
; cl.jar contians a class file that contains a class named x.cl | |
; x.cl is a ClassLoader which is extended to have a method 'add' | |
; 'add' takes a ClassLoader or a URL | |
; in the case you call 'add' on a URL the URL is wrapped in a URLClassLoader | |
; x.cl searches the list of 'add'ed ClassLoaders for classes | |
; | |
; idea is to use it for developement, when dynamically adding classes from | |
; jars could be useful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default: | |
echo "(+ 1 2) (+ 10 3)" | ruby tlisp.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
module HashLikeSmalltalkConditionals | |
class ::Object | |
def nil? hash | |
hash[:if_false].call | |
self | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Chris Rathman / [email protected] | |
************************************************************************ | |
* Allowable characters: * | |
* - a-z * | |
* - A-Z * | |
* - 0-9 * | |
* - .+/\*~<>@%|&? * | |
* - blank, tab, cr, ff, lf * | |
* * | |
* Variables: * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn foldr [f acc coll] | |
(if (first coll) | |
(f (first coll) (foldr f acc (rest coll))) | |
acc)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn neighbours [[x y]] | |
(for [dx [-1 0 1] dy (if (zero? dx) [-1 1] [-1 0 1])] | |
[(+ dx x) (+ dy y)])) | |
(defn step [cells] | |
(set (for [[loc n] (frequencies (mapcat neighbours cells)) | |
:when (or (= n 3) (and (= n 2) (cells loc)))] | |
loc))) | |
(def board #{[2 1] [2 2] [2 3]}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Validate moves | |
Scenario: Moving the knight illegally | |
Given the following board: | |
| | | | | | | | |8| | |
| | | | | | | | |7| | |
| | | | | | | | |6| | |
| | | | | | | | |5| | |
| | | |♞| | | | |4| | |
| | | | | | | | |3| | |
|♙| | | | | | | |2| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# responds to requests with Forsyth-Edwards notation in URL with an image: | |
# http://dia-x.info/fen/2S5/1bQKpR2/4s3/2bkpP2/Sr1p2r1/1P1R3B/1B2s3/8 | |
# | |
class FenController < ApplicationController | |
include Magick |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
if ARGV.size < 2 | |
$stderr.puts 'usage: monitor <path> <command> [arg1 arg2 ...]' | |
exit 100 | |
end | |
PATH = ARGV[0] | |
COMMAND = ARGV[1] | |
ARGS = ARGV[2..-1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package demo | |
class Coder(words: List[String]) { | |
private val mnemonics = Map( | |
'2' -> "ABC", '3' -> "DEF", '4' -> "GHI", '5' -> "JKL", | |
'6' -> "MNO", '7' -> "PQRS", '8' -> "TUV", '9' -> "WXYZ") | |
private val charCode: Map[Char, Char] = | |
for ((digit, str) <- mnemonics; letter <- str) yield letter -> digit |