Skip to content

Instantly share code, notes, and snippets.

View veloutin's full-sized avatar

Vincent Vinet veloutin

  • rtings.com
  • Canada
View GitHub Profile
@veloutin
veloutin / bitbucket.py
Created October 26, 2018 14:28
Modification or builtbot's BitbucketPullrequestPoller to support auth and fix encoding issues.
# This file is part of Buildbot. Buildbot 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, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
@veloutin
veloutin / explicitoverride_meta.py
Last active November 30, 2016 02:45
Example of printing a warning for implicit overriding of functions
#!/usr/bin/env python3
import types
class ExplicitOverloadType(type):
def __init__(self, name, bases, dict):
for key, val in dict.items():
if isinstance(val, types.FunctionType):
if getattr(val, "_is_overriden", False):
#!/usr/bin/env python
import sys
ports = set()
for s in ("tcp","udp","tcp6","udp6"):
with open("/proc/net/%s" % s) as f:
for l in f.readlines()[1:]:
ports.add(int(l.split(":")[2][:4],16))
@veloutin
veloutin / freeze-buildout-merges.py
Last active August 29, 2015 14:13
Freeze Buildout Merges
#!/usr/bin/env python
# *-* coding: utf-8 *-*
from __future__ import print_function, unicode_literals
import os
import sys
import subprocess
def get_merged_version(cwd, branch):
""" Attempt to find the version at which branch was merged """
@veloutin
veloutin / pre-commit
Created March 27, 2014 21:16
flake8 git pre-commit hook
#!/usr/bin/env python
# inspired by http://tech.myemma.com/python-pep8-git-hooks/
from __future__ import with_statement
import re
import subprocess
import sys
def system(*args, **kwargs):
kwargs.setdefault('stdout', subprocess.PIPE)
@veloutin
veloutin / evil1.py
Last active December 31, 2015 04:28
Attempt to rewrite bytecode to preallocate dicts
from types import FunctionType, CodeType
import opcode
import struct
import sys
_BUILDMAP = opcode.opmap['BUILD_MAP']
if sys.version_info.major > 2:
from io import BytesIO
exop = int
@veloutin
veloutin / gist:6040766
Last active December 20, 2015 00:19
FizzBuzz
for i in range(1, 100):
print ''.join(["Fizz", "Buzz"][1-(i%3==0):1+(i%5==0)]) or i
@veloutin
veloutin / p;a.py
Created May 22, 2013 18:01
There there
>>> import p.a
B notfound
A <module 'p.b' from 'p/b.py'>