Skip to content

Instantly share code, notes, and snippets.

View rhizoome's full-sized avatar
💭
Gluing elephants to the ceiling

Jean-Louis Fuchs rhizoome

💭
Gluing elephants to the ceiling
View GitHub Profile
struct uv_loop_s {
/* User data - use this for whatever. */
void* data;
/* Loop reference counting. */
unsigned int active_handles;
void* handle_queue[2];
void* active_reqs[2];
/* Internal flag to signal loop stop. */
unsigned int stop_flag;
UV_LOOP_PRIVATE_FIELDS
@rhizoome
rhizoome / gist:53100f053933a7a53aad
Created March 27, 2016 19:33
Solution libuv WTF
//uv.h
struct uv_loop_s {
/* User data - use this for whatever. */
void* data;
/* Loop reference counting. */
unsigned int active_handles;
void* handle_queue[2];
void* active_reqs[2];
/* Internal flag to signal loop stop. */
unsigned int stop_flag;
@rhizoome
rhizoome / oiginal.py
Created April 8, 2016 08:27
Shrinking for checking the test
import datetime
def iso_first_week_start(iso_year, tzinfo=None):
"""The gregorian calendar date of the first day of the given ISO year
:param iso_year: Year to find the date of the first week.
:type iso_year: int"""
fourth_jan = datetime.datetime(iso_year, 1, 4, tzinfo=tzinfo)
delta = datetime.timedelta(fourth_jan.isoweekday() - 1)
RES_COUNT = 35
range_intagers_st = st.integers(min_value=0, max_value=RES_COUNT)
@st.composite
def provide_require_st(draw, filter_=True):
commands = draw(range_intagers_st)
provides = draw(
st.lists(
#!/usr/bin/env python
import tempfile
import sys
import os
import subprocess
proc = None
try:
tmp = tempfile.NamedTemporaryFile(delete=False)
tmp.write(sys.stdin.read().encode("UTF-8"))
@rhizoome
rhizoome / gist:0f440ce3dda19635988695dfbedd91ac
Created April 8, 2016 15:12
check_output can fail with ValueError
Traceback (most recent call last):
File "/home/ganwell/.pyenv/versions/3.5.1/bin/structureshrink", line 9, in <module>
load_entry_point('structureshrink==0.0.1', 'console_scripts', 'structureshrink')()
File "/home/ganwell/.pyenv/versions/3.5.1/lib/python3.5/site-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/home/ganwell/.pyenv/versions/3.5.1/lib/python3.5/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/home/ganwell/.pyenv/versions/3.5.1/lib/python3.5/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/ganwell/.pyenv/versions/3.5.1/lib/python3.5/site-packages/click/core.py", line 534, in invoke
"""Testing dependency graphs"""
import random
import sys
from . import Command, FunctionCommand, test
if not sys.version_info < (2, 7):
from hypothesis import strategies as st
from hypothesis import given
typedef struct {
// Network data, has to be sent in network order
char identity[16];
char serial[16];
int8_t message_type;
int16_t header_len;
int16_t actor_len;
int32_t data_len;
// These fields follow the message in this order (see _len above)
char* header;
File "/home/ganwell/.pyenv/versions/pypy-5.1/site-packages/finja/__init__.py", line 966, in parse_file
f.seek(0)
File "/home/ganwell/.pyenv/versions/pypy-5.1/lib-python/2.7/codecs.py", line 709, in seek
self.writer.reset()
IOError: File not open for writing
import timeit
def memoize(function):
"""Caching results of a function"""
# This is bad of course, it just to be able to compare the solutions
memoize.cache = {}
def memoizer(*args, **kwargs):
"""Memoize helper"""