Skip to content

Instantly share code, notes, and snippets.

View pbaille's full-sized avatar
🏠
Working from home

Pierre Baille pbaille

🏠
Working from home
  • Freshcode, Ardoq
  • France
View GitHub Profile
@pbaille
pbaille / indentation-helpers.el
Last active March 28, 2023 12:26
bunch of elisp functions to tweak indentation of lisp code
(defun pb/shift-expression (delta)
(setq evil-shift-width 1)
(let ((p (point)))
(evil-shift-right (if (< delta 0) (- p 1) p)
(save-excursion (evil-jump-item))
delta nil)
(goto-char (+ delta p))))
(defun pb/shift-expression-right ()
(interactive)
@pbaille
pbaille / stress_terminus2.clj
Last active October 7, 2021 15:01
stress terminus 2 threads
(require 'clj-http.client)
(def DURATION 10)
(def tics (atom 1))
(def responses (atom []))
(def start (System/currentTimeMillis))
@pbaille
pbaille / stress_terminus.clj
Created October 7, 2021 14:35
stress test terminus
(require 'clj-http.client)
(def DURATION 10)
(def tics (atom []))
(def start (System/currentTimeMillis))
@pbaille
pbaille / quote-question.txt
Last active May 12, 2021 15:21
#lisp IRC discution about quote and quasiquote
I'm wondering if a lisp can have only quasiquote and no regular quote. What would be the downsides ? (sorry if this message appears for the second time, I can't tell if it was posted or not)
beach
Do you mean "no reader macro '", or "no special operator QUOTE"?
_death
`(foo ',bar).. you don't need either of course, (list (quote foo) (list (quote quote) bar))
beach
I think the former is definitely possible. Not so much the latter.
@pbaille
pbaille / rec.clj
Last active December 18, 2020 10:40
lambda recursion
(ns xp.rec)
(do :chapter1
;; clojure
(defn f [x]
(if (zero? x) x (f (dec x))))
;; without recursion
(def f1
{
"Blackhaw Viburnum": "https://caseytrees.org/wp-content/uploads/2017/01/primary_blackhaw_viburnum-293x172-c-default.jpg",
"Crape Myrtle": "https://caseytrees.org/wp-content/uploads/2017/01/primary_crepe_myrtle-293x172-c-default.jpg",
"Cryptomeria": "https://caseytrees.org/wp-content/uploads/2019/07/primary_cryptomeria-293x172-c-default.png",
"American Hornbeam": "https://caseytrees.org/wp-content/uploads/2017/01/primary_american_hornbeam-293x172-c-default.jpg",
"Nuttall Oak": "https://caseytrees.org/wp-content/uploads/2017/01/primary_nuttall_oak-293x172-c-default.jpg",
"Overcup Oak": "https://caseytrees.org/wp-content/uploads/2017/01/primary_overcup_oak-293x172-c-default.jpg",
"Loblolly Pine": "https://caseytrees.org/wp-content/uploads/2017/01/primary_loblolly_pine-293x172-c-default.jpg",
"Pawpaw": "https://caseytrees.org/wp-content/uploads/2017/01/primary_pawpaw-293x172-c-default.jpg",
"Bald Cypress": "https://caseytrees.org/wp-content/uploads/2017/01/primary_baldcypress-293x172-c-default
@pbaille
pbaille / clj-to-md.clj
Created September 5, 2020 13:46
turning a clojure source into an md file
(ns clj-to-md
(:require [clojure.string :as str]))
;; a very crude way to turn a commented clojure file into a markdown file
(defn blocks [s]
(str/split s #"\n\n"))
(defn lines [s]
(str/split s #"\n"))
@pbaille
pbaille / conts.clj
Created June 7, 2020 09:26
delimited continuations with cloroutine
(ns cloroutine.conts
(:require [clojure.test :refer :all]
[cloroutine.core :refer [cr]]))
;; I'm trying to port code from https://en.wikipedia.org/wiki/Delimited_continuation
;; using delimited continuations cloroutine's implementation
(def ^:dynamic *coroutine*)
(def ^:dynamic *result*)
@pbaille
pbaille / matching_records.clj
Last active October 14, 2019 20:08
matching records
(ns matching-records
(:require [clojure.core.match :as m]
[clojure.core.match.protocols :as mp]
[clojure.set :as set]))
;; utils
(defn mksym [& xs]
(symbol (apply str (map name xs))))
@pbaille
pbaille / fn-bench.cljs
Last active November 17, 2018 19:55
cljs fns simple forms benchmark
(simple-benchmark [f (fn [a b c] (+ a b c))]
(f 1 2 3)
1000000) ;; 30ms
(simple-benchmark [f (fn [& xs] (apply + xs))]
(f 1 2 3)
1000000) ;; 1700 ms
(simple-benchmark [f (partial apply +)]
(f [1 2 3])