Skip to content

Instantly share code, notes, and snippets.

@meeuw
meeuw / gist:b6bc07ab66e93931dabc053914373398
Created February 2, 2017 08:40
convert cmyk tif to rgb using imagemagick
convert image.tif -profile /usr/share/color/icc/colord/sRGB.icc test.png
@meeuw
meeuw / injectinput.py
Last active September 27, 2021 09:40
Simple script to replace xdotool when using Gnome/Wayland for entering keystrokes using evdev. This requires root.
# MOVED TO: https://github.com/meeuw/injectinput
#!/usr/bin/python3
import evdev
import sys
upper = { '!': '1', '@': '2', '#': '3', '$': '4', '%': '5', '^': '6', '&': '7', '*': '8', '(': '9', ')': '0' }
with evdev.UInput() as ui:
escape = False
@meeuw
meeuw / ipythontunnel.sh
Created November 15, 2016 20:35
ipython kernel tunnel script
#!/bin/bash
scp $1 $2:
ssh $(grep _port $1|sed 's/^[^:]*: \([^,]\+\).*/\1/'|
while read PORT ; do
echo -R $PORT:localhost:$PORT
done) $2
@meeuw
meeuw / myclic.py
Created September 22, 2016 05:51
mycli wrapper for tunneled connections and bash auto completion
#!/usr/bin/python3
import os
import sys
import argcomplete
import argparse
import glob
import os.path
import sys
import subprocess
parser = argparse.ArgumentParser()
[Desktop Entry]
Name=Sound Settings
Icon=preferences-system
Exec=gnome-control-center sound
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;System;
OnlyShowIn=GNOME;Unity;
X-GNOME-Bugzilla-Bugzilla=GNOME
@meeuw
meeuw / generate_stubs.py
Created June 5, 2016 11:31
Generate stubs for missing symbols which can be registered using a callback function
#!/usr/bin/python3
import fileinput
import re
import json
callbackcode = '''
'''
classes = {}
functions = []
for line in fileinput.input():
@meeuw
meeuw / dedup.py
Last active April 27, 2016 19:00
find duplicates in a (sorted) tsv by multiple keys, example usage mysql -Be 'select * from table order by field3,field4'|dedup.py field3,field4
#!/usr/bin/python
import sys
header = None
keys = []
firstmatch = None
for line in sys.stdin.readlines():
s = line[:-1].split('\t')
@meeuw
meeuw / checkall.js
Created April 25, 2016 07:18
check all checkboxes for a certain table
$($.find("table:eq(1) input")).prop("checked", true)
@meeuw
meeuw / portstatus.py
Created March 30, 2016 05:55
quick hack to log port status of cisco switches
#!/usr/bin/python
import os
import telnetlib
import time
prompt = os.environ['PROMPT']+">"
if 'USERN' in os.environ:
usern = os.environ['USERN']
else:
usern = None
@meeuw
meeuw / renamepng.py
Created March 29, 2016 09:50
rename png's numbered with an underscore
import fileinput
import os.path
d = {}
for line in fileinput.input():
s = line[:-1].split('\t')
d[s[0]] = s[1]
for key, value in d.items():
i = 0
while 1: