This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -Eeuo pipefail | |
new_version=$( | |
curl -fsL https://updater.factorio.com/get-available-versions | | |
jq -r '."core-linux_headless64"[].to|select(.)' | | |
python -c'import sys;v=max(sys.stdin,key=lambda x:tuple(map(int,x.split("."))));print(v.strip())' | |
) | |
cur_version=$(cat $HOME/factorio/.cur-version || true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68026 fi.freelancer.com | |
21031 fi.hotels.com | |
13819 fi.pinterest.com | |
12616 geocaching.com | |
9991 dwensa.info | |
9991 pelaajalehti.com | |
9986 menot.info | |
9939 forums.offipalsta.com | |
9493 etuovi.com | |
9319 nettikone.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77110 yle.fi | |
58025 aalto.fi | |
54801 iltalehti.fi | |
52602 helsinki.fi | |
26634 tekniikanmaailma.fi | |
26594 tulospalvelu.fi | |
22594 aprs.fi | |
20667 oikotie.fi | |
20482 uusisuomi.fi | |
20445 ilmatieteenlaitos.fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import base64 | |
import json | |
def main(path): | |
with open(path, 'rt') as fh: | |
j = json.load(fh) | |
for entry in j['log']['entries']: | |
if not 200 <= entry['response']['status'] < 300: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
headers = { | |
'Accept-Encoding': 'gzip, deflate, br', | |
'Accept-Language': 'fi', | |
'User-Agent': 'Mozilla/5.0', | |
'Accept': '*/*', | |
'Referer': 'https://www.verkkokauppa.com/fi/syyssiivous', | |
'Connection': 'keep-alive', | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# Prints the most recent timestamp for a file in a ZIP file (RFC-3339 format without timezone) | |
import datetime as dt | |
import sys | |
import zipfile | |
if not sys.argv[1:]: | |
print ('Usage: {} foo.zip'.format(sys.argv[0])) | |
exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Usage: arff2json.sh < foo.arff > foo.json | |
# Requires arff: pip install liac-arff | |
# Why shell instead of python? Probably because I thought the default one-liner was neat:) | |
# Default format: .data = list of lists | |
python -c 'import json,sys,arff;json.dump(arff.load(sys.stdin),sys.stdout)' | |
exit 0 | |
# Or convert data to attribute maps: .data = list of JSON objects/dicts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# pip install zstandard | |
# | |
# The zstandard bindings are a little off, compared to gzip, etc. | |
# So small tricks like this are needed to fully decompress a file in-memory: | |
dctx = zstd.ZstdDecompressor() | |
data = b''.join(dctx.read_to_iter(open('foo.zst', 'rb'))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# Usage: ndjson_to_csv <files... or stdin> > output.csv | |
# NB: Assumes that each line is a simple JSON object with no nested arrays or objects | |
import csv | |
import json | |
import sys | |
import fileinput | |
from collections import namedtuple, OrderedDict | |
lines = fileinput.input() |