Skip to content

Instantly share code, notes, and snippets.

View andreyvit's full-sized avatar

Andrey Tarantsov andreyvit

View GitHub Profile
@andreyvit
andreyvit / Как редактировать подкаст.md
Last active May 1, 2018 11:36
Как редактировать подкаст

Как редактировать подкаст

На входе

Файлы от каждого участника подкаста (FLAC / AAC). По сути моно. У некоторых два канала с микрофона. У некоторых в левом канале микрофон (это то, что нас интересует), а в правом то, что они слышали (это нужно использовать для выравнивания звуковых дорожек, а потом выбросить). Моменты начала (и окончания) записи на файлах не синхронизированы.

Что нужно сделать

  1. Добавить файлы в многотрековый проект Adobe Audition.
  2. Совместить файлы так, чтобы разговор на разных дорожках совпадал.
@andreyvit
andreyvit / MYPROJPromise.h
Created December 25, 2017 10:45
My template for server operations with using AFNetworking or any other 3rd-party code (in Objective-C)
@import Foundation;
typedef void (^MYPROJPromiseResultBlock)(id result);
typedef void (^MYPROJPromiseErrorBlock)(NSError *error);
typedef void (^MYPROJPromiseResultAndErrorBlock)(id result, NSError *error);
typedef void (^MYPROJPromiseErrorAndResultBlock)(NSError *error, id result);
typedef void (^MYPROJPromiseResultOrErrorBlock)(id resultOrError);
typedef void (^MYPROJPromiseWorkBlock)(MYPROJPromiseResultAndErrorBlock completionHandler);

SHELESNAKE

Ресурсы на планете Шелезяка подходят к концу, и роботы были вынуждены перейти на питание упавшими частицами метеоритов. Через несколько дней ожидается большой метеоритный дождь, поэтому вам поручили написать программу для небольшой серии из трех роботов, позволяющую им в сумме собрать максимальное число метеоритных осколков.

Поверхность планеты представляет собой плоский круг, по которому раскидано 100 метеоритных осколков. Как роботы, так и осколки считаются точками. Когда робот подходит к осколку на расстояние 1.0 или ближе, он подбирает осколок, а с неба в произвольное место планеты падает новый (таким образом, количество осколков всегда ровно 100).

Действия роботов разделены на такты. У вас всего есть 5000 тактов, чтобы собрать максимальное количество осколков.

require 'rake/clean'
HAML = FileList['**/*.haml']
LESS = FileList['**/*.less']
COFFEE = FileList['**/*.coffee']
HTML = HAML.ext('html')
CSS = LESS.ext('css')
JS = COFFEE.ext('js')
#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.
//
@andreyvit
andreyvit / LoggingPolicy.md
Last active May 24, 2016 14:54
Proposal for a Michigan Logging Policy

Logging Policy

What's this, and why is it needed?

People often pick log levels randomly, making them fairly useless. I've recently seen a very useful definition of log levels, and I liked it very much. So here we go.

Log Levels

  • Notice: notable events that should be aggregated and reviewed by the system administrator or development team regularly. This is a good fit for something that's normal in moderation, but may represent a problem if it starts happening too often.
// 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 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){}}})();