Skip to content

Instantly share code, notes, and snippets.

View gubatron's full-sized avatar

Angel Leon gubatron

View GitHub Profile
gubatron /
Last active June 9, 2024 06:09
DHT walkthrough notes

DHT Walkthrough Notes

I've put together these notes as I read about DHT's in depth and then learned how the libtorrent implementation based on the Kademlia paper actually works.

What problem does this solve?

400,000,000,000 (400 billion stars), that's a 4 followed by 11 zeros. The number of atoms in the universe is estimated to be around 10^82. A DHT with keys of 160 bits, can have 2^160 possible numbers, which is around 10^48

gubatron /
Last active April 18, 2024 07:58
Things to remember when compiling and linking C/C++ programs

Things to remember when compiling/linking C/C++ software

by Angel Leon. March 17, 2015;

Last update on December 14, 2023

Updated on February 27, 2023

Updated August 29, 2019.

gubatron /
Last active March 17, 2024 05:18
Building lurl-lab/lurk-rs dart binding for iOS
git clone
cd lurk-rs
git submodule update --init --recursive
rustup target add aarch64-apple-ios
cargo build --target aarch64-apple-ios --release
ls -l target/aarch64-apple-ios/release/
cd target/aarch64-apple-ios/release
ar x liblurk.rlib
ar rcs liblurk.a *.o
ls -l liblurk.a
gubatron /
Last active March 12, 2024 07:34
How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent

How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent

Let's say alice is a user, with 2 or more private repositories repoN. For this example we'll work with just two repositories named repo1 and repo2

You need to be to pull from these repositories without entering a passwords probably on a server, or on multiple servers.

gubatron / Entitlements.plist
Last active December 15, 2023 12:52
An example Entitlements.plist file to allow a desktop app to run a Java Runtime Environment on a signed .app
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
function selectText(element) {
var doc = document
, text = doc.getElementById(element)
, range, selection
if (doc.body.createTextRange) { //ms
range = doc.body.createTextRange();
} else if (window.getSelection) { //all others
gubatron /
Last active June 30, 2023 20:08
Batch delete 30 Github Workflow Run Logs using the github command line tool
# This script uses the github command line tool
# to delete the last 30 logs from your repository's workflow runs
# Requirements
# gh - github command line (brew install gh)
# you will need a GH_TOKEN, create it here:
# once you've created the personal access token with permission to manage your workflows
gubatron / random_pixel_generator_test.cpp
Last active June 27, 2023 10:56
Playing with /dev/urandom Random Number generation and ImageMagick in C++ to visualize randomness or patterns.
#include <Magick++.h>
#include <random>
#include <iostream>
#define HEIGHT 1024
#define WIDTH 1024
#define RANDOM_POINTS 786432 //75% of the area if no points would repeat
using namespace Magick;
using namespace std;
gubatron /
Created September 6, 2014 12:10
check if command exists (linux, mac)
function command_exists {
#this should be a very portable way of checking if something is on the path
#usage: "if command_exists foo; then echo it exists; fi"
type "$1" &> /dev/null
gubatron / galton.js
Last active February 22, 2023 13:31
simulation of balls falling into normal distribution to teach javascript
function rand(max) {
return parseInt(Math.random() * max);
function f(h, i) {
if (rand(1000) < 500) {
return i
return i + 1