Skip to content

Instantly share code, notes, and snippets.


Alexandre Macabies zopieux

View GitHub Profile
# -*- coding: utf-8 -*-
import smtplib
from email.mime.text import MIMEText
from email.header import Header
import urllib.request as urllib
from bs4 import BeautifulSoup
from random import choice
def randomWikipediaPage():
zopieux /
Last active Aug 31, 2022
Bitbucket webhooks to IRC broker
#!/usr/bin/env python3
# coding: utf-8
# This launches a webserver listening on HTTP_HOST and a IRC client to display the messages.
# Configuration using capital variables below.
# Dependencies: Python 3, pypeul (Python 3 branch)
from http.server import BaseHTTPRequestHandler, HTTPServer
from pypeul import IRC, Tags
import json
View gist:8759785
import re
import unicodedata
import difflib
import urlparse
def slugify(value):
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
value = re.sub('[^\w\s-]', '', value).strip().lower()
return re.sub('[-\s]+', '-', value)
#!/usr/bin/env python3
#-*- encoding: utf-8 -*-
# Simple bot which displays urls titles
# Copyright (c) 2010 Mick@el and Zopieux
# Copyright (c) 2014 gustavi
# This program is free software: you can redistribute it and/or modify
View gist:52c6e643cc6dcf963902
def do_work(i):
# do something very time-consuming here
print("computing stuff for i =", i)
return i < 2
# Test with lists
print( all( [ do_work(i) for i in range(6) ] ) )
# computing stuff for i = 0
# computing stuff for i = 1
# computing stuff for i = 2
zopieux /
Created Aug 25, 2014
Find KO chapters in SRT for ~phennequin
#!/usr/bin/env python
# Usage: python <> <output.txt>
from __future__ import print_function
from itertools import zip_longest
except ImportError:
from itertools import izip_longest as zip_longest
def grouper(iterable, n, fillvalue=None):
zopieux /
Created Sep 27, 2014
Quizz Fever networking
def messageToBytes(type, body=None):
data = {'type': type}
if body is not None:
data['body'] = body
return json.dumps(data).encode('ascii') + b"\n"
except ValueError:
raise ValueError("message could not be JSON-encoded")
except UnicodeEncodeError:
raise UnicodeEncodeError("JSON could not be converted to bytes")
zopieux /
Created Dec 28, 2014
Google API OAuth2 persistent token
# Example with Contacts API
import atom.http_core
import gdata.contacts.client
import gdata.gauth
auth_kwargs = {
'client_id': '', # CHANGEME (see API auth console)
'client_secret': 'client-secret-xxx', # CHANGEME (see API auth console)
'scope': '', # CHANGEME (see API reference)
zopieux / result
Last active Aug 29, 2015
pacaur shellcheck analysis
View result
In - line 15:
^-- SC2034: TEXTDOMAIN appears unused. Verify it or export it.
In - line 16:
^-- SC2034: TEXTDOMAINDIR appears unused. Verify it or export it.
zopieux /
Last active Aug 29, 2015
compress/uncompress/listcompress shell functions
function compress() {
function usage() {
echo "Usage: $this file.{zip,tgz,tbz2,xz,7z,exe} target [target ...]" >&2
test $# -lt 2 && ( usage; return 1 )
case "$name" in