Skip to content

Instantly share code, notes, and snippets.

@iwconfig
iwconfig / bookmarklet_image_fetcher.js
Last active April 30, 2018 14:14
bookmarklet for getting image url from svtplay | svt | öppetarkiv | urskola | urplay
javascript:!(function() {
url = window.location.href;
imgs = new Set();
if (url.indexOf('svtplay.se') > -1) {
request = new XMLHttpRequest();
request.onreadystatechange = function () {
if(request.readyState === 4 && request.status === 200) {
__svtplay = JSON.parse(/__svtplay'] = ({.*});/.exec(request.responseText)[1]);
imgs.add(__svtplay.videoPage.video.poster.replace('{format}', 'extralarge'));
};
@iwconfig
iwconfig / FFnewtab.ahk
Last active September 25, 2018 22:02
Select and clear the address bar in firefox when using New Tab Override or the like. Change "My Custom New Tab - Mozilla Firefox" so it matches yours (without the quotes). There's a minor lag and I'm guessing we can't do anything about it. If this is not the case, please feel free to contribute.
;
; Change "My Custom New Tab - Mozilla Firefox" so it matches yours (without the quotes)
;
#NoEnv
#SingleInstance force
SendMode Input
while 1 {
WinWaitActive, Agenda View - Mozilla Firefox ahk_class MozillaWindowClass
{
@iwconfig
iwconfig / antagning.se_toggle_info.user.js
Last active October 16, 2018 12:59
This userscript toggles all the 'Mer information' (more information) links on every course at antagning.se
// ==UserScript==
// @name Antagning.se - toggle all information about multiple courses
// @description This userscript toggles all the 'Mer information' (more information) links on every course at antagning.se
// @namespace Leonard Högström
// @version 2.1
// @downloadURL https://gist.github.com/iwconfig/9c7701c69cc61bef42b56c631567cef4/raw/antagning.se_toggle_info.user.js
// @match https://www.antagning.se/*/favourites
// @match https://www.antagning.se/*/search*
// @match https://www.antagning.se/*/mypages/applications*
// @grant none
@iwconfig
iwconfig / codeacademy.com_enhanced.user.js
Last active October 15, 2018 19:43
codeacademy.com enhancements. Currently changes the text opacity of unfinished tasks and also adds additional keyboard shortcuts (Alt-LeftArrow and Alt-RightArrow) for Back and Next.
// ==UserScript==
// @name codeacademy.com enhancements
// @namespace Leonard Högström
// @match https://www.codecademy.com/courses/*
// @grant none
// ==/UserScript==
// Change the text opacity of unchecked tasks for better readability
// so you can do all of them at once instead of having to run the code with every completed task.
[].filter.call(document.querySelectorAll('.fcn-checkpoint--disabled .fcn-checkpoint__body'),item => item)
@iwconfig
iwconfig / antagning.se_toggle_application.user.js
Created October 16, 2018 22:43
Antagning.se enhancements - show/hide the individual applications (each term)
// ==UserScript==
// @name Antagning.se enhancements - show/hide the individual applications
// @description show/hide the individual applications (each term)
// @namespace Leonard Högström
// @version 1.0
// @match https://www.antagning.se/*/mypages/applications*
// @match https://www.antagning.se/*/mypages/
// @match https://www.antagning.se/*/mypages
// @grant none
// ==/UserScript==
@iwconfig
iwconfig / objsize.py
Created January 16, 2019 10:31
Get real size of python object
import sys
# Taken from: https://goshippo.com/blog/measure-real-size-any-python-object/
def get_size(obj, seen=None):
"""Recursively finds size of objects"""
size = sys.getsizeof(obj)
if seen is None:
seen = set()
obj_id = id(obj)
@iwconfig
iwconfig / callback_server.py
Created January 17, 2019 11:31
simple callback server for oauth2. quits itself once code is retrieved
import threading, webbrowser
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import urlparse, parse_qs
class S(BaseHTTPRequestHandler):
def do_GET(self):
code = parse_qs(urlparse(self.path).query)['code'][0]
threading.Thread(target=httpd.shutdown, daemon=True).start()
def callback_server(server_class=HTTPServer, handler_class=S, port=8080):
@iwconfig
iwconfig / run-filebot.py
Last active April 2, 2019 15:56
script for transmission to pass downloaded file(s) to filebot and make sure the ownership and permissions are correct
#!/usr/bin/env python3
# Note: on synology, make sure your user is added to transmission
# group so you can have read and write access to the destination
# without sudo.
import subprocess, sys, pwd, grp, os
processed_path = '/tmp/filebot-output-dir'
@iwconfig
iwconfig / xdg-open-organized-path.py
Last active February 25, 2019 10:46
Using transmission-remote-gtk, visit the file or folder in your organized library. If item is not (yet?) organized, visit the origin instead (i.e. the 'Downloads' folder).
#!/usr/bin/env python3
# This script is supposed to be used with a remote torrent client,
# such as transmission-remote-gtk. Add this script as a local command
# and it will check if the file/dir has been sorted by filebot and if
# so, open the sorted file path. If not, open the path to the unsorted
# path (i.e. file/dir in 'Downloads' folder). It translates the path
# to correspond to the local mount point (samba share).To parse the
# xml file from filebot I use the untangle package because I'm lazy
# and because it's so easy to use. Install it with pip.
@iwconfig
iwconfig / clip_magic.py
Last active November 9, 2019 17:46 — forked from bwagner/clip_magic.py
copy to clipboard ipython magic -- linux only
"""
Add copy to clipboard from IPython!
To install, just copy it to your profile/startup directory, typically:
~/.ipython/profile_default/startup/
Example usage:
%clip hello world
# will store "hello world"