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 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)) |
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
-- 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 |
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
(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 |
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 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; |
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 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"))) |
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 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))) |
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
(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"]] |