Skip to content

Instantly share code, notes, and snippets.

@sbastn
sbastn / fizzbuzz.clj
Created December 15, 2010 20:24
Simple fizzbuzz
(ns hello-world.core
(:require [clojure.string :as str]))
(def substitute (sorted-map 3 "Fizz" 5 "Buzz"))
(defn play [n]
(let [match (filter #(= 0 (mod n %)) (keys substitute))]
(if (empty? match)
n
(str/join "" (map #(substitute %) match)))))
import pymongo
from pymongo import Connection
from pymongo.dbref import DBRef
from pymongo.database import Database
# connect
connection = Connection()
db = Database(connection, "things")
# clean up
@sbastn
sbastn / mongo_with_java_driver.groovy
Created January 7, 2011 18:00
Groovy using mongo's java driver
import com.mongodb.*
// connect
mongo = new Mongo('localhost', 27017)
mongo.dropDatabase('things')
db = mongo.getDB('things')
owners = db.getCollection('owners')
tasks = db.getCollection('tasks')
(ns dependency-mgmt.core
(:require [clojure.contrib.string :as str]))
(def classes "A B C
B C E")
(def deps (ref {}))
(defn build-dependency-map [seq]
(let [name (keyword (str (first seq)))
@sbastn
sbastn / FizzBuzzTest.java
Created July 29, 2011 08:52
AgileAlicanteJuly2011
import static org.junit.Assert.*;
import java.util.HashMap;
import org.junit.Test;
public class FizzBuzzTest {
@Test
public void devuelveUno() throws Exception {
assertEquals("1", dime(1));
@sbastn
sbastn / TicTacToe.groovy
Created November 29, 2011 17:20
tic tac toe with Ruben
class Board {
def fields = ["."]
def mark(token){
if (fields[0] != ".") {
throw new RuntimeException("Already Taken!")
}
fields[0] = token
}
}
@sbastn
sbastn / Readme.txt
Created February 14, 2012 08:22
My coffeescript TDD super fast feedback loop
Get the parts
* jasmine-node (https://github.com/mhevery/jasmine-node)
* watchr (https://github.com/mynyml/watchr)
* growlnotify (you can brew this)
* And of course coffeescript :)
You can see the demo here: http://holatdd.com/videos/kata-lonja (just advance the 5 first mins or so)
Create a project like this
├── spec
@sbastn
sbastn / dabblet.css
Created May 29, 2012 19:01
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
.container {
}
.clip {
position: absolute;
//clip:rect(50px 218px 155px 82px);
}
package com.learning;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class RomanNumeralsTest {
interface RomanNumber {
require 'formula'
class Dblatex < Formula
env :userpaths
url 'http://downloads.sourceforge.net/project/dblatex/dblatex/dblatex-0.3/dblatex-0.3.tar.bz2'
homepage 'http://dblatex.sourceforge.net'
md5 '7de6bf72b8b2934169ce0ec911e966ed'
def install
system "python", "setup.py", "install", "--prefix=#{prefix}", "--install-scripts=#{bin}"