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
["Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Åland","Azerbaijan","Bosnia and Herzegovina","Barbados","Bangladesh","Belgium","Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Saint Barthélemy","Bermuda","Brunei","Bolivia","Bonaire","Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos [Keeling] Islands","Congo","Central African Republic","Republic of the Congo","Switzerland","Ivory Coast","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica","Cuba","Cape Verde","Curacao","Christmas Island","Cyprus","Czechia","Germany","Djibouti","Denmark","Dominica","Dominican Republic","Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji","Falkland Islands","Micronesia","Faroe Islands","France","Gabon","United Kingdom","Grenada","Georgia","French Guiana","Guernsey","Ghana","Gibraltar","Greenl
@sebble
sebble / speedtest-cron.py
Last active February 6, 2016 11:32
Speed Tests
#!/usr/bin/env python
from commands import getstatusoutput
from datetime import datetime
from re import findall
REPEAT = 3
for i in range(REPEAT):
now = datetime.now()
OUTPUT_CSV = now.strftime('/var/log/speedtest/speedtest_%Y%m.log')
#!/bin/bash
# some utility functions (not used)
str256() { echo $((0x$(echo $1|md5sum|cut -c-4)%256)); }
str2color() { echo -e "\033[38;5;$(str256 "$1")m$1\033[00m"; }
# create a new host-colour file if not exists (allows manual override)
HOSTNAME_COLOUR_FILENAME="$HOME/.$(hostname)-colour"
test -f "$HOSTNAME_COLOUR_FILENAME" || \
echo $((0x$(hostname|md5sum|cut -c-4)%256)) > "$HOSTNAME_COLOUR_FILENAME"
<!doctype html>
<meta charset=utf-8>
<title>Scroll test</title>
<style>
html, body {
width: 100%;
height: 100%;
background-color: #eee;
box-sizing: border-box;
padding: 0;
@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.

@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 / 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):
dotdotdot() { while sleep ${1:-10};do echo -n .;done; }
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!';
@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 {