Skip to content

Instantly share code, notes, and snippets.

View gubatron's full-sized avatar

Angel Leon gubatron

View GitHub Profile
@gubatron
gubatron / split_huge_diff.sh
Last active September 26, 2024 15:26
split_huge_diff.sh
split_file() {
local file="$1"
if [[ ! -f "$file" ]]; then
echo "File '$file' does not exist."
return 1
fi
# Use short options compatible with your version of split
split -b 50k -a 2 "$file" "${file}.part"
@gubatron
gubatron / liblurk_mobile_build.sh
Last active March 17, 2024 05:18
Building lurl-lab/lurk-rs dart binding for iOS
git clone git@github.com:lurk-lab/lurk-rs.git
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
gubatron / delete_github_workflow_run_logs.sh
Last active October 12, 2024 22:06
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: https://github.com/settings/tokens
#
# once you've created the personal access token with permission to manage your workflows
@gubatron
gubatron / dynamic_dockerfile_host_architecture.md
Last active November 28, 2022 17:56
How to build your Docker image using the same Dockerfile regardless of the host architecture

How to build your Docker image using the same Dockerfile regardless of the host architecture

Problem

If you are now using docker on a Mac M1 (arm64 platform), you don't want to use amd64 as the architecture for your Linux Images.

You could have 2 lines on your Dockerfile and comment each one depending on where you're building the image

Dockerfile

# Building on Apple Silicon host
@gubatron
gubatron / config_php8.sh
Created September 12, 2022 23:03
script to build php8.1.10 from source so that we can link to openssl1.1.1 (new ubuntu 22.04 makes use of openssl 3 and it breaks a lot of stuff that depended on weaker ciphers)
sudo apt install build-essential autoconf libtool bison re2c pkg-config libwebp-dev libxml2-dev libsqlite3-dev libbz2-dev libcurl4-openssl-dev libpng-dev libjpeg-dev libfreetype-dev libonig-dev libedit-dev libreadline-dev libzip-dev
cd php-8.1.10
#builds configure file if there isn't one
./buildconf
#./configure --help for full list of options
./configure --with-curl \
--disable-cgi \
@gubatron
gubatron / eight_queens.py
Last active April 19, 2022 22:04
eight_queens.py - Decent brute force 8 queens state finder (takes about 235k iterations)
from random import shuffle
'''
This module tries to solve the 8 queens problem.
'''
identity_rows = [0, 1, 2, 3, 4, 5, 6, 7]
def queens_attack_each_other(queen_a, queen_b):
'''True if 2 queens face each other'''
return queen_a[0] == queen_b[0] or queen_a[1] == queen_b[1] or abs(queen_a[0] - queen_b[0]) == abs(queen_a[1] - queen_b[1])
@gubatron
gubatron / complex.js
Created April 14, 2022 17:46
Class to represent a Complex number and a few operations that can be done with them
class Complex {
constructor(real, imag) {
this.real = real
this.imag = imag
}
length() {
return Math.sqrt(this.real * this.real + this.imag * this.imag)
}
@gubatron
gubatron / merkle.py
Created March 23, 2022 20:50
Crates a Merkle Tree using the given data, per light Clients for Lazy Blockchains paper by Ertem Nusret Tas et. al
import hashlib
import binascii
def H(data):
if type(data) == str:
data = str.encode(data)
if type(data) == int:
data = data.to_bytes(4, 'big')
return hashlib.sha256(data).digest()
@gubatron
gubatron / remove_repeated_snapshots_from_sqlite3_db.py
Last active March 6, 2022 16:24
remove repeated entries on a sqlite3 table (there's no delete limit 1 in sqlite3, you gotta do a select within the delete statement)
import sqlite3
# python script to cleanup double entries on the marketsnapshots table.
#CREATE TABLE marketsnapshots (
# symbol TEXT,
# ...
# lastupdatetime INTEGER);
def symbolList(cur):
@gubatron
gubatron / gist:c8ecee2d54033a0b131812324e5a7a33
Created January 6, 2022 15:50
Fixing "configure: error: ACC conformance test failed. Stop." when building ucl on macos with M1 (arm64) CPU
git clone git@github.com:Distrotech/ucl.git
cd ucl
./configure CFLAGS="$CFLAGS -Wno-error=implicit-function-declaration"
make -j 10
sudo make install