Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
RichardBronosky / mkpasswd.py
Last active February 15, 2024 12:35
Platform independant what of generating Linux compatible crypt(3) sha512 hashes ($6$ style). For systems (like macOS/OSX) where you can't `mkpasswd -m sha-512`.
#!/usr/bin/env python3
# Because OSX doesn't have mkpasswd...
# Based on https://stackoverflow.com/a/17992126/117471
# python3 -c "from passlib.hash import sha512_crypt; print(sha512_crypt.encrypt(input()))" <<< bruno # NOQA
# Usage:
#
# $ ./mkpasswd.py
@abraithwaite
abraithwaite / config.go
Created March 15, 2017 03:03
Awesome way to do configuration in go. Taken from https://github.com/influxdata/telegraf
package main
import (
"io/ioutil"
"log"
"github.com/naoina/toml"
"github.com/naoina/toml/ast"
)
@bobbytables
bobbytables / build.sh
Created February 18, 2017 15:49
Protocol Buffer build script for multiple folders
#!/usr/bin/env bash
# This script is meant to build and compile every protocolbuffer for each
# service declared in this repository (as defined by sub-directories).
# It compiles using docker containers based on Namely's protoc image
# seen here: https://github.com/namely/docker-protoc
set -e
REPOPATH=${REPOPATH-/opt/protolangs}
CURRENT_BRANCH=${CIRCLE_BRANCH-"branch-not-available"}
@001101
001101 / accounting.sql
Created February 18, 2017 09:08 — forked from NYKevin/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...
@abacaphiliac
abacaphiliac / run-kafka-container.md
Last active January 21, 2024 12:10
Run Kafka Container

Start Kafka service

The following commands will start a container with Kafka and Zookeeper running on mapped ports 2181 (Zookeeper) and 9092 (Kafka).

docker pull spotify/kafka
docker run -d -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=kafka --env ADVERTISED_PORT=9092 --name kafka spotify/kafka

Why Spotify?

ADVERTISTED_HOST was set to kafka, which will allow other containers to be able to run Producers and Consumers.

@skarllot
skarllot / Makefile.makefile
Created May 3, 2016 21:24
Makefile to merge coverage data from all subpackages (Golang)
.PHONY: test-cover-html
PACKAGES = $(shell find ./ -type d -not -path '*/\.*')
test-cover-html:
echo "mode: count" > coverage-all.out
$(foreach pkg,$(PACKAGES),\
go test -coverprofile=coverage.out -covermode=count $(pkg);\
tail -n +2 coverage.out >> coverage-all.out;)
go tool cover -html=coverage-all.out
@pierophp
pierophp / index.html
Last active December 30, 2021 10:59
Communication Between Tabs With Shared Worker
<html>
<body>
<a id="worker-message" href="javascript:void(0)">Send Message</a>
<script src="test.js"></script>
</body>
</html>
// Require all .js and .jsx files inside tree
let reactFiles = require.context("./components", true, /^(.*\.(jsx?$))[^.]*$/igm);
reactFiles.keys().forEach(function(key){
reactFiles(key);
});
@drmalex07
drmalex07 / README-python-service-on-systemd-activated-socket.md
Last active January 20, 2025 10:48
An example network service with systemd-activated socket in Python. #systemd #python #socket #socket-activation

README

The example below creates a TCP server listening on a stream (i.e. SOCK_STREAM) socket. A similar approach can be followed to create a UDP server on a datagram (i.e. SOCK_DGRAM) socket. See man systemd.socket for details.

An example server

Create an simple echo server at /opt/foo/serve.py.

@iamralch
iamralch / golang_pprof.go
Last active June 23, 2020 03:22
A code snippet that demonstrates how to use custom pprof profiles
package main
import (
"bufio"
"fmt"
"net/http"
pprofHTTP "net/http/pprof"
"os"
"runtime/pprof"
"strings"