Skip to content

Instantly share code, notes, and snippets.

def test_cleanup():
cleaned_objects = []
class A:
def cleanup(self):
cleaned_objects.append(self)
objects = main.init([A, A, A])
main.cleanup(objects)
DICT = {'hi', 'there', 'hit', 'here'}
def camelcase(tail, head=''):
heads = [head.title()] if head in DICT else []
return ([h + t for h in heads for t in camelcase(tail)] + camelcase(tail[1:], head + tail[0])
if tail else heads)
print(camelcase('hithere'))
@isagalaev
isagalaev / main.rs
Created January 14, 2016 00:32
Copying memory
extern crate time;
use std::env;
use std::ptr;
use time::Duration;
const SIZE: usize = 10 * 1024 * 1024;
@isagalaev
isagalaev / test.c
Created July 10, 2015 05:08
yajl performance test
#include <stdio.h>
#include <time.h>
#include <yajl/yajl_parse.h>
unsigned char buffer[64 * 1024];
unsigned int count = 0;
int count_string(void *ctx, const unsigned char *value, size_t length) {
@isagalaev
isagalaev / gist:0bcc45df34f0826abda6
Created April 23, 2015 05:32
lifetime parameters
const BUFSIZE: usize = 64 * 1024;
use std::fs::File;
use std::io::Read;
struct Lexer<'a> {
buf: & 'a mut [u8; BUFSIZE],
len: usize,
pos: usize,
f: File,
import ijson
def parse(events):
for prefix, event, value in events:
if event == 'number':
value = float(value)
yield prefix, event, value
f = urllib.request.urlopen('...')
for obj in ijson.common.items(parse(ijson.parse(f)), '... prefix ...'):

Keybase proof

I hereby claim:

  • I am isagalaev on github.
  • I am isagalaev (https://keybase.io/isagalaev) on keybase.
  • I have a public key whose fingerprint is CD82 579D D412 FA0F D9CF 8797 4817 287F 1B64 69EA

To claim this, I am signing this object:

@isagalaev
isagalaev / img.py
Last active December 11, 2015 05:48 — forked from bobuk/img.py
#!/usr/bin/env python
# coding: utf-8
import os
import random
import glob
from PIL import Image
import numpy
@isagalaev
isagalaev / fabfile.py
Created August 29, 2012 06:43
highlight.js fabfile for softwaremaniacs.org
# coding: utf-8
from fabric.api import env, cd, run, local, get
from fabric.contrib.files import sed
env['hosts'] = ['softwaremaniacs.org']
SRC = '/home/maniac/code/highlight'
MEDIA = '/var/www/media/soft/highlight'
CACHE = '/home/maniac/app-data/hljs_cache'