Skip to content

Instantly share code, notes, and snippets.

Avatar
🐇
Knock, knock.

Jonathan H sheljohn

🐇
Knock, knock.
  • Oxford
View GitHub Profile
@sheljohn
sheljohn / mystat.py
Last active Aug 22, 2018
Python 3 wrapper for os.stat_result
View mystat.py
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 Aug 17, 2018
wtf-python: Features, not bugs
View absolute-import.sh
# 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
View keybase.md

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 Sep 15, 2017
Publish/Subscribe singleton in JavaScript
View pubsub.js
/**
* 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 Sep 4, 2017
Webpack fails to build on NTFS filesystems
View reproduce-build-error.sh
#!/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 Mar 30, 2020
Print with colors in most shells (Python, standalone)
View colours-old.py
# 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 Apr 9, 2016
Fixing FieldTrip issues with Matlab
View gist:a77702e3de1ef8892b7f62665d1d33f5
  • 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 Nov 30, 2019
Building Armadillo + OpenBLAS [on Intel + Ubuntu]
View 0_Introduction.md

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.

You can’t perform that action at this time.