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
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 / console.save.ts
Created November 1, 2023 16:06
Console Save
declare global {
interface Console {
save(data: any, filename?: string): void;
}
}
(function (console: Console) {
console.save = function (data: any, filename?: string): void {
if (!data) {
console.error('Console.save: No data');

Source

source

jpeg

jpeg

@32teeth
32teeth / pre-commit
Created May 26, 2023 13:55
git pre-commit hook to clean your Eagle CAD files
#!/bin/sh
find ./ -type f \( -iname \*.b#\* -o -iname \*.s#\* \) -delete
const MAX_LOOP_DURATION = 100; // Maximum duration of the ResizeObserver loop in ms
let resizeTimeout;
let resizeStartTime;
const observer = new ResizeObserver(entries => {
if (resizeTimeout) {
clearTimeout(resizeTimeout);
}
@32teeth
32teeth / index.html
Created September 15, 2022 03:24
Waves with blurred backdrop - JavaScript Segments
<canvas></canvas>
<section>
<h1>32teeth</h1>
<h2>this pen needs ❤</h2>
</section>
<div class='blur'></div>

List

code --list-extensions | xargs -L 1 echo code --install-extension

Dump

code --install-extension amazonwebservices.aws-toolkit-vscode
code --install-extension arcticicestudio.nord-visual-studio-code
code --install-extension dbaeumer.vscode-eslint
@32teeth
32teeth / CRC.h
Created February 4, 2020 17:23
CRC
#include <rom/crc.h>
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include "gui.h"
#include "odroid_display.h"