Skip to content

Instantly share code, notes, and snippets.

View gbin's full-sized avatar

Guillaume Binet gbin

View GitHub Profile
@gbin
gbin / asciiart.py
Last active October 4, 2015 22:23
Errbot recipes: templates
from errbot import BotPlugin, botcmd
from pyfiglet import Figlet
class AsciiArt(BotPlugin):
""" Ascii Art related commands. """
@botcmd(template='biginfo')
def big(self, mess, args):
""" Generates a big version of what you want to say."""
return {'small': args, 'big': Figlet(font='slant').renderText(args)}
@gbin
gbin / asciiart.py
Created October 4, 2015 22:15
Errbot recipes: Online help
from errbot import BotPlugin, botcmd
class AsciiArt(BotPlugin):
""" Ascii Art related commands. """
@botcmd
def big(self, mess, args):
""" Generates a big version of what you want to say."""
return args.upper()
@gbin
gbin / asciiart.py
Created October 4, 2015 22:07
Errbot recipes: dependencies
from errbot import BotPlugin, botcmd
from pyfiglet import Figlet
class AsciiArt(BotPlugin):
@botcmd
def big(self, mess, args):
return "```\n" + Figlet(font='slant').renderText(args) + "\n```"
@gbin
gbin / asciiart.plug
Last active October 4, 2015 22:13
Errbot recipes: Minimal plugin
[Core]
Name = AsciiArt
Module = asciiart
[Documentation]
Description = Make what you say big !
[Python]
Version = 3
@gbin
gbin / school.py
Last active August 30, 2015 16:20
Simple sample to read a file and return the output
from errbot import BotPlugin, botcmd
from os.path import join
DAYS_PATH = 'f:/errplugins/'
class School(BotPlugin):
@botcmd
def missed_day(self, msg, args):
"""Get missed day and provide assignment summary."""
with open(join(DAYS_PATH, "summary.%s" % args), 'r') as f:
@gbin
gbin / PluginMaker.py
Last active July 24, 2019 21:16
This is an example plugin for errbot generating plugins and commands dynamically
from errbot import BotPlugin, botcmd
class PluginMaker(BotPlugin):
""" Example demonstrating how to create an errbot plugin out of thin air.
This basically generates a plugin from scratch and registers it at activation.
"""
def activate(self):
super().activate()
@gbin
gbin / hipchatex.plug
Last active August 29, 2015 14:26
This demonstrate how to extend an existing backend with a custom feature for your (private) plugins.
[Core]
Name = HipchatEx
Module = hipchatex
[Documentation]
Description = This is my customized hipchat backend.
@gbin
gbin / convert.py
Created May 27, 2015 17:54
Converting a Python 2 berkeley db shelve to a python 3 one.
## py3
import shelve
import dbm
import pickle
with dbm.open('source', 'r') as source: # no .db here on purpose.
with shelve.open('destination.db') as destination:
for key in source.keys():
key = key.decode('utf-8')
value = pickle.loads(source[key])
print(key, value)
#!/usr/bin/env python3
#
# This script is a tool that helps you calculate the potential benefits
# in occupied size on disk using the ext4 inlinedata new feature on
# Linux kernels 3.8.0+:
# "The new Inline Data Support feature allows Ext4 to store files that only consist of a few bytes together with the inode to save storage space and accelerate access"
# see http://www.h-online.com/open/features/What-s-new-in-Linux-3-8-1804240.html for details.
#
# Just run it on your ext4 mountpoints and it will tell give you the trade off
@gbin
gbin / err-map.py
Created September 11, 2012 10:56
How I quickly plotted the Err usage on a map
#! /usr/bin/python
import matplotlib
matplotlib.use('Qt4Agg')
from datetime import datetime
import os
DIR = 'data/'
dirList=os.listdir(DIR)
unzip = lambda l:tuple(zip(*l))