Skip to content

Instantly share code, notes, and snippets.

@pikariop
pikariop / symmetric-difference.clj
Created February 27, 2024 11:08
symmetric-difference.clj
(defn symmetric-difference [& sets]
(set/difference (apply set/union sets) (apply set/intersection sets)))
@pikariop
pikariop / random-string.clj
Last active December 15, 2023 15:14
random-string.clj
(defn random-string
"Generates a string of `length` characters between ascii code points 65...90 (A-Z) and 97...122 (a-z)"
[length]
(let [random-ascii-char-seq (repeatedly #(char (+ (rand-nth [65 97])
(rand-int 26))))]
(apply str (take length random-ascii-char-seq))))
@pikariop
pikariop / clipboard.clj
Last active December 15, 2023 14:48 — forked from exupero/clipboard.clj
Clojure code to interact with the system clipboard
(require '[clojure.pprint :as pp])
(import '[java.awt.datatransfer DataFlavor StringSelection Transferable])
(defn clipboard []
(.getSystemClipboard (java.awt.Toolkit/getDefaultToolkit)))
(defn slurp-clipboard []
(try
(.getTransferData (.getContents (clipboard) nil) (DataFlavor/stringFlavor))
(catch java.lang.NullPointerException e nil)))
@pikariop
pikariop / count-lines.sh
Last active March 5, 2024 11:16
Total lines of code without empty lines or comments (clojure)
#!/bin/bash
#
# in repository root, find files with typical clojure extensions, grep and count lines that are not comments or blank, then sum with awk
find . -type f -name "*.clj" -o -name "*.cljc" -o -name "*.cljs" |
xargs -I '%' grep --count --invert-match --extended-regexp "^;|^[[:blank:]]*$" % |
awk '{lines += $1} END {print lines}'
# -L = follow symlinks
# prune results under path "./target" which contains generated cljs
@pikariop
pikariop / keybase.md
Created November 17, 2017 10:21
keybase.md

Keybase proof

I hereby claim:

  • I am pikariop on github.
  • I am pikariop (https://keybase.io/pikariop) on keybase.
  • I have a public key ASCGKmPerKw3t1AEEq0NBQfSLqqRjitSHWU3uM1nH7sSzQo

To claim this, I am signing this object:

#!/usr/bin/php
<?php
/*
* https://rekry.poutapilvi.fi
*/
function quadratic_residue($seed, $mod) {
return $seed * $seed % $mod;