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
(fact "answers get validated" | |
(let [ctx {:state :composing | |
:players #{"data" "geordi" "picard"} | |
:submissions {} | |
:letters [\S \I \T \M] | |
;:live? true | |
}] | |
(submit-answer ctx "data" "sock it to me") | |
=> (contains {:submissions {"data" "sock it to me"}}) |
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
(ns lazybot.plugins.hackernews | |
(:use [lazybot registry] | |
[clojure.data.json :only [read-json]]) | |
(:require [clj-http.client :as client]) | |
(:import org.apache.commons.lang.StringEscapeUtils) | |
) | |
; we've got a couple choices for hacker news APIs | |
; both APIs return similar JSON | |
; but ihackernews seems faster but unreliable (500s a lot) |
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
(def input [["a" "apple"] ["a" "amazon"] ["b" "banana"] ["c" "clown"]]) | |
(->> (group-by first input) ; now we have our keys pointing to lists of every key value pair with that key | |
(map (fn [[k v]] [k (map second v)])) ; for each key value pair, keep only the second parts of the values | |
(into {})) ; throw it into a hash map | |
;=> {"a" ("apple" "amazon"), "b" ("banana"), "c" ("clown")} |
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 | |
# find and run the latest version of h2 in the local maven repo | |
H2VERSION=$(ls ~/.m2/repository/com/h2database/h2/ | grep '^[.0-9]*$' | tail -n 1) | |
if [[ -z "$H2VERSION" ]]; then | |
echo "NOPE: I can't find any h2 jars installed in your maven repo." | |
else | |
echo detected H2 version is $H2VERSION. | |
java -cp ~/.m2/repository/com/h2database/h2/${H2VERSION}/h2-${H2VERSION}.jar org.h2.tools.Server $@ |
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
-- | Re-implementing the Maybe monad from memory, to make sure I | |
-- understand it. | |
module MyMaybe where | |
import Prelude hiding (Maybe, Just, Nothing) | |
data MyMaybe a = MyNothing | MyJust a | |
deriving (Eq, Show) | |
instance Monad MyMaybe where |
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
(ns lazybot.plugins.commandlinefu | |
(:use [lazybot registry] | |
[clojure.data.json :only [read-json]]) | |
(:require [clj-http.client :as client]) | |
(:import org.apache.commons.lang.StringEscapeUtils) | |
) | |
; http://www.commandlinefu.com/site/api | |
(def CLFU-URL "http://www.commandlinefu.com/commands/random/json") |
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
// show a loading animation while AJAX requests are pending | |
angular | |
.module('loadingOnAJAX', []) | |
.config(function($httpProvider) { | |
var numLoadings = 0; | |
var loadingScreen = $('<div style="position:fixed;top:0;left:0;right:0;bottom:0;z-index:10000;background-color:gray;background-color:rgba(70,70,70,0.2);"><img style="position:absolute;top:50%;left:50%;" alt="" src="data:image/gif;base64,R0lGODlhQgBCAPMAAP///wAAAExMTHp6etzc3KCgoPj4+BwcHMLCwgAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAQgBCAAAE/xDISau9VBzMu/8VcRTWsVXFYYBsS4knZZYH4d6gYdpyLMErnBAwGFg0pF5lcBBYCMEhR3dAoJqVWWZUMRB4Uk5KEAUAlRMqGOCFhjsGjbFnnWgliLukXX5b8jUUTEkSWBNMc3tffVIEA4xyFAgCdRiTlWxfFl6MH0xkITthfF1fayxxTaeDo5oUbW44qaBpCJ0tBrmvprc5GgKnfqWLb7O9xQQIscUamMJpxC4pBYxezxi6w8ESKU3O1y5eyts/Gqrg4cnKx3jmj+gebevsaQXN8HDJyy3J9OCc+AKycCVQWLZfAwqQK5hPXR17v5oMWMhQEYKLFwmaQTDgl5OKHP8cQjlGQCHIKftOqlzJsqVLPwJiNokZ86UkjDg5emxyIJHNnDhtCh1KtGjFkt9WAgxZoGNMny0RFMC4DyJNASZtips6VZkEp1P |
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
(defn index-of | |
"return the index of the supplied item, or nil" | |
[v item] | |
(let [len (count v)] | |
(loop [i 0] | |
(cond | |
(<= len i) nil, | |
(= item (get v i)) i, | |
:else (recur (inc i )))))) |
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
(ns example.typetest | |
(:use [clojure.core.typed])) | |
; using [org.clojure/core.typed "0.2.13"] | |
(def-alias House "a House has some :people in it and maybe a :mortgage." | |
(HMap :mandatory {:id String | |
:people (Coll String) | |
} | |
; comment out this :optional line and it all works | |
:optional {:mortgage Number} |
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
#SingleInstance Force | |
#MaxHotkeysPerInterval 99999 | |
#IfWinActive ahk_class DarkSouls2 | |
; AHL script to remove input lag from DarkSouls2 PC, and add hotkeys for | |
; Guard break / Jump Attack | |
; | |
; Current settings (some can be easily changed) | |
; LMB / RMB = normal attacks | |
; Shift + LMB / RMB = strong attacks |