Skip to content

Instantly share code, notes, and snippets.

View acarapetis's full-sized avatar

Anthony Carapetis acarapetis

View GitHub Profile
#!/usr/bin/ruby
WACOM_DEVICE_IDS = [12, 13]
ROTATIONS = %w{ NONE CCW HALF CW };
RANDR_VALUES = {
'NONE' => 'normal',
'CCW' => 'left',
'HALF' => 'inverted',
'CW' => 'right',
#!/bin/bash
#
# "Wacom Rotation" can be 0, 1, 2 or 3 where 1 is +90, 2 is -90 and 3 is 180 in degrees
# "Wacom ISDv4 E3" id=11
# "Wacom ISDv4 E3" eraser id=12
# "Wacom ISDv4 E3" id=13
#
# using device numbers of the stylus (10) or screen (12) is fragile as they can
# change however "Wacom ISDv4 E3" is not unique afaict
@acarapetis
acarapetis / shakemap_conda.txt
Created January 31, 2019 02:57
Working miniconda environment for shakemap 4
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: linux-64
affine=2.2.2=py_0
alabaster=0.7.12=py_0
amptools=1.1.7=py_0
asn1crypto=0.24.0=py35_3
atomicwrites=1.2.1=py_0
attrs=18.2.0=py_0
autopep8=1.4.3=py_0
grammar NotJSON
rule document
(space value space) {
capture(:value).value
}
end
rule value
number | str | hash
end
@acarapetis
acarapetis / covid19.ipynb
Last active January 14, 2022 02:39
quick covid19 log plot
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@acarapetis
acarapetis / RIstats.py
Last active April 8, 2022 10:39
Python script to assess EC2 Reserved Instance usage
#!/usr/bin/env python3
import boto3
from collections import defaultdict
ris = boto3.client("ec2").describe_reserved_instances()["ReservedInstances"]
ri_counts = defaultdict(lambda: 0)
for ri in ris:
if ri["State"] == "active":
ri_counts[ri["InstanceType"]] += ri["InstanceCount"]
@acarapetis
acarapetis / dag_runner.py
Last active August 15, 2022 08:04
simple task DAG executor in python
from concurrent.futures import ProcessPoolExecutor, wait, FIRST_COMPLETED
from typing import Iterable, Set
from time import sleep
class Task:
_tasks = {} # job registry: see run_job below
def __init__(self, fun, name=None, deps=None, **kwargs):
self.do_work = fun
self.deps = set(deps or [])
@acarapetis
acarapetis / csv_to_parquet.py
Last active September 14, 2022 06:49
csv_to_parquet.py
"""CLI tool to stream CSV (from stdin) to parquet"""
import sys
from pathlib import Path
from typing import TextIO
import pandas as pd
CHUNKSIZE=2**16 # ~65k rows per parquet chunk
def convert(instream: TextIO, outdir: Path, chunksize=CHUNKSIZE):
@acarapetis
acarapetis / rename_replays.py
Last active February 24, 2024 20:19
Stormgate replay renamer - See https://github.com/acarapetis/shroudstone for newest version
#!/usr/bin/env python3
# This script works, but a nicer version is now available at https://github.com/acarapetis/shroudstone
from pathlib import Path
from typing import NamedTuple
from urllib.request import urlopen
from datetime import datetime, timezone, timedelta
from time import sleep
import json
import pandas as pd
@acarapetis
acarapetis / .xsession
Last active July 11, 2024 01:05
Simple local VNC setup [NO SECURITY]
#!/bin/bash
# ~/.xsession
systemctl --user import-environment DISPLAY XAUTHORITY
systemctl --user restart xdg-desktop-portal-gtk
i3