Skip to content

Instantly share code, notes, and snippets.

View sebble's full-sized avatar

Sebastian Mellor sebble

  • Sebble.com
  • Newcastle upon Tyne
View GitHub Profile
@sebble
sebble / main.go
Last active November 13, 2021 18:03
An idea for capturing context of errors in go for better logging
package main
import (
"errors"
"fmt"
"os"
"github.com/go-kit/log"
)
@sebble
sebble / .bash_aliases
Last active February 19, 2017 11:16
Dokku 'alias' for host running Dokku as a container
dokku() { docker exec -i "$(docker ps|awk '$2=="sebble/dokku"{print $1}'|head -1)" sudo dokku "$@"; }
@sebble
sebble / run_per.sh
Created February 6, 2017 13:03
Run a shell script only once per time interval
#!/bin/sh
# Configuration
INTERVAL=10 # (seconds)
LASTRUN=".lastrun" # (optional)
# Run_per logic
NOW=$(date +%s)
test -f "$LASTRUN" && THEN=$(cat "$LASTRUN") || THEN=0
test $INTERVAL -gt $(($NOW - $THEN)) && exit 0
@sebble
sebble / stars.sh
Last active February 17, 2024 16:49
List all starred repositories of a GitHub user.
#!/bin/bash
USER=${1:-sebble}
STARS=$(curl -sI https://api.github.com/users/$USER/starred?per_page=1|egrep '^Link'|egrep -o 'page=[0-9]+'|tail -1|cut -c6-)
PAGES=$((658/100+1))
echo You have $STARS starred repositories.
echo
@sebble
sebble / index.html
Last active October 25, 2016 11:23
<!doctype html>
<meta charset=utf-8>
<title>THEAD</title>
<!-- Basic Style -->
<style>
table {
font-size: 3rem;
}
th, td {
import { Component } from '@angular/core';
import { NginxlogService } from './nginxlog.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app works!';
dotdotdot() { while sleep ${1:-10};do echo -n .;done; }
@sebble
sebble / server.py
Last active September 20, 2016 14:05
Best match gist redirection (no cache, no rate-limit protection)
#!/usr/bin/env python
from SimpleHTTPServer import SimpleHTTPRequestHandler
from SocketServer import TCPServer
from requests import get
from os import environ
cache = {}
user = environ.get('GITHUB_USERNAME','sebble')
def find(key):
@sebble
sebble / index.html
Last active September 20, 2016 13:37
Simple demo of almost-native ES and module loading
<!doctype html>
<meta charset=utf-8>
<title>ES6+Loaders</title>
<script data-main=./index>/*Stuk/require1k*/R=function(e,n,v1){function t(e,o,u,a){if(e.g)return o(e.e,e);var c=e.g=e.l,f=new XMLHttpRequest;f.onload=function(i,l){function s(){l--||o(n,e)}200==f.status||e.t?(i=[],(e.t=e.t||f.response).replace(/(?:^|[^\w\$_.])require\s*\(\s*["']([^"']*)["']\s*\)/g,function(e,n){i.push(n)}),l=i.length,i.map(function(o){t(r(e.l,o),s,"."!=o[0]?c+"/../":n,o)}),s()):u?t(e.n=r(u+="../",a),o,u,a):(e.e=f,o(f,e))},e.t?f.onload():(f.open("GET",c,!0),f.send())}function r(e,n,t){if(e.e)throw e.e;return n?(f.href=e,i.href="."!=n[0]?"./node_modules/"+n:n,t=i.href+".js",f.href="",u[t]=u[t]||{l:t}):e.n?r(e.n):(e[c]||(e.f||a("(function(require,"+c+",module){"+e.t+"\n})//# sourceURL="+e.l))(function(n){return r(r(e.l,n))},e[c]={},e),e[c])}function o(e,n){t(e.call?{l:"",t:""+e,f:e}:r("",e),function(t,o){try{e=r(o)}catch(u){t=u}n&&n(t,e)})}var u={},a=eval,c="createElement",f=e[c]("base"),i=e[c]("a");return e.head.appendChild(f),c=e
@sebble
sebble / README.md
Last active September 6, 2016 10:40
Bootstrap environment variables from `.env` file in Python 3

Storing application variables in a 'hidden' file called .env?

Need to load these variables for dev/testing but didn't start jupyter notebook with them already exported?

Just drop the following into a Python 3 cell.