Skip to content

Instantly share code, notes, and snippets.

@dapithor
dapithor / bash-template.sh
Last active October 28, 2022 20:52
Best practices for bash
#!/usr/bin/env bash
# https://github.com/ralish/bash-script-template
#{{{ Bash settings
# shorthand: set -euo pipefail ...
# Only enable these shell behaviours if we're not being sourced
# Approach via: https://stackoverflow.com/a/28776166/8787985
if ! (return 0 2> /dev/null); then
# A better class of script...
set -o errexit # Exit on most errors (see the manual)
@dapithor
dapithor / lmdb.tcl
Created May 2, 2017 04:48 — forked from antirez/lmdb.tcl
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <[email protected]>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@dapithor
dapithor / main.go
Created October 19, 2016 05:08 — forked from julz/main.go
containersched minicontainer
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {
@dapithor
dapithor / replify
Last active August 20, 2016 19:09 — forked from postpostscript/ replify
replify - Create a REPL for any command
#!/bin/sh
command="${*}"
printf "Initialized REPL for [%s]\n" "$command"
printf "%s> " "$command"
read -r input
while [ "$input" != "" ];
do
eval "$command $input"
printf "\n%s> " "$command"
@dapithor
dapithor / keybase-proof.txt
Created February 5, 2016 01:34
keybase proof
### Keybase proof
I hereby claim:
* I am dapithor on github.
* I am dapithor (https://keybase.io/dapithor) on keybase.
* I have a public key whose fingerprint is 53E2 4859 A7A7 96CB 14A7 8B46 C4F7 404B 381E 78E4
To claim this, I am signing this object:
@dapithor
dapithor / gpg-offline-master.md
Created December 9, 2015 01:24 — forked from abeluck/gpg-offline-master.md
GPG Offline Master Key w/ smartcard
@dapithor
dapithor / consul.coffee
Created November 23, 2015 23:49 — forked from tfhartmann/consul.coffee
work in progress on a consul hubot script
# Description:
# Query Consul with Hubot
#
# Commands:
# hubot consul datacenters - Show Datacenters
# hubot consul services - Show Services
# hubot consul service <servicename> - Show Detailed info about a service
#
# Notes:
# They are commented out by default, because most of them are pretty silly and
@dapithor
dapithor / xpub-xsub.js
Created October 21, 2015 17:00 — forked from tjanczuk/xpub-xsub.js
How to connect 5 publishers with 5 subscribers over TCP using ZeroMQ's XPUB/XSUB proxy
// How to connect 5 publishers with 5 subscribers
// over TCP using ZeroMQ's XPUB/XSUB proxy.
// sub (connect)
// <-8701->
// (bind) xpub <---> xsub (bind)
// <-8700->
// (connect) pub
var zmq = require('zmq');
@dapithor
dapithor / zcurve-poc.c
Created October 19, 2015 23:32 — forked from hintjens/zcurve-poc.c
zcurve -- CurveCP over ZeroMQ -- proof of concept
// Proof of concept CurveCP handshake over 0MQ.
//
// Demonstrates a confidential, authenticated connection between
// two 0MQ peers (two DEALER sockets in this example). See the
// curvecp.org website for details of the security design.
//
// This is a flat walk-through in code with minimal abstraction.
// The next version of this code will be more packaged.
//
// IMPORTANT NOTE: this code has not been reviewed by security experts
@dapithor
dapithor / philips.huelabs.connector.js
Created October 5, 2015 17:25 — forked from PhilipsHueLabs/philips.huelabs.connector.js
Philips HueLabs connection Javascript
/*** Example connection ***/
Philips.connect({
bridge_username: "philips-huelabs",
bridge_ipaddress: "192.168.0.1",
success: function(res){
console.log(res);
},
fail: function(res){
//