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
-- | 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
#!/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
(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
(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
(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.feelings | |
(:require [clojure.string :as string]) | |
(:use [lazybot registry] | |
[somnium.congomongo :only [fetch fetch-one insert! destroy!]])) | |
; feelings.clj: a lazybot plugin to remember and report how people feel about various stuff | |
; TODO: parameterize prefix instead of literal '@', or don't bother? | |
(def love-responses |
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 simplebot.core | |
(:use [clj-time.core :exclude [extend]] | |
[clj-time.local]) | |
(:require [irclj.core :as ircb] | |
[overtone.at-at :as at-at] | |
[clojure.string :as string])) | |
(def CHANNEL "#silly-bot-test") | |
(defn -main [& args] |
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 big-ben.core | |
(:use [clj-time.core :exclude [extend]] | |
[clj-time.local]) | |
(:require [irclj.core :as ircb] | |
[overtone.at-at :as at-at] | |
[clojure.string :as string])) | |
(def HOUR-IN-MS (* 60 60 1000)) | |
(def config |
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.greetings | |
(:use lazybot.registry) | |
(:use [lazybot.utilities :only [prefix]]) | |
(:require [clojure.string :as s])) | |
(def morning-patterns | |
[#".*good.morning.*" | |
#".*top.*o.*morning.*" | |
]) |