Skip to content

Instantly share code, notes, and snippets.

curl 'http://localhost:15672/api/queues' | jq '.[].name' | xargs -I{} curl -X DELETE 'http://localhost:15672/api/queues/%2F/{}/contents'
@fabienhinault
fabienhinault / dice29.bash
Created March 31, 2018 18:28
generates random digits in 2-9 as you type enter. Useful for practicing multiplication. type any char, then enter and it stops.
while read line
do
if [ -z "$line" ]
then
cat /dev/urandom | tr -dc '2-9' | head -c 1
else
break
fi
done < /dev/tty
tmpfile=$(mktemp /tmp/gitlogXXXXXX.txt); for d in ./*; do echo "#######$d" >> $tmpfile; git -C $d log >> $tmpfile; done; grep -n "\(######\)\|\(marker\)" $tmpfile
@fabienhinault
fabienhinault / jq_help.yml
Last active February 17, 2025 13:45
complementary help on jq
body: |
Manual id at
https://github.com/stedolan/jq/blob/master/docs/content/3.manual/manual.yml
sections:
- title: "\"id\": null is equivalent to no \"id\""
examples:
(define-syntax (hyphen-define/0.9 stx)
(let* [(l (syntax->datum stx))
(a (second l))
(b (third l))
(args (fourth l))
(body (cddddr l))
(name (string->symbol (format "~a-~a" a b)))]
(datum->syntax stx `(define (,name . ,args) ,@body))))
# m h dom mon dow command
0 * * * * for d in ~/projetcs/*/git/* ; do echo $d; if [ $(git -C $d symbolic-ref --short HEAD | grep develop) ] ; then git -C $d pull --ff-only ; else git -C $d fetch ; fi ; done
# https://github.com/stedolan/jq/blob/master/src/builtin.jq
# https://github.com/stedolan/jq/blob/ca12bd9b5d15c0c4e5bd01d706ddbb3f4edefd36/src/builtin.jq
# Apply f to composite entities recursively, and to atoms
def walk(f):
. as $in
| if type == "object" then
reduce keys_unsorted[] as $key
( {}; . + { ($key): ($in[$key] | walk(f)) } ) | f
elif type == "array" then map( walk(f) ) | f
else f
#!/bin/bash
printf '%s000\n' $(date -d "$*" "+%s")
@fabienhinault
fabienhinault / showff.bash
Created December 20, 2017 12:18
show a json file in a firefox tab
#!/bin/bash
mkdir -p /tmp/showff
tmpfile=$(mktemp /tmp/showff/XXXXXX.json)
cat - > $tmpfile
firefox -new-tab $tmpfile
#lang racket
(define-syntax-rule (let1 a b body ...)
(let ((a b)) body ...))
(require rackunit)
; convert a number n to the list of boolean of its binary writing
(define (number->bools n size)
(define (iter n size result)