Skip to content

Instantly share code, notes, and snippets.

View arekbulski's full-sized avatar

Arkadiusz Bulski arekbulski

  • Poland
  • 17:13 (UTC +02:00)
View GitHub Profile
@xfail(not supportsksyexport, reason="KSY exporter requires yaml and unicode strings")
def test_exportksy():
d = Struct(
"nothing" / Pass * "field docstring",
"data1" / Bytes(10),
"data2" / GreedyBytes,
"bitstruct" / BitStruct(
"flag" / Flag,
@arekbulski
arekbulski / con.py
Last active September 25, 2016 08:43
class Container(collections.OrderedDict):
r"""
Generic ordered dictionary that allows both key and attribute access, and preserve key order by insertion. Also it uses __call__ method to chain add keys, because **kw does not preserve order.
Struct and Sequence, and few others parsers returns a container, since their members have order so do keys.
Example::
Container([ ("name","anonymous"), ("age",21) ])
class Container(collections.OrderedDict):
__slots__ = ["__keys_order__","__recursion_lock__"]
def __getattr__(self, name):
try:
return self[name]
except KeyError:
raise AttributeError(name)
def __setattr__(self, name, value):
import os
istravis = os.environ.get('TRAVIS') == 'true'
$ ooo_cat ideas.odt mission.odt responses.odt > combined.odt
Traceback (most recent call last):
File "/usr/local/bin/ooo_cat", line 58, in <module>
t.transform (o)
File "/usr/local/lib/python2.7/dist-packages/ooopy/Transformer.py", line 1383, in transform
t.apply_all (self.trees)
File "/usr/local/lib/python2.7/dist-packages/ooopy/Transforms.py", line 854, in apply_all
self.style_merge (f)
File "/usr/local/lib/python2.7/dist-packages/ooopy/Transforms.py", line 1134, in style_merge
or namemap [key][name] == newname
def dfs(graph, start):
color = {i : 'white' for i in graph}
stack = [start]
visited = []
while stack:
vertex = stack.pop()
if color[vertex] == 'grey':
return True
color[vertex] = 'grey'
def dfs(graph, start):
color = {i : 'white' for i in graph}
stack = [start]
visited = []
while stack:
vertex = stack.pop()
if color[vertex] == 'grey':
return True
color[vertex] = 'grey'
On Sun, 2015-10-18 at 23:39 +0200, Arek Bulski wrote:
> I read an interview where you said that disks nowadays guarantee
> atomic sector writes. I am inclined to believe that. However, I
> stumbled upon some comments on LWN saying that its all baloney because
> electronics outside the disk can fail before the disk, due to power
> loss, and therefore pass corrupted data to disk. Is there some
> citation that could authoritatively confirm one way or another?
Both can be true; though the exact characteristics of (especially
@arekbulski
arekbulski / Program.cs
Last active October 24, 2015 15:48
Mono.Simd code checking byte[] is all zeros
/// Add references to: Mono.Simd, System, System.Core
using System;
using Mono.Simd;
using System.Diagnostics;
using System.Linq;
using System.Runtime;
namespace testzeros
{
class MainClass
def divide(inputlist):
"""Dzieli liste na wejsciu na liste list pojedynczych elementow.
>>> divide([1,2,3])
[[1],[2],[3]]
"""
pass
def merge(onelist, seclist):
"""Scala dwie posortowane listy w jedna posortowana liste.
>>> merge([1,2,4],[2,3,5])