Skip to content

Instantly share code, notes, and snippets.

View snoack's full-sized avatar

Sebastian Noack snoack

  • polypoly GmbH
  • Detroit, MI, United States
View GitHub Profile
@snoack
snoack / gist:3818148
Created October 2, 2012 10:53
Shared/exclusive lock implementation on top of pipes and UNIX file locks
import os
import fcntl
import errno
from multiprocessing.util import register_after_fork
def _reset_level_after_fork(lock):
lock._level = 0
class _ShrdExclLock(object):
function findPositions(text, query, boundary) {
let lastBoundary = 0;
let numMatched = 0;
let found = false;
let positions = [];
for (let pos = 0; pos < text.length; pos++) {
let c = text[pos];
if (c == boundary) {
function getException(page, url, typeMask, docDomain, sitekey)
{
let thirdParty = !!docDomain && isThirdParty(url, docDomain);
let urlString = stringifyURL(url);
if (!docDomain)
docDomain = getDecodedHostname(url);
let filter = defaultMatcher.whitelist.matchesAny(
urlString, typeMask, docDomain, thirdParty, sitekey
import ast
import re
import tokenize
import sys
__version__ = '0.1'
DEPRECATED_APIS = {
('re', 'match'): 'A101 use re.search() instead re.match()',
('codecs', 'open'): 'A102 use io.open() instead codecs.open()',
import ast
import re
import tokenize
import sys
__version__ = '0.1'
DEPRECATED_APIS = {
('re', 'match'): 'A101 use re.search() instead re.match()',
('codecs', 'open'): 'A102 use io.open() instead codecs.open()',
def check_redundant_parenthesis(logical_line, tokens):
if tokens[0][2][0] != tokens[-1][3][0]:
return
statement = None
level = 0
for kind, token, start, end, _ in tokens:
if kind == tokenize.INDENT:
continue
import sys
import re
import os
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
import flake8.engine
import tokenize
import sys
import re
re_string = re.compile(r'^([rub]*)([\'"]{1,3})(.*)\2$', re.S)
class Converter:
def __init__(self, filename):
self.filename = filename
self.out = []
/home/sebastian/src/adblockpluschrome/background.js
20:24 error 'require' is not defined no-undef
21:20 error 'require' is not defined no-undef
22:28 error 'require' is not defined no-undef
23:32 error 'require' is not defined no-undef
24:16 error 'require' is not defined no-undef
25:18 error 'require' is not defined no-undef
51:34 error Expected to return a value at the end of this function consistent-return
55:18 error 'ext' is not defined no-undef
63:18 error 'Promise' is not defined no-undef