Skip to content

Instantly share code, notes, and snippets.

@dw
dw / README.md
Created March 2, 2014 02:22 — forked from sarg/README.md

Obtaining RK3066 boot ROM.

Here are my steps.

At first, I took a look to RK30xxLoader(L)_V1.18.bin. This file appears in update.img for my device. So, I unpacked update.img using rk29Kitchen.

strings on that file returns nothing interesting, so I assumed the file is crypted

#
# with 2047 of 2048 reader slots allocated
#
$ python -mtimeit -s 'import lmdb; e = lmdb.open("/tmp/test")' 'e.begin().abort()'
100000 loops, best of 3: 10.1 usec per loop
$ git stash &>/dev/null ; python setup.py build &> /dev/null
$ python -mtimeit -s 'import lmdb; e = lmdb.open("/tmp/test")' 'e.begin().abort()'
1000000 loops, best of 3: 0.47 usec per loop
[00:34:19 eldil!1 ~] cat bin/ts
#!/bin/bash
while read; do
echo `date +%Y-%m-%d+T%H:%M:%S` "$REPLY"
done
@dw
dw / fs.c
Last active August 29, 2015 14:02
// create 1 million files, final directory size ~4.1gb:
// for i in {1..1024} ; do mkdir -p junk/$i ; for j in {1..1024} ; do cp /etc/hostname junk/$i/$j ; done; done
/*
[20:23:18 k2!58 ~] gcc -O2 -oa a.c
[20:23:19 k2!59 ~] time ./a
real 0m13.000s
*/
#include <sys/types.h>
/**
* Match methods on `obj` of the form "_onCssClassAction", extracting
* "CssClass" and "Action", then:
*
* - Transform "CssClass" to ".cssClass"
* - Transform "Action" to "action"
* - Find elements matching .cssClass inside `elem`
* - Wire up the corresponding jQuery action (e.g. click()) to a bound
* copy of the method.
*
import collections, types
class frozendict(collections.UserDict):
def __init__(self, d=None, **kw):
d = kw if d is None else dict(d, **kw)
self.data = types.MappingProxyType(d)
self._h = sum(map(hash, self.data.items()))
__hash__ = lambda self: self._h
__repr__ = lambda self: repr(dict(self))
[23:19:21 k3!2 py-lmdb] ~/pypy-2.4.0/bin/pypy examples/dirtybench.py
permutate 1876098 words avglen 13 took 2.74sec
DB_PATH: /ram/testdb
insert: 3.070s 611142/sec
stat: {'branch_pages': 244L, 'entries': 1876098L, 'overflow_pages': 0L, 'psize': 4096, 'depth': 4, 'leaf_pages': 25385L}
k+v size 50911.31kb avg 27, on-disk size: 101540.00kb avg 55
enum (key, value) pairs: 0.544s 3447601/sec
reverse enum (key, value) pairs: 0.495s 3790924/sec
import lmdb
def test():
env = lmdb.open("test.lmdb", max_dbs=1, map_size=15*1024*1024)
try:
value = bytearray(" "*9*1024*1024)
with env.begin(write=True, buffers=True) as txn:
txn.put("big", value, dupdata=False, overwrite=True)
@dw
dw / a.py
Created September 2, 2016 22:15
def flags(names):
"""Return the result of ORing a set of (space separated) :py:mod:`termios`
module constants together."""
return sum(getattr(termios, name) for name in names.split())
def flags(names):
"""Return the result of ORing a set of (space separated) :py:mod:`termios`
module constants together."""
n = 0
@dw
dw / mito.py
Last active September 21, 2017 10:14
Mitogen (local and remote loop example)
import subprocess
import mitogen
def main(router):
u = router.ssh(hostname='u')
root = router.sudo(via=u, password='x')
for x in xrange(100):
root.call(subprocess.check_call, ['true'])
if __name__ == '__main__' and mitogen.is_master: