Skip to content

Instantly share code, notes, and snippets.

View pronebird's full-sized avatar

Andrej Mihajlov pronebird

View GitHub Profile
//
// main.m
//
#import <UIKit/UIKit.h>
#import <pop/POP.h>
#import "AppDelegate.h"
static CGFloat deceleration_for_distance(CGFloat distance, CGFloat velocity)
{
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="https://raw.githubusercontent.com/konvajs/konva/master/konva.min.js"></script>
</head>
<body>
<label><input type="checkbox" value="yes" id="disableHitFromCache" /> Disable drawHitFromCache</label>
<div id="konva" style="width: 300px; height: 300px;"></div>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="https://raw.githubusercontent.com/konvajs/konva/master/konva.min.js"></script>
</head>
<body>
<div id="konva"></div>
<script id="jsbin-javascript">
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
UIImage *receipt = [UIImage imageWithContentsOfFile:url.path];
// BUG: http://www.openradar.me/20447945
// Skip one run loop to hook up transition coordinator and run action when picker dismissed
dispatch_async(dispatch_get_main_queue(), ^{
// iOS < 8.3
if(controller.transitionCoordinator) {
[controller.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
//: Playground - noun: a place where people can play
import Foundation
//: We have to define init() method for ObjectType() to work
protocol Creatable {
init()
}
@pronebird
pronebird / DynamicTypePlayground.swift
Last active November 12, 2015 13:39
preferredFontForTextStyle for each content size
//: Playground - noun: a place where people can play
/*
This playground prints CSV with all font sizes for each content size category and text style.
*/
import UIKit
import XCPlayground
/*
@pronebird
pronebird / MagicalRecord+Seam.m
Created December 23, 2015 13:41
MagicalRecord + Seam bridge
//
// MagicalRecord + Seam bridge
//
#import "MagicalRecord+SeamStore.h"
@import Seam;
@implementation NSPersistentStoreCoordinator (SeamStore)
@pronebird
pronebird / AppDelegate.swift
Created April 8, 2016 08:49
Reproducing issue in Earthquakes app when one of operations does not transition from .Ready to .Executing state.
import UIKit
let sharedQueue = OperationQueue()
class TestOperation : Operation
{
override func execute() {
dispatch_async(dispatch_get_main_queue()) {
// print("Finished.")
@pronebird
pronebird / BasePresentationController.h
Created April 27, 2016 15:12
Keep presenting controller in charge of status bar appearance during modal presentation. Useful on modal presentations that only partially cover the window.
//
// BasePresentationController.h
//
// Created by pronebird on 4/27/16.
// Copyright © 2016 Andrey Mikhaylov. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface BasePresentationController : UIPresentationController
@pronebird
pronebird / BaseTableView.m
Created April 30, 2016 19:34
Capture target content offset when using scrollToRowAtIndexPath
//
// BaseTableView.m
//
// Created by pronebird on 1/12/16.
// Copyright © 2016 pronebird. All rights reserved.
//
@interface BaseTableView ()
@property (nonatomic) BOOL isCallingFromScrollToRowAtIndexPath;