Skip to content

Instantly share code, notes, and snippets.

@franks42
franks42 / test-cons-abs.cljs
Created December 9, 2025 22:18
Testing availability of function abs and constant cljs.core/Cons in nbb after adding entries to core.cljs' clojure.core namespace map
;; Test file to verify cljs.core/Cons and abs availability in nbb
;; Run with: nbb test-cons-abs.cljs
;;
;; Expected output WITHOUT fix:
;; Test 1 (abs): ERROR - Could not resolve symbol
;; Test 2 (Cons): ERROR - Could not resolve symbol
;;
;; Expected output WITH fix:
;; Test 1 (abs): 42
;; Test 2 (Cons): shows constructor function
@franks42
franks42 / test-cons.html
Last active December 9, 2025 20:33
Testing of cljs.core/Cons addition to Scittle source code in scittle/code.cljs in namespaces clojure.core
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test cljs.core/Cons availability</title>
<script src="/js/scittle.js"></script>
<!-- CDN version (without fix - uncomment to test error):
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/scittle.js"></script>
-->

Keybase proof

I hereby claim:

  • I am franks42 on github.
  • I am fs42 (https://keybase.io/fs42) on keybase.
  • I have a public key whose fingerprint is 0CC8 D451 DA7F 6180 FD69 CA93 343C A317 E8F6 DE8E

To claim this, I am signing this object:

@franks42
franks42 / clj.security.message-digest.repl.clj
Last active December 14, 2015 10:48
Clojure repl-session to show usage of secure hash or message digest operations like SHA-1 and MD5 with the clj.security.message-digest library. See "https://github.com/franks42/clj.security.message-digest"
user=> (require '(clj.security [message-digest :as md]))
nil
user=> (def my-sha1-digest-0 (md/make-message-digest :sha-1 :utf-8)) ;; create a message digest object
#'user/my-sha1-digest-0
user=> my-sha1-digest-0
#<TMessageDigest clj.security.message_digest.TMessageDigest@66da7ad5>
user=> (md/digest my-sha1-digest-0) ;; sha-1 digest of an empty string - initial accumulator digest
#<byte[] [B@1cefd3c>
user=> (md/bytes2hex (md/digest my-sha1-digest-0)) ;; bytes are somewhat easier to "read" in hex
"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709"
@franks42
franks42 / cljs_uuidv4.cljs
Created November 28, 2012 06:34
UUID generation algorithm for a v4/random UUID
(ns cljs-uuidv4
"Generator for a v4/random UUID that works with cljs.core/UUID"
(:require [goog.string.StringBuffer]))
(defn UUIDv4
"Returns a new randomly generated (version 4) cljs.core/UUID,
like: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
as per http://www.ietf.org/rfc/rfc4122.txt.
Usage:
-- Corona Game SDK example of how to let two bodies circle each other by applying a continuous, attracting force
--
-- The example uses the physics engine, sets gravity to 0, creates two balls separated in the x-direction,
-- with initial speeds in opposite y-direction.
-- Thru an enterFrame event handler, an attracting force is continuously applied to both balls with body:applyForce().
-- The force is normalized over the distance between the two balls.
-- By playing with the initial speed and force factors, you can make the balls spin faster/slower in circles or ellipses
--
-- Save this file as "main.lua" in a project directory and load it in the simulator
--
-- Color to RGB value table for Lua coding with Corona
-- Color values copied from "http://www.w3.org/TR/SVG/types.html#ColorKeywords"
--
-- Usage for Corona toolkit:
-- add this file "colors-rgb.lua" to your working directory
-- add following directive to any file that will use the colors by name:
-- require "colors-rgb"
--
-- If you need the RGB values for a function list, you can use "colorsRGB.RGB()", like
-- colorsRGB.RGB("chocolate"), which returns the multi value list "210 105 30"
user> (def md (java.security.MessageDigest/getInstance "SHA1"))
#'user/md
user> md
#<Delegate SHA1 Message Digest from SUN, <initialized>
>
user> (def ba (.getBytes "abc"))
#'user/ba
user> ba
#<byte[] [B@1f5fa713>
user> (def r (.update md ba))