Skip to content

Instantly share code, notes, and snippets.

@rbitr
rbitr / random_notes.md
Last active November 10, 2023 16:34
Confusion about using $RANDOM to generate random numbers

Random numbers in bash et al

There is a variable $RANDOM than you can read in bash or zsh to get a random number beteen 0 and 32767. Here in zsh on my (old) mac:

% echo $RANDOM
13757
% echo $RANDOM
16896
@AdamISZ
AdamISZ / RIDDLE.md
Last active April 3, 2023 20:00
Lightweight anti-Sybil with anonymity in Bitcoin

RIDDLE

Due to unexpected failures of github's LaTeX parsing (which were not evident until I published this, but have persisted afterwards), and since the mathematical parts are important in this, I have migrated this proposal to a blog post with identical content, but correctly formatted equations.

Please continue to put any comments here.

Replace by Fee Improvements

This post discusses limitations of current Bitcoin Core RBF policy and attempts to start a conversation about how we can improve it, summarizing some ideas that have been discussed. Please reply if you have any new input on issues to be solved and ideas for improvement!

Background

Please feel free to skip this section if you are already familiar

@zeux
zeux / clang27.md
Last active January 27, 2024 11:45
How does clang 2.7 hold up in 2021?

A friend recently learned about Proebsting's law and mentioned it to me off hand. I knew about the law's existence but I never really asked myself - do I believe in it?

For people who aren't aware, Proebsting's law states:

Compiler Advances Double Computing Power Every 18 Years

Which is to say, if you upgrade your compiler every 18 years, you would expect on average your code to double in performance on the same hardware.

Let's C about this

@prologic
prologic / LearnGoIn5mins.md
Last active July 3, 2024 04:05
Learn Go in ~5mins
@gubatron
gubatron / hack_n_debug_bitcoin_with_gdb_or_LLDB.md
Last active January 18, 2023 16:21
How to build bitcoin and debug with GDB or LLDB

Hack and Debug with gdb or LLDB, using Bitcoin's code as an example

/*
 * Copyright CC0 Angel Leon <@gubatron>
 */

Update: I believe now it's better to use lldb, at least on MacOS, here's a LLDB to GDB command map

Here's how to use gdb to debug issues you might be having hacking bitcoinclassic (or any other C++ program)

@joepie91
joepie91 / .md
Last active April 12, 2024 16:08
Prefix codes (explained simply)

A "prefix code" is a type of encoding mechanism ("code"). For something to be a prefix code, the entire set of possible encoded values ("codewords") must not contain any values that start with any other value in the set.

For example: [3, 11, 22] is a prefix code, because none of the values start with ("have a prefix of") any of the other values. However, [1, 12, 33] is not a prefix code, because one of the values (12) starts with another of the values (1).

Prefix codes are useful because, if you have a complete and accurate sequence of values, you can pick out each value without needing to know where one value starts and ends.

For example, let's say we have the following codewords: [1, 2, 33, 34, 50, 61]. And let's say that the sequence of numbers we've received looks like this:

1611333425012

@KristobalJunta
KristobalJunta / display-layout.sh
Created December 14, 2016 12:59
A script to display current keyboard layout in i3status
#!/bin/bash
# a shell scipt to prepend i3status with more stuff
i3status --config ~/.i3status.conf | while :
do
read line
LG=$(setxkbmap -query | awk '/layout/{print $2}')
echo "LG: $LG | $line" || exit 1
done
@yvan-sraka
yvan-sraka / max.py
Last active October 14, 2023 17:00
Max function implementation explained in Python
# Input data
list_0 = [1, 3, 6, 7, 8, 9, 10, 2, 3, 4]
list_1 = [12, 56, 3, 78, 34, 56, 2, 10]
list_2 = [123, 567, 234, 890]
list_3 = [5, 7, 8, 9, 3, -2, -4, -2, 5, 6, 8, 11, 2]
# Iterative algorithm
def maximum(L):
biggest_item = L[0]
for item in L:
@fffaraz
fffaraz / lsniffer.c
Last active February 12, 2023 11:42
Packet Sniffer Code in C using Linux Sockets | http://www.binarytides.com/packet-sniffer-code-c-linux/
/*
Packet sniffer using libpcap library
*/
#include<pcap.h>
#include<stdio.h>
#include<stdlib.h> // for exit()
#include<string.h> //for memset
#include<sys/socket.h>
#include<arpa/inet.h> // for inet_ntoa()