Skip to content

Instantly share code, notes, and snippets.

@nlothian
nlothian / gist:3127581
Created July 17, 2012 06:25
OpenStack authentication return
{
"access": {
"token": {
"expires": "2012-04-23T23:54:00",
"id": "<id>",
"tenant": {
"id": "<tenantId>",
"name": "<username>"
}
},
@nlothian
nlothian / Trystack images JSON
Created July 17, 2012 06:43
JSON returned from Trystack
{
"images":[
{
"status":"ACTIVE",
"updated":"2012-02-02T19:11:00Z",
"name":"oneiric-server-cloudimg-amd64",
"links":[
{
"href":"https://nova-api.trystack.org:9774/v1.1/<tenantId>/images/15",
"rel":"self"
@nlothian
nlothian / Penn Treebank II Tags.md
Last active June 11, 2024 19:06
Penn Treebank II Tags
from flask import Flask
from flask import request
import simplejson as json
from decimal import Decimal
import numpy as np
import os
import sys
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
nlothian / fasttext_to_tensorboard.py
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
nlothian / Untitled.ipynb
Created August 5, 2020 11:13
Weird PIL behaviour
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nlothian
nlothian / matplotlib2base64MD.py
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')
buf.seek(0)
b64str = base64.b64encode(buf.read()).decode('ascii')
plt.close()
markdown_txt = f"""
!
""""
#
$
%
&
'
(
)
*