Skip to content

Instantly share code, notes, and snippets.

@littleli
littleli / paillier.clj
Last active July 20, 2021 11:49
The implementation of Paillier cryptosystem for Clojure and Babashka
(ns fun.clojure.paillier
(:import [java.math BigInteger]
[java.security SecureRandom]
[java.nio.charset StandardCharsets]))
(defn- random-number! [end]
(let [start (BigInteger/valueOf 2)
interval (.subtract end start)
i (BigInteger. (.bitCount interval) (SecureRandom.))]
(.add start i)))
@hansbugge
hansbugge / lint.clj
Created September 26, 2020 10:34
Code Quality report for Clojure projects in Gitlab using babashka and clj-kondo.
#!/usr/bin/env bb
(ns script
"Make a 'Code Quality' report from clj-kondo for use in GitLab CI.
JSON issue format:
https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html#implementing-a-custom-tool
Usage:
Add the following job in .gitlab-ci.yml:
@prestancedesign
prestancedesign / README.md
Last active December 8, 2020 14:06
A TODO cli with Clojure (Babashka)
@borkdude
borkdude / foo.html
Last active December 9, 2020 11:58
Prism Clojure highlighting
<html>
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism-tomorrow.min.css" rel="stylesheet" />
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/components/prism-core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/plugins/autoloader/prism-autoloader.min.js"></script>
<pre>
<code class="language-clojure">
(defn foo []
(require '[clojure.string :as s])
;; Maze GENERATION
(defn north-of [[row col]] [(dec row) col])
(defn south-of [[row col]] [(inc row) col])
(defn west-of [[row col]] [row (dec col)])
(defn east-of [[row col]] [row (inc col)])
(defn neighbours [rows cols cell]
@elnygren
elnygren / expression_problem.clj
Last active December 3, 2022 16:33
Solving the Expression Problem with Clojure
; The Expression Problem and my sources:
; http://stackoverflow.com/questions/3596366/what-is-the-expression-problem
; http://blog.ontoillogical.com/blog/2014/10/18/solving-the-expression-problem-in-clojure/
; http://eli.thegreenplace.net/2016/the-expression-problem-and-its-solutions/
; http://www.ibm.com/developerworks/library/j-clojure-protocols/
; To begin demonstrating the problem, we first need some
; "legacy code" with datastructures and functionality: