Skip to content

Instantly share code, notes, and snippets.

Andrey Tarantsov andreyvit

Block or report user

Report or block andreyvit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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-прокси)
* кэширование запросов (с управляемыми параметрами)
@andreyvit
andreyvit / UglifyJS-0001-Fix-broken-calls-of-complex-binary-expressions-471.patch
Created Nov 1, 2012
UglifyJS-0001-Fix-broken-calls-of-complex-binary-expressions-471
View UglifyJS-0001-Fix-broken-calls-of-complex-binary-expressions-471.patch
From 46089d511b7f7d718b79c4ce8a685366e1c73161 Mon Sep 17 00:00:00 2001
From: Andrey Tarantsov <andrey@tarantsov.com>
Date: Thu, 1 Nov 2012 10:10:34 +0700
Subject: [PATCH] Fix broken calls of complex binary expressions [#471]
When deciding whether to parenthesize the expression being called, a
simple test of f.charAt(0) results in a broken code when calling a
complex expression which just happens to start with a paren but is
not actually parenthesized.
@andreyvit
andreyvit / npm-package.woot.yml
Created Jul 9, 2012
Wootemplate for an npm package
View npm-package.woot.yml
params:
- name: name
example: FooBar
description: The name of your package
- name: description
example: Cool package.
description: A short description of your package
- name: user-name
example: Andrey Tarantsov
description: Package author's full name
You can’t perform that action at this time.