Skip to content

Instantly share code, notes, and snippets.

@cgrand
cgrand / core.cljc
Last active October 14, 2020 12:18
Mixing macros and code in cljc and supporting clj, cljs and self-hosted cljs, see https://github.com/cgrand/macrovich
;; SEE: https://github.com/cgrand/macrovich
;; macros and code in a single cljc working across clj, cljs and self-hosted cljs
;; require clojurescript from master
(ns foo.core
#?(:cljs (:require-macros
[net.cgrand.meta-macros :refer [macros no-macros]]
[foo.core :refer [add]])
:clj (:require
@cherti
cherti / alert.sh
Created December 9, 2016 13:47
send a dummy alert to prometheus-alertmanager
#!/bin/bash
name=$RANDOM
url='http://localhost:9093/api/v1/alerts'
echo "firing up alert $name"
# change url o
curl -XPOST $url -d "[{
\"status\": \"firing\",
# This ConfigMap is used to configure a self-hosted Calico installation.
# Documentation: http://docs.projectcalico.org/v1.6/getting-started/kubernetes/installation/hosted/
kind: ConfigMap
apiVersion: v1
metadata:
name: calico-config
namespace: kube-system
data:
# Configure this with the location of your etcd cluster.
# etcd_endpoints: "$ETCDENDPOINTS"
(defmacro assert-all
[& pairs]
`(do (when-not ~(first pairs)
(throw (IllegalArgumentException.
(str (first ~'&form) " requires " ~(second pairs) " in " ~'*ns* ":" (:line (meta ~'&form))))))
~(let [more (nnext pairs)]
(when more
(list* `assert-all more)))))
(defmacro when-let*
@purp
purp / rbenv-copy-gems.rb
Created July 7, 2016 16:01
rbenv: install all gems from one version to another
#!/bin/bash
# copy is a misnomer; it's actually LIST + INSTALL
# --from 2.2.1 [--to other-version-else-whatever-is-currently-set]
#
# TODO: install only most-recent version that's installed in FROM
# TODO: use gem names only from FROM, install latest available version (might be more recent than in FROM)
# TODO: pass arguments to gem command (e.g. --no-document)
CURRENT_VERSION=`rbenv version | cut -d' ' -f1`
GEM_LIST_ARGS="--local"
@Deraen
Deraen / spec-coercion.clj
Created June 14, 2016 15:47
Clojure.spec coercion test
(ns spec-test.core
(:require [clojure.spec :as s]))
(defn x-integer? [x]
(if (integer? x)
x
(if (string? x)
(try
(integer/parseint x)
(catch exception e
(ns lcm.utils.jython
"This NS has functionality for interop between jython and clojure"
(:require [clojure.tools.logging :as log]
[clojure.pprint :refer [pprint]]
[slingshot.slingshot :refer [throw+ try+]])
(:import [org.python.core
Py
JyAttribute
PyString
PyInteger
@joepie91
joepie91 / .md
Last active July 8, 2021 18:07
Batch-migrating Gitolite repositories to Gogs

NOTE: This will only work if you are an administrator on your Gogs instance, or if an administrator has enabled local repository importing for all users.

First, save the following as migrate.sh somewhere, and make it executable (chmod +x migrate.sh):

HOSTNAME="git.cryto.net"
BASEPATH="/home/git/old-repositories/projects/joepie91"

OWNER_ID="$1"
CSRF=`cat ./cookies.txt | grep _csrf | cut -f 7`
(def-map-type MapLayer [hm dissoced m mta]
(get [_ k default-value]
(let [v (get m k ::none)]
(if (= v ::none)
(if (contains? dissoced k)
default-value
(get hm k default-value))
v)))
(assoc [_ k v]
(MapLayer. hm (disj dissoced k) (assoc m k v) mta))
@sax
sax / postgresql.conf
Created December 9, 2015 19:37
PostgreSQL configuration
# -----------------------------
# PostgreSQL configuration file
# -----------------------------
#
# This file consists of lines of the form:
#
# name = value
#
# (The "=" is optional.) Whitespace may be used. Comments are introduced with
# "#" anywhere on a line. The complete list of parameter names and allowed