Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:

Ruben Horn rubenhorn

:shipit:
  • Germany
View GitHub Profile
@rubenhorn
rubenhorn / firebase-sms-jwt.py
Created Mar 13, 2022
Generate Firebase ID token for SMS based authentication
View firebase-sms-jwt.py
#!/usr/bin/python3
import argparse, requests
url_request_code = (
"https://identitytoolkit.googleapis.com/v1/accounts:sendVerificationCode"
)
url_sign_in_with_phone_number = (
"https://identitytoolkit.googleapis.com/v1/accounts:signInWithPhoneNumber"
)
@rubenhorn
rubenhorn / .vimrc
Last active Jan 21, 2022
My current .vimrc
View .vimrc
" Plugin manager
execute pathogen#infect()
filetype plugin indent on
" Syntax highlighting
syntax on
" Line numbers
set number
" Support for emojis
set encoding=utf-8
@rubenhorn
rubenhorn / aws-mfa.py
Last active Jan 3, 2022
Simple command line tool for updating AWS MFA session credentials
View aws-mfa.py
#!/usr/bin/python3
import json
from pathlib import Path
from subprocess import PIPE, Popen
import sys
"""
Before using this script:
- Configure AWS cli to output JSON (https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-output-format.html)
@rubenhorn
rubenhorn / random-wallpaper.ps1
Created Jul 6, 2021
Run from autostart folder using .bat-script with: start /min powershell -File path\to\random-wallpaper.ps1
View random-wallpaper.ps1
#====================
# Settings
#====================
$superSampling = 2
$urlTemplate = "https://picsum.photos/{width}/{height}?grayscale"
#====================
# Await connection
#====================
$null = $urlTemplate -match "^https?://([^/]*)/"
@rubenhorn
rubenhorn / totp.py
Last active Jun 23, 2021
Simple TOTP implementation using Python
View totp.py
#!/usr/bin/python3
import time, hashlib, hmac, base64
secret = 'q5ma qo4x irgv cm6k auai kjyv ak57 5keu'
T_0 = 0
X = 30
d = 6
K = base64.b32decode(secret.upper().replace(' ', ''))
@rubenhorn
rubenhorn / conda_snippets.md
Last active May 26, 2021
The following snippets can be used to build a (cross platform) script to manage a local Anaconda environment by anyone.
View conda_snippets.md

Conda snippets

The following snippets can be used to build a cross platform script to manage a local Anaconda environment by anyone.

Create new environment

conda create -y -p ./.env python=3.9 && conda activate ./.env

Deactivate environment

conda deactivate

Remove environment

@rubenhorn
rubenhorn / list-videos.py
Last active Mar 18, 2021
A script to process youtube playlist takeout
View list-videos.py
#!/usr/bin/python3
import os, sys, requests, re, html
banner = '''
#==================================================
# A script to process youtube playlist takeout
#==================================================
'''
print(banner)
@rubenhorn
rubenhorn / summon_window.ahk
Last active Dec 13, 2020
AutoHotkey script for moving active window to main monitor
View summon_window.ahk
#SingleInstance force
; Hotkey: Alt + S
!s::
; Check if window active window exists
WinGetTitle, t, a
if(t = "Program Manager" or t = "") {
MsgBox ,, No window selected!, Please select a window.`n(Alt + Tab)
return
@rubenhorn
rubenhorn / retrolink-nes-controller.js
Created Dec 10, 2020
Function for reading input from Retrolink NES controller (https://www.gadgetreview.com/retrolink-usb-nes-controller-review) in the browser
View retrolink-nes-controller.js
@rubenhorn
rubenhorn / mnist_demo.py
Last active Aug 16, 2020
Neural network digit recognition example with GUI
View mnist_demo.py
# Based on https://www.tensorflow.org/datasets/keras_example
# Requires numpy, pygame, tensorflow and tensorflow-datasets
NUMBER_OF_EPOCHS = 8
import numpy as np
import pygame
pygame.init()
pygame.display.set_caption('MNIST digits')