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
<!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;
#!/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"
@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')
["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 / check-repos.sh
Created October 4, 2015 20:49
Check for changes in all git repos on system
#!/bin/bash
sudo updatedb
for git in `locate -b --regex '^.git$'`; do
cd $git/..;
if git status 2>/dev/null|grep -E '(Untracked|Changes|ahead)'>/dev/null; then
echo Changes in $git;
else
echo None in $git;
@sebble
sebble / remote_ip.conf
Last active September 11, 2015 03:02
Nginx Remote IP
map $http_user_agent $mode {
default 'plain';
~*(Mozilla) 'html';
}
map $http_user_agent $html {
default '';
~*(Mozilla) '<title>$remote_addr</title>';
}
server {
@sebble
sebble / data.csv
Last active August 29, 2015 14:19 — forked from psealock/data.csv
id type amount
01 Restaurant 100
02 Entertainment 100
03 Rent 200
04 Groceries 250
@sebble
sebble / vimnote
Created March 25, 2015 08:59
Start Goyo in Vim in terminal with note
mkdir -p '~/Notebooks/Vim' && xfce4-terminal --maximize -x bash -c 'source ~/.bashrc;vim +"norm i$(date -I)^M^M" +Goyo +startinsert "~/Notebooks/Vim/$(date -I)_$(zenity --entry --title="New Note" --text="~/Notebooks/Vim/$(date -I)\_<title>:" --entry-text="new_note")"'
@sebble
sebble / README.md
Last active August 29, 2015 14:16
Distraction Free IPython Notebook

Distraction free writing in IPython notebooks

  • Minimal styles to emphasise writing
  • WYWIWYG markdown editing to improve writing flow

Can we outsource HTML->MD editing to https://jejacks0n.github.io/mercury/documentation/#markdown-region?

Note: IPython notebooks use marked internally, a reverse (HTML->MD converter should match supported marked syntax, IPython configurations, and ignore dynamic IPython features (e.g., heading anchors, MathJax)

IPython features to avoid

@sebble
sebble / 00-setup.sh
Last active August 29, 2015 14:15
Jupyter Kernels
# http://jupyter.cs.brynmawr.edu/hub/dblank/public/Jupyter%20Help.ipynb#1.4.2-Enable-Python-3-kernel
# https://nbviewer.jupyter.org/github/ellisonbg/talk-2014-summer/blob/cfa/Multilanguage.ipynb
## Python 2
sudo apt-get install python-pip libzmq3-dev
sudo pip install -U pip
sudo pip install ipython pyzmq matplotlib
#sudo pip install -I ipython==3.* # force v3
## Python 3