Skip to content

Instantly share code, notes, and snippets.

View jhadida's full-sized avatar
🦑
I type with fingers.

Jonathan H jhadida

🦑
I type with fingers.
View GitHub Profile
@jhadida
jhadida / ghlatest.py
Created December 28, 2020 15:11
Get latest version from Github repository
#!/usr/bin/env python3
#
# Example:
# ghlatest.py nvm-sh/nvm
import urllib.request
import json
import sys
try:
@jhadida
jhadida / instructions.md
Created March 15, 2020 01:45
Configure drawing tablet on Linux

Installing drivers

If your tablet is not a Wacom, checkout this project to see if your tablet is supported. If so, installation instructions can be found on the Github repo.

I personally used these drivers for a Huion Giano tablet on Ubuntu 18.04, and the DEB package worked flawlessly.

Mapping the tablet to primary monitor

@jhadida
jhadida / perm2mask.py
Created August 8, 2019 15:08
Permission string to mask
import stat
def perm2mask(p):
"""
Turn permission string with 9 characters (e.g. "rwsr-x-wt") to a mask
that can be used with os.chmod().
"""
assert len(p) == 9, 'Bad permission length'
assert all(p[k] in 'rw-' for k in [0,1,3,4,6,7]), 'Bad permission format (read-write)'
@jhadida
jhadida / closecol.py
Last active July 14, 2019 20:08
Find closest colornames on http://latexcolor.com/
#!/usr/bin/env python3
HelpText = """
For a given input color, find the nearest color(s) listed on the webpage: http://latexcolor.com
OPTIONS
-------
LongName ShortName Description
@jhadida
jhadida / fourier.m
Last active July 8, 2019 16:34
Fourier transform with correct normalisation
function [frq,dfc] = fourier( vals, fs, npts )
%
% Computes the Fast Fourier Transform of a given time-series.
% For real inputs, the positive spectrum is returned with correctly scaled amplitude/power.
% For complex inputs, the full spectrum centered around frequency 0 is returned.
%
% [freq,amp,phi] = fourier( vals, fs [,npts] )
%
% Inputs:
%