Skip to content

Instantly share code, notes, and snippets.

View andreyvit's full-sized avatar

Andrey Tarantsov andreyvit

View GitHub Profile
@andreyvit
andreyvit / DualNibViewController.h
Last active December 17, 2015 09:29
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).
#import <Foundation/Foundation.h>
@interface DualNibViewController : UIViewController {
NSDictionary *_viewStates;
}
@end
@andreyvit
andreyvit / LiveReload-DevEnv.md
Created February 7, 2013 07:31
LiveReload development instructions. Basically a wiki for LiveReload hackers.

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

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){}}})();
@andreyvit
andreyvit / Delegate-README.txt
Created November 29, 2012 07:18
Delegate-README
В этой директории лежит 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 November 1, 2012 03:19
UglifyJS-0001-Fix-broken-calls-of-complex-binary-expressions-471
From 46089d511b7f7d718b79c4ce8a685366e1c73161 Mon Sep 17 00:00:00 2001
From: Andrey Tarantsov <[email protected]>
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 July 9, 2012 18:32
Wootemplate for an npm package
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
@andreyvit
andreyvit / Rakefile
Created June 27, 2012 00:55
Rakefile for setting up new Macs (part of my private ~/env Git repository)
desc "Install zsh config"
task :zshconfig do
sh 'chsh -s /bin/zsh'
sh 'rm -f ~/.zshrc ~/.zshenv'
sh 'ln -s ~/env/config/zshenv ~/.zshenv'
sh 'ln -s ~/env/config/zshrc ~/.zshrc'
end
desc "Install ssh config"
task :sshconfig do
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

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
andreyvit / AmazonS3BucketPolicy.xml
Created June 5, 2012 16:00
S3 bucket policy to enable everyone to access a certain bucket's file
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
@andreyvit
andreyvit / ObjCObject.mm
Created May 5, 2012 04:02
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,