Skip to content

Instantly share code, notes, and snippets.

@aidilfbk
aidilfbk / twitch_live_url.py
Last active May 2, 2024 02:37
Requesting special low latency m3u8 playlist file
import requests
import json
import re
import argparse
import random
import m3u8
USHER_API = 'https://usher.ttvnw.net/api/channel/hls/{channel}.m3u8?player=twitchweb' +\
'&token={token}&sig={sig}&allow_audio_only=true&allow_source=true&fast_bread=true' + \
'&type=any'
@aidilfbk
aidilfbk / clear-osx-notification-center.scpt.js
Created March 22, 2018 10:50
Dump this into Script Editor.app and run when you want to clear all notifications in the Notifications Center panel
var app = Application("System Events");
var ncToggle = app.processes.byName('SystemUIServer').menuBars[0].menuBarItems.byName("Notification Center");
ncToggle.click(); // show Notification Center panel on screen right
var notificationCenter = app.processes.byName('NotificationCenter');
var ncWindow = notificationCenter.windows[0];
var ncNotifTabBtn = ncWindow.radioGroups[0].radioButtons.byName("Notifications");
var originalNotifTab = "notifications";
if(!ncNotifTabBtn.value()){

Keybase proof

I hereby claim:

  • I am aidilfbk on github.
  • I am aidilfbk (https://keybase.io/aidilfbk) on keybase.
  • I have a public key ASA5o0eoq1XEoupOr0zqZf_xCddiEHxDhzsa-K6nzGFVVgo

To claim this, I am signing this object:

@aidilfbk
aidilfbk / multithread_method_sync.py
Created August 11, 2015 10:51
Function decorator that causes multiple calls to the same function from multiple threads to wait on one thread to actually perform the function. Works with recursive functions (via threading.RLock)
import threading
def multithread_method_sync(method):
rlock = threading.RLock()
revent = threading.Event()
# result has to be a list because of Python closure weirdness
result = [None]
def callable(*args, **kwargs):
@aidilfbk
aidilfbk / throw-scary-warning.js
Created October 11, 2014 16:13
Makes browsers using Google's Safe Browsing lists show their warning screens. Tested on Safari and Chrome
(new Image()).src = "http://malware.testing.google.test/testing/malware/";
((3|6)[0-9]|(8[1-9]|9[0-8])[0-9]?)[0-9]{6}
@aidilfbk
aidilfbk / country-ip-addr.sh
Created March 16, 2014 08:35
Filters the ARIN IP address delegations by a country code and parses it into CIDR notation. Wrote it based on http://blog.erben.sk/2014/01/28/generating-country-ip-ranges-lists/
#!/usr/bin/env sh
# based on http://blog.erben.sk/2014/01/28/generating-country-ip-ranges-lists/
# change accordingly
country_code='US';
# please reference the proper registry
# United States, Canada, several parts of the Caribbean region, and Antarctica: http://ftp.arin.net/pub/stats/arin/delegated-arin-extended-latest
# Europe, Russia, the Middle East, and Central Asia: http://ftp.ripe.net/ripe/stats/delegated-ripencc-latest
# Africa: http://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-latest
@aidilfbk
aidilfbk / SafariLocalStorageCleanup.py
Created August 17, 2013 19:03
Small python script to delete any empty OS X Safari localstorage files By default, it runs a "simulated delete" Execute with --deleteForReal to actually delete
#!/usr/bin/env python
############################################################
# SafariLocalStorageCleanup.py (18 Aug 2013)
# small script to delete any empty Safari localstorage databases
# default mode runs a "simulated delete"
# run with --deleteForReal to actually delete
############################################################
import sqlite3, sys, os, os.path, platform
@aidilfbk
aidilfbk / singtel-tumblr-proxy.pac
Created July 27, 2013 09:34
Proxy autoconfiguration file to allow Singtel users to send asks on Tumblr
function FindProxyForURL(url, host){
var singtel_proxy = "PROXY proxy.singnet.com.sg:8080; DIRECT";
if(dnsDomainIs(host, "tumblr.com")){
if(shExpMatch(url, '*ask_form*') || shExpMatch(url, '*submit_form*')) {
return singtel_proxy;
}
}
return "DIRECT";
@aidilfbk
aidilfbk / HTTP Status Codes.js
Created November 14, 2011 06:31
A simple Javascript Object Literal which lets you query the HTTP status text for a particular HTTP status code. (scraped from Wikipedia)
{
100: "Continue",
101: "Switching Protocols",
102: "Processing",
103: "Checkpoint",
122: "Request-URI too long",
200: "OK",
201: "Created",
202: "Accepted",