Skip to content

Instantly share code, notes, and snippets.


Andrey Tarantsov andreyvit

View GitHub Profile
View elevators.js
init: function(elevators, floors) {
var DIR_UP = 1, DIR_DOWN = -1, DIR_IDLE = 0;
var FLOOR_NINF = -1, FLOOR_PINF = 1000;
var floorUpRequests = [];{
init: function(elevators, floors) {
var DIR_UP = 1, DIR_DOWN = -1, DIR_IDLE = 0;
var FLOOR_NINF = -1, FLOOR_PINF = 1000;
andreyvit /
Last active Aug 29, 2015
WWDC 2014 Summaries

A Look Inside Presentation Controllers (228)


A Strategy for Great Work (237)

  1. “Know a good idea when you see it”: a demo of KHTML running on a Mac, made in 2 days, helped them pick it for Safari.

  2. “Don't try to solve every problem at once”: was extracting KHTML from KDE, had no idea how it worked, just compiled one file at a time, and stubbed missing functions one at a time.

andreyvit / ObservationPlayground.swift
Last active Aug 29, 2015
Code from “In search of a clean closure-based observation API in Swift” on Apple Dev Forums
View ObservationPlayground.swift
import Foundation
func weakify<T: AnyObject>(object: T, block: (T) -> Void) -> () -> Void {
weak var weakObject = object
return {
if let strongObject = weakObject {
View ATUnclippedTextField.h
#import <Cocoa/Cocoa.h>
// NSTextField has alignmentRectInsets = {.left=.right=3, .top=.bottom=0}, so
// when autolayout aligns NSTextField to its container's side margin (e.g. to x=0),
// the actual x position is -3, and the label gets clipped.
// ATUnclippedTextField compensates for that by overriding drawRect to extend
// the clipping rect by alignmentRectInsets.
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 gist:5944549
// GorillaScript as of 2013-07-08
macro assert-equals(x, y)
@maybe-cache x, #(set-x, x)
@maybe-cache y, #(set-y, y)
if $set-x != $set-y
throw new Error("assert-equals failed: " & $x & " != " & $y)
macro assert-deep-equals(x, y)
andreyvit / DualNibViewController.h
Last active Dec 17, 2015
An old code fragment demonstrating the use of a separate landscape .nib in a UIViewController (the view hierarchies of the two .nib files must match exactly, and only the frames are adjusted when going into landscape, although you can obviously add more properties to the save/restore code).
View DualNibViewController.h
#import <Foundation/Foundation.h>
@interface DualNibViewController : UIViewController {
NSDictionary *_viewStates;
andreyvit /
Created Feb 7, 2013
LiveReload development instructions. Basically a wiki for LiveReload hackers.

Developing LiveReload on a Mac

Mac directory structure

Under ~/dev/livereload:

View gist:4713440
View Delegate-README.txt
В этой директории лежит delegate (универсальный прокси-сервер и сервер
контекта) для Windows. Остальные версии можно найти на сайте.
Вот примерный список функций:
* входящие (т.е. с вашего компьютера) соединение по протоколам
HTTP, HTTPS, "HTTPS-tunnel", FTP, NNTP, Telnet, SOCKS и др.
* исходящие соеднинения (т.е. к настоящим серверам) по тем же
протоколам, причём, например, можно FTP (на входе) пустить
через SOCKS-прокси (или через HTTPS-прокси)
* кэширование запросов (с управляемыми параметрами)