Skip to content

Instantly share code, notes, and snippets.

import operator
import re
def pairs(l):
return zip(l[::2], l[1::2])
def vm(ops, env={}):
class closure:
def __init__(self, pc, env): self.pc, self.env = pc, env
def popn(n):
@jonasrosland
jonasrosland / docker-swarm-data-persistence.md
Last active August 23, 2020 02:19
Use Docker Swarm with a data persistence layer

Use Docker Swarm with a data persistence layer

Create a Docker Swarm discovery token

curl -X POST https://discovery.hub.docker.com/v1/clusters
YOURSWARMTOKEN

Export the correct environment variables

@flaccid
flaccid / gist:97473d0d85e2d6f4e292
Created July 23, 2015 07:00
Quick example of blue/green app ugprade on Rancher
$ export RANCHER_HOST=foo.bar.suf
$ export RANCHER_PORT=8080
$ export RANCHER_PROJECT_ID=1a8
$ export RANCHER_STACK_NAME=killerapp
$ ./cattle-deploy.py
output:
snapshot epoch is1437634695
created temp file /var/folders/sx/ht6gznq979v5r725sqt7_p617p38sz/T/tmpprzZsd
@ohanhi
ohanhi / frp.md
Last active May 6, 2024 05:17
Learning FP the hard way: Experiences on the Elm language

Learning FP the hard way: Experiences on the Elm language

by Ossi Hanhinen, @ohanhi

with the support of Futurice 💚.

Licensed under CC BY 4.0.

Editorial note

@kwmiebach
kwmiebach / pytest.md
Last active April 18, 2025 16:10 — forked from amatellanes/pytest.sh
pytest cheat sheet

Usage

(Create a symlink pytest for py.test)

pytest [options] [file_or_dir] [file_or_dir] ...

Help:

@lewisd32
lewisd32 / iptableflip.sh
Created April 15, 2015 18:20
Snippet of Unbounce script for restarting HAProxy with zero downtime
echo "Flipping tables! (╯°□°)╯︵ ┻━┻"
num_rules=3
real=3 # exposed to the ELB as port 443
test=4 # used to install test certs for domain verification
health=5 # used by the ELB healthcheck
blue_prefix=855
green_prefix=866
@rodneyrehm
rodneyrehm / gist:40e7946c0cff68a31cea
Last active March 12, 2025 19:23
Diagrams for Documentation

some tools for diagrams in software documentation

Diagrams For Documentation

Obvious Choices

ASCII

@amatellanes
amatellanes / pytest.sh
Last active December 12, 2024 07:19
Useful py.test commands.
py.test test_sample.py --collect-only # collects information test suite
py.test test_sample.py -v # outputs verbose messages
py.test -q test_sample.py # omit filename output
python -m pytest -q test_sample.py # calling pytest through python
py.test --markers # show available markers
@john2x
john2x / 00_destructuring.md
Last active April 10, 2025 15:15
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@jafingerhut
jafingerhut / inputstream.clj
Created July 8, 2014 15:01
Example of reading java.io.InputStream in Clojure
(ns inputstream.core
(:require [clojure.java.io :as io]))
(defn read-is [^java.io.InputStream is]
(let [bufsize 8192
buf (byte-array bufsize)]
(loop [total-len 0]
(let [n (.read is buf)]
(cond