Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Munk mmmunk

View GitHub Profile
@mmmunk
mmmunk / receive_commands.py
Last active Jan 12, 2021
Simple UDP packet commands from one program to another
View receive_commands.py
import sys
import socket
import random
# Create and bind UDP socket
bind_ip = sys.argv[1]
bind_port = int(sys.argv[2])
msgsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
msgsock.bind((bind_ip, bind_port))
print('Waiting for commands on', bind_ip, 'port', bind_port)
@mmmunk
mmmunk / BinSearchReplace.dpr
Created Oct 28, 2020
Search for and optionally replace strings in files
View BinSearchReplace.dpr
{ BinSearchReplace Version 0.9 }
program BinSearchReplace;
{$APPTYPE CONSOLE}
{$R *.res}
uses
Windows, SysUtils;
const
cFileChunkSize = 500000;
@mmmunk
mmmunk / check-checksums.sh
Last active Jan 15, 2021
Usage of HashDeep (apt install hashdeep)
View check-checksums.sh
#!/bin/bash
# Files changed or deleted since checksum creation are noted.
# New files are not noted.
if [ -z "$1" ]; then
DIR=`pwd`
else
DIR=`realpath $1`
fi
@mmmunk
mmmunk / rsync-verify.txt
Last active Sep 17, 2020
Verify filetree via rync
View rsync-verify.txt
Create/update the copy:
rsync -avi --delete A/ B/
Verify:
rsync --dry-run --recursive --checksum --times --delete --itemize-changes --verbose --stats A/ B/
@mmmunk
mmmunk / fetch-ex.js
Created Sep 3, 2020
Example use of Javascript Fetch
View fetch-ex.js
function call_api(url, args, rsp_json, result_func) {
// Start the fetch chain of promises
fetch(url, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(args)
})
.then(rsp => {
// rsp.ok true if rsp.status is 200-299
if (rsp.ok) {
@mmmunk
mmmunk / TempLoggerService.c
Created Jun 18, 2020
Very basic Windows Service template in C
View TempLoggerService.c
// Very basic Windows Service template - maybe not fully correct/complete but it works.
// x86_64-w64-mingw32-gcc -mwindows -municode -O2 -s -o TempLoggerService.exe TempLoggerService.c
// SC create TempLoggerService binpath="C:\Temp\TempLoggerService.exe"
// SC delete TempLoggerService
#include <windows.h>
#include <stdio.h>
#define SERVICE_NAME L"TempLoggerService"
@mmmunk
mmmunk / picdir-to-html.py
Last active May 15, 2020
Reads a directory of picture files and creates a single-file HTML-document including all the pictures as Base64 data inside the document
View picdir-to-html.py
# Reads a directory of picture files and creates a single-file HTML-document including all the pictures as Base64 data inside the document
import sys
import os
import io
import math
import base64
from PIL import Image, UnidentifiedImageError
# ---------- TagBuilder ----------
@mmmunk
mmmunk / WindowsBatchTipsTricks.cmd
Last active Oct 23, 2019
Tips & Tricks for Windows Batch files
View WindowsBatchTipsTricks.cmd
REM This file is not meant to be run in it's entirety
REM --- Check if script is run as administrator
net session >nul 2>&1
if %errorlevel% neq 0 (
echo This script must be run with administrator privileges
pause
exit /B
)
@mmmunk
mmmunk / Create.txt
Created May 24, 2019
64-bit WAMP (Windows, Apache, MariaDB/MySQL, PHP) til udvikling/test
View Create.txt
64-bit WAMP (Windows, Apache, MariaDB/MySQL, PHP) til udvikling/test
====================================================================
Webserver med PHP
-----------------
Opret C:\WAMP
Opret C:\WAMP\www
Download nyeste Apache binary (httpd 2.4) VC15 Win64 fra https://www.apachelounge.com/download/
@mmmunk
mmmunk / helper.c
Created Feb 19, 2019
Example of creating and using a Windows DLL with MinGW
View helper.c
// x86_64-w64-mingw32-gcc -Wall -shared -O2 -s -o helper.dll helper.c
#include <stdio.h>
#include <string.h>
__declspec(dllexport) __stdcall int proc_sql_modify(char *sql, int size) {
strcpy(sql, "NEW SQL HERE");
return 0;
}
You can’t perform that action at this time.