Skip to content

Instantly share code, notes, and snippets.

View 32teeth's full-sized avatar
:octocat:
Get it done. Right.

Eugene Andruszczenko 32teeth

:octocat:
Get it done. Right.
View GitHub Profile
/**
* Ask clarifying questions:
* - What types of input are we expecting (valid HTML strings)?
* - What should happen in the event of invalid or non-HTML inputs?
* - Should we focus solely on HTML or handle any generic XML/HTML-like string input?
*
* Analyze various solutions and tradeoffs:
* - We could use `DOMParser()` to parse the HTML and detect structural errors.
* - Alternative methods like regular expressions are not suitable for parsing HTML due to its complexity.
@32teeth
32teeth / mypy.ini
Created August 19, 2024 20:27
mypy ini file (generic)
# mypy.ini
[mypy]
python_version = 3.10
strict = True
warn_unused_ignores = True
warn_redundant_casts = True
warn_unused_configs = True
warn_unreachable = True
show_error_codes = True
@32teeth
32teeth / challenge.c
Last active July 8, 2024 22:10
CODE100 - GSM-7 or UCS-2
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define GSM7_BITSET_SIZE 32 // 256 / 8
unsigned char gsm7_bitset[GSM7_BITSET_SIZE] = {0};
void init_gsm7_bitset() {
const char *gsm7_chars = "@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞ\x1BÆæßÉ "
"!\"#¤%&'()*+,-./0123456789:;<=>?"
@32teeth
32teeth / variables.css
Created March 29, 2024 00:31
CSS Variables: Used as a CDN for multiple projects
:root {
--scale-0: 1rem;
--scale-1: 1.125rem;
--scale-2: 1.25rem;
--scale-3: 1.5rem;
--scale-4: 1.875rem;
--scale-5: 2.25rem;
--scale-6: 3rem;
--scale-7: 3.75rem;
--scale-8: 4.5rem;
# Update your EV2 Amazon Linux box to whatever version you want
sudo apt purge nodejs npm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
nvm install node
source ~/.bashrc
nvm install latest
# LIVE THE DREAM
@32teeth
32teeth / EntityRelationship.js
Created March 13, 2024 19:45
Entity Relationship
class Queue {
constructor() {
this.elements = [];
}
enqueue = (e) => this.elements.push(e);
dequeue = (e) => this.elements.shift();
isEmpty = () => this.elements.length === 0;
peek = () => !this.isEmpty() ? this.elements[0] : undefined;
length = () => this.elements.length;
dump = () => this.elements;
const PORTS = new Map();
const CLIENTS = new Map();
onconnect = (e) => {
const port = e.ports[0];
PORTS.set(port, { port: port, uuid: this.uuid, username: null});
port.start();
@32teeth
32teeth / formatter.js
Created November 10, 2023 20:22
Cheap and dirty date formatter
const date = new Date();
date.setDate(date.getDate() - 2); // Set date to 2 days ago
const now = new Date();
const diffInMilliseconds = now - date;
const seconds = Math.floor(diffInMilliseconds / 1000);
const formatter = new Intl.RelativeTimeFormat('en', { numeric: 'auto' });
const formattedDate = formatter.format(
@32teeth
32teeth / hexToAnsiColors.sh
Last active November 2, 2023 20:50
Convert HTML Colors to ANSI esc colors
#!/bin/bash
hexToAnsiColors() {
local color_name="$1"
local hex="$2"
hex=${hex#"#"}
r=$(printf '0x%0.2s' "$hex")
g=$(printf '0x%0.2s' ${hex#??})
b=$(printf '0x%0.2s' ${hex#????})
@32teeth
32teeth / puppeteer_logging.md
Created November 1, 2023 16:45
Puppeteer Logging

Option 1

Wondering if we should enable sloMo

The slowMo option slows down Puppeteer operations by the specified amount of milliseconds. It's another way to help see what's going on.

This

    const config = {