This file contains 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
require "lifx" # http://www.rubydoc.info/gems/lifx | |
def calculate_color(i) # 0 <= i <= 1 | |
h = [40 * 2 * i, 40].min # will be 40 (yellow) at i=1/2 and stay there | |
s = 1.0 - [(i - 0.5) * 2, 0].max # will be 1 until i=1/2 and then go down to 0 | |
b = i | |
LIFX::Color.hsbk(h, s, b, LIFX::Color::KELVIN_MIN) | |
end | |
duration = 10 * 60 # seconds |
This file contains 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
// This version allows LHS to be any expression | |
// (and makes sure it's only evaluated once by storing the result) | |
let (?.) = macro { | |
rule infix { $lhs:expr | $rhs:ident } => { | |
(function ($tmp) { | |
return $tmp === null ? null : $tmp.$rhs; | |
})($lhs) | |
} | |
} |
This file contains 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
import javax.servlet.*; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
import java.io.IOException; | |
import java.net.URI; | |
import java.net.URISyntaxException; | |
import static java.lang.String.format; | |
public class HttpsFilter implements Filter { |
This file contains 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
;; lein try joda-time org.clojure/algo.generic | |
;; Let's first shave the parsing yak: | |
(import (org.joda.time.format PeriodFormatterBuilder)) | |
(def h:m-formatter | |
(-> (PeriodFormatterBuilder.) | |
(.appendHours) | |
(.appendSeparator ":") |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>spiped-ssh</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/local/bin/spiped</string> | |
<string>-d</string> |
This file contains 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
# Benchmarking (.split test-input "\\.") | |
Evaluation count : 72101040 in 60 samples of 1201684 calls. | |
Execution time mean : 828.458928 ns | |
Execution time std-deviation : 29.055494 ns | |
Execution time lower quantile : 800.771006 ns ( 2.5%) | |
Execution time upper quantile : 895.752028 ns (97.5%) | |
Overhead used : 2.778847 ns | |
Found 5 outliers in 60 samples (8.3333 %) |
This file contains 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
import scalaz._ | |
trait ScalazLight | |
extends std.AllInstances | |
with syntax.std.ToOptionIdOps | |
with syntax.std.ToOptionOps | |
with syntax.ToEqualOps | |
with syntax.ToIdOps |
This file contains 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
implicit class StringExtensions(val _value: String) extends AnyVal { | |
def =~(r: Regex): Boolean = _value match { | |
case `r`() => true | |
case `r`(xs @ _*) => throw new IllegalArgumentException("Regex must not contain captures") | |
case _ => false | |
} | |
def !~(r: Regex): Boolean = !(this =~ r) | |
} |
This file contains 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
;; Benchmarks for different implementations of `for-map` | |
;; Can be run with `lein try proteus criterium` | |
;; See http://www.lexicallyscoped.com/2013/04/17/transients-in-clojure.html | |
;; for some relevant discussion. | |
(defn pairs-to-map-without-transient [pairs] | |
(reduce (fn [m [k v]] (assoc m k v)) {} pairs)) |
This file contains 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
#!/bin/sh | |
set -ex | |
version=1.7.8 | |
jar=jruby-complete-$version-with-bundler.jar | |
curl -o $jar http://jruby.org.s3.amazonaws.com/downloads/$version/jruby-complete-$version.jar |