Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# this script expects an image, a target resolution and an output file.
# it then outputs a new png image with the given resolution
# and the given image, centered with transparent background.
# requires imagemagick
image="$1"
targetres="$2"
@maik-s
maik-s / wget_vbs.ps
Last active April 29, 2020 10:43 — forked from sckalath/wget_vbs
wget vbscript
echo 'strUrl = WScript.Arguments.Item(0)' > wget.vbs
echo 'StrFile = WScript.Arguments.Item(1)' >> wget.vbs
echo 'Const HTTPREQUEST_PROXYSETTING_DEFAULT = 0' >> wget.vbs
echo 'Const HTTPREQUEST_PROXYSETTING_PRECONFIG = 0' >> wget.vbs
echo 'Const HTTPREQUEST_PROXYSETTING_DIRECT = 1' >> wget.vbs
echo 'Const HTTPREQUEST_PROXYSETTING_PROXY = 2' >> wget.vbs
echo 'Dim http,varByteArray,strData,strBuffer,lngCounter,fs,ts' >> wget.vbs
echo 'Err.Clear' >> wget.vbs
echo 'Set http = Nothing' >> wget.vbs
echo 'Set http = CreateObject("WinHttp.WinHttpRequest.5.1")' >> wget.vbs
@maik-s
maik-s / killdockercontainers.sh
Created July 10, 2019 17:11
command to kill exited docker containers easily
# Add this command to your ~/.bashrc
killdockercontainers() {
docker container ls --all | grep "Exited" | grep -Eo "^[a-z0-9]{12}" | xargs -I ID docker stop ID | xargs -I ID docker rm ID
}
@maik-s
maik-s / xml_xpath.py
Created May 23, 2019 19:29
Simple gist to demonstrate how to use lxml to find elements within an XML string with xpath expressions.
#!/bin/python3
from lxml import etree
from StringIO import StringIO
parser = etree.XMLParser(remove_blank_text=True)
f = StringIO('<foo><bar>test</bar></foo>')
tree = etree.parse(f, parser)
elem = tree.xpath('/foo/bar')
print (elem[0].text)
@maik-s
maik-s / xpath_html5.py
Created May 23, 2019 19:24
Simple gist to demonstrate how to use lxml for HTML5 to find elements with xpath.
#!/bin/python3
from lxml import etree
filename = "html5file.html"
parser = etree.HTMLParser(remove_blank_text=True)
tree = etree.parse(filename, parser)
elem = tree.xpath('/html/head')
@maik-s
maik-s / create.cmd
Last active March 24, 2016 12:50
this is a simple batch wrapper for creating new batch shortcuts placed in lpath. usage: `create name "path"`
@echo off
set LNAME=%1
set LDIR="%2%"
set LPATH=C:/users/name/path/to/dir
set LEXT=.cmd
set FILENAME=%LPATH%%LNAME%%LEXT%
if not exist FILENAME (
echo @echo off > "%FILENAME%"
echo cd "%LDIR%" >> "%FILENAME%"
@maik-s
maik-s / gpg-import-and-export-instructions.md
Last active September 19, 2015 14:39 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...