Skip to content

Instantly share code, notes, and snippets.

View AndreVallestero's full-sized avatar
🦀

Andre Vallestero AndreVallestero

🦀
View GitHub Profile
@AndreVallestero
AndreVallestero / config
Last active September 26, 2022 14:54
amazon-ubuntu-i3
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
@AndreVallestero
AndreVallestero / Godot_icon.min.svg
Last active November 29, 2021 20:32
Optimized by hand for a 7x size reduction based on https://commons.wikimedia.org/wiki/File:Godot_icon.svg, can be compressed further using pigz -11n -I 99 Godot_icon.min.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AndreVallestero
AndreVallestero / binary_search.py
Created November 2, 2021 01:14
binary_search.py
def binarySearch(arr, x):
maxIndex = len(arr) - 1
low = 0
high = maxIndex
mid = 0
while low <= high:
mid = (low + high) // 2
if arr[mid] < x: low = mid + 1
elif arr[mid] > x: high = mid - 1
@AndreVallestero
AndreVallestero / 4_sum.py
Created November 1, 2021 22:26
Solution for 4 sum problem, has duoTarget optimization for 33% speedup
class Solution:
def fourSum(self, nums: List[int], target: int) -> List[List[int]]:
lenNums = len(nums)
nums.sort()
quads = []
for i in range(lenNums - 3):
if nums[i] == nums[i-1] and i > 0: continue
for j in range(i + 1, lenNums - 2):
if nums[j] == nums[j-1] and j > i + 1: continue
// timeout in ms
async function checkTxConfirmation(txId, timeout) {
console.log(`Waiting for TX: ${txId}`);
const start = Date.now();
for (;;) {
const status = (await arweave.transactions.getStatus(txId)).status;
switch (status) {
case 202:
case 404:
break;
@AndreVallestero
AndreVallestero / serde_benchmark.js
Last active August 26, 2021 15:22
Javascript [de]serialization benchmark
const fs = require("fs");
const { serialize, deserialize } = require("v8")
// wget https://www.bundler.openkoi.com/state/current
const stateStr = fs.readFileSync("current.json", "utf8");
const state = JSON.parse(stateStr);
const stateStrBuf = Buffer.from(stateStr);
const stateSer = serialize(state);
// Warmup
@AndreVallestero
AndreVallestero / minimal-image.md
Last active June 30, 2021 19:26
Guide for cloning drives to make a minimal image
@AndreVallestero
AndreVallestero / chunk-generate-combinations.rs
Last active June 29, 2021 23:42
Chunk generate combinations for multi threaded combination generation
/*
* n Number of elements in the pool
* k Number of elements to choose for each combination, k <= n
* init_index The starting index, init_index + k <= n
*/
fn chunk_generate_combinations(n: usize, k: usize, init_index: usize) {
let mut indices: Vec<usize> = (init_index..init_index + k).collect();
let k_sub_1 = k - 1;
let n_sub_k = n - k;

alpine-persistent-usb

Guide for making an Alpine Linux USB with persistence

Note: Replace all instances of {?X} (including the braces) with the proper value

Preparation

  1. Download the latest version of Alpline Standard x86_64
  2. Write it to a USB using dd or rufus and leave a shared or unallocated partition to use later for your /home directory
  3. Reboot to your boot menu and boot to Alpine on the USB
@AndreVallestero
AndreVallestero / clicker.py
Created March 19, 2021 15:04
window clicker
from win32gui import GetWindowRect, FindWindow, GetCursorInfo
from ctypes import windll
MOUSEEVENTF_LEFTDOWN = 0x0002
MOUSEEVENTF_LEFTUP = 0x0004
MOUSEEVENTF_CLICK = MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP
class Clicker():
def __init__(self, windowTitle: str):
self.win_x, self.win_y, win_x2, win_y2 = GetWindowRect(FindWindow(None, windowTitle))