Skip to content

Instantly share code, notes, and snippets.

View sheljohn's full-sized avatar
🐇
Knock, knock.

Jonathan H sheljohn

🐇
Knock, knock.
  • Oxford
View GitHub Profile
@sheljohn
sheljohn / mystat.py
Last active August 22, 2018 18:11
Python 3 wrapper for os.stat_result
import os, stat, math
import pwd, grp
from datetime import datetime
'''
Wrapper for os.stat_result, which contains all the information I usually need,
in a form that is simple to interact with.
For example:
@sheljohn
sheljohn / absolute-import.sh
Created August 17, 2018 13:32
wtf-python: Features, not bugs
# Take any version of Python that can import numpy, and run this in a terminal
D=$(mktemp -d) # temporary folder
pushd "$D" # move there
mkdir foo # create subfolder
echo 'import numpy' >| foo/a.py # script a.py
echo 'x++' >| foo/math.py # script math.py (invalid)
python foo/a.py # run a.py
popd # leave temp folder

Keybase proof

I hereby claim:

  • I am sheljohn on github.
  • I am jhadida (https://keybase.io/jhadida) on keybase.
  • I have a public key ASA5lXj8BvOyYA8en01OimcYim0sgaXQ-DNHYacTsjBkGgo

To claim this, I am signing this object:

@sheljohn
sheljohn / pubsub.js
Created September 15, 2017 01:11
Publish/Subscribe singleton in JavaScript
/**
* Singleton publish/subscribe hub.
*/
module.exports = (function() {
const channel = {};
const noset = new Set();
return {
publish: (name,data) => {
@sheljohn
sheljohn / reproduce-build-error.sh
Last active September 4, 2017 10:27
Webpack fails to build on NTFS filesystems
#!/bin/bash
# create temporary directory and move to it
FOLDER=$(mktemp -d)
echo "Moving to folder $FOLDER"
cd $FOLDER
# create a 50M file
FILE=test.ntfs
echo "Creating empty file $FILE"
@sheljohn
sheljohn / colours-old.py
Last active July 27, 2024 09:05
Print with colors in most shells (Python, standalone)
# Python 2, class
# Author: J.Hadida (jhadida87 at ggooglemail)
class ColorPrinter:
"""
Usage:
cprint = ColorPrinter()
cprint.cfg('c','m','bux').out('Hello','World!')
cprint.rst().out('Bye now...')
@sheljohn
sheljohn / gist:a77702e3de1ef8892b7f62665d1d33f5
Created April 9, 2016 22:48
Fixing FieldTrip issues with Matlab
  • Change directory to fieldtrip, delete all Mex files in the src/ directory
  • Edit src/ft_getopt.c and replace any mxErrMsgTxt to mexErrMsgTxt (notice the 'mex' instead of 'mx')
  • Rename mxSerialize.c to mxSerialize.cpp (same for mxDeserialize)
  • Edit those files, and replace the prototype declarations to:
// MX_API_VER has unfortunately not changed between R2013b and R2014a,
// so we use the new MATRIX_DLL_EXPORT_SYM as an ugly hack instead
#if defined(__cplusplus) && defined(MATRIX_DLL_EXPORT_SYM)
 namespace matrix{ namespace detail{ namespace noninlined{ namespace mx_array_api{
@sheljohn
sheljohn / 0_Introduction.md
Last active November 30, 2019 11:01
Building Armadillo + OpenBLAS [on Intel + Ubuntu]

Introduction

I actually found very few indications on the net to install Armadillo with OpenBLAS on Ubuntu, and I ran into problems when I tried to install the Ubuntu pre-build packages (using apt-get). So I decided to share my experience building the whole thing from scratch, hopefully this can serve as a step-by-step through the install.

Platform

As of writing this, I'm using Ubuntu desktop 14.04 with an Intel i7 4820k Ivy-Bridge E CPU.