Skip to content

Instantly share code, notes, and snippets.

View philippkueng's full-sized avatar

Philipp Küng philippkueng

View GitHub Profile
@borkdude
borkdude / 1) bb.edn
Last active January 25, 2023 23:52
Work bb.edn files
{:tasks {:requires ([babashka.fs :as fs])
:init (do (when (seq (fs/modified-since "deps.edn"
["deps.template.edn"
"../base/deps.edn"]))
(shell {:dir ".."} "script/gen-deps.clj")))
;; Maintenance tasks
install {:doc "Install frontend dependencies from NPM"
:task (shell "npm install")}
clean {:doc "Clean all artifacts"
@holyjak
holyjak / http-server.bb
Last active March 19, 2023 04:36
Babashka HTTP server for serving static files, similar to `python -m http.server` but more flexible :)
#!/usr/bin/env bb
#_" -*- mode: clojure; -*-"
;; Based on https://github.com/babashka/babashka/blob/master/examples/image_viewer.clj
(ns http-server
(:require [babashka.fs :as fs]
[clojure.java.browse :as browse]
[clojure.string :as str]
[clojure.tools.cli :refer [parse-opts]]
[org.httpkit.server :as server]
@TronPaul
TronPaul / AttributeFactoryHelpers.java
Created February 27, 2020 06:07
Substitutions needed to run Lucene 8.4.1 on a GraalVM native image
package org.apache.lucene.util;
import java.lang.reflect.Constructor;
import java.lang.reflect.UndeclaredThrowableException;
public final class AttributeFactoryHelpers {
static final AttributeFactory DEFAULT = new DefaultAttributeFactory();
static final Constructor<? extends AttributeImpl> findAttributeImplCtor(Class<? extends AttributeImpl> clazz) {
try {
@ozbillwang
ozbillwang / Git_Behind_Proxy.md
Last active April 20, 2024 15:58
Configure Git to use a proxy (https or SSH+GIT)
@ordnungswidrig
ordnungswidrig / microweb.cljs
Created December 10, 2019 11:12
Webserver in clojurescript on espruino
(set! *warn-on-infer* true)
(def ^js wifi (js/require "Wifi"))
(def ^js http (js/require "http"))
(def n (atom 0))
(defn build-response []
(str
"<html>"
@mfikes
mfikes / ESP32-REPL.md
Last active July 6, 2022 22:32
ClojureScript REPL into ESP32

To set up a REPL that has cljs.core available, we need to re-partition the ESP32 and allocate more memory in Espruino for "JsVars".

The default Espruino bootloader.bin, pre-built variants of partitions_esprinuo.bin and rebuilt espruino_esp32.bin, and the ClojureScript runtime core.bin are also available here.

bootloader.bin gets flashed to 0x1000, partitions_espruino.bin gets flashed to 0x8000, and espruino_esp32.bin gets flashed to 0x10000 as per a usual ESP32 Espruino setup, and we put the ClojureScript runtime at 0x2C0000:

theory
Consensus_Demo
imports
Network
begin
datatype 'val msg
= Propose 'val
| Accept 'val
@holyjak
holyjak / monitor-usage.sh
Last active February 14, 2023 14:03
Script to monitor the usage of CPU, memory by a process via `top`
#!/bin/sh
##
## BEWARE: Check with your impl. of top what exactly it returns, it migth differ from mine
##
# Usage: ./monitor-usage.sh <PID of the process>
# Output: top.dat with lines such as `1539689171 305m 2.0`, i.e. unix time - memory with m suffix - CPU load in %
# To plot the output, see https://gist.github.com/holyjak/1b58dedae3207b4a56c9abcde5f3fdb5
export PID=$1
rm top.dat
while true; do top -p $PID -bn 1 -em | egrep '^ *[0-9]+' | awk -v now=$(date +%s.%N) '{print now,$6,$9}' >> top.dat; done
@rbnpi
rbnpi / SequencerReadMe.md
Last active November 13, 2022 21:26
Sonic Pi and TouchOSC Sequencer Instructions in readme file. Acompanying article at https://rbnrpi.wordpress.com/sonic-pi-and-touchosc-sequencer/ Video available at https://youtu.be/FrAGd6vbQuQ

UPDATED NOVEMBER 13th 2022 for new format OSC message parsing introduced in Sonic Pi Feb 2020 Use the file Sequencer2.0-RF.rb for Sonic Pi >= 3.2. which uses the new format

The index.xml file will still work, but once you hav it loaded you may like to amend the top label to Sonic Pi Sequencer 2 by Robin Newman, but this is purely cosmetic and not essential

For convenience I have added 4 specimen json files seq1.json to seq4.json which you can use. You can generate your own otherwise using the write commands in the interface. The location of these files is specified in the program. Adjust to suit your own requirements.

orginal ReadMe text follows

@comnik
comnik / policing.clj
Created June 25, 2018 22:22
Applying access policies to Datomic queries.
(require '[datomic.api :as d])
(def uri "datomic:mem://policing")
(d/create-database uri)
(def conn (d/connect uri))
;; We are managing classified documents.
(def schema
[{:db/ident :level/rank