Skip to content

Instantly share code, notes, and snippets.

View mchampine's full-sized avatar

Mark Champine mchampine

View GitHub Profile
(ns ufo.core
(:use (incanter core stats charts datasets))
(require [ :as json]
[clj-time.format :as tf]
[net.cgrand.enlive-html :as html]
[clojure.string :as string]))
;; URL with one month of data (january, 2015)
(def ufourl "")
<pre><code class="language-klipse">
(def default-config
{:chart {:zoomType :xy
:type :scatter}
:legend {:layout :vertical
:align :left
:verticalAlign :top
:x 100
:y 70
:floating :true
mchampine / gist:f6e88b97dd76617d1f4ac8db38e43bed
Last active January 2, 2019 18:15
Beginners SQL translated to DataScript
(ns trydatahike.beginnersql
(:require [datahike.api :as d :refer :all :exclude [filter]]
[clojure.string :as string]))
;;(require '[datahike.migrate :refer [export-db import-db]])
;;(export-db @bookconn "src/trydatahike/begsqldump.edn")
;;(import-db new-conn "src/trydatahike/begsqldump.edn")
;; SQL example translated to DataScript
mchampine / pwprot.clj
Created March 13, 2011 19:13
Strong password hasher/verifier for Clojure - incorporating salt and iterations
(ns pwprot
(:import ( MessageDigest Security)))
;;generate n random chars
(defn gensalt [n]
(let [charseq (map char (concat
(range 48 58) ; 0-9
(range 97 123)))] ; 0-z
(apply str
(take n
mchampine / gist:dca965226148dfd19d5e4d7f3d4600c5
Created July 6, 2020 05:31
Poker Hand Scoring in Clojure
(defn score
"Return a tuple representing the best score that can be made from the hand."
(let [isflush (apply = (map second hand))
ranks (map first hand)
rsranks (reverse (pk-ranksort ranks))
fq (frequencies ranks)
keyswith (partial getkeyswithval fq)
fs (sort (vals fq))
match-ranks? #(= (set ranks) (set %))
(ns mlstudy.linalgbook
(:require [uncomplicate.neanderthal.linalg :as linalg]
[tech.viz.vega :as vega])
(:use [uncomplicate.neanderthal core native vect-math]
;;; See also
;; Based on Gareth Williams 9th Edition - Linear Algebra with Applications 2017