Skip to content

Instantly share code, notes, and snippets.

View 0ex-d's full-sized avatar

Precious 0ex-d

  • In The Company Of MEV Bots
  • My Naija Village
View GitHub Profile
@0ex-d
0ex-d / binary_tree.rs
Created November 21, 2024 20:13
Optimal Binary tree I use often in Rust
struct BinaryTree {
tree: Vec<u32>,
max_size: usize,
curr_size: usize,
}
impl BinaryTree {
fn new(max_size: usize) -> Self {
BinaryTree {
tree: vec![0; max_size + 1], // 1-based indexing
@0ex-d
0ex-d / wifi_scanner.rs
Created November 21, 2024 19:07
Wi-Fi scanner module for my ESP32 microcontroller
#![no_std]
#![no_main]
use embassy::executor::Spawner;
use embassy_net::wifi::{Wifi, WifiConfig};
use embassy_time::{Duration, Timer};
use esp_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*};
use log::info;
#[embassy::main]
@0ex-d
0ex-d / test-max-call-stack.js
Created November 18, 2024 15:44
A stack overflow can consume all available memory, leading to crashes.
const recurseFn =(counter)=> {
console.log(`Call count: ${counter}`);
recurse(counter + 1);
}
try {
recurseFn(1);
} catch (e) {
console.error(`Error: ${e.message}`);
}
@0ex-d
0ex-d / chunk-array.js
Created November 17, 2024 23:12
Reusable Array chuncks in Javascript
export const chunkArray = (arr, size) => arr.reduce((chunks, el, idx) => {
if (idx % size === 0) {
chunks.push([el]);
} else {
chunks[chunks.length - 1].push(el);
}
return chunks;
}, []);
// Usage:
@0ex-d
0ex-d / meter.py
Created October 26, 2024 02:37
Python script to read data from PPC Smart Meter Gateway Customer Interface (SMGW) via the HAN interface
#!/usr/bin/env python3
import requests, base64
from requests.auth import HTTPDigestAuth
from bs4 import BeautifulSoup
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
user= '12345678'
password = 'secret'

My Apps

  1. C'8 Coordinate: An international disaster aid coordination platform connecting first responders, volunteers, aid givers, and disaster victims to facilitate direct, transparent, and efficient aid distribution. Technologies: Python, JQuery/Vanilla Javascript, Socket.IO websockets, Google Cloud.

  2. AUOSIS Online: A student virtual platform developed during the COVID-19 used in my school. Technologies: Golang, React Native, Expo SDK.

  3. Hubyt: A community-driven platform for managing local hubs, enabling users to create and join local groups for sharing resources and information. Technologies: Python, React, Amazon S3.

  4. Hoztal: A web app for managing hostel accommodations, allowing users to book rooms, view amenities, and connect with hostel staff. Technologies: Python, React, Google Cloud.

@0ex-d
0ex-d / WS-optcode
Created November 20, 2023 13:28
My personal optcodes for WS handshakes
Text:
ping
pong
Binary:
01110000 01101001 01101110 01100111
01110000 01101111 01101110 01100111
Hex (ASCII):
@0ex-d
0ex-d / CLI_install.txt
Last active June 25, 2023 00:00
AWS setup on machine (Dowload latest AWS SDK for CLI https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) Most of the fiels are stored in ~/aws/
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
@0ex-d
0ex-d / create_bucket.js
Last active June 24, 2023 23:59
This is used for Cloudflare R2 which has a very similar Cloud infra stetup with AWS S3
const { S3Client, CreateBucketCommand } = require("@aws-sdk/client-s3");
// Replace the following placeholders with your own values
const bucketName = "your-bucket-name";
const region = "your-preferred-region";
// Set up the S3 client
const s3Client = new S3Client({ region });
// Create the S3 bucket