Skip to content

Instantly share code, notes, and snippets.

@jnschulze
jnschulze / windows_get_adapters_addresses.cpp
Created August 15, 2023 21:21
Windows GetAdaptersAddresses test
#include <winsock2.h>
// Must be included after winsock2.h
#include <iphlpapi.h>
#include <cassert>
#include <format>
#include <iostream>
#pragma comment(lib, "Iphlpapi.lib")
@jnschulze
jnschulze / sercomm-fg1000b.11-bootlog.txt
Created May 4, 2023 07:50
Sercomm FG1000B.11 boot log
BTRM
V1.0
R1.0
L1CD
MMUI
MMU9
DATA
ZBBS
MAIN
OTP?
/dts-v1/;
/ {
compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
model = "Raspberry Pi 3 Model B";
interrupt-parent = <0x1>;
#address-cells = <0x1>;
#size-cells = <0x1>;
chosen {
#!/bin/bash
# Disable Sudden Motion Sensor (SMS)
sudo pmset -a sms 0
# Diable Hibernation
sudo pmset -a hibernatemode 0
# Disable local TimeMachine Snapshots
sudo tmutil disablelocal
@jnschulze
jnschulze / osx_ramdisk.sh
Last active February 5, 2024 13:48
Move Chrome, Safari and iTunes Cache to Ramdisk.
#!/bin/bash
# Size at the end is * 2048 where 2048 = 1 MB, so 1572864 = 768 MB
#DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://1572864`
DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://2097152`
/usr/sbin/diskutil erasevolume HFS+ "RamDiskCache" $DISK
CACHEDIR="/Volumes/RamDiskCache/$USER"
@jnschulze
jnschulze / collatz.c
Created October 1, 2013 17:42
Collatz using libgmp.
#include <stdio.h>
#include <stdint.h>
#include <gmp.h>
int main()
{
//const char* startValue = "45411764953495434350345765765756765750345456565445435436536546545324213324233";
const char* startValue = "999349349859230394049534503485093452390984540385348304894503459235843908542390482950283945048902849230583496038920385934087";
// bisection counter
@jnschulze
jnschulze / dwcas16.d
Created May 2, 2011 20:04
double-word compare-and-swap function using cmpxchg16b (D language)
// by Niklas Schulze / nischu7 <n7@pronghorn.org>
//
// requires cmpxchg16b CPU instruction
// required GDC patch: http://bitbucket.org/nischu7/gdc/changeset/d8a2a73fb3d8
bool dwcas16(T, V1, V2)(T* here, const V1 ifThis, const V2 writeThis)
{
asm
{
/*
mov RAX, ifThis; // copy ifThis[0] to RAX