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 / Features.php
Created Apr 5, 2017
Playing around with features
View Features.php
// could be abstract class?
interface FeatureInterface {
function isSupported();
interface LetmeinInterface extends FeatureInterface {
function letmein($username, $password);
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
stojg /
Last active Oct 4, 2016 — forked from codepunkt/
find/delete corrupt whisper-files
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;;
View anonymiser.go
package main
import (
stojg / ContentAwareImage.php
Created Apr 23, 2012
Testing content aware cropping for SilverStripe Idea is that the automatic cropping will crop the most interesting part of the image
View ContentAwareImage.php
* ContentAwareImage
* @author stig
class ContentAwareImage {
protected static $start_time = 0.0;
View hello
stojg / parse.php
Last active Jun 23, 2016
simple parsing of aws cloudtrail logs
View parse.php
$files = glob("*.json");
foreach($files as $file) {
$content = file_get_contents($file);
$data = json_decode($content, true);
if(!isset($data['Records'])) {
stojg / sleep_server.go
Created Mar 16, 2016
Sleep server, connects, but takes ages to respond
View sleep_server.go
package main
stojg /
Created Feb 3, 2016
delete corrupted graphite whisper files
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 / MockStaticTest.php
Last active Dec 27, 2015
An example on how to test a static function call in SilverStripe using the Injection system, see discussion at!topic/silverstripe-dev/f9agsTc3iJo
View MockStaticTest.php
class MockStaticTest extends FunctionalTest {
function foo() {
// Since Director doesnt extends Object, you have to do it like this, otherwise
// Director::create() should return an Injected Director
$director = Injector::inst()->get('Director');
$director::forceSSL(array('/^Security/', '/^api/'));
You can’t perform that action at this time.