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
@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 / 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