Skip to content

Instantly share code, notes, and snippets.

View chekunkov's full-sized avatar

Alex chekunkov

  • Mountain View, California
View GitHub Profile
"""I suspect that there is a race condition in datetime module.
When I ran the following code in a multi-threading application:
datetime.datetime.strptime('20120509100335', "%Y%m%d%H%M%S")
I've noticed the following error in the log.
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 522, in __bootstrap_inner
{% if is_paginated %}
<div class="pagination pagination-centered">
<ul>
{% if page_obj.has_previous %}
<li><a href="?page={{ page_obj.previous_page_number }}{{ getvars }}{{ hashtag }}">← Prev</a></li>
{% else %}
<li class='disabled'><a>← Prev</a></li>
{% endif %}
{% for page in pages %}
import re
def camelcase_to_lowercase_with_underscores(name):
"""
>>> camelcase_to_lowercase_with_underscores('CamelCase')
'camel_case'
>>> camelcase_to_lowercase_with_underscores('CamelCamelCase')
'camel_camel_case'
>>> camelcase_to_lowercase_with_underscores('Camel2Camel2Case')
from optparse import OptionParser
import os
import sys
import csv
import hashlib
# workaround for error:
# Field larger than field limit
csv.field_size_limit(sys.maxsize)
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get install -y python python-dev python-pip git \
libffi-dev libxml2-dev libxslt1-dev zlib1g-dev libssl-dev
RUN mkdir -p /var/log/supervisord /project
@chekunkov
chekunkov / rlock.py
Last active January 25, 2021 06:27
File based reentrant lock
# -*- coding: utf-8 -*-
"""Reentrant lock based on lock file.
Copyright (c) 2015 Alexander Chekunkov
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
@chekunkov
chekunkov / card.css
Last active August 29, 2015 14:21
Anki card template
.card {
font-family: arial;
font-size: 20px;
text-align: center;
color: black;
background-color: white;
}
.synonyms {
font-size: 14px;
@chekunkov
chekunkov / export_csv.py
Created May 24, 2015 07:48
Anki export to CSV add-on
# -*- coding: utf-8 -*-
"""Anki add-on which adds "Notes in CSV format" option of Export desc dialog.
Copyright (c) 2015 Alex Chekunkov
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
@chekunkov
chekunkov / Numpy integer overflow.ipynb
Created August 1, 2015 15:03
Numpy array integer overflow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chekunkov
chekunkov / s3_gz.py
Last active April 20, 2022 12:55
Stream gzip file from s3
import zlib
import boto
def decompress(key):
d = zlib.decompressobj(16 + zlib.MAX_WBITS)
for chunk in key:
yield d.decompress(chunk)
yield d.flush()