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
var DATASTORES = [ | |
"PostgreSQL", | |
"MySQL", | |
"MariaDB", | |
"MongoDB", | |
"RethinkDB", | |
"Elasticsearch", | |
"Redis", | |
"Cassandra", | |
"CouchDB" |
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 failjure.core | |
(:require [clojure.algo.monads :refer [domonad defmonad]])) | |
; Public API | |
; failed, message part of prototype | |
(declare fail) | |
(declare attempt-all) | |
(declare if-failed) | |
(declare attempt->) | |
(declare attempt->>) |
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
from xml.etree import ElementTree | |
import csv | |
class CircularLookup(object): | |
key = "FILEZILLA1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
def __len__(self): | |
return len(self.key) |
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 hearthstone-stats | |
(:require [clojure.data.json :as json] | |
[clojure.java.io :as io] | |
[clojure.string :as s])) | |
(defn get-results [] | |
(json/read-str (slurp "results.json") :key-fn keyword)) | |
(def uncounted-cards #{"Reinforce", "Lesser Heal", "Shapeshift", "The Coin", "Armor Up!", "Totemic Call", "Steady Shot", "Life Tap", "Dagger Mastery", "Fireblast"}) |
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 random | |
from collections import deque | |
class Card(object): | |
def __init__(self, cost): | |
self.cost = cost | |
def __eq__(self, other): | |
return isinstance(other, self.__class__) and self.cost == other.cost | |
def __cmp__(self, other): |
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 redditlater.analysis | |
(:import | |
java.util.Date | |
java.util.Calendar | |
java.util.TimeZone | |
java.util.SimpleTimeZone | |
) | |
(:require | |
[somnium.congomongo :as mongo] | |
[redditlater.reddit-api :as api] |
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 multi(dispatch_fn): | |
def _inner(*args, **kwargs): | |
return _inner.__multi__.get( | |
dispatch_fn(*args, **kwargs), | |
_inner.__multi_default__ | |
)(*args, **kwargs) | |
_inner.__multi__ = {} | |
_inner.__multi_default__ = lambda *args, **kwargs: None # Default default | |
return _inner |
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 parsley.core | |
(:require [net.cgrand.parsley :as p])) | |
(def parse (p/parser {:main :blat*} :blat #{["{{" #"[a-zA-Z_\-]*" "}}"]})) | |
(defmulti render-node (fn [node _] (:tag node))) | |
; Pull out the middle bit and look it up in the context | |
(defmethod render-node :blat [node context] | |
(get context (nth (:content node) 1) "")) |
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 whatlang.core | |
(:require [clojure.java.io :as io] | |
[clojure.string :as str] | |
[clojure.set :as sets] | |
)) | |
(defn load-data | |
"Read the country data file from the resource. The data has been | |
mangled in to lines like so: |
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 '[schema.core :as s]) | |
(require '[myproject.helpers :refer [uuid hash-password ]]) | |
(require '[myproject.errors :refer [attempt-all fail]]) | |
; Actual code | |
(s/defrecord User | |
[id :- s/Str | |
email :- s/Str | |
password_hash :- s/Str]) |