Skip to content

Instantly share code, notes, and snippets.

View jaydeesimon's full-sized avatar

Jeffrey Simon jaydeesimon

View GitHub Profile
(ns hmac-test.core
(:require [goog.crypt :as crypt]
[goog.crypt.Sha256]
[goog.crypt.Hmac]))
(defn string->bytes [s]
(crypt/stringToUtf8ByteArray s))
(defn bytes->hex [bytes]
(crypt/byteArrayToHex bytes))
@jaydeesimon
jaydeesimon / postgres_queries_and_commands.sql
Last active September 8, 2017 15:17 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query
(defn neighbors [board coord]
(let [directions [[1 0] [-1 0] [0 1] [0 -1]]]
(->> (map #(mapv + coord %) directions)
(filter (fn [coord']
(= (get-in board coord') \.))))))
(defn bfs-path [board start end]
(loop [frontier [[start [start]]]
visited #{start}]
(let [[[current current-path] & frontier] frontier
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class MergeIntervals {
private static class Interval {
public int start;
public int end;
@jaydeesimon
jaydeesimon / better-version.clj
Last active June 13, 2016 23:58
Got sucked in
(ns email-jonas.core
(:import (java.util Base64)))
(defn build-cipher [xs]
(let [[frst scnd] (partition (int (/ (count xs) 2)) xs)]
(merge (zipmap frst scnd) (zipmap scnd frst))))
(def ciphers (merge (build-cipher "abcdefghijklmnopqrstuvwxyz")
(build-cipher "ABCDEFGHIJKLMNOPQRSTUVWXYZ")))
@jaydeesimon
jaydeesimon / core.clj
Created May 31, 2016 20:49
Trying to work out how to structure my core.async channel
(ns core-async-playground.core
(:require [clojure.core.async
:as a
:refer [>! <! >!! <!! go go-loop chan buffer close! thread
alts! alts!! timeout]])
(:gen-class))
(defn create-bulb-chans [bulbs]
(into {} (map (fn [bulb] [bulb (chan)]) bulbs)))
@jaydeesimon
jaydeesimon / project.clj
Created November 19, 2015 17:48
Project.clj for working Figwheel CLJS REPL
(defproject figwheel-test "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.170"]
[org.clojure/core.async "0.2.374"]
[figwheel-sidecar "0.4.0"]]