Skip to content

Instantly share code, notes, and snippets.


Andrey Tarantsov andreyvit

View GitHub Profile

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

# remap prefix to Control + a
andreyvit / fpdi_with_annots.php
Created Mar 12, 2012
FPDI extension to preserve external hyperlinks
View fpdi_with_annots.php
// FPDI extension that preserves hyperlinks when copying PDF pages.
// (c) 2012, Andrey Tarantsov <>, provided under the MIT license.
// Published at:
// Note: the free version of FPDI requires unprotected PDFs conforming to spec version 1.4.
// I use qpdf ( to preprocess PDFs before running through this
andreyvit / extractiraw.go
Created Jun 18, 2020
Extract .iraw files that some Flash videoconferencing systems use
View extractiraw.go
package main
import (
andreyvit / ATRichCheckbox.h
Created Jun 10, 2020
UIKit checkbox control that supports embedded links (for ToS acceptance checkbox)
View ATRichCheckbox.h
@import UIKit;
typedef void (^RDLCheckboxURLHandler)(NSURL *url);
@interface ATRichTextCheckbox : UIControl
@property (nonatomic, readonly) UIButton *checkbox;
andreyvit /
Created Mar 24, 2012
A script to remove old DB backup files, keeping one backup per month, one backup per day for the last X months and the last Y backups.
#! /bin/bash
# vim: sw=2 ts=2 et ai
# Deletes old DB backup files from the folder specified as an argument.
andreyvit /
Created May 5, 2012
Fake an Objective-C class out of a C++ class
// Fakes an Objective-C class out of a C++ class.
// Note that this is a very bad and completely superfluous idea, but after looking up a way
// to build Objective-C classes at run time, I just had to do this no matter what. (Besides,
// I really hated maintaining mutual pointers in UIElement/UIElementDelegate class pairs.)
// Building up a whole class from scratch (objc_allocateClassPair) looked like a lot of trouble,
// so I compile a real Objective-C class instead, but instead of instantiating it by regular means
// (alloc/init or class_createInstance), I simply cast a part of a C++ object to (id).
// I've looked at the source code for class_createInstance and this hack should work perfectly,
View gist:384389
// call when zoom level or page size changes (i.e. after zooming or after rotation)
- (void)updateContentInsetForPageScrollView:(UIScrollView *)pageScrollView {
UIImageView *imageView = (UIImageView *) [pageScrollView viewWithTag:TAG_IMAGE_VIEW];
CGFloat zoomScale = pageScrollView.zoomScale;
CGSize imageSize = imageView.bounds.size;
CGSize zoomedImageSize = CGSizeMake(imageSize.width * zoomScale, imageSize.height * zoomScale);
CGSize pageSize = pageScrollView.bounds.size;
View 1_fpdi_with_annots.php
require_once 'pdflib/fpdf.php';
require_once 'pdflib/fpdi.php';
// FPDI extension that preserves hyperlinks when copying PDF pages.
// (c) 2012, Andrey Tarantsov <>, provided under the MIT license.
// Published at:
View Delegate-README.txt
В этой директории лежит delegate (универсальный прокси-сервер и сервер
контекта) для Windows. Остальные версии можно найти на сайте.
Вот примерный список функций:
* входящие (т.е. с вашего компьютера) соединение по протоколам
HTTP, HTTPS, "HTTPS-tunnel", FTP, NNTP, Telnet, SOCKS и др.
* исходящие соеднинения (т.е. к настоящим серверам) по тем же
протоколам, причём, например, можно FTP (на входе) пустить
через SOCKS-прокси (или через HTTPS-прокси)
* кэширование запросов (с управляемыми параметрами)

Memory Leak Report

Many web apps leak memory on IE11 despite running fine on other browsers. We've identified two main causes of this.

The first kind of leak is simple, entirely predictable and caused by a quirk in how IE's JavaScript engine handles closures. Let's call it an “undead closure leak”. This leak goes away if you properly clean up all references or reload the page, and thus affects only AJAXy parts of the apps.

The second kind of leak is a complex permanent one, leaking the entire page context even if you reload the page. Let's call it a “GC singularity leak”. It's triggered by certain JavaScript code patterns, seemingly because IE's garbage collector never finishes its job (our theory is that it exhibits exponential complexity and encounters some sort of timeout/threshold).

This might not be an exhaustive list; internet posts point to other issues, notably when handling IFRAMEs, but we haven't encountered any of these.

You can’t perform that action at this time.