Skip to content

Instantly share code, notes, and snippets.

View stefanor's full-sized avatar

Stefano Rivera stefanor

View GitHub Profile
##########################################################################
#
# Copyright (c) 2005 Imaginary Landscape LLC and Contributors.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
diff --git a/lib/Map.py b/lib/Map.py
index 1ed1685..28895e8 100644
--- a/lib/Map.py
+++ b/lib/Map.py
@@ -51,7 +51,7 @@ class Map():
def loadMap(self, filepath):
- f = open(filepath)
+ f = open(filepath, 'U')
#! /usr/bin/perl -W
use strict;
use FileHandle;
use Fcntl qw(:DEFAULT O_DIRECT);
use POSIX;
#use Sys::Mmap;
use integer;
# we have several drives in the array, in different states each
# we keep in in @drv, in no particular order
======================================================================
FAIL: CheckOpcodeCount (sqlite3.test.hooks.ProgressTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/«BUILDDIR»/pypy-2.3+dfsg/lib-python/2.7/sqlite3/test/hooks.py", line 165, in CheckOpcodeCount
self.assertTrue(first_count > second_count)
AssertionError: False is not true
----------------------------------------------------------------------
Ran 233 tests in 0.469s
def relocateable_ve(ve_dir):
log.debug('Making virtualenv relocatable')
virtualenv.make_environment_relocatable(ve_dir)
# Make activate relocatable, using approach taken in
# https://github.com/pypa/virtualenv/pull/236
activate = []
with open(os.path.join(ve_dir, 'bin', 'activate')) as f:
for line in f:
line = line.strip()
@stefanor
stefanor / pycon-wifi.py
Last active August 29, 2015 14:18
PyCon Wifi
#!/usr/bin/env python
import argparse
import logging
import platform
import subprocess
import time
import requests
from requests.exceptions import ConnectionError, ReadTimeout
# final_package, package, min_rev, max_rev
('python-pysnmp4', 'pysnmp', None, 278),
('python-pysnmp4', 'pysnmp4', 279, 513),
('python-pysnmp4', 'python-pysnmp4', 514, None),
('genshi', 'markup', None, 1463),
('genshi', 'genshi', 1464, None),
# Not actually a rename, but python-cherrypy is gone
('cherrypy3', 'python-cherrypy', None, 1646),
('cherrypy3', 'cherrypy3', 1647, None),
('python-decorator', 'decorator', None, 2111),
cd /dev/shm
git clone --single-branch ~/git/yola/sitebuilderui
git remote rm origin
git update-ref -d refs/tags/pre-template-component-purge
git filter-branch --index-filter '
git ls-files -s \
| sed "s|\t.*/nabtext\.js$|\tnabtext/nabtext.js|" \
@stefanor
stefanor / demo.py
Last active September 2, 2016 21:01
buffering demo
#!/usr/bin/env python3
import difflib
import subprocess
import sys
qty = 1000000
seq = subprocess.check_output(
('seq', str(qty))).decode('utf-8')
#!/usr/bin/env python
from __future__ import print_function
import codecs
import sys
encoding = getattr(sys.stdout, 'encoding', '')
if encoding in (None, 'ANSI_X3.4-1968'):
UTF8Writer = codecs.getwriter('utf8')