Skip to content

Instantly share code, notes, and snippets.

View barbuza's full-sized avatar
🇺🇦
Stand with Ukraine

Victor Kotseruba barbuza

🇺🇦
Stand with Ukraine
View GitHub Profile
class ParallelWorker(threading.Thread):
def __init__(self, cb, fn, args, kwargs):
self._cb = cb
self._fn = fn
self._args = args
self._kwargs = kwargs
super(ParallelWorker, self).__init__()
def run(self):
--- ../orig/nginx-1.0.11/src/http/modules/ngx_http_memcached_module.c 2010-05-20 15:46:01.000000000 +0400
+++ src/http/modules/ngx_http_memcached_module.c 2012-01-13 17:58:18.000000000 +0400
@@ -312,22 +312,15 @@
if (ngx_strncmp(p, "VALUE ", sizeof("VALUE ") - 1) == 0) {
p += sizeof("VALUE ") - 1;
-
- if (ngx_strncmp(p, ctx->key.data, ctx->key.len) != 0) {
- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
- "memcached sent invalid key in response \"%V\" "
@barbuza
barbuza / gist:1087877
Created July 17, 2011 18:09
tag tv show episodes from <SHOW NAME>_S<SEASON NUM>_E<EPISODE NUM>_<EPISODE ID>
set seasonNumPattern to "\\d\\d"
set episodeNumPattern to "\\d\\d"
tell application "iTunes"
repeat with I from 1 to count tracks of user playlist "show"
set track_ to track I of user playlist "show"
set name_ to name of track_
set seasonNum to (find text "(?<=S)(" & seasonNumPattern & ")" in name_ with regexp and string result) as integer
set episodeNum to (find text "(?<=E)(" & episodeNumPattern & ")" in name_ with regexp and string result) as integer
@barbuza
barbuza / contract.py
Created May 11, 2011 14:05
validate arbitrary data structures in python
# -*- coding: utf-8 -*-
import functools
import inspect
"""
Contract is tiny library for data validation
It provides several primitives to validate complex data structures
Look at doctests for usage examples
"""
@barbuza
barbuza / bitoptionsfield.py
Created May 11, 2011 10:43
BitOptionsField holds a short list of predefined options in a single integer field
# -*- coding: utf-8 -*-
from django.db import models
from django.core import exceptions
__all__ = ("BitOptionsField", )
class BitOptionsField(models.Field):
Element.implement({
show: function() {
this.setStyle("visibility", "visible");
},
hide: function() {
this.setStyle("visibility", "hidden");
}
});
@barbuza
barbuza / gist:302045
Created February 11, 2010 22:30
mailru api
require 'net/http'
require 'cgi'
require 'uri'
require 'md5'
require 'json'
module Mailru
API_METHODS = ['friends.get', 'friends.getAppUsers', 'users.getInfo',
'users.isAppUser', 'users.hasAppPermission', 'payments.openDialog',
function remote-trailing-whitespaces {
read -n 1 -e -p 'are you sure? [y/n] ' answ
if [[ $answ == y ]]; then
echo removing trailing whitespaces from
find . -iname "$1" -type f
find . -iname "$1" -type f -print0 | xargs -0 sed -i .bak -E "s/[[:space:]]*$//"
fi
}
require 'rubygems'
require 'optparse'
require 'URI'
require 'Time'
require 'eventmachine'
@fails = 0
@requests = 0
@request_timings = []
package {
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import mx.logging.Log;
import mx.logging.LogEventLevel;
import org.casalib.display.CasaMovieClip;