Skip to content

Instantly share code, notes, and snippets.


Nick Lothian nlothian

View GitHub Profile
nlothian /
Created Feb 18, 2021
Convert a matplotlib graph to base64, suitable for inclusing as a data: url in HTML.
def build_GRAPHS_MD(fig):
# encode as base64 for markdown display
buf = io.BytesIO()
fig.savefig(buf, format='png')
b64str = base64.b64encode('ascii')
markdown_txt = f"""
nlothian / Untitled.ipynb
Created Aug 5, 2020
Weird PIL behaviour
View Untitled.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
inp = Input(shape=(maxlen,), name="text_input") # featureized text comes in here
x = Embedding(embedding_matrix.shape[0], embed_size, weights=[embedding_matrix], trainable=True)(inp)
x = Dense(some_num_here, activation="relu")(x)
extra_data = Input(shape=(1,), name="extra_data") # your continous features comes in here
combined = concatenate([x, extra_data])
# maybe some ReLu + Dropout here
nlothian /
Created Nov 23, 2017
Convert a FastText model to a form suitable for viewing in Tensorboard
from tensorflow.contrib.tensorboard.plugins import projector
import tensorflow as tf
import numpy as np
import os
meta_file = "g2x_metadata.tsv"
output_path = "./projections"
# read embedding file into list and get the size
with open('./ft_model.vec', 'r') as embedding_file:
View M.2 256GB Samsung 950 EVO
sudo fio --filename=./testfile --direct=1 --sync=1 --rw=read --bs=4k --numjobs=8 --iodepth=32 --runtime=60 --time_based --group_reporting --size=1G --name=journal-test
journal-test: (groupid=0, jobs=8): err= 0: pid=3092: Thu Jun 2 22:48:23 2016
read : io=21433MB, bw=365792KB/s, iops=91447, runt= 60001msec
clat (usec): min=11, max=15999, avg=86.72, stdev=34.31
lat (usec): min=11, max=15999, avg=86.81, stdev=34.31
clat percentiles (usec):
| 1.00th=[ 60], 5.00th=[ 63], 10.00th=[ 66], 20.00th=[ 75],
| 30.00th=[ 78], 40.00th=[ 80], 50.00th=[ 82], 60.00th=[ 90],
from flask import Flask
from flask import request
import simplejson as json
from decimal import Decimal
import numpy as np
import os
import sys
View Penn Treebank II
nlothian / Trystack images JSON
Created Jul 17, 2012
JSON returned from Trystack
View Trystack images JSON
nlothian / gist:3127581
Created Jul 17, 2012
OpenStack authentication return
View gist:3127581
"access": {
"token": {
"expires": "2012-04-23T23:54:00",
"id": "<id>",
"tenant": {
"id": "<tenantId>",
"name": "<username>"