Skip to content

Instantly share code, notes, and snippets.

View tmountain's full-sized avatar

Travis Whitton tmountain

View GitHub Profile
(ns clj-sleuth.crawl
(:require [jsoup.soup :as c]
[clojure.pprint :as p]
[clojure.tools.logging :as log]))
(Thread/setDefaultUncaughtExceptionHandler
(reify Thread$UncaughtExceptionHandler
(uncaughtException [_ thread ex]
(log/error ex "Uncaught exception on" (.getName thread)))))
(defn birthday-collision?
"Generates a birthday (0-364) for person-count
number of people. Returns a boolean value
indicating whether there were two or more
people with the same birthday."
[person-count]
(let [rand-days
(for [x (range person-count)]
(rand-int 365))]
(let [matches (->> (frequencies rand-days)
(reduce
(fn [m word]
(assoc m word (inc (get m word 0))))
{}
["foo", "bar", "car", "car"])
import Html exposing (text)
type alias User =
{ name : String
, age : Maybe Int
}
canBuyAlcohol : User -> Bool
canBuyAlcohol user =
case user.age of
def interest(principal, rate, times, years)
principal * (1 + rate.to_f/times.to_f) ** (times.to_f * years.to_f)
end
1.upto(50) do |y|
puts sprintf("%.02f", interest(1000, 0.05, 1, y))
end
(defrecord Constant [value])
(defrecord BinaryPlus [lhs rhs])
(defmulti evaluate class)
(defmethod evaluate Constant
[c] (:value c))
(defmethod evaluate BinaryPlus
[bp] (+ (evaluate (:lhs bp)) (evaluate (:rhs bp))))
module RPS exposing (main)
import Html exposing (Html, div, text, button)
import Html.Events exposing (onClick)
import Random
-- MODEL
(def jira-time-format (f/formatter "yyyy-MM-dd HH:mm"))
(def short-time-format (f/formatter "yyyy-MM-dd"))
(defn get-time-series
([start-date end-date]
(let [start-date (f/parse jira-time-format start-date)
end-date (f/parse jira-time-format end-date)]
(get-time-series start-date end-date start-date [])))
([start-date end-date current-date series]
(if-not (t/within? (t/interval start-date end-date) current-date)
-- TYPE MISMATCH ---------------------------------------------------------------
The argument to function `toFullName` is causing a mismatch.
6│ toFullName { fistName = "Hermann", lastName = "Hesse" }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Function `toFullName` is expecting the argument to be:
{ …, firstName : … }
A few other small pieces of advice that I'll be applying to any project I ever start from scratch again.
1) Think about how the service will scale from day-1, and don't box yourself in with any vertical architectural decisions (think about keys and things like that early).
2) Design your service so that any node can fail without consequence to the overall operation of the system.
3) Host it somewhere sane ;-).
4) Leverage as much existing technology as humanly possible (orchestration, monitoring, deployment, etc... are all "solved" problems).