Skip to content

Instantly share code, notes, and snippets.

View kornysietsma's full-sized avatar

Korny Sietsma kornysietsma

View GitHub Profile
lazy val javascriptIntegrationTest = task {
val statusLogger: JasmineStatusLogger = new JasmineStatusLogger(log)
val workingDirectory = new File(info.projectPath.asFile, "src/it/javascript").getPath
val phantomJasmine = workingDirectory + "/phantom-jasmine.js"
val specRunner = workingDirectory + "/SpecRunner.html"
val reportDir = new File(info.projectPath.asFile.getParent,
"app/target/reports/javascript-test/").getPath
try {
run(List("/usr/bin/phantomjs", phantomJasmine, specRunner, reportDir), true)
@kornysietsma
kornysietsma / sbtSample2.scala
Created August 12, 2011 06:25
sbt sample 2
val scalatra = "org.scalatra" %% "scalatra" % scalatraVersion withSources ()
val scalate = "org.scalatra" %% "scalatra-scalate" % scalatraVersion withSources ()
val servletApi = "org.mortbay.jetty" % "servlet-api" % "2.5-20081211" % "provided"
val specs = "org.scalatra" %% "scalatra-specs" % scalatraVersion % "test" withSources ()
val mockito = "org.mockito" % "mockito-all" % "1.8.5" % "test" withSources ()
@kornysietsma
kornysietsma / sbtSample3.scala
Created August 12, 2011 06:30
sbt sample 3
sealed trait Aggregation
final object Aggregation
{
def apply(dependencies: Seq[ProjectReference], transitive: Boolean = true): Aggregation
= new Explicit(dependencies, transitive)
implicit def fromBoolean(b: Boolean): Aggregation = if(b) Enabled else Disabled
val Enabled = new Implicit(true)
val Disabled = new Implicit(false)
final case class Implicit(enabled: Boolean) extends Aggregation
final class Explicit(val dependencies: Seq[ProjectReference], val transitive: Boolean)
(ns test.core)
(defn foo
"I don't do a whole lot."
[x]
(println x "Hello, World!"))
@kornysietsma
kornysietsma / wikiparse.clj
Last active January 2, 2021 18:41
parsing wikipedia dumps in clojure
(ns wikiparse.core
(:require [clojure.java.io :as io]
[clojure.data.xml :as xml]
[clojure.zip :refer [xml-zip]]
[clojure.data.zip.xml :refer [xml-> xml1-> text]])
(:import [ org.apache.commons.compress.compressors.bzip2 BZip2CompressorInputStream])
(:gen-class :main true))
(defn bz2-reader
"Returns a streaming Reader for the given compressed BZip2
@kornysietsma
kornysietsma / game-loop.cljs
Created September 28, 2013 11:34
simple game loop that reads regular ajax results and also updates on every animation frame
(defn game-loop []
(let [anim-chan (au/anim-ch active)
ajax-chan (au/ajax-loop "world" slowth active)]
(go
(loop [state {:world {} :timestamp (js-now)}]
(when @active
(let [next-state
(alt!
anim-chan ([val] (do
(graphics/draw-map
(def moneys {:nickel 5 :dime 10 :quarter 25 :dollar 100})
(def prices {:a 65 :b 100 :c 150})
(def initial-state
{:inserted-money [:nickel :dime]
:items {:a 15 :b 3}
})
(defn in-stock? [state item]
(let [stock-level (item (:items state))]
package foo;
import java.util.*;
public class BadMap implements Map<String,String> {
private Map<String,String> theMap;
public BadMap(Map<String,String> m) {
theMap = m;
}
@kornysietsma
kornysietsma / higher_order.clj
Last active August 29, 2015 14:05
basic clojure functional functions
; this page: http://tinyurl.com/ndfzluz
; "higher order functions" basically means using functions as parameters to functions. Lots of languages have this - even C has function pointers
; Structure and Interpretation of Computer Programs, a classic 1993 text from MIT, says:
; "It is better to have 100 functions operate on one data structure than to have 10 functions operate on 10 data structures"
; http://mitpress.mit.edu/sicp/
; simple example - define "is-even":
(def is-even (fn [x] (= (mod x 2) 0)))

Keybase proof

I hereby claim:

  • I am kornysietsma on github.
  • I am korny (https://keybase.io/korny) on keybase.
  • I have a public key whose fingerprint is CCA6 2821 5A0F 290B 5040 1F49 1C12 9115 703D B610

To claim this, I am signing this object: