Skip to content

Instantly share code, notes, and snippets.

@jboner
jboner / latency.txt
Last active November 16, 2024 21:28
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@preshing
preshing / sort1mb.cpp
Created October 25, 2012 11:28
Sort one million 8-digit numbers in 1MB RAM
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef unsigned int u32;
typedef unsigned long long u64;
//-------------------------------------------------------------------------
// WorkArea
//-------------------------------------------------------------------------
@vishvananda
vishvananda / tunnel.sh
Created October 22, 2013 03:16
Script to set up an ipsec tunnel between two machines For Example: ./tunnel.sh 10.10.10.1 10.10.10.2 192.168.0.1 192.168.0.2 would set up an ipsec tunnel over 10.10.10.1 address using 192.168.0.1 as a virtual address passwordless sudo required for user on remote machine
#!/bin/bash
if [ "$4" == "" ]; then
echo "usage: $0 <local_ip> <remote_ip> <new_local_ip> <new_remote_ip>"
echo "creates an ipsec tunnel between two machines"
exit 1
fi
SRC="$1"; shift
DST="$1"; shift
@syuu1228
syuu1228 / arm-mmap.s
Last active December 8, 2021 21:20
Linux/arm EABI system call sample program
@ This is Linux/arm EABI system call sample program.
@
@ Build with following command:
@ as -o arm-mmap.o arm-mmap.s
@ ld -o arm-mmap arm-mmap.o
@
@ You can see the program issues system calls by following command:
@ strace ./arm-mmap
@
/*
* Copyright 2009 Johannes Berg <[email protected]>
* Copyright 2010 Luis R. Rodriguez <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@junian
junian / twitch-recorder.py
Last active October 14, 2024 06:01
Record Twitch Streams Automatically in Python
# This code is based on tutorial by slicktechies modified as needed to use oauth token from Twitch.
# You can read more details at: https://www.junian.net/2017/01/how-to-record-twitch-streams.html
# original code is from https://slicktechies.com/how-to-watchrecord-twitch-streams-using-livestreamer/
import requests
import os
import time
import json
import sys
import subprocess
@itsff
itsff / process_hollowing.c
Created March 8, 2017 21:30
A pretty neat exploit called Process Hollowing. You start a process suspended, then replace its content with the content of another.
#include <stdio.h>
#include <Windows.h>
#include <winternl.h>
#pragma comment(lib,"ntdll.lib")
EXTERN_C NTSTATUS NTAPI NtTerminateProcess(HANDLE,NTSTATUS);
EXTERN_C NTSTATUS NTAPI NtReadVirtualMemory(HANDLE,PVOID,PVOID,ULONG,PULONG);
EXTERN_C NTSTATUS NTAPI NtWriteVirtualMemory(HANDLE,PVOID,PVOID,ULONG,PULONG);
EXTERN_C NTSTATUS NTAPI NtGetContextThread(HANDLE,PCONTEXT);
@restorer
restorer / chooser.js
Last active September 29, 2020 06:32
Phone chooser
'use strict';
// На текущий момент страница со списком устройств на сайте /e/ поменяла дизайн,
// так что проверка поддерживает ли устройство /e/ не работает. Но раньше работало :)
const fs = require('fs').promises;
const path = require('path');
const axios = require('axios');
const cheerio = require('cheerio');
const Iconv = require('iconv').Iconv;
@c0d3z3r0
c0d3z3r0 / smcbmc_backup_crypt.txt
Last active November 1, 2024 05:14
Decrypt and re-encrypt Supermicro BMC config backups
Decrypt
openssl enc -d -des-ede3-cbc -in save_config.bin -out save_config.dec -K f1da33a298120612060792ffaa998811998877445588aabb -iv 0
dd if=save_config.dec bs=4 skip=1 | tar -xzf -
ls preserve_config/
bmc_hostname hostname_for_dhcp network SDRBlock tag
ddns ipctrl ntp server.pem timezone
DDNS_CONFIG lighttpd.conf OEMPSBlock service.conf wsman
ddns.key lighttpd_port.conf PSBlock snmpd.conf
ddns.private log ps.xml syslog.conf
@CarloCattano
CarloCattano / pi_MIDI_Brain.md
Last active May 9, 2024 01:48
Raspberry pi UART MIDI Serial

rp3.+ raspberry OS lite (or better PatchboxOS as a starting point)

https://blokas.io/patchbox-os/

testing notes
Disable bluetooth or send bt to another serial port
    sudo nano /boot/config.txt

    enable_uart=1    
   
 dtoverlay=midi-uart0