Skip to content

Instantly share code, notes, and snippets.

View fnordomat's full-sized avatar
🌴
On vacation

fnord fnordomat

🌴
On vacation
View GitHub Profile
# Will probably trigger rate limiting.
# It would be a lot smarter to mirror the whole history and then search offline.
from mastodon import Mastodon as M
from optparse import OptionParser
import sys
import re
parser = OptionParser()
parser.add_option("-a", "--api-token", dest="apitoken",
#!/usr/bin/python3
# Takes care of Hamburg (HAM) Airport "free wifi" captive portal
# see also captive-be-gone folder in my repo fnordomat/misc
# https://github.com/fnordomat/misc
import subprocess
import re
import lxml
from lxml import html
#!/usr/bin/python3
# Takes care of "hospitality.thecloud.eu" captive portal
# see also captive-be-gone folder in my repo fnordomat/misc
# https://github.com/fnordomat/misc
import subprocess
import re
import lxml
from lxml import html
@fnordomat
fnordomat / irpoll.c
Created September 26, 2020 07:40
Decode 38kHz IR signals from a TV remote control using RasPi and TSPO48xx
/**
* Receive and "decode" some TV remote control signals using TSOP48xx
*
* Single-threaded operation, attempting decoding and matching every time a pause
* of 30ms between signal toggles is detected.
*
* "decoding" = binning toggles into periods of 1/38000s, registering a "1" if
* the signal went or remained high and a "0" if it went or remained low during
* the period.
*
# for some reason this was missing from Z3py:
def Sequence(name, ctx=None):
"""Return a sequence constant named `name`. If `ctx=None`, then the global context is used.
>>> x = Sequence('x')
"""
ctx = z3.get_ctx(ctx)
int_sort = z3.IntSort(ctx)
return z3.SeqRef(
z3.Z3_mk_const(ctx.ref(),
z3.to_symbol(name, ctx),
@fnordomat
fnordomat / m34.py
Last active September 7, 2021 07:34
Automatic negotiation of a captive portal: connect to m3connect ("conn4.com" variant) wifi in some Accor group hotels without having to jump through hoops.
#!/usr/bin/env python3
import subprocess
import re
import lxml
from lxml import html
import urllib
import urllib.request
import urllib3
import base64
@fnordomat
fnordomat / wifipass.py
Created December 30, 2019 14:11
Automatic negotiation of a captive portal: connect to "wifipass.org" hotel wifi without having to jump through hoops.
#!/usr/bin/env python3
# not pretty but worked for me
# curl --stderr - --trace - -v -L -A '' http://foobar.com | tee step0001
# # -> the href in there, including the mac address
# curl --stderr - --trace - -v -L -A '' -c kookie.jar "https://passman01.wifipass.org/w2p/login-url-real.php?id=BLABLA&domain=controleur.wifipass.org&mac=XX-XX-XX-XX-XX-XX&page=http%3A%2F%foobar.com%2F" | tee step0002
# # -> the _token value in there
# curl --stderr - --trace - -v -L -A '' -c kookie.jar 'https://passman01.wifipass.org/w2p/formulaire_fin.php?id=BLABLA&domain=controleur.wifipass.org' -F "registration[id1]=1" -F "registration[id2]=243" -F "registration[newsLetterType]=FOOFOO" -F "registration[email]=foo@bar.com" -F "_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -F "accept=true" --post301 --post302 --post303 | tee step0003
# # took this path again, ended in a cycle:
@fnordomat
fnordomat / CDWiFi (České dráhy) WiFi Internet Access
Last active November 7, 2023 16:58
Automatic negotiation of a captive portal: connect to icomera wifi in CD trains without having to jump through hoops.
# I believe this is the necessary and sufficient step to get internet access on board the Czech long distance trains (e.g. EuroCity which runs from Prague to Kiel)
curl -vLA '' 'http://cdwifi.cz/portal/api/vehicle/gateway/user/authenticate'
# It says "500 internal server error" but that doesn't keep it from working.
# check with this request, answer should contain "authenticated":1
curl -vLA '' 'http://cdwifi.cz/portal/api/vehicle/gateway/user'
# Also nice: GPS data (but seems outdated)
curl -vLA '' 'http://cdwifi.cz/portal/internal/api/x6/position'
@fnordomat
fnordomat / m3connect.sh
Last active September 7, 2021 07:34
Automatic negotiation of a captive portal: connect to m3connect wifi in some Accor group hotels without having to jump through hoops.
#!/bin/bash
# Accor group hotels offer "free wifi" (ESSID: "m3connect") service
# with internet access (with paid options for higher transfer rates).
#
# This takes care of the m3connect captive portal.
#
# Please drop me a note if it stops working, is insecure etc.
#
@fnordomat
fnordomat / Main.hs
Last active June 2, 2018 12:15
Something like Cocke-Younger-Kasami in Haskell (no Chomsky Normal Form required). Not well optimized, but appears to work.
module Main where
import Data.Either
import Data.List
import Data.Array.IArray as A
import Control.Arrow (second)
import Control.Monad.Except
-- Partition a number n into exactly l parts of sizes \in \{1..f\}
-- 1st arg: the number to be partitioned