Skip to content

Instantly share code, notes, and snippets.

View ramnes's full-sized avatar

Guillaume Gelin ramnes

View GitHub Profile
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 / 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
@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
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.
"""
#!/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
@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"
class classproperty(property):
def __get__(self, cls, owner):
return self.fget.__get__(None, owner)()
#!/usr/bin/env python3
"""xev output data parser to get mouse polling rate.
Usage:
$ chmod a+x mouserate
$ xev | mouserate
"""
import sys
import re
@ramnes
ramnes / topwords
Last active August 29, 2015 14:11
à a y
an au ce cm de du en et eu il je la le ma me ne ni on ou pu sa se si un
va vu
ait ans aux bas bel bon car cas ces cet des dit dix dur est etc été eux fer feu
fil fin fut gaz ici ils jeu les loi lui mal mer mes met mis moi mon mot nom non
nos ont par pas peu put que qui roi rue ses six soi sol son sud sur tel une vie
vif vin vit vos vue
class Factory(object):
model = object
def __init__(self):
self._objs = {}
def create(self, name):
self._objs[name] = type(name, self.model.__bases__, dict(self.model.__dict__))
return self._objs[name]