Skip to content

Instantly share code, notes, and snippets.

View system123's full-sized avatar

Lloyd Hughes system123

View GitHub Profile
@system123
system123 / FastCNNFeatures.py
Created March 12, 2019 16:32
Fast Dense CNN Features
import torch
import torch.nn.functional as F
from torch import nn
from torchvision import models
from math import ceil, floor
from functools import reduce
# https://www.dfki.de/fileadmin/user_upload/import/9245_FastCNNFeature_BMVC.pdf
@system123
system123 / google_auth.py
Created March 2, 2021 17:09
Google Auth TOTP code generator, just seed it with your MFA secret key and it'll generate codes exactly as Google Auth does.
def get_totp_token(secret, refresh_time=int(time.time())//30):
secret = secret.strip().replace(' ', '')
secret = secret.ljust((len(secret) + 7) & (-8) ,'=')
key = base64.b32decode(secret, True)
msg = struct.pack(">Q", refresh_time)
h = bytearray(hmac.new(key, msg, hashlib.sha1).digest())
o = h[19] & 15
h = str((struct.unpack(">I", h[o:o+4])[0] & 0x7fffffff) % 1000000)
return h.zfill(6)
@system123
system123 / download_orbit.py
Last active October 8, 2021 11:42
Download Sentinel 1 POE and RES orbit files from aux.sentinel1.eo.esa.int
"""Get Sentinel-1 orbit file(s) from ESA archive website"""
import argparse
import logging
import os
import re
import sys
from datetime import datetime
from pyroSAR.examine import ExamineSnap
@system123
system123 / problem7ab.cpp
Last active December 8, 2021 08:00
AoC2021 Problem 7
#include <fstream>
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
template <typename T>
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDWC960i4OMbRFUel7tQBVRXd6mQHyz7WGGw/OG6dHCWnExPk3mFfHTccrd76Q7pE01Em7lY3npT8pd5k4zuigZUBO4oel1p4KcHjeQya5BXMi0Xgunyny/8vn3VSPwr6qA9YppnMGmxq35BxLei7iuWcM5ibpnj9xKF7ws0tqU06n0JSz50Gd1LWH7uVcQyFj3UBflgPhQ/3LBAwCIsb3/aWL0D5eZ3vdXRLl114H50qBCgMoFgeQXNRYn8MCOmmC6ZzOz0nGk1DnTiN71kHZqP8KWUQGYjGDNCNjRitWUd4dnM3ZcHVNmrASczmQ/yyE8PWzHrHC5qpOaYbklPeWF lloyd@Lloyds-MacBook-Pro.local