Skip to content

Instantly share code, notes, and snippets.

View eliask's full-sized avatar
🥼

Elias Kunnas eliask

🥼
View GitHub Profile
@eliask
eliask / groq.sh
Last active August 8, 2024 22:58
Groq simple CLI
#! /usr/bin/env bash
# Usage: groq.sh "Convert foo to bar" < file.foo > file.bar
set -Eeuo pipefail
content="$@
$(cat)"
escaped_content=$(jq -Rsa . <<< "$content")
model="llama-3.1-8b-instant"
@eliask
eliask / nformat.ts
Created July 10, 2024 09:02
nformat - significant digits and maximum precision aware number formatting in Typescript
/**
* nformat - significant digits and maximum precision aware number formatting with SI prefixes + null value handling
*
* Examples:
* nformat({na: "", maxPrecision: 5, significantDigits: 4, si: "si", unit: 'J', value: 1231.2278346237846e12})
* -> "1.2313 PJ"
* nformat({na: "", maxPrecision: 1, significantDigits: 9, si: "english", unit: ' kg', value: 1231.2278346237846e4})
* -> "12.3122783M kg"
* nformat({na: "", maxPrecision: 2, significantDigits: 3, unit: ' s', value: 1231.2278346237846e-3})
* -> "0.12 s"
@eliask
eliask / braiinsApi.ts
Created February 25, 2023 13:31
Braiins pool API responses in Typescript
// https://help.braiins.com/en/support/solutions/articles/77000433512-api-configuration-guide
type HashRateUnit = "Gh/s" | "Th/s" | "Ph/s";
const _sampleStatsResponse: GeneralPoolStatsResponse = {
btc: {
luck_b10: "0.77",
luck_b50: "0.85",
luck_b250: "0.93",
hash_rate_unit: "Gh/s",
@eliask
eliask / mount.sh
Created June 9, 2022 09:43
Mount drive on WSL2 manually
sudo mount -t drvfs 'G:\\' -o 'uid=1000;gid=1000;metadata;symlinkroot=/mnt/,mmap,access=client,msize=262144,trans=virtio,rw,noatime,dirsync,aname=drvfs' /mnt/g
@eliask
eliask / wintoast.py
Created February 17, 2022 17:17
Windows toast notification with Python
import sys
from xml.sax.saxutils import escape
import winrt.windows.ui.notifications as notifications
import winrt.windows.data.xml.dom as dom
from winrt.windows.ui.notifications import ToastNotificationManager, ToastNotification, ToastTemplateType
if not sys.argv[2:]:
print(f'Usage: {sys.argv[0]} <title> <message ...>')
sys.exit(1)
@eliask
eliask / telegram_types.py
Created October 23, 2020 13:55
Telegram Bot API types in Python
from typing import List, Optional, Union
from dataclasses import dataclass
@dataclass
class CallbackGame: pass # Placeholder - zero fields in API doc
InputMessageContent = Union[
'InputTextMessageContent',
'InputLocationMessageContent',
@eliask
eliask / classify.py
Last active April 27, 2020 13:01
Classifying images with Python and HTML (type o/x for ok/bad)
import http.server
import socketserver
import os, sys, re, glob, shutil
from pathlib import *
PORT = int(sys.argv[1])
def get_known():
try:
known_bad = list({x.strip() for x in open('known_bad.txt').read().strip().split('\n')})
import os, glob, sys
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.expected_conditions import presence_of_element_located
from selenium.webdriver.support import expected_conditions as EC
@eliask
eliask / fix_stepmania_chart_links.sh
Created October 8, 2019 12:24
Fix Stepmania/ITG chart BGCHANGES videos/images
@eliask
eliask / install_s4tf.sh
Created August 26, 2019 10:02
Swift for Tensorflow Ubuntu 18.04 idempotent install script
#! /usr/bin/env bash
#
# This is an install script to get a working Swift for Tensorflow
# environment with minimal fuss. Assumes Ubuntu 18.04 and bash.
#
# The script is idempotent so it can be safely run multiple times.
#
# The script uses an existing Anaconda/Miniconda installation
# or installs Miniconda to ~/miniconda3 if missing
#