Skip to content

Instantly share code, notes, and snippets.

@usr-ein
usr-ein / grad_odeint_all_neural_ode_appendix_D.py
Created July 20, 2019 16:31
Autograd Implementation of packed ODE solver with augmented state
"""
From Appendix D in the Neural ODE paper
Implementation of autograd
"""
import scipy.integrate
import autograd.numpy as np
from autograd.extend import primitive, defvjp_argnums
from autograd import make_vjp
@usr-ein
usr-ein / gist:f401e036bbd6306b6a46345bf16301ad
Last active May 9, 2020 19:52
Dubex Redteam Card Cloner utility
#!/bin/bash
#set -x
# Found in the description of https://www.youtube.com/watch?v=c0Qsmgvj_oo
# Hosted originaly on https://www.lostserver.com/static/nfc-cloner.sh
# This is not mine, I'm just making sure it doesn't disappear from the web.
# If you're the author and want to remove it, contact me.
# I slightly modified it to work with non GNU/Linux installations (adding $(which) in the defs)
#------------------------------------------------------
# Keld Norman, Dubex A/S, Sep, 2018 - CLONE ID CARD POC
#------------------------------------------------------

Keybase proof

I hereby claim:

  • I am sam1902 on github.
  • I am samuelprevost (https://keybase.io/samuelprevost) on keybase.
  • I have a public key whose fingerprint is 9788 786C 7774 B243 A037 2C8F 190F A963 37B3 CCE0

To claim this, I am signing this object:

@usr-ein
usr-ein / positionSwitchFlipflop.ino
Created August 24, 2020 15:06
Position flipflop switch with timeout
/*
* Author: Samuel Prevost <samuel.prevost@pm.me>
* Date: 2020-08-24
*
* WIRING:
* A two way switch is wired onto pin SWITCH_PIN:
* - either pin SWITCH_PIN is linked to ground (default position)
* - or pin SWITCH_PIN is linked to VCC (pressed switch position)
* If pin SWITCH_PIN is connected to neither, it's an anomaly and will result in random behaviour.
*
@usr-ein
usr-ein / elgatoFix.sh
Last active September 17, 2020 19:00
Make Elgato Cam Link 4K work on GNU Linux (tested in debian 4.19.0-9-amd64)
#!/usr/bin/env bash
# You need to run
# sudo apt install v4l2loopback-utils v4l2loopback-dkms
# And restart your computer after that so that it reloads the kernel (just in case)
# Creates a dummy device
sudo modprobe v4l2loopback devices=1 exclusive_caps=1
# Find the dummy device file path
V4LOOP=$(v4l2-ctl --list-devices | grep Dummy -A 1 | tail -n 1 | tr -d '\t')
@usr-ein
usr-ein / check_domain_name.sh
Last active October 11, 2020 13:03
Check Domain Name Availability
#!/usr/bin/env bash
# Released under MIT License
# Copyright (c) 2020 Samuel Prevost.
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
# software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
# to whom the Software is furnished to do so, subject to the following conditions:
@usr-ein
usr-ein / load_images_keras.py
Created December 1, 2020 23:23
Loading and augmenting image dataset in Keras
from collections import Counter
from typing import Tuple, Dict
from os import PathLike
from pathlib import Path
from os.path import isdir, join as join_paths
from tensorflow.python.keras.preprocessing.image import (
ImageDataGenerator,
DirectoryIterator,
)
from tensorflow.python.keras.applications.vgg19 import (
@usr-ein
usr-ein / iban_checker.py
Last active April 11, 2021 17:28
IBAN Checker and Generator
#!/usr/bin/env python3
"""
Checks for the validity of an IBAN number
You can either pipe IBANS into it, provide it a file directly,
or provide it a single IBAN. In the case of a single IBAN, it'll
show you the steps to verify it.
Samuel Prevost 2021-03-19
"""
@usr-ein
usr-ein / LiveMap.py
Created March 23, 2021 00:33
Twitter live map of geolocated tweets in an area, streamed to .kml file, which can be viewed in Google Earth
import re
from tempfile import mkstemp
from shutil import move
from os import remove, close
class LiveMap(object):
def __init__(self, livePoints, pathToLive = "live.kml"):
super(LiveMap, self).__init__()
self.livePoints = livePoints
self.pathToLive = pathToLive
@usr-ein
usr-ein / geothmetic_meandian.py
Last active March 23, 2021 23:41
Computes the Geothmetic Meandian https://xkcd.com/2435/
#!/usr/bin/env python3
"""Module doc"""
import numpy as np
from sys import argv
def residual_size(values, axis=None):
# shape: (4, 3, 5, 2, 3)
# axis: (0, 2)