Skip to content

Instantly share code, notes, and snippets.

View joshdholtz's full-sized avatar
👨‍👩‍👦
Family first then OSS

Josh Holtz joshdholtz

👨‍👩‍👦
Family first then OSS
View GitHub Profile
@joshdholtz
joshdholtz / HistoricalObservableExtension.swift
Last active October 5, 2016 22:34
RxSwift - Create historical observable to see how the data changed
extension Observable {
func asHistoricalObservable() -> Observable<(previous: Element, next: Element)> {
return makeHistoricalObservable(observable: self)
}
}
extension Variable {
func asHistoricalObservable() -> Observable<(previous: Element, next: Element)> {
return makeHistoricalObservable(observable: self.asObservable())
}
@joshdholtz
joshdholtz / StopJumpingTableViewOnInsertRows.swift
Last active August 22, 2022 07:08
Used when loading more data into UITableView for a smooth "infinite scroll" feel
// I dont want my table jumping/animation when appending new rows
// for an infinite scroll feel
//
// Some of this might not be needed but it works
//
// TODO: Possibly garbage
extension UITableView {
func reloadDataSmoothly() {
UIView.setAnimationsEnabled(false)
// Differences from defaults
// 1. Tab instead of backspace on left hand
// 2. Control was taken off of Z
// 3. LGui (CMD/Windows) on bottom left left hand
// 4. AlfShf replaced with Alt on left hand (for hots)
#include "ergodox_ez.h"
#include "debug.h"
#include "action_layer.h"
@joshdholtz
joshdholtz / ViewController.swift
Last active March 22, 2016 14:26
Should add to dispose bag
class ViewController : UIViewController {
let viewModel = ViewModel()
private let disposeBag = DisposeBag()
override func viewDidLoad(){
super.viewDidLoad()
self.viewModel.navigationVariable.asObservable()
.subscribeNext { data in
@joshdholtz
joshdholtz / StringExtensions.swift
Last active January 14, 2016 15:27
Swift - Add isEmpty to Optional<String>
extension Optional where Wrapped: StringLiteralConvertible {
var isEmpty: Bool {
return true
}
}
@joshdholtz
joshdholtz / File.swift
Created December 15, 2015 02:54
Import JSON object/array into RestKit
// Imports comment JSON into RestKit
let json: RestKitJSON = ["some_key": "some_value"] // [NSObject: AnyObject]
importObject(json, finished: { (model: YourModel?) -> () in
print("YourModel - \(model)")
})
@joshdholtz
joshdholtz / .env
Created October 27, 2015 15:33
Rakefile Template
SLACK_TOKEN=blahblahblah
@joshdholtz
joshdholtz / circle.yml
Created September 16, 2015 20:40
circle.yml for Xcode 7 / iOS 9
machine:
xcode:
version: "7.0"
dependencies:
pre:
- brew uninstall xctool && brew install --HEAD xctool
@joshdholtz
joshdholtz / HarmonicStuff.swift
Created June 15, 2015 00:26
OMG, protocol extensions for Harmonic
var json : Dictionary<String, AnyObject> = ["first_name" : "Josh", "last_name" : "Holtz",
"best_friend" : ["first_name" : "Bandit", "last_name" : "The Cat"],
"friends" : [ ["first_name" : "Red Ranger"], ["first_name" : "Green Ranger"] ],
"birthday" : "1989-03-01"
]
var jsons = [json]
/*
* OLD WAY (before protocol extensions)
*/
@joshdholtz
joshdholtz / app.js
Last active August 29, 2015 14:22
Caching locally created files with imgcache.js
app.config(['$compileProvider',
function ($compileProvider) {
$compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|local|data):/);
}]);