This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isShuffle2(x,y,z): | |
m = len(x) | |
n = len(y) | |
r = len(z) | |
S = {} | |
#inicializace pole | |
for i in range(-1,r+1): | |
for j in range(-1,r+1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'truty' | |
module Jekyll | |
module TrutyFilter | |
def truty(input) | |
Truty.fix(input, :czech) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_surprising(seq, d): | |
subseq = set() | |
collisions = 0 | |
for i in range(0, len(seq)-d-1): | |
word = (seq[i], seq[i+d+1]) | |
if word in subseq: | |
collisions += 1 | |
else: | |
subseq.add(word) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewWillAppear:(BOOL)animated | |
{ | |
[super viewWillAppear:animated]; | |
[[self transitionCoordinator] animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) { | |
[self.navigationController.navigationBar setTintColor:[UIColor blackColor]]; | |
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor]}]; | |
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg_navbar"] forBarMetrics:UIBarMetricsDefault]; | |
} completion:nil]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol Service { | |
init() | |
} | |
class ServiceHolder { | |
private var servicesDictionary: [String: Service] = [:] | |
init(services: [Service.Type]? = nil) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
protocol Coordinator { | |
/// Triggers navigation to the corresponding controller | |
func start() | |
/// Stops corresponding controller and returns back to previous one | |
func stop() | |
/// Called when segue navigation form corresponding controller to different controller is about to start and should handle this navigation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func debounce<A>(delay:Int, queue:DispatchQueue, action: @escaping ((A)->())) -> (A)->() { | |
var lastFireTime = DispatchTime.now() | |
let dispatchDelay = DispatchTimeInterval.milliseconds(delay) | |
return { state in | |
lastFireTime = DispatchTime.now() | |
let dispatchTime: DispatchTime = DispatchTime.now() + dispatchDelay | |
queue.asyncAfter(deadline: dispatchTime, execute: { | |
let when: DispatchTime = lastFireTime + dispatchDelay | |
let now = DispatchTime.now() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func throttle<A>(delay:Int, queue:DispatchQueue, action: @escaping ((A)->())) -> (A)->() { | |
var lastFireTime = DispatchTime.now() | |
let dispatchDelay = DispatchTimeInterval.milliseconds(delay) | |
return { state in | |
let dispatchTime: DispatchTime = DispatchTime.now() + dispatchDelay | |
queue.asyncAfter(deadline: dispatchTime, execute: { | |
let when: DispatchTime = lastFireTime + dispatchDelay | |
let now = DispatchTime.now() | |
if now.rawValue >= when.rawValue { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIViewController { | |
public func dch_checkDeallocation(afterDelay delay: TimeInterval = 2.0) { | |
let rootParentViewController = dch_rootParentViewController | |
// We don’t check `isBeingDismissed` simply on this view controller because it’s common | |
// to wrap a view controller in another view controller (e.g. in UINavigationController) | |
// and present the wrapping view controller instead. | |
if isMovingFromParentViewController || rootParentViewController.isBeingDismissed { | |
let type = type(of: self) | |
let disappearanceSource: String = isMovingFromParentViewController ? "removed from its parent" : "dismissed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# based on http://www.gamedev.net/topic/534655-aabb-triangleplane-intersection--distance-to-plane-is-incorrect-i-have-solved-it/ | |
def intersects_box(triangle, box_center, box_extents): | |
X, Y, Z = 0, 1, 2 | |
# Translate triangle as conceptually moving AABB to origin | |
v0 = triangle[0] - box_center | |
v1 = triangle[1] - box_center |
OlderNewer