Skip to content

Instantly share code, notes, and snippets.

View hertzg's full-sized avatar
🏠
Working from home

George Hertz hertzg

🏠
Working from home
View GitHub Profile
@hertzg
hertzg / 7seg2bcd.mjs
Last active December 2, 2023 02:21
7 Segment to BCD encoder
const seg7_bcd = ([a, b, c, d, e, f, g]) => {
const w = (a & b & f & g) | (!b & !c & e) | (!a & e);
const x = (!a & b & g) | (a & !f & !g) | (a & !b);
const y = (!b & e & g) | (!d & e) | (a & !f);
const z = (!c & !d & g) | (c & !f) | (a & !e) | (!a & e);
return [w, x, y, z];
};
const TRUTH_TABLE = [
["0000000", "0000", " "],
@hertzg
hertzg / build.yml
Created September 29, 2023 12:10 — forked from aslak01/build.yml
private tap github actions publish on tag
name: build
on:
push:
branches: master
jobs:
tap:
runs-on: macos-latest
steps:
@hertzg
hertzg / catalog.jsond
Last active May 8, 2023 15:21
საქკაბელის კატალოგი
{"page":1,"items":[{"id":"16274","name":"NA2XSEY კაბელი – 3*50 / 16 6/10KV","price":"₾30.000","url":"https://www.sakcable.ge/sk-product/na2xsey-sakcable-%e1%83%99%e1%83%90%e1%83%91%e1%83%94%e1%83%9a%e1%83%98/"},{"id":"6697","name":"H05VV-F 4*240","price":"₾393.8700","url":"https://www.sakcable.ge/sk-product/h05vv-f-4-240-%e1%83%a1%e1%83%90%e1%83%a5%e1%83%99%e1%83%90%e1%83%91%e1%83%94%e1%83%9a%e1%83%98-sakcable/"},{"id":"6698","name":"H05VV-F 4*120+1*35","price":"₾214.5900","url":"https://www.sakcable.ge/sk-product/h05vv-f-4120135/"},{"id":"6674","name":"ას 50/8.0","price":"₾2.67","url":"https://www.sakcable.ge/sk-product/%e1%83%90%e1%83%a1-50-8-sadeni-%e1%83%a1%e1%83%90%e1%83%93%e1%83%94%e1%83%9c%e1%83%98-%e1%83%94%e1%83%9a%e1%83%94%e1%83%a5%e1%83%a2%e1%83%a0%e1%83%9d/"},{"id":"6654","name":"ას 25/4/.2","price":"₾1.44","url":"https://www.sakcable.ge/sk-product/%e1%83%90%e1%83%a1-25-4-2-acsr-iec-61089-kabelebi-kabeli-araizolirebuli-kabelebi/"},{"id":"6638","name":"ას 16/2.7","price":"₾0.97","url":"https://www.
@hertzg
hertzg / mikrotik-ping-notification.txt
Created March 28, 2023 23:41 — forked from sitchi/mikrotik-ping-notification
MikroTik check ping status and send SMS
# RouterOS script for pinging a list of addresses (sending SMS from UBILL API https://ubill.ge)
# Example
# Insert script: System > Scheduler > + Name=ubill-ping; interval=00:01:00;
# insert IP for monitoring: IP > Firewall > Address Lists > + Name=ubill-ping; Address=1.1.1.1; Comment=Router-Tbilisi;
:local ip;
:local disabled;
:local com;
/ip firewall address-list
@hertzg
hertzg / createRsaPublicKeyFromComponents.mjs
Created September 16, 2022 22:03
Create RSA Public Key Object form modulus and exponent components using node Crypto
import { createPublicKey } from "node:crypto";
const length = (n) => {
if (n < 0x80) {
return [n];
} else if (n < 0x100) {
return [0x81, n];
} else if (n < 0x10000) {
return [0x82, n >>> 8, n & 255];
} else if (n < 0x1000000) {
name platform slug uname -m
x86/i686 linux/i386 i386 i386
Linux x86-64 linux/amd64 amd64 x86_64
ARMv5 32-bit linux/arm/v5 arm32v5 armv5l
ARMv6 32-bit linux/arm/v6 arm32v6 armv6l
ARMv7 32-bit linux/arm/v7 arm32v7 armv7l
ARMv8 64-bit linux/arm64/v8 arm64v8 aarch64
IBM POWER8 linux/ppc64le ppc64le ppc64le
IBM z Systems linux/s390x s390x s390x
@hertzg
hertzg / 00-cloud-config.yml
Created March 13, 2021 22:59 — forked from janeczku/00-cloud-config.yml
Annotated RancherOS Cloud-init configuration snippets
#cloud-config
# Set the hostname for this machine (takes precedence over hostname assigned by DHCP lease).
hostname: myhost
# Authorize SSH keys for the `rancher` sudoer user
ssh_authorized_keys:
- ssh-rsa AAA...ZZZ example1@rancher
@hertzg
hertzg / notes.txt
Created September 4, 2020 16:11
etekcity esn00 protocol samples.txt
<Buffer fe ef c0 a2 e0 01 00 e1> - err on
<Buffer fe ef c0 a2 e0 01 01 e2> - err off
<Buffer fe ef c0 a2 d3 01 00 d4> - Tare set/update
<Buffer fe ef c0 a2 d3 01 01 d5> - Tare off
<Buffer fe ef c0 a2 e4 01 00 e5> - Item on scale
<Buffer fe ef c0 a2 e4 01 01 e6> - No item on scale
<Buffer fe ef c0 a2 d0 05 01 06 4a 00 01 27> - sld - g - t - -161
@hertzg
hertzg / footgun.md
Created August 13, 2019 13:20 — forked from Rich-Harris/footgun.md
Top-level `await` is a footgun

Edit — February 2019

This gist had a far larger impact than I imagined it would, and apparently people are still finding it, so a quick update:

  • TC39 is currently moving forward with a slightly different version of TLA, referred to as 'variant B', in which a module with TLA doesn't block sibling execution. This vastly reduces the danger of parallelizable work happening in serial and thereby delaying startup, which was the concern that motivated me to write this gist
  • In the wild, we're seeing (async main(){...}()) as a substitute for TLA. This completely eliminates the blocking problem (yay!) but it's less powerful, and harder to statically analyse (boo). In other words the lack of TLA is causing real problems
  • Therefore, a version of TLA that solves the original issue is a valuable addition to the language, and I'm in full support of the current proposal, which you can read here.

I'll leave the rest of this document unedited, for archaeological

@hertzg
hertzg / save.py
Created March 30, 2019 15:32 — forked from mickael9/save.py
Factorio map metadata parser
from zipfile import ZipFile
from struct import Struct
class Deserializer:
u16 = Struct('<H')
u32 = Struct('<I')
def __init__(self, stream):
self.stream = stream