Skip to content

Instantly share code, notes, and snippets.

View tvlooy's full-sized avatar
🐧
<(o)

Tom Van Looy tvlooy

🐧
<(o)
View GitHub Profile
@dumkydewilde
dumkydewilde / cloudflare-worker-csp-header.js
Created December 9, 2021 12:57
Use Cloudflare Workers to inject CSP headers in your requests
const NONCE_SECRET = "S3CR3T" // Identify where to inject nonces in your page
class ElementHandler {
constructor(generatedNonce, nonceReplaceValue) {
this.generatedNonce = generatedNonce
this.nonceReplaceValue = nonceReplaceValue
}
element(element) {
// An incoming element, such as `div`
@TomCan
TomCan / mysql-group-replication-docker.sh
Created September 24, 2021 06:39
Setting up MySQL group replication in docker
#!/bin/bash
#
# This will create and setup a MySQL group replication cluster with a given number of members.
# Set the number of members below, and then execute this file. You probably want at least 3 members.
#
# This will create volumes and containers named mysql-X, where X is the number of the member.
# If you currently have volumes with the same name, these might be destroyed!
#
MEMBERS=3
@chrispage1
chrispage1 / README.md
Last active February 15, 2023 13:22
Restoring databases using Docker

Restoring databases using Docker

This guide requires you have the original database directories handy. You may also struggle restoring InnoDB instances because of the way they work, however a guide can be found at the bottom of this gist.

Move your backup database folders to an appropriate location, a temporary folder is preferable as MariaDB will put its own data within this directory.

Within the directory, run the following docker command:

@akpoff
akpoff / curl_imap_query_commands.md
Created January 2, 2018 17:29
curl commands to query imap servers

curl commands to query imap servers

Based on https://busylog.net/telnet-imap-commands-note/

curl options

  • -k -- don't verify certificate (optional)
  • -n -- use .netrc for username and password (optional)
  • -X -- request to send to server
@DragonBe
DragonBe / FinalClass.php
Created July 20, 2017 15:05
Testing final classes is tricky, but possible even though you cannot directly mock a "final" class
<?php
namespace FinalClass;
require_once __DIR__ . '/vendor/autoload.php';
use PHPUnit\Framework\TestCase;
final class Foo
{
protected $bar;
@Neo23x0
Neo23x0 / nmap-cmdline
Last active March 19, 2020 17:10
Nmap Scan Params for CVE-2017-0143 MS17-010 Scanning
# Scan for CVE-2017-0143 MS17-010
# The vulnerability used by WannaCry Ransomware
#
# 1. Use @calderpwn's script
# http://seclists.org/nmap-dev/2017/q2/79
#
# 2. Save it to Nmap NSE script directory
# Linux - /usr/share/nmap/scripts/ or /usr/local/share/nmap/scripts/
# OSX - /opt/local/share/nmap/scripts/
#
@marcan
marcan / linux.sh
Last active December 1, 2023 15:18
Linux kernel initialization, translated to bash
#!/boot/bzImage
# Linux kernel userspace initialization code, translated to bash
# (Minus floppy disk handling, because seriously, it's 2017.)
# Not 100% accurate, but gives you a good idea of how kernel init works
# GPLv2, Copyright 2017 Hector Martin <marcan@marcan.st>
# Based on Linux 4.10-rc2.
# Note: pretend chroot is a builtin and affects the current process
# Note: kernel actually uses major/minor device numbers instead of device name
@beeman
beeman / remove-all-from-docker.sh
Created November 15, 2016 03:04
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
anonymous
anonymous / answer.txt
Created August 27, 2016 11:24
I think the best way to answer this definitively without just handwaving
and talking about the C preprocessor is to actually write two small
example programs and compare the generated code from both. When I was
first learning C I did this constantly trying to understand how the
compiler worked. You don't need to understand assembly in great detail
to be able to spot differences in the output:
$ cat a.c
int main() {
char *line = "HTTP/1.0 500 Internal Server Error";
OpenBSD 6.0-beta (GENERIC.MP-vmm) #5: Fri Jun 3 16:44:43 CEST 2016
reyk@bsd.plumbing:/usr/src/sys/arch/amd64/compile/GENERIC.MP-vmm
real mem = 17024200704 (16235MB)
avail mem = 16503730176 (15739MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.8 @ 0xd7bfb000 (65 entries)
bios0: vendor LENOVO version "N1FET38W (1.12 )" date 03/30/2016
bios0: LENOVO 20FBCTO1WW