Skip to content

Instantly share code, notes, and snippets.

@flyser
flyser / libvirt-quadro.xml
Created February 14, 2015 13:17
The libvirt config of my vga passthrough vm
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>Windows8-OVMF1</name>
<uuid>d3d9d84e-3ce4-d77e-9bcc-d1fb5ba85813</uuid>
<memory unit='GiB'>8</memory>
<memoryBacking>
<hugepages/>
<locked/>
<nosharepages/>
</memoryBacking>
<memtune>
@flyser
flyser / gist:ed235b51474465c67648
Created May 24, 2014 19:28
My shell shortcut to start a dlna server in the current directory
function dlna {
DIR="$(pwd)"
if [[ "$1" != "" ]]; then
DIR="$(realpath "$1")"
fi
echo "Serving '$DIR'"
sed -i "s#.*media_dir.*=.*#media_dir=${DIR}#" ~/.minidlna.conf || return 1
/usr/sbin/minidlnad -d -v -R -f ~/.minidlna.conf -P /dev/null
}
#!/usr/bin/env python3
filename = "/var/tmp/test"
interval = 10
targetsize = 2*1000*1000*1000*1000 # 2 TB
import os, time, datetime
file = os.open(filename, os.O_RDONLY)
startsize = os.lseek(file, 0, os.SEEK_END)
@flyser
flyser / makemkv.sh
Last active August 29, 2015 13:57 — forked from powerswitch/makemkv.sh
#!/bin/sh
if [[ "x$1" = "x" ]]; then
echo "Usage:"
echo " $0 <searchpath>"
exit 1
fi
find "$(readlink -f "$1")" -type d -name STREAM | while read M ; do
cd "$M"
@flyser
flyser / Cournal save hook script
Created November 30, 2013 14:30
An example save hook script for a Cournal server. Warning: If you use Cournal a lot, the directory will grow quickly. Additional measures are needed to prevent that.
#!/bin/sh
cd "$1"
shift
# Try to determine a hostname
[[ -z "${HOSTNAME}" ]] && HOSTNAME="$(hostname)"
[[ -z "${HOSTNAME}" ]] && HOSTNAME="localhost"
# Create a predictable git environment
--- a/net-misc/openvswitch/files/ovsdb-server_conf 2013-11-14 14:57:07.672176882 +0100
+++ b/net-misc/openvswitch/files/ovsdb-server_conf 2013-11-14 14:46:45.000000000 +0100
@@ -2,12 +2,12 @@
DB_SOCKET="/var/run/openvswitch/db.sock"
# Remote sockets are defined in the database by default
-REMOTE_DB="db:Open_vSwitch,manager_options"
+REMOTE_DB="db:Open_vSwitch,Open_vSwitch,manager_options"
# All certificates and keys are stored in the database (if any)
@flyser
flyser / gist:6183740
Last active December 20, 2015 19:29 — forked from anonymous/gist:6183623
## This is on python 2.7:
In [1]: a = '12345678'
In [2]: %timeit [a[max(i-3,0):i] for i in range(len(a), 0, -3)][::-1]
1000000 loops, best of 3: 1.91 us per loop
In [3]: %timeit format(int(a), ',').split(',')
1000000 loops, best of 3: 1.62 us per loop
@flyser
flyser / What Dart does better than Python.
Created June 27, 2013 08:35
What Dart does better than Python.
def __init__(self, what, dart, does, better, than, python):
self.what = what
self.dart = dart
self.does = does
self.better = better
self.than = than
self.python = python
@flyser
flyser / stdin.txt
Created June 13, 2012 22:44 — forked from anonymous/stdin.txt
stdin
diff --git a/cournal-server.py b/cournal-server.py
index 75cf46a..44c99cd 100755
--- a/cournal-server.py
+++ b/cournal-server.py
@@ -41,12 +41,14 @@ USERNAME = "test"
PASSWORD = "testpw"
class Page:
+ """
+ A page in a document, having multiple strokes.

Cournal is a collaborative note taking and journal application using a stylus.

Why?

I need something to allow collaborative annotation of PDF files, Cournal is therefore heavily inspired by Xournal (note taking) and Gobby (collaboration).

Aim