Skip to content

Instantly share code, notes, and snippets.

@sbastn
sbastn / run.rb
Created December 24, 2016 09:15
get '/run/:location' do |location|
geocoder = Geocoder.search(location)
unless geocoder.empty?
latitude = geocoder.first.data['geometry']['location']['lat']
longitude = geocoder.first.data['geometry']['location']['lng']
forecast = Forecast::IO.forecast(latitude, longitude)
@location = geocoder.first.data['formatted_address']
tz = TZInfo::Timezone.get(forecast.timezone)
next_hours = forecast.hourly.data.first(7).each_with_index.map do |data, index|
{
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}"
package com.learning;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class RomanNumeralsTest {
interface RomanNumber {
@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);
}
@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 / 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 / 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));
(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 / 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')
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