Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
"""xev output data parser to get mouse polling rate.
Usage:
$ chmod a+x mouserate
$ xev | mouserate
"""
import sys
import re
class classproperty(property):
def __get__(self, cls, owner):
return self.fget.__get__(None, owner)()
@ramnes
ramnes / etded
Created February 16, 2015 14:59
#!/bin/sh
DAEMON="/home/et/etded"
DAEMON_OPT="+set net_port 27960 +set fs_game etpro +exec server"
DAEMON_USER="et"
DAEMON_NAME="etded.x86"
DAEMON_DESC="Wolfenstein Enemy Territory server"
PATH="/sbin:/bin:/usr/sbin:/usr/bin"
#!/bin/bash
# Collect DBUS_SESSION_BUS_ADDRESS from running process
function set_dbus_adress
{
USER=$1
PROCESS=$2
PID=`pgrep -o -u $USER $PROCESS`
ENVIRON=/proc/$PID/environ
from marshmallow.fields import Nested as BaseNested
class Nested(BaseNested):
"""An overloaded Nested field that can handle more than a single schema.
By giving it a list of schemas, it will iterate through them to find one
that matches with the input data. It raises an error if the data doesn't
correspond to any schema.
"""
@ramnes
ramnes / 10-automount.rules
Last active February 17, 2020 16:01
Automatically mount USB storages when plugged
KERNEL!="sd[b-z][0-9]", GOTO="automount_end"
# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"
# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
# Global mount options
@ramnes
ramnes / config
Last active January 23, 2020 10:42
Modeless Uzbl config, à la Emacs
# Default locations
set cache_home = @(echo $XDG_CACHE_HOME)@
set config_home = @(echo $XDG_CONFIG_HOME)@
set data_home = @(echo $XDG_DATA_HOME)@
set prefix = @(echo $PREFIX)@
set scripts_dir = @data_home/uzbl:@prefix/share/uzbl/examples/data:scripts
# Default variables
set default_mode = insert
set fifo_dir = /tmp
def str_base(number, base):
div, mod = divmod(number, len(base))
if div > 0:
return str_base(div, base) + base[mod]
return base[mod]
@ramnes
ramnes / confused.gif
Last active March 20, 2024 18:40
How did this gif end up here?
confused.gif
import json
def flatten(o):
"""Flatten dicts and lists, recursively, JSON-style
It's a generator that yields key-value pairs.
Example:
>>> dict(flatten({"a": [{"b": 1}, [2, 3], 4, {"c.d": 5, True: 6}]}))