Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kasnder's full-sized avatar
🔒

Konrad Kollnig kasnder

🔒
View GitHub Profile
@kasnder
kasnder / landgericht_aachen_downloader.py
Created May 13, 2018 21:24
Python script to aggreate and filter the events of the courts in Aachen, Germany.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import locale
import csv, codecs, cStringIO
from pprint import pprint
import time
from BeautifulSoup import BeautifulSoup
# From the Pyton documentation
@kasnder
kasnder / nmsmax.jl
Last active November 24, 2019 10:00
Nelder-Mead simplex method for direct search optimisation in JULIA.
"""
nmsmax(fun, x[, trace = true, initial_simplex = 0, target_f = Inf, max_its = Inf, max_evals = Inf, tol = 1e-3])
Nelder-Mead simplex method for direct search optimization.
This function attempts to maximize the function `fun`, using the
starting vector `x`. The Nelder-Mead direct search method is used.
Adaption of the original *MATLAB* source by Nick Higham to *Julia*.
@kasnder
kasnder / top_senteces_from_text.py
Last active January 7, 2020 15:31
Attempt to classify top sentences in the Wikipedia article on New York
# Authored by Konrad Kollnig
# Oxford, 20 April 2019
import wikipedia
from nltk.tokenize import sent_tokenize, RegexpTokenizer
from nltk.corpus import stopwords
from collections import defaultdict
import math
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer
@kasnder
kasnder / helpers.ts
Last active January 21, 2020 12:16
Some TypeScript code that I've use repeatedly
const fs = require('fs');
const parseDomain = require("parse-domain");
function readJson(filename) {
return JSON.parse(
fs.readFileSync(filename)
);
}
function getDomain(url) {
@kasnder
kasnder / mapping_android_ios_categories.py
Created June 15, 2020 13:30
Super genres from "Third Party Tracking in the Mobile Ecosystem" by Binns et al. adopted to iOS
super_genres = {
'ART_AND_DESIGN': 'Art & Photography',
'AUTO_AND_VEHICLES': 'Productivity & Tools',
'BEAUTY': 'Health & Lifestyle',
'BOOKS_AND_REFERENCE': 'Productivity & Tools',
'BUSINESS': 'Productivity & Tools',
'COMICS': 'Games & Entertainment',
'COMMUNICATION': 'Communication & Social',
'DATING': 'Communication & Social',
'EDUCATION': 'Education',
@kasnder
kasnder / compare_disconnect.py
Last active August 15, 2020 11:09
Checks that https://github.com/mozilla-services/shavar-prod-lists is up-to-date with Disconnect blacklist
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import urllib.request, json
import argparse
parser = argparse.ArgumentParser(description='Compare Shavar and Disconnect.me blacklist.')
parser.add_argument("-f", "--file", help="blacklist to verify")
args = parser.parse_args()
@kasnder
kasnder / snippet.tex
Last active May 6, 2022 22:59
Responsive figures for ACM TAPS submission. UPDATE: While this script theoretically works, the TAPS system is actually not compatible with it (despite it being legitimate Latex code).
%insert before \begin{document}
\usepackage{wrapfig}
\makeatletter%
\newenvironment{responsivefig}[2]{%
\if@twocolumn%
\begin{figure}%
\else%
\wrapfigure{#1}{#2}%
@kasnder
kasnder / 1_grant_ios_notification_permission.sh
Last active May 6, 2022 23:04
Grant the notification permission to an iOS app. More permissions here: https://gist.github.com/kasnder/3eb32449512a4dba4a92949c8d337a92 Raw
# This script runs on macOS
# One needs a working, passwordless SSH login with login 'ios' on a jailbroken iOS 14.+
# One also needs Activator and ActivatorCrashFix14: https://stackoverflow.com/questions/21706050/how-to-unlock-ios-screen-programmatically)
# Backup and preparation
ssh ios "cp -n /var/mobile/Library/BulletinBoard/VersionedSectionInfo.plist ~/VersionedSectionInfo.plist.bak"
scp ios:/var/mobile/Library/BulletinBoard/VersionedSectionInfo.plist ./VersionedSectionInfo2.plist
# Prepare notification settings
/usr/libexec/PlistBuddy -c "Set :\$objects:2 $appId" `pwd`/base2.plist
@kasnder
kasnder / keybase.md
Created December 9, 2022 09:54
Keybase

Keybase proof

I hereby claim:

  • I am kasnder on github.
  • I am kkollnig (https://keybase.io/kkollnig) on keybase.
  • I have a public key ASCIm7oChhTGxAbhihcGtb6sti7I_thSsWJKIaNlggKnVgo

To claim this, I am signing this object:

@kasnder
kasnder / grant_ios_local_network_permission.sh
Created March 10, 2023 12:11
Grant the local network permission to an iOS app. More permissions here: https://gist.github.com/kasnder/3eb32449512a4dba4a92949c8d337a92
#!/bin/bash
# Todo: This currently fails to update the file signature. It still seems to work but should not be used on a production device.
# Usage:./grant_ios_local_network_permission.sh.sh [bundleId]
# Example: ./grant_ios_local_network_permission.sh.sh com.spotify.client
if [ -z "$1" ]; then
echo "Please pass bundleId"
exit -1