Skip to content

Instantly share code, notes, and snippets.

View danielepantaleone's full-sized avatar
👨‍💻

Daniele Pantaleone danielepantaleone

👨‍💻
View GitHub Profile
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import subprocess
BUTTON_PIN = 40
BUTTON_SHUTDOWN_TIMEOUT = 3
# we will use the pin numbering to match the pins on the Pi, instead of the
# GPIO pin outs (makes it easier to keep track of things)
@danielepantaleone
danielepantaleone / mst.py
Last active August 29, 2015 14:15
MsTPlugin
#
# MstPlugin for BigBrotherBot(B3) (www.bigbrotherbot.net)
# Copyright (C) 2013 Daniele Pantaleone <fenix@bigbrotherbot.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@danielepantaleone
danielepantaleone / gist:5a81f9863eececd67a4e
Last active August 29, 2015 14:11
DatabaseStorage.context_query
from contextlib import contextmanager
@contextmanager
def context_query(self, query, bindata=None):
"""
Alias for DatabaseStorage.query which can make use of the python 'with' statement.
The contextmanager approach ensures that the generated DatabaseStorage.Cursor object instance
is always closed whenever the execution goes out of the 'with' statement block.
Example:

How to contribute

With the many games the B3 project supports, third party patches are essential to keep the project great. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping B3 project as clean and organized as possible.


Contributing Issues

@danielepantaleone
danielepantaleone / get_wrap.py
Last active August 29, 2015 14:02
Possible implementation of getWrap function of B3 Parser class
def getWrap(self, text, length=80, sv_prefix_length=9):
"""
Returns a sequence of lines for text that fits within the limits
:param text: The text to be splitted
:param length: The maximum length of each line
:param sv_prefix_length: The length of the prefix added by the server to the message
"""
if not text:
return []
@danielepantaleone
danielepantaleone / cod6plugin.py
Last active August 29, 2015 14:01
Cod6Parser patch plugin
#
# BigBrotherBot(B3) (www.bigbrotherbot.net)
# Copyright (C) 2014 Fenix <fenix@bigbrotherbot.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,