Skip to content

Instantly share code, notes, and snippets.

@jaseg
jaseg / README.md
Last active March 26, 2024 14:21
Convert openldap .schema files to .ldif files

This is old!

Hey there,

occassionally, people still seem to stumble across this script because it seems it shows up in some search results. Please be aware that I made this script ten years ago, and by now, there is probably a better way to achieve the same result.

Have a nice day!

@jaseg
jaseg / README.md
Created August 27, 2012 10:10
Windows XP as your screensaver!

Windows XP as your screensaver!

Overview

When xscreensaver starts screen saving, instead of a boring screen saver it spawns a small shell script. This shell script starts a new X server with a very minimal awesome window manager and unfreezes a kvm virtual machine containing a Windows XP on that X server, ready to be used by any passersby. To unlock the screen, you need to switch back to the VT where your usual X is running. As soon as the screen is unlocked, xscreensaver sends a SIGTERM to the shell script which in turn stops all the X servers, window managers and virtual machines it launched and resets the VM image. Should the VM exit before the screen is unlocked because somebody pressed "Shut down" the VM image is reset and the VM restarted.

Setup

@jaseg
jaseg / mpv_render_context_gtk_example.py
Last active September 9, 2022 07:37
Basic test of python-mpv mpv render context mapping used with GTK
#!/usr/bin/env python3
import ctypes
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GLib
gi.require_version('GL', '1.0')
from OpenGL import GL, GLX
@jaseg
jaseg / gist:8e56071398ce814511b8
Created February 4, 2015 10:21
IRC in pure bash, just with builtins
#!/bin/bash
user="crlf"
function irccmd {
echo -e "$1\r" >&3
}
function send_message {
if [ -n "$2" ]; then
@jaseg
jaseg / gist:3334991
Created August 12, 2012 22:32
Password manager without a password manager

Prelude

Since password managers are big and complicated and I currently am pretty bored since I am sitting in a car for a few hours, here is a simple algorithm to generate resource-specific, unique passwords using a master password and no password database.

WARNING

As pointed out here: http://news.ycombinator.com/item?id=4374888 this method is broken.

Usage

@jaseg
jaseg / gist:ef83d89b39ae69fad07a
Created July 23, 2014 23:54
Doing 3D projection in a few lines of python to render a rotating tetraeder to SVG
#!/usr/bin/env python3
import numpy as np
from math import sin, cos, pi, sqrt
import svgwrite
import itertools
def cam(f):
""" Returns a camera matrix for the given focal length """
return np.array(((1,0,0,0),
(0,1,0,0),
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
pinyinToneMarks = {
u'a': u'āáǎà', u'e': u'ēéěè', u'i': u'īíǐì',
u'o': u'ōóǒò', u'u': u'ūúǔù', u'ü': u'ǖǘǚǜ',
u'A': u'ĀÁǍÀ', u'E': u'ĒÉĚÈ', u'I': u'ĪÍǏÌ',
u'O': u'ŌÓǑÒ', u'U': u'ŪÚǓÙ', u'Ü': u'ǕǗǙǛ'
}
@jaseg
jaseg / mailboxorg_to_fritzbox.py
Last active December 25, 2016 16:06
Convert mailbox.org/openXchange contact exports to Fritzbox Phonebook backup files
#!/usr/bin/env python3
# coding: utf-8
import csv
import argparse
avm_xml_template = '''<?xml version="1.0" encoding="utf-8"?>
<phonebooks>
<phonebook>
{entries}
@jaseg
jaseg / README.md
Created April 28, 2014 10:55
systemd service file for running a transmission-daemon through OpenVPN

What is still missing

  • mullvad-up.sh as called from openvpn.conf would be unnecessary if openvpn would fork after setting up the tun interface, for then its contents could be realized with a few systemd ExecStartPost-directives.
  • Some means of automatically detecting and stopping/reconnecting a broken connection would be nice.
  • Due to libcurl being buggy, transmission-daemon leaks DNS requests. I don't mind, if you do, consider using a couple of iptables rules to route any packets coming from transmission's UID through a special routing table.
# Modified cd that also displays the directory's contents if the listing is less than 5 lines long
function cd
if test -n "$argv"
if test -e $argv -a ! -d (realpath $argv)
set argv (dirname $argv)
end
end
builtin cd $argv
and test (ls -C -w $COLUMNS |wc -l) -le 5; and ls
end