Skip to content

Instantly share code, notes, and snippets.

@apeckham
apeckham / .clj
Last active February 19, 2025 08:17
find free port in clojure
(defn get-free-port []
(with-open [socket (ServerSocket. 0)]
(.getLocalPort socket)))
const pipeline = (...fns) => (val) => fns.reduce((prom, fn) => prom.then(fn), Promise.resolve(val));
const myPipe = pipeline(
(val) => val + 1,
(val) => val + 1
);
Promise.resolve(1)
.then(myPipe)
.then((result) => {
@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active April 2, 2025 11:18
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@rauchg
rauchg / README.md
Last active January 6, 2024 07:19
require-from-twitter
@jackrusher
jackrusher / core.cljs
Last active June 4, 2021 19:59
The simplest possible @thing_clj physics + @Quilist demo
(ns gumball-machine.core
(:require [thi.ng.color.core :as col]
[thi.ng.math.core :as m]
[thi.ng.geom.core :as g]
[thi.ng.geom.core.vector :refer [vec3]]
[thi.ng.geom.physics.core :as ph]
[thi.ng.geom.sphere :refer [sphere]]
[quil.core :as q :include-macros true]))
(def particles
@ElijahLynn
ElijahLynn / pipe_to_docker_examples
Last active July 2, 2024 01:27
How to pipe to `docker exec` examples
# These examples assume you have a container currently running.
# 1 Pipe from a file
sudo docker exec --interactive CONTAINER_NAME /bin/bash < the_beginning.sh | tee the_beginning_output.txt`
#2a Pipe by piping
echo "echo This is how we pipe to docker exec" | sudo docker exec --interactive CONTAINER_NAME /bin/bash -
@msgodf
msgodf / condition-systems.md
Created December 15, 2015 08:23
Condition Systems in an Exceptional Language by Chris Houser

Condition Systems in an Exceptional Language by Chris Houser

I recently watched Chris Houser's talk from Clojure/conj 2015 on condition systems in Clojure. I enjoyed the subject, so I decided to write up the talk as a way of encouraging me to really understand it, and in the hope that it might help others understand it.

The last time I heard about Common Lisp's condition system was at a talk by Didier Verna at ACCU in Bristol in 2013 (slides here). It sounded really interesting, but I didn't understand it well enough.

tl;dr

Chris Houser talks about different ways of handling errors in Clojure. Based on examples from Peter Seibel's book, Practical Common Lisp, he describes condition systems, which are also known as resumable exceptions, or restarts.

-- paste into http://elm-lang.org/try and click "compile"
-- http://imgur.com/gallery/W6TwgZw
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Text
import Color exposing (..)
import Time
import Signal
@rf-
rf- / nvim-client
Last active December 9, 2024 06:07
#!/usr/bin/env python
import pynvim, os, re, sys, time
# Get a list of buffers that haven't been deleted. `nvim.buffers` includes
# buffers that have had `:bdelete` called on them and aren't in the buffer
# list, so we have to filter those out.
def get_listed_buffers(nvim):
return set(buf.number for buf in nvim.buffers \
if nvim.eval('buflisted(%d)' % buf.number))