Skip to content

Instantly share code, notes, and snippets.

nlothian / gist:3127581
Created July 17, 2012 06:25
OpenStack authentication return
View gist:3127581
"access": {
"token": {
"expires": "2012-04-23T23:54:00",
"id": "<id>",
"tenant": {
"id": "<tenantId>",
"name": "<username>"
nlothian / Trystack images JSON
Created July 17, 2012 06:43
JSON returned from Trystack
View Trystack images JSON
nlothian / Penn Treebank II
Last active January 29, 2024 19:54
Penn Treebank II Tags
View Penn Treebank II
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 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],
nlothian /
Created November 23, 2017 23:28
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:
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 / Untitled.ipynb
Created August 5, 2020 11:13
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.
nlothian /
Created February 18, 2021 02:33
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"""
View clip_words.txt