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
array = [1,2,3] | |
for x in range(len(array)-1): | |
indexToSwap = x | |
for y in range(x+1, len(array)): | |
if array[indexToSwap] > array[y]: | |
indexToSwap = y | |
array[x], array[indexToSwap] = array[indexToSwap], array[x] | |
print array |
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)test { | |
NSArray *test = @[@"ASDASD", @"BAQWEQWE", @"ASDQWEQEW", @"RTYTYERTRWEEWR", @"NBVBCVVA"]; | |
for (unichar i = 'a'; i <= 'z' ; i++) { | |
NSPredicate *filterPredicate = [NSPredicate predicateWithBlock:^BOOL(NSString *evaluatedObject, NSDictionary *bindings) { | |
return tolower([evaluatedObject characterAtIndex:0]) == i; | |
}]; | |
NSArray *filteredArray = [test filteredArrayUsingPredicate:filterPredicate]; | |
} | |
} |
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 quicksort(array): | |
if len(array) <= 1: | |
return array | |
less = [] | |
more = [] | |
equal = [] | |
pivot = array[len(array)/2] | |
for x in array: | |
if x < pivot: | |
less.append(x) |
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 fibonacci(n): | |
if n <= 2: | |
return 1 | |
elif n <= 0: | |
return 0 | |
if n % 2 == 0: | |
x = n/2 | |
return fibonacci(x) * (fibonacci(x + 1) + fibonacci(x - 1)) | |
else: |
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
// | |
// MBTableViewController.m | |
// MBTableViewController | |
// | |
// Created by Mert Buran on 20/06/2015. | |
// Copyright (c) 2015 Mert Buran. All rights reserved. | |
// | |
#import "MBTableViewController.h" | |
#import "CustomTableViewController.h" //just in case, you should use your own custom UITableViewController subclass |
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
#!/usr/bin/env/python | |
test_data = [3, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100] | |
test_goal = 5 | |
def find_subsequence(data, goal): | |
temp = list(data) | |
depth = 1 | |
while len(temp) > 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 "ViewController.h" | |
#import <AVFoundation/AVFoundation.h> | |
#import "AFNetworking.h" | |
static NSString * const DummyModelUUID = @"a1303fcf-e6e2-4741-a028-82db4d566068"; | |
@interface ViewController () <AGTViewControllerProtocol> | |
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator; | |
@property (weak, nonatomic) IBOutlet AGTView *ARView; |
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
# remove prefix | |
for file in *; do mv "$file" "$(echo "$file"|cut -c3-)"; done | |
# add prefix | |
for file in *; do mv "$file" {{{new_pre}}}"$file"; done |
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)ag_addSubview:(UIView *)subview withInsets:(UIEdgeInsets)insets { | |
[self addSubview:subview]; | |
[subview setTranslatesAutoresizingMaskIntoConstraints:NO]; | |
[self addConstraintFromSubview:subview forAttribute:NSLayoutAttributeTop withConstant:insets.top]; | |
[self addConstraintFromSubview:subview forAttribute:NSLayoutAttributeBottom withConstant:insets.bottom]; | |
[self addConstraintFromSubview:subview forAttribute:NSLayoutAttributeLeft withConstant:insets.left]; | |
[self addConstraintFromSubview:subview forAttribute:NSLayoutAttributeRight withConstant:insets.right]; | |
} | |
- (BOOL)addConstraintFromSubview:(UIView *)subview forAttribute:(NSLayoutAttribute)attribute withConstant:(CGFloat)constantValue { |
OlderNewer