Skip to content

Instantly share code, notes, and snippets.

@serxa
serxa / c++expr
Last active February 15, 2022 07:38
Bash script to compile, run and benchmark C++ one-liners
#!/usr/bin/env bash
set -e
usage() {
cat <<EOF >&2
USAGE: c++expr [-c CXX | -C | -I] [-i INCLUDE] [-b STEPS] [-t TESTS] [-o FILE] [-O CXX_OPTS...] [-g 'GLOBAL CODE'] 'MAIN CODE'
OPTIONS:
-c CXX use specified c++ compiler
-C use cmake
-I integrate into ClickHouse build tree in current directory
@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
@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;
@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);
/*
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
* Copyright 2010 Luis R. Rodriguez <lrodriguez@atheros.com>
*
* 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
@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
@
@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
@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
//-------------------------------------------------------------------------
@jboner
jboner / latency.txt
Last active May 17, 2024 01:05
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