Skip to content

Instantly share code, notes, and snippets.

View bwesterb's full-sized avatar
⚛️

Bas Westerbaan bwesterb

⚛️
View GitHub Profile
@bwesterb
bwesterb / gist:4636517
Created January 25, 2013 18:01
On rPi python pypy/test_all.py pypy/jit/backend/arm/test/test_basic.py
This file has been truncated, but you can view the full file.
root@raspberrypi:~/pypy# python pypy/test_all.py pypy/jit/backend/arm/test/test_basic.py
============================= test session starts ==============================
platform linux2 -- Python 2.7.3 -- pytest-2.2.4.dev2
pytest-2.2.4.dev2 from /root/pypy/pytest.pyc
collected 171 items
pypy/jit/backend/arm/test/test_basic.py .ssssss..........FFFF.FF.F..............F...F..............F.FFFFF.F.F.F.F......FFFFF...F.......FFFFFFFFF......FFFFF...F.FFFF..FFFFF..FFFFF.FF..sF.FFFF.F.......FF....s....
=================================== FAILURES ===================================
__________________ TestBasic.test_loop_invariant_mul_bridge1 ___________________
import struct
def f():
f = open('test')
s = f.read(1000000)
ret = 0
for i in xrange(len(s)/4):
ret = (ret + struct.unpack("i", s[4*i:4*i+4])[0]) % 6000
return ret
[37bcd55331c] {jit-backend-dump
BACKEND x86_64
SYS_EXECUTABLE /opt/pypy/bin/pypy
CODE_DUMP @103d21000 +0 4157415641554154415341524151415057565554535251504889E749BBD0B1D3000100000041FFD3488D65D848BB10E88D010100000048832B10415F415E415D415C5B5DC3
[37bcd562868] jit-backend-dump}
[37bcd56aad2] {jit-backend-dump
BACKEND x86_64
SYS_EXECUTABLE /opt/pypy/bin/pypy
CODE_DUMP @103d21045 +0 41574156415541544153415241514150575655545352515049BBC8D4C20201000000498B1B49BBC0D4C2020100000049C7030000000049BBC8D4C2020100000049C703000000004889E749BBD0B1D3000100000041FFD348895818488D65D848BB10E88D010100000048832B10415F415E415D415C5B5DC3
[37bcd56d613] jit-backend-dump}
#!/usr/bin/env python
# sudo apt-get install python-gmpy python-crypto
# # or
# easy_install gmpy pycrypto
import gmpy
import math
import Crypto
import Crypto.Random
@bwesterb
bwesterb / pycrypto-shuffle.py
Created April 21, 2013 21:01
Faster random.shuffle for PyCrypto
import math
import random
import timeit
import functools
import Crypto.Random.random
def shuffle(s):
r = Crypto.Random.random.randrange(0, math.factorial(len(s)))
for i in xrange(len(s)-1, 0, -1):
@bwesterb
bwesterb / test
Last active December 17, 2015 23:38
Try-out for the interactive editing format for `pol`
CONTAINER 1
github #1 this is a note
nonote #2
test test this has its secret
CONTAINER 2
facebook #4 user: bla
"google id" #5 "a multiline\nnote"
import os
import urllib2
import socket
from bs4 import BeautifulSoup
def teespring_amount_ordered(what):
html = urllib2.urlopen('http://teespring.com/'+what).read()
soup = BeautifulSoup(html)
return int(soup.find(attrs={'class': 'amount-ordered'}).text)
facebook #1 username: john.doo
github #2 username: johnd
linkedin #3 email: linkedin@john.doo
bios.pc #4
wrongline
# ^
# Expected stringEnd (at char 169), (line:5, col:6)
bios.notebook #5
"facebook rescue code" #6
@bwesterb
bwesterb / run
Last active December 30, 2015 09:09
$ ./run
-- Curve SECG-K256:
real 0m3.534s
user 0m2.253s
sys 0m1.280s
$ time pol -w 1 touch
[==============================================================================]
-- vif-route 2014-09-02 08:20:19.000000000 +0200
+++ our-vif-route 2016-01-26 08:57:14.557343864 +0100
@@ -23,11 +23,37 @@
dir=$(dirname "$0")
. "${dir}/vif-common.sh"
+ip6_of()
+{
+ ip -6 addr show "$1" | perl -wane '/scope global/ && /inet6 (([0-9a-f]+:*)+)/ && print $1;'
+}