Skip to content

Instantly share code, notes, and snippets.

View jamesdavidson's full-sized avatar

James Davidson jamesdavidson

View GitHub Profile
@jmorrill
jmorrill / tvm.cs
Created April 19, 2020 08:40
tvm c#
using System;
namespace LibNative
{
using System.Runtime.InteropServices;
public static partial class libnative
{
/// <summary>
///
@jeremygilly
jeremygilly / thread_test.py
Created March 28, 2020 12:57
Raspberry Pi test code for James
''' Jeremy's test script - 28 Mar 2020.
It creates two threads and waits for both to finish before presenting the results.
Each thread generates random data, but data that is similar to what is expected from the sensor devices.
The results are added to the queue, removed, then presented to the user.
Not completed: writing to '''
import queue, threading, time, random, math, numpy, sys

React Native + macOS + Clojurescript

image

Project Catalyst

Since the recent release of Catalina, macOS has shipped with the ability to allow iOS/iPAD apps to run on macOS without any modification via a featureset known as Project Catalyst.

This is exciting, as writing React Native + Clojurescript apps as a target for the desktop is much more compelling than a pure Electron app (imo).

@ReeseWang
ReeseWang / [email protected]
Created October 13, 2019 10:49
Systemd service file for starting a DHCP server on a specific interface with a separate lease file, modified from the dhcp package from Arch Linux.
[Unit]
Description=IPv4 DHCP server on %i
After=network.target network-online.target
Wants=network-online.target
[Service]
Type=forking
ExecStartPre=/usr/bin/touch /var/lib/dhcp/dhcpd@%i.leases
ExecStart=/usr/bin/dhcpd -4 -q -cf /etc/dhcpd.conf.d/%i.conf -pf /run/dhcpd4/dhcpd@%i.pid -lf /var/lib/dhcp/dhcpd@%i.leases %i
RuntimeDirectory=dhcpd4
@schmee
schmee / assembly.log
Created August 6, 2019 18:53
Vector API in Clojure!
vector_clj/core$i256_add.invoke(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; [0x000000011f8acdc0, 0x000000011f8ad058] 664 bytes
[Entry Point]
[Constants]
# {method} {0x000000013253d3b8} 'invoke' '(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;' in 'vector_clj/core$i256_add'
# this: rsi:rsi = 'vector_clj/core$i256_add'
# parm0: rdx:rdx = 'java/lang/Object'
# parm1: rcx:rcx = 'java/lang/Object'
# [sp+0x30] (sp of caller)
.....
0x000000011f8acec3: prefetchw BYTE PTR [r10+0x180]
@jmlsf
jmlsf / js-in-cljs.md
Last active January 25, 2024 23:15
Using JavaScript modules in ClojureScript

Using JavaScript Libraries from ClojureScript

Using JavaScript libraries from ClojureScript involves two distinct concerns:

  1. Packaging the code and delivering it to the browser
  2. Making ClojureScript code that accesses JavaScript libraries safe for advanced optimization

Right now, the only single tool that solves these probems reliably, optimally, and with minimal configuration is shadow-cljs, and so that is what I favor. In paricular, shadow-cljs lets you install npm modules using npm or yarn and uses the resulting package.json to bundle external dependencies. Below I describe why, what alternatives there are, and what solutions I disfavor at this time.

Packaging and Delivering Code

@mrrodriguez
mrrodriguez / clj-data-fressian-serde.clj
Last active April 3, 2025 14:15
Clojure Serialization With Fressian
;;;; Fressian dependency used in these examples
;; [org.clojure/data.fressian "0.2.1"]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Using only `org.clojure/data.fressian`
(require '[clojure.data.fressian :as fres])
(defn serde-obj
@thegeez
thegeez / spec_parsing.clj
Last active December 30, 2023 18:17
Parsing with clojure.spec for the Advent of Code challenge
(ns net.thegeez.advent.spec-parsing
(:require [clojure.string :as str]
[clojure.spec :as s]
[clojure.spec.gen :as gen]
[clojure.test.check.generators :as tgen]))
;; Dependencies:
;; [org.clojure/clojure "1.9.0-alpha14"]
;; [org.clojure/test.check "0.9.0"]
;; Advent of Code is a series of code challenges in the form of an advent
@BurkeB
BurkeB / microphone.clj
Created October 7, 2016 19:49
Microphone Clojure test
(def audioformat (new javax.sound.sampled.AudioFormat 44100 16 2 true true))
(def info (new javax.sound.sampled.DataLine$Info javax.sound.sampled.TargetDataLine audioformat))
(if (not= (javax.sound.sampled.AudioSystem/isLineSupported info))(print "dataline not supported")(print "ok lets start\n"))
(def line (javax.sound.sampled.AudioSystem/getTargetDataLine audioformat))
(.open line audioformat)
(.start line)
(let [size (/ (.getBufferSize line) 5)
buf (byte-array size)]
@aputs
aputs / jwt.cljs
Created September 21, 2016 02:01
clojurescript JWT encode/decode (SHA version only)
(ns cljsjs.jwt
(:require
[clojure.spec :as s]
[clojure.string :as str]
[goog.json :as json]
[goog.crypt.base64 :refer [encodeString decodeString]]))
;; https://github.com/Caligatio/jsSHA
;; goog.crypt.hmac produces different signature than nodejs version
(def jssha (js/require "jssha"))