Skip to content

Instantly share code, notes, and snippets.

View nlitsme's full-sized avatar

willem nlitsme

View GitHub Profile
@nlitsme
nlitsme / mpmp12.md
Last active August 14, 2020 20:29
mpmp12 Marchingband solution

Marching Band problem

In this document I describe a solution to the 'marchingband' problem as stated on think-maths:

What is the fewest number of performers you require for your marching band to
have 64 marching options? (Only whole positive numbers will be accepted)

Where a 'marchingband' can march only in a rectangular shape.

@nlitsme
nlitsme / countries.txt
Created July 29, 2020 11:30
python scripts to show corona statistics
EMRO AF Afghanistan 647500 37171921 World;Asia;NonCKIR
EURO AL Albania 28748 2876591 World;Europe;NonEU
AFRO DZ Algeria 2381740 34178188 World;Africa;North Africa
WPRO AS American Samoa (United States) 199 55465 World;Oceania;Polynesia
EURO AD Andorra 468 77281 World;Europe;NonEU
AFRO AO Angola 1246700 12799293 World;Africa;Central Africa
AMRO AI Anguilla (United Kingdom) 91 14731 World;North America
AMRO AG Antigua and Barbuda 442 96286 World;North America
AMRO AR Argentina 2766890 44361150 World;South America
EURO AM Armenia 29743 2951745 World;Europe;NonEU
@nlitsme
nlitsme / README.md
Last active February 5, 2022 18:48
mpmp8 stackfolding

This gist describes my solution to Matt Parker's puzzle #8:

My solution involves looking at the pattern of folds when viewing the folded stack from the sides. And then using some python code to generate all possible ways the folds can match up in a way that you will still end up with two rows of 4 sheets.

The list below shows all ways to fold a piece of paper, including ways where the top-left ends up on the inside of the folded stack.

@nlitsme
nlitsme / lbk
Created November 14, 2019 08:46
Search timemachine backups and apfs snapshots for a specific file
#!/bin/bash
#
# Script which scans all your mounted timemachine volumes, and apfs snapshots for a specific file.
#
# Willem Hengeveld <itsme@xs4all.nl>
#
if [[ $(id -u) -ne 0 ]]; then
sudo $0 "$@"
exit $?
@nlitsme
nlitsme / breachquery.sh
Created December 14, 2017 08:10
query.sh for older bash versions - from magnet:?xt=urn:btih:7ffbcd8cee06aba2ce6561688cf68ce2addca0a3
#!/bin/bash
# query.sh from BreachCompilation - magnet:?xt=urn:btih:7ffbcd8cee06aba2ce6561688cf68ce2addca0a3
# works with older bash versions.
# patch by Willem <itsme@xs4all.nl>
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ "$1" != "" ]; then
word1=$(echo $1 | tr A-Z a-z)
letter1=$(echo $word1|cut -b1)
if [[ $letter1 == [a-zA-Z0-9] ]]; then
"""
Python script for finding a still available pretty phonenumber on the sha2017 POC network.
Register your phone number on: https://poc.sha2017.org/
Author: Willem Hengeveld <itsme@xs4all.nl>
This code is released under the Beerware license.
"""
from __future__ import print_function
"""
Example how to decrypt whatsapp msgstore backups with extension .crypt12.
Author: Willem Hengeveld <itsme@xs4all.nl>
"""
from Crypto.Cipher import AES
import zlib
import sys
datafile = keyfile = None
@nlitsme
nlitsme / kallsyms.py
Created June 6, 2017 18:43
idapython script decoding the linux kernel symbol table
# Linux kernel kallsyms unpacker
# Version 0.2
# Copyright (c) 2010-2013 Igor Skochinsky
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
@nlitsme
nlitsme / switchgcc.sh
Created May 3, 2017 23:48
Bash script for switching the current gcc compiler.
if [[ -z "$1" ]]; then
exit 1
fi
if [[ -e $1/bin/avr-gcc-7.1.0 ]]; then
cppopt=gnu++1z
elif [[ -e $1/bin/avr-gcc-4.9.2 ]]; then
cppopt=gnu++11
else
echo unknown compiler version
@nlitsme
nlitsme / g0.sh
Created November 4, 2014 18:30
combine find, xargs and grep in one command
#!/bin/bash
GREPARGS=()
FINDPATHS=()
while [[ $# != 0 ]]; do
if [[ -d "$1" ]]; then
FINDPATHS+=("$1")
else
GREPARGS+=("$1")
fi
shift