Skip to content

Instantly share code, notes, and snippets.

View BalestraPatrick's full-sized avatar

Patrick Balestra BalestraPatrick

View GitHub Profile
@BalestraPatrick
BalestraPatrick / persistentStorageCalculator
Created March 15, 2014 11:47
Easily calculate the bytes used in your Pebble app with the Persistent Storage API. The maximum memory you can use is 4kb.
int totalSize = 0;
// Adjust the value (in this example: 2000) to your maximum key that you know you're using in your app
for (int i = 0; i < 2000; i++) {
if (persist_exists(i)) {
int size = persist_get_size(i);
totalSize = totalSize + size;
}
}
APP_LOG(APP_LOG_LEVEL_DEBUG, "Persistent storage used = %d", totalSize);
@BalestraPatrick
BalestraPatrick / Info.plist
Last active June 14, 2022 15:57
Custom URL scheme Launch Storyboard Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
func getUsers() -> Observable<[SectionModel<String, User>]> {
return Observable.create { (observer) -> Disposable in
let users = [User(followersCount: 1005, followingCount: 495, screenName: "BalestraPatrick"),
User(followersCount: 380, followingCount: 5, screenName: "RxSwiftLang"),
User(followersCount: 36069, followingCount: 0, screenName: "SwiftLang")]
let section = [SectionModel(model: "", items: users)]
observer.onNext(section)
observer.onCompleted()
use_frameworks!
target 'RxTableView' do
pod 'RxSwift'
pod 'RxDataSources'
end
import RxSwift
import RxDataSources
import UIKit
import RxSwift
import RxDataSources
class ViewController: UIViewController, UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
import Foundation
struct User {
let followersCount: Int
let followingCount: Int
let screenName: String
}
let dataSource = RxTableViewSectionedReloadDataSource<SectionModel<String, User>>()
import UIKit
import RxSwift
class ViewModel {
}
func getUsers() -> Observable<[SectionModel<String, User>]> {
return Observable.create { (observer) -> Disposable in
let users = [User(followersCount: 1005, followingCount: 495, screenName: "BalestraPatrick"),
User(followersCount: 380, followingCount: 5, screenName: "RxSwiftLang"),
User(followersCount: 36069, followingCount: 0, screenName: "SwiftLang")]
let section = [SectionModel(model: "", items: users)]
observer.onNext(section)
observer.onCompleted()
return AnonymousDisposable{}
}