Skip to content

Instantly share code, notes, and snippets.

View stojg's full-sized avatar

Stig Lindqvist stojg

View GitHub Profile
@stojg
stojg / consul
Created December 1, 2014 04:51
consul service init script for debian
#!/bin/sh
### BEGIN INIT INFO
# Provides: consul
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Consul service discovery framework
# Description: Healthchecks local services and registers
# them in a central consul database.
@stojg
stojg / keybase.md
Created April 1, 2020 03:50
keybase.md

Keybase proof

I hereby claim:

  • I am stojg on github.
  • I am stojg (https://keybase.io/stojg) on keybase.
  • I have a public key ASB_XpPl1n_gZ9b6be0KAUwCV7CHuGWXj0UFJGnJhESWjQo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am stojg on github.
  • I am stojg (https://keybase.io/stojg) on keybase.
  • I have a public key ASAXrGdkyAeTpbLy6bmEMZ3sDC0S3HVnfR0m1p5ujhJcMgo

To claim this, I am signing this object:

@stojg
stojg / Flowdock.php
Last active January 24, 2018 21:31
<?php
/**
* Send an message to a Flowdock "flow".
*
* # Initialization:
* <code>
* $fd = new Flowdock();
* $fd->setToken('asdadsads');
* </code>
*
@stojg
stojg / Flowdock.php
Created November 5, 2013 22:27
Sending a message via php and curl to a flowdock "flow"
<?php
/**
* Send an message to a Flowdock "flow".
*
* # Initialization:
* <code>
* $fd = new Flowdock();
* $fd->setToken('asdadsads');
* </code>
*
@stojg
stojg / slowpoke.go
Created December 16, 2017 02:15
go program to run after a slow process, which sends you a text so that you know when it's finished
// This golang program is a remix/parody of https://gist.github.com/mrmorphic/7cb86c7b1a5e3da9d8664d6e8a1e3518
// that notifies the user that notifies a user after a slow process have finished, but instead of using the computers
// speech synthesiser or notification system, sends you a text instead. This means that you can leave the safe confines
// of your desk while scavenging office supplies, stalk colleagues or have a quiet smoko. I.e. it's the 2020 version of
// https://xkcd.com/303/. Ideal for those dependency fetching / compiling steps.
//
// To make this work you need to at least setup a `https://www.twilio.com` trial account and define a couple ENV
// variables:
//
// # Get this from your twilio account
@stojg
stojg / Cache_Stamped_example.php
Created July 20, 2014 11:21
Cache Stampede example
<?php
/**
* Cache stampede protection examples
*/
class cache
{
/**
* @var array
@stojg
stojg / Features.php
Created April 5, 2017 00:27
Playing around with features
<?php
// could be abstract class?
interface FeatureInterface {
function isSupported();
}
interface LetmeinInterface extends FeatureInterface {
function letmein($username, $password);
}
@stojg
stojg / mini_statemachine.js
Last active October 10, 2016 04:22
a mini example on how to implement a state machine for transitioning between states, like a user flow
// these are generic functions that return boolean depending of the state in data
// they are used by state transitions to progress the state machine
const hasStarted = (data) => data.started === true;
const isEmployee = (data) => data.employee === true;
const isPersonal = (data) => data.personal === true;
// this is where we set up the full statemachine and connect 'from' states (e.g "initState") and where
// they can transition to (e.g. "setTypeState") and what would trigger that transition
const transitions = {
// initial state
@stojg
stojg / rm-corrupt.sh
Last active October 4, 2016 05:27 — forked from codepunkt/rm-corrupt.sh
find/delete corrupt whisper-files
#!/bin/bash
options=('find' 'delete')
PS3='state your wish: '
echo -e "\nfind/delete corrupt whisper-files"
select opt in "${options[@]}"; do
case $REPLY in
[12] ) option=$opt; break;;
* ) exit;;