Skip to content

Instantly share code, notes, and snippets.

View Jan-Zeiseweis's full-sized avatar

Jan Zeiseweis Jan-Zeiseweis

View GitHub Profile
@Jan-Zeiseweis
Jan-Zeiseweis / kill_wrapper.sh
Created November 3, 2023 18:48
kill_wrapper
#!/bin/bash
# run some program, and KILL it with deadly force upon ^C :) --sq5bpf
# this is a hack to make
CPID=0
intr() {
echo "killing $CPID"
kill -9 $CPID
}
@Jan-Zeiseweis
Jan-Zeiseweis / codestyle.xml
Created April 26, 2023 17:23
PyCharm code style.xml
<code_scheme name="Default" version="173">
<JSCodeStyleSettings version="0">
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
<option name="FORCE_SEMICOLON_STYLE" value="true" />
<option name="SPACE_BEFORE_GENERATOR_MULT" value="true" />
<option name="REFORMAT_C_STYLE_COMMENTS" value="true" />
<option name="USE_DOUBLE_QUOTES" value="false" />
<option name="FORCE_QUOTE_STYlE" value="true" />
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
<option name="SPACES_WITHIN_IMPORTS" value="true" />
@Jan-Zeiseweis
Jan-Zeiseweis / remove_outdated_snaps.sh
Created September 23, 2021 08:45
Removes outdated snaps.
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
LANG=C snap list --all | awk '/disabled/{print $1, $3}' |
while read -r snapname revision; do
snap remove "$snapname" --revision="$revision"
done
" Settings
set nohud
set nosmoothscroll
set noautofocus " The opposite of autofocus; this setting stops
" sites from focusing on an input box when they load
set typelinkhints
let searchlimit = 30
let scrollstep = 70
let barposition = "bottom"
import cProfile
from datetime import datetime
def profileit(func):
def wrapper(*args, **kwargs):
datafn = f"{func.__name__}_{datetime.now().strftime('%Y%m%d_%H%M%S_%f')}.profile"
prof = cProfile.Profile()
retval = prof.runcall(func, *args, **kwargs)
prof.dump_stats(datafn)
// ==UserScript==
// @name Track Pageview
// @namespace deKexx
// @description Sends Url to a local server
// @include http://www.youtube.com/watch*
// @include https://www.youtube.com/watch*
// @connect popo.local
// @author Jan Zeiseweis
// @version 0.1
// @grant GM_xmlhttpRequest
import pickle
from pathlib import Path
from flask import Flask, request
app = Flask(__name__)
seen_video_ids_path = Path("video_ids.pkl")
if seen_video_ids_path.is_file():
with open(str(seen_video_ids_path), 'rb') as dump:
@Jan-Zeiseweis
Jan-Zeiseweis / mark_watched.js
Last active September 19, 2018 14:03
yt marked watched
// ==UserScript==
// @name Marked watched videos
// @namespace deKexx
// @description Mark watched videos on Youtube
// @include http://www.youtube.com/watch*
// @include https://www.youtube.com/watch*
// @connect popo.local
// @author Jan Zeiseweis
// @version 0.1
// @grant GM_xmlhttpRequest
@Jan-Zeiseweis
Jan-Zeiseweis / 00-load.py
Created October 18, 2017 12:22
Pandas create dataframe from clipboard
import pandas as pd
def clipboard_to_dataframe():
"""
Parses tables in the format:
| Col1 | Col2 |
-------------------
| 1111 | abcdefgh |
| 2222 | abcdefgj |
-------------------
@Jan-Zeiseweis
Jan-Zeiseweis / date_user_defined_functions_redshift.sql
Last active August 8, 2020 14:40
User defined python functions for date dimensions in redshift
create or replace function f_sk_date (ts timestamp )
returns integer
stable as $$
if not ts:
return None
return int(str(ts)[0:10].replace('-',''))
$$ language plpythonu;
create or replace function f_date (ts timestamp)
returns date