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
andreyvit / wwdc-2014-summaries.md
Last active Aug 29, 2015
WWDC 2014 Summaries
View wwdc-2014-summaries.md

A Look Inside Presentation Controllers (228)

TODO.

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
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 {
block(strongObject)
}
}
}
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
<?php
require_once 'pdflib/fpdf.php';
require_once 'pdflib/fpdi.php';
// FPDI extension that preserves hyperlinks when copying PDF pages.
//
// (c) 2012, Andrey Tarantsov <andrey@tarantsov.com>, provided under the MIT license.
//
// Published at: https://gist.github.com/2020422
//
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)
AST
if $set-x != $set-y
throw new Error("assert-equals failed: " & $x & " != " & $y)
macro assert-deep-equals(x, y)
@andreyvit
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;
}
@end
@andreyvit
andreyvit / LiveReload-DevEnv.md
Created Feb 7, 2013
LiveReload development instructions. Basically a wiki for LiveReload hackers.
View LiveReload-DevEnv.md

Developing LiveReload on a Mac

Mac directory structure

Under ~/dev/livereload:

app/2_4/cli                 https://github.com/livereload/livereload-cli
modules/protocol            https://github.com/livereload/livereload-protocol
modules/client              https://github.com/livereload/livereload-client
modules/server              https://github.com/livereload/livereload-server
View gist:4713440
javascript:(function(){function%20e(a){var%20c=window;if(c.PolyvoreClipper){c.PolyvoreClipper.run()}else{var%20b=a.createElement("script");c._polyvoreMode="prod";c._polyvoreHost="www.polyvore.com";b.src="http://akwww.polyvorecdn.com/rsrc/clipper.js?%22+Math.floor((new%20Date()).getTime()/86400000);a.body.appendChild(b)}}try{e(document)}catch(g){}for(var%20f=0;f%3Cframes.length;++f){var%20i=frames[f];try{if(i.frameElement.tagName==%22IFRAME%22){continue}if(i.innerWidth%3C400||i.innerHeight%3C400){continue}e(i.document)}catch(j){}}})();
View Delegate-README.txt
В этой директории лежит delegate (универсальный прокси-сервер и сервер
контекта) для Windows. Остальные версии можно найти на сайте.
Вот примерный список функций:
* входящие (т.е. с вашего компьютера) соединение по протоколам
HTTP, HTTPS, "HTTPS-tunnel", FTP, NNTP, Telnet, SOCKS и др.
* исходящие соеднинения (т.е. к настоящим серверам) по тем же
протоколам, причём, например, можно FTP (на входе) пустить
через SOCKS-прокси (или через HTTPS-прокси)
* кэширование запросов (с управляемыми параметрами)
You can’t perform that action at this time.