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
// This is an example of taking an Objective-C model and making a string property into an RxSwift style Observable. | |
// Note that it is "String", even though it may be "NSString" in the original model class. | |
objectiveCModelInstance.rx.observe(String.self, "stringPropertyName", options: .new) | |
.subscribe(onNext: { value in | |
NSLog(value!) | |
}) | |
.addDisposableTo(disposeBag) |
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
UIStoryboard *storyboard = | |
[UIStoryboard storyboardWithName:@"StoryboardName" bundle:nil]; | |
NSAssert(storyboard != nil, @"Missing expected storyboard."); | |
UIViewController *controller = [storyboard instantiateInitialViewController]; |
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
//: Playground - noun: a place where people can play | |
var dict = [ "user" : ["attribute" : "attribute_value"] ] | |
if let d = dict as? [String : AnyObject], | |
let user_d = d["user"] as? [String : String] { | |
print(user_d) | |
} else { | |
print("Didn't work.") | |
} |
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
protocol X { | |
func myfunc() -> Int | |
} | |
protocol Y { | |
} | |
protocol Z { | |
} |
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)application:(UIApplication *)application | |
didReceiveLocalNotification:(UILocalNotification *)notification { | |
UIViewController *top = [[application keyWindow] rootViewController]; | |
while (top.presentedViewController != nil) { | |
top = top.presentedViewController; | |
} | |
UIAlertController *alert = |
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
var optional: String? = "Hello World" | |
if let o = optional { // Same as: optional as String! | |
print(o) | |
} | |
// Output: Hello World. | |
if let o = optional as String! { | |
print(o) | |
} | |
// Output: Hello World. |
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
static func uniqueIdentifier() -> String { | |
let quasiUniqueString = ProcessInfo.processInfo.globallyUniqueString | |
let index = quasiUniqueString.index(quasiUniqueString.startIndex, offsetBy: 10) | |
return quasiUniqueString.substring(to: index) | |
} |
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 matplotlib.pyplot as plt | |
fig, ax = plt.subplots() | |
ax.plot(range(NUM_EPOCH), train_loss1, label="MLP") | |
ax.plot(range(NUM_EPOCH), train_loss2, label="CNN") | |
ax.legend() | |
ax.set(xlabel='Epochs', ylabel='Loss', | |
title="Training Loss (MLP vs CNN)") | |
ax.grid() |
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
source activate environment_name | |
python script.py | |
# Example: | |
# | |
# Kasim:pytorch-cifar Kasim$ python --version | |
# Python 2.7.14 | |
# Kasim:pytorch-cifar Kasim$ source activate base | |
# (base) Kasim:pytorch-cifar Kasim$ python --version | |
# P ython 3.6.5 :: Anaconda, Inc. |
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
# note, this is for mac | |
# more: https://blog.jasonmeridth.com/posts/use-git-grep-to-replace-strings-in-files-in-your-git-repository/ | |
git grep -l 'original_text' | xargs sed -i '' -e 's/original_text/new_text/g' |
OlderNewer