Skip to content

Instantly share code, notes, and snippets.

View eliask's full-sized avatar
🥼

Elias Kunnas eliask

🥼
View GitHub Profile
@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 / fetch_edenred.sh
Last active May 28, 2022 14:10
Fetch data on places which accept Edenred.fi cards/vouchers
#! /usr/bin/env bash
set -eu
city=helsinki
for type in restaurant sport culture; do
for page in {0..5000}; do # limit to 5000 queries on failure.
url="https://search.edenred.fi/affiliates?page=${page}&count=30&city=${city}&type=${type}"
file=edenred_${type}_${city}_page_${page}.json
curl -fL "$url" > "$file"
@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 / factorio-recipe-parser.lua
Last active September 10, 2021 15:41 — forked from pfmoore/factorio-recipe-parser.lua
Parse the Factorio recipe files to create a CSV of recipes
--[[ Usage
Windows:
lua factorio-recipe-parser.lua "C:/Apps/Factorio/data/base/prototypes/recipe/"
Steam on macOS:
lua factorio-recipe-parser.lua ~/"Library/Application Support/Steam/steamapps/common/Factorio/factorio.app/Contents/"
NB: json.lua is from https://gist.github.com/tylerneylon/59f4bcf316be525b30ab
]]--
@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 / dump_ryver.py
Created June 11, 2018 13:31
Dump/Archive/Export Ryver.com forum chat history
#! /usr/bin/env python3
# Usage: dump_ryver_forum.py <PHPSESSID> <forum name, like "foo.ryver.com"> <forum ids, e.g. 1217356 ...>
# Requires Python 3.6 and the `requests` library:
# pip install requests
import requests
import sys
import time
session_id = sys.argv[1]
forum_name = sys.argv[2]
@eliask
eliask / ppxml.py
Last active August 24, 2020 11:40
Pretty print XML files with python xml.dom.minidom
#!/usr/bin/env python
# ppxml - pretty print XML from stdin or argv files
#
# NB: if multiple XML files are specifies, concatenates the prettyprinted
# versions one after the other.
#
# Python 2 and Python 3 compatible AFAICT.
#
import sys
import xml.dom.minidom as md
@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