Skip to content

Instantly share code, notes, and snippets.

Stig Lindqvist stojg

Block or report user

Report or block stojg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stojg
stojg / slowpoke.go
Created Dec 16, 2017
go program to run after a slow process, which sends you a text so that you know when it's finished
View slowpoke.go
// 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 / Features.php
Created Apr 5, 2017
Playing around with features
View Features.php
<?php
// could be abstract class?
interface FeatureInterface {
function isSupported();
}
interface LetmeinInterface extends FeatureInterface {
function letmein($username, $password);
}
@stojg
stojg / rm-corrupt.sh
Last active Oct 4, 2016 — forked from codepunkt/rm-corrupt.sh
find/delete corrupt whisper-files
View rm-corrupt.sh
#!/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;;
@stojg
stojg / mini_statemachine.js
Last active Oct 10, 2016
a mini example on how to implement a state machine for transitioning between states, like a user flow
View mini_statemachine.js
// 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
View anonymiser.go
package main
import (
"fmt"
"io"
"math/rand"
"os"
"path"
"path/filepath"
"sort"
View hello
-----BEGIN CERTIFICATE-----
MIIDQzCCAiugAwIBAgIJAJp4tvc4WSmQMA0GCSqGSIb3DQEBCwUAMDgxCzAJBgNV
BAYTAk5aMSkwJwYDVQQDDCBhZDEuZGMuY3dwLndndG4uc2lsdmVyc3RyaXBlLmNv
bTAeFw0xNjA2MjcwMjU2MTRaFw0xNzA2MjcwMjU2MTRaMDgxCzAJBgNVBAYTAk5a
MSkwJwYDVQQDDCBhZDEuZGMuY3dwLndndG4uc2lsdmVyc3RyaXBlLmNvbTCCASIw
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMcKuK7H0pRzslSwDu9X3yMA7QIv
qAo/gOmjdPTmOjC3a6bLJEFgO8+RHOC+p2WvttGvLQqKOP2H4L1yqD+yNHpfSQAL
6bqq7byUPm4MFMgmx6LD+LaQWii7b9awLOJ8cxZ+d6wmYxcIkY1SDOjO2jpYz6pS
DMknsuWXcJfDejyl4MyRMZGyW46iPxi6jg+eMTsX6CeHjPIHBdg9g6YZvG++fRI3
Vbm4LB/fz3GNQBkq0VAWTuVp9e4ymVyAXEIrs/GSYt7mqFnVDL8bhgXBIhEA2VZ+
@stojg
stojg / sleep_server.go
Created Mar 16, 2016
Sleep server, connects, but takes ages to respond
View sleep_server.go
package main
import(
"fmt"
"net/http"
"log"
"time"
"flag"
)
@stojg
stojg / sleep.ino
Last active May 6, 2019
Arduino sleep example
View sleep.ino
#include "Arduino.h"
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>
// Blink Before sleeping
#define LED_PIN (13)
// This variable is made volatile because it is changed inside
// an interrupt function
@stojg
stojg / clean_whisper.sh
Created Feb 3, 2016
delete corrupted graphite whisper files
View clean_whisper.sh
#!/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;;
@stojg
stojg / curl.php
Last active Aug 29, 2015
simple curl template
View curl.php
<?php
function get($url) {
$timeout = 2;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
You can’t perform that action at this time.