Skip to content

Instantly share code, notes, and snippets.

@riyad
riyad / firewall.npt6
Last active April 28, 2025 15:14
OpenWRT firewall script to configure network prefix translation for IPv6
#!/bin/sh
#
# Author: Riyad Preukschas <[email protected]>
# License: Mozilla Public License 2.0
# SPDX-License-Identifier: MPL-2.0
#
# OpenWRT firewall script for configuring NPTv6 (network prefix translation).
#
# # Installation
#
@thesauri
thesauri / change-mac-address-sequoia.md
Last active April 28, 2025 15:13
Change MAC address macOS 12 Monterey

Change MAC address in macOS Sequoia

I was unable to change the MAC address of the Wi-FI device on a MacBook Air (M1 2020) running macOS Sequoia due to the following error: ifconfig: ioctl (SIOCAIFADDR): Can't assign requested addres.

By running the commands in following sequence I was able to change it successfully:

  1. Turn WiFi device off
  2. Turn the WiFi device on again: networksetup -setairportpower en0 on
  3. Change the MAC: ifconfig en0 ether <mac-address-here>
  4. Run: networksetup -detectnewhardware
@ogrrd
ogrrd / dnsmasq OS X.md
Last active April 28, 2025 15:13
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

Pessimistic Locking in Node.js with TypeORM

In this article, we will explore pessimistic locking, its main aspects, and how to implement it in Node.js using TypeORM. Pessimistic locking is a strategy to prevent concurrent access to a resource by obtaining exclusive access to the resource before making any changes. This approach ensures that other transactions cannot modify the locked resource until the lock is released.

We will use a practical example to demonstrate how to implement pessimistic locking in a Node.js application using the TypeORM library. Our example will focus on a payment processing scenario, where multiple processes might attempt to update the status of a payment concurrently.

@KitsuneSemCalda
KitsuneSemCalda / DynamicsWallpaper.sh
Created April 28, 2025 15:11
Script to change randomically wallpapers when you use gnome.
#!/usr/bin/env bash
WALLPAPER_DIR="$(xdg-user-dir PICTURES)/Wallpaper"
if [ ! -d "$WALLPAPER_DIR" ]; then
echo "Wallpaper Directory not founded: $WALLPAPER_DIR"
exit 1
fi
WALLPAPER_LIGHT=$(find "$WALLPAPER_DIR/Light" -type f \( -iname '*.jpg' -o -iname '*.png' -o -iname '*.jpeg' \) | shuf -n 1)
@ofgulban
ofgulban / pyvista_360.py
Created October 24, 2021 11:23
Generate 360 rotating with pyvista
"""Used for rendering frames as png files."""
import sys
import os
import numpy as np
import pyvista as pv
import nibabel as nb
FILENAME = "/path/to/image3D.nii.gz"
OUTDIR = "/path/to/output"
@avamsi
avamsi / irctc.py
Last active April 28, 2025 15:05
Python script to semi-automate tatkal ticket booking.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep, strftime
def waituntil(s):
while strftime('%H:%M:%S') < s:
print strftime('%H:%M:%S')
sleep(1)
@wmealing
wmealing / C-states.md
Last active April 28, 2025 15:03
What are CPU "C-states" and how to disable them if needed?

To limit a CPU to a certain C-state, you can pass the processor.max_cstate=X option in the kernel line of /boot/grub/grub.conf.

Here we limit the system to only C-State 1:

    kernel /vmlinuz-2.6.18-371.1.2.el5 ... processor.max_cstate=1

On some systems, the kernel can override the BIOS setting, and the parameter intel_idle.max_cstate=0 may be required to ensure sleep states are not entered:

@albinowax
albinowax / race-condition-probe.java
Last active April 28, 2025 15:02
Race condition custom action for Burp Repeater
// This will use the single-packet attack for HTTP/2, and last-byte synchronisation for HTTP/1
int NUMBER_OF_REQUESTS = 10;
var reqs = new ArrayList<HttpRequest>();
for (int i = 0; i < NUMBER_OF_REQUESTS; i++) {
reqs.add(requestResponse.request());
}
var responses = api().http().sendRequests(reqs);
var codes = responses.stream().map(HttpRequestResponse::response).filter(Objects::nonNull).map(HttpResponse::statusCode).toList();
logging().logToOutput(codes);
@fellipec
fellipec / pihole-dhcp.md
Last active April 28, 2025 15:02
Pi-Hole DHCP configuration guide

Introduction

Pi-Hole's primary function is to be a DNS server with the ability to block domains, usually used for advertising, tracking or other unwanted sites. It also features a built-in DHCP Server.

Usually, your router will also have a built-in DHCP server, pre-configured from factory, and for most users this is perfectly fine. But in some cases you may want to run another DHCP server instead of relying on your router's one. This guide will help you understand how a DHCP server works and how to configure it without disturbing your network.

If you already know the networking basics, you can cut to the chase and read just the configuration part

Understanding the IP Addressing