Skip to content

Instantly share code, notes, and snippets.

View joshrotenberg's full-sized avatar
💀

josh rotenberg joshrotenberg

💀
View GitHub Profile
@joshrotenberg
joshrotenberg / fizzbuzz.clj
Created May 4, 2012 21:57
fizzbuzz in clojure
(defn fizzbuzz
[]
(doseq [i (range 0 100)]
(cond
(and (= 0 (mod i 3)) (= 0 (mod i 5))) (prn "FizzBuzz")
(= 0 (mod i 3)) (prn "Fizz")
(= 0 (mod i 5)) (prn "Buzz")
:else (prn i))))
defmodule Math.GCD do
@moduledoc "Functions for finding the Greatest Common Denominator"
@doc "Given two numbers, find their GCD"
def gcd(a, b) do
gcd b, rem a, b
end
@doc "Given a list of numbers, find their GCD."
def gcd(l) do
@joshrotenberg
joshrotenberg / FizzBuzz.scala
Created October 31, 2012 21:55
FizzBuzz in Scala
object FizzBuzz {
def main(args: Array[String]) {
1.to(100).foreach( (i:Int) => (i % 3, i % 5) match {
case (0,0) => println("FizzBuzz")
case (0, _) => println("Fizz")
case (_, 0) => println("Buzz")
case _ => println(i)
}
)
}
@joshrotenberg
joshrotenberg / korma_h2_raw.clj
Created November 20, 2012 02:17
see if raw/exec-raw works with korma and h2
(use 'korma.core 'korma.db)
(defdb mydb {:classname "org.hd.Driver" :protocol "file" :subprotocol "h2" :subname "./tmp/mydb"})
doubleMe x = x + x
fizzBuzz :: (Integral a, Show a) => a -> String
fizzBuzz n
| n `mod` 3 == 0 && n `mod` 5 == 0 = "FizzBuzz"
| n `mod` 3 == 0 = "Fizz"
| n `mod` 5 == 0 = "Buzz"
| otherwise = show n
-- [fizzBuzz x | x <- [1..100]]
@joshrotenberg
joshrotenberg / gist:5518496
Created May 4, 2013 19:36
tl;dr searchBatch call
Joshs-MacBook-Air:~ josh$ curl https://api.tldr.io/tldrs/s":["http://www.taigeair.com/why-gmail-2013-sucks-terribad-user-experience.html"]}' -v
* About to connect() to api.tldr.io port 443 (#0)
* Trying 178.79.181.8...
* connected
* Connected to api.tldr.io (178.79.181.8) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
@joshrotenberg
joshrotenberg / .gitignore
Last active December 17, 2015 20:18
Gists for a blog post about Haskell, http-streams and Aeson: http://joshrotenberg.com/haskell/2013/05/28/http-streams-and-aeson/
.hsenv/
hsenv.log
*.hi
*.o
import Data.Aeson
(defproject builder-post "0.1.0")