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 / remove-tmp-db.php
Created Jun 13, 2012
Remove SilverStripe test databases
View remove-tmp-db.php
<?php
/**
* This script will drop all the databases that contains this string 'tmpdb'.
* Those databases are likely to be left over from a SilverStripe test run
* Usage: Make sure you change the db connection string below and run the
* script like:
* php remove-tmp-db.php
*/
// Change this to your db connection
@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 / 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
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;;
View anonymiser.go
package main
import (
"fmt"
"io"
"math/rand"
"os"
"path"
"path/filepath"
"sort"
@stojg
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
<?php
/**
* ContentAwareImage
*
* @author stig
*/
class ContentAwareImage {
protected static $start_time = 0.0;
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 / parse.php
Last active Jun 23, 2016
simple parsing of aws cloudtrail logs
View parse.php
<?php
$files = glob("*.json");
foreach($files as $file) {
$content = file_get_contents($file);
$data = json_decode($content, true);
if(!isset($data['Records'])) {
continue;
}
@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 / 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;;
You can’t perform that action at this time.