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
// | |
// UICollectionView+ScrollViewAnimateable.swift | |
// persimmon | |
// | |
// Created by Keith Norman on 5/24/16. | |
// Copyright © 2016 Good Eggs. All rights reserved. | |
// | |
/// Based on https://github.com/plancalculus/MOScrollView. This allows animating contentOffset with a timing function. It's not possible to animate contentOffset via a CAAnimation. It is possible to animate bounds but then scrollview delegate methods don't get called which may be an issue if the animation exposes new cells in a table view or collection view and you expect those cells to render when the scroll into view. |
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
class ViewController { | |
var observable<[String]> | |
public var viewModel: ViewModel? { | |
didSet { | |
self.observable = Observable(viewModel?.someProperty) | |
self.observable.bind { [unowned self] (someProperty) in | |
if let dataSource = self.dataSource { | |
dataSource.someProperty = someProperty | |
} |
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
class Delegator | |
@delegate: [] | |
constructor: -> | |
for delegate in @constructor.delegate | |
target = delegate[delegate.length - 1].to | |
for attribute in delegate when not attribute.to | |
property = {} | |
if /\(\)$/.test attribute |
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/UIKit.h> | |
@interface UILabel (StyleExtensions) | |
@property (nonatomic, strong) NSString *fontTextStyle; | |
@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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
void merge(int **a, int start, int end, int sz) { | |
int *a1 = a[start]; | |
int *a2 = a[end]; | |
int res[sz]; | |
int i = 0; | |
int j = 0; |
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 math | |
import itertools | |
def length(x, y): | |
dx = x[0] - y[0] | |
dy = x[1] - y[1] | |
return math.sqrt(dx*dx + dy*dy) | |
def solve_tsp_dynamic(points): | |
#calc all lengths |
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
// a heap is good at finding min in O(log n) time | |
// it supports the following methods: | |
// - insert | |
// - getMin | |
// - deleteMin | |
// it gets initialized with an array | |
// it stores its data internally as an array, but we visualize it as a binary tree | |
// 4 | |
// / \ | |
// 5 6 |
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
diff --git a/public/js/client.js b/public/js/client.js | |
index feb581f..95bcd9b 100644 | |
--- a/public/js/client.js | |
+++ b/public/js/client.js | |
@@ -8,6 +8,7 @@ var stream; | |
var room_count = 0; | |
var pc = new webkitRTCPeerConnection(configuration); | |
var connected = false; | |
+var shouldInitConnection = false; | |
var mediaConstraints = { |
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
$target = 15.05 | |
$items = [2.25, 2.75, 3.35, 3.55, 4.20, 5.80].select{|item| item <= $target} | |
def main(arr) | |
(1..arr.length).each do |n| | |
# this finds all combinations of subarrays http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-combination | |
# given something like [1, 2, 3, 4] | |
# each iteration of this loop contains something like | |
# [[1], [2], [3], [4]] | |
# [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]] |
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
{ | |
education = ( | |
{ | |
school = { | |
id = 110086219021467; | |
name = Harvey; | |
}; | |
type = "High School"; | |
year = { | |
id = 143018465715205; |