Skip to content

Instantly share code, notes, and snippets.

View phuysmans's full-sized avatar

Philippe Huysmans phuysmans

View GitHub Profile
@phuysmans
phuysmans / annotator-example-plugin.js
Created May 26, 2020 15:01 — forked from itskingori/annotator-example-plugin.js
Example AnnotatorJS Plugin showing events
Annotator.Plugin.Example = function (element, options) {
var myPlugin = {};
myPlugin.pluginInit = function () {
// This annotator instance
this.annotator
// LOADING
.subscribe("annotationsLoaded", function (annotations) {
console.log("annotationsLoaded called when the annotations have been loaded.");
console.log(annotations);
@phuysmans
phuysmans / portable-zip-pathnames.ps1
Created May 7, 2020 09:14 — forked from lantrix/portable-zip-pathnames.ps1
PowerShell encoding Zip paths to use forward slash (Zip Spec) instead of backslash (Windows Style); for portable zip files - thanks to @sethjackson
# When using System.IO.Compression.ZipFile.CreateFromDirectory in PowerShell, it still uses backslashes in the zip paths
# despite this https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/mitigation-ziparchiveentry-fullname-path-separator
# Based upon post by Seth Jackson https://sethjackson.github.io/2016/12/17/path-separators/
#
# PowerShell 5 (WMF5) & 6
# Using class Keyword https://msdn.microsoft.com/powershell/reference/5.1/Microsoft.PowerShell.Core/about/about_Classes
#
@phuysmans
phuysmans / run.bat
Created May 7, 2020 08:00 — forked from thinkerbot/run.bat
Execute a powershell script via ssh
# Notes:
# 1) The input format must be specified to prevent ssh from hanging
# 2) The full path to the script is required
# 3) An SSH server must be running on the Windows box, naturally. WinSSHD
# is free for personal, non-commercial use and worked for this example.
# See http://www.bitvise.com/winsshd
#
# You have to set the execution policy for scripts so that powershell has
# permissions to run the script. To do so, search for 'Powershell' under
# the Start menu. Then right-click and 'Run as administrator' so that you
// polyfill window.getMatchedCSSRules() in FireFox 6+
if ( typeof window.getMatchedCSSRules !== 'function' ) {
var ELEMENT_RE = /[\w-]+/g,
ID_RE = /#[\w-]+/g,
CLASS_RE = /\.[\w-]+/g,
ATTR_RE = /\[[^\]]+\]/g,
// :not() pseudo-class does not add to specificity, but its content does as if it was outside it
PSEUDO_CLASSES_RE = /\:(?!not)[\w-]+(\(.*\))?/g,
PSEUDO_ELEMENTS_RE = /\:\:?(after|before|first-letter|first-line|selection)/g;
// convert an array-like object to array
@phuysmans
phuysmans / mozGetMatchedCSSRules.js
Created March 27, 2020 10:53 — forked from ydaniv/mozGetMatchedCSSRules.js
A Gecko only polyfill for Webkit's window.getMatchedCSSRules
// polyfill window.getMatchedCSSRules() in FireFox 6+
if ( typeof window.getMatchedCSSRules !== 'function' ) {
var ELEMENT_RE = /[\w-]+/g,
ID_RE = /#[\w-]+/g,
CLASS_RE = /\.[\w-]+/g,
ATTR_RE = /\[[^\]]+\]/g,
// :not() pseudo-class does not add to specificity, but its content does as if it was outside it
PSEUDO_CLASSES_RE = /\:(?!not)[\w-]+(\(.*\))?/g,
PSEUDO_ELEMENTS_RE = /\:\:?(after|before|first-letter|first-line|selection)/g;
// convert an array-like object to array
@phuysmans
phuysmans / mozGetMatchedCSSRules.js
Created March 27, 2020 10:53 — forked from darrnshn/mozGetMatchedCSSRules.js
A Blink only polyfill for Webkit's window.getMatchedCSSRules
// polyfill window.getMatchedCSSRules() in Chrome
if ( typeof window.getMatchedCSSRules !== 'function' ) {
var ELEMENT_RE = /[\w-]+/g,
ID_RE = /#[\w-]+/g,
CLASS_RE = /\.[\w-]+/g,
ATTR_RE = /\[[^\]]+\]/g,
// :not() pseudo-class does not add to specificity, but its content does as if it was outside it
PSEUDO_CLASSES_RE = /\:(?!not)[\w-]+(\(.*\))?/g,
PSEUDO_ELEMENTS_RE = /\:\:?(after|before|first-letter|first-line|selection)/g;
// convert an array-like object to array
#!/usr/bin/env bash
set -eo pipefail
CONTAINER=$1
NOW=$(date +%s)
if [ "$(docker ps -a -q -f name=${CONTAINER})" ]; then
STARTED_AT=$(docker inspect -f "{{.State.StartedAt}}" ${CONTAINER})
STARTED=$(date -d "${STARTED_AT}" +%s)
@phuysmans
phuysmans / fritzbox-cert-update.sh
Created August 8, 2019 08:37 — forked from wikrie/fritzbox-cert-update.sh
Fritzbox Fritz!Box AVM SSL Letsencrypt automatically update
#!/bin/bash
# parameters
USERNAME="maybe empty"
PASSWORD="fritzbox-password"
CERTPATH="path to cert eg /etc/letsencrypt/live/domain.tld/"
CERTPASSWORD="cert password if needed"
HOST=http://fritz.box
# make and secure a temporary file
@phuysmans
phuysmans / gist:82b2700eef279db2dd201001912f08c2
Created July 22, 2019 08:44
detect time errors in tcx files - strava bad time data
# install xml2json
npm install xml2json
# convert tcx to json
node_modules/xml2json/bin/xml2json < Downloads/3868462012.tcx > Downloads/3868462012.json
# find all trackpoints where date not starts with the activity date
jq '.TrainingCenterDatabase.Activities.Activity.Lap.Track.Trackpoint[] | select(.Time | startswith("2019-07-21") | not )' Downloads/3868462012.json
# edit and upload
#determine the labels
import pyvw #vw python interface
DEST = 1
PROP = 2
FAC = 3
...
#create the class for the Sequence Labeler
class SequenceLabeler(pyvw.SearchTask):