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 / split_and_gzip.sh
Last active September 14, 2015 17:15
split and gzip bash script
#!/bin/bash -e
# usage: bash ./split_and_gzip.sh file.txt
FILE=$1
LINES_PER_FILE=10000000 #10m
$(split -l $LINES_PER_FILE -d $FILE ${FILE}.)
FILES=${FILE}.*
@Jan-Zeiseweis
Jan-Zeiseweis / unzip_rm_zip_md5_sum_rm_dups.sh
Created September 14, 2015 17:17
Unzip all zip files in a directory and remove unzipped file if a file with the same md5checksum already unzipped
#!/bin/bash
declare -A arr
for zip_file in *.zip; do
unzip -q $zip_file && rm $zip_file
file=${zip_file%.zip}
read cksm _ < <(md5sum "$file")
if ((arr[$cksm]++)); then
echo "rm $file"
rm $file
fi
@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
@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 / 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
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:
// ==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 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)
" 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"
@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