Skip to content

Instantly share code, notes, and snippets.

View gubatron's full-sized avatar

Angel Leon gubatron

View GitHub Profile
@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 [email protected]:Distrotech/ucl.git
cd ucl
./configure CFLAGS="$CFLAGS -Wno-error=implicit-function-declaration"
make -j 10
sudo make install
@gubatron
gubatron / int_as_array.cpp
Last active November 12, 2021 17:10
Access and manipulate an int via char array using an union. C Plus plus
#include <iostream>
int main() {
union {
unsigned int a; // 32 bit number, 4 bytes
unsigned char aa[4]; // access a's bytes as an array
};
a = 0xaabbccdd;
printf("a: 0x%x\n", a); // a: 0xaabbccdd
@gubatron
gubatron / adb_logcat_ndk_stack.md
Created September 12, 2021 02:08
How to isolate crashes with `ndk-stack` from `adb logcat` output

adb logcat | ndk-stack -sym <path to folder with .so files>

Example: adb logcat | ndk-stack -sym ~/workspace.frostwire/frostwire-jlibtorrent/swig/bin/release/android/armeabi-v7a

@gubatron
gubatron / random_squares.html
Created August 22, 2021 03:52
Bouncing random colored squares in Javascript using basic canvas 2D api
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Canvas tutorial</title>
<script type="text/javascript">
const max_x = 2048
const max_y = 2048
const bgcolor = 'rgb(0,0,0)'
const fgcolor0 = 'rgb(200, 0, 0)'
@gubatron
gubatron / testListingNetworkInterfaces.java
Created June 26, 2021 01:07
testListingNetworkInterfaces.java
private static void testListingNetworkInterfaces() {
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
NetworkInterface iface;
while (networkInterfaces.hasMoreElements()) {
iface = networkInterfaces.nextElement();
LOG.info("displayName:" + iface.getDisplayName() + " " +
"index:" + iface.getIndex() + " " +
"isUp:" + iface.isUp() + " " +
"isVirtual:" + iface.isVirtual() + " " +

1er Semestre

  • Calculo I
  • Geometría Descriptiva I
  • Lenguaje
  • Humanidades I

2do Semestre

  • Calculo II
  • Geometría Descriptiva II
  • Lógica Computacional