Skip to content

Instantly share code, notes, and snippets.

func testBug260SnakeCase() {
let dataStack = Helper.dataStackWithModelName("ToOne")
let JSON = Helper.objectsFromJSON("to-one-snakecase.json") as! [String : AnyObject]
Sync.changes([JSON], inEntityNamed: "RentedHome", dataStack: dataStack, completion: nil)
XCTAssertEqual(Helper.countForEntity("RentedHome", inContext:dataStack.mainContext), 1)
XCTAssertEqual(Helper.countForEntity("LegalPerson", inContext:dataStack.mainContext), 1)
try! dataStack.drop()
}
@3lvis
3lvis / content.md
Last active August 5, 2016 12:49
Script to generate 10 000 labeled images
  • brew install imagemagick
  • brew install ghostscript
  • brew install parallel
  • Then run in Terminal
seq -w 10000 | parallel --bar 'convert -gravity center -size 3000x3000 -background black -fill white -font Helvetica -pointsize 1000 label:{=$_+=0=} image{}.jpg'

Changelog:

let remoteItems = localPrimaryKey
let localRelationship = self.valueForKey(relationship.name)
let localItems = localRelationship?.valueForKey(entity.sync_localPrimaryKey()) as? NSArray ?? NSArray()
let intersection = NSMutableSet(array: remoteItems as [AnyObject])
intersection.intersectSet(Set(arrayLiteral: localItems))
let updatedItems = intersection.allObjects
let deletedItems = localItems.mutableCopy()
deletedItems.removeObjectsInArray(remoteItems as [AnyObject])
@3lvis
3lvis / prettyprint.swift
Last active September 25, 2022 17:58
JSON Pretty Print Swift 5
print(String(data: try! JSONSerialization.data(withJSONObject: dict, options: .prettyPrinted), encoding: .utf8)!)
export ZSH=/Users/elvis/.oh-my-zsh
ZSH_THEME="robbyrussell"
plugins=(git wd xcode)
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
import Foundation
protocol Syncable {
static func sync(dictionary: [Dictionary<String, AnyObject>])
}
extension Syncable {
static func sync(dictionary: [Dictionary<String, AnyObject>]) {
}
[
{
"__v":0,
"name":"test 2",
"createdAt":"01.10.2015 19:11",
"latitude":"",
"longitude":"",
"_id":"560d9f051f2c3ec00ed756c8"
},
{
@3lvis
3lvis / ManagedObject.swift
Created September 18, 2015 14:07
ManagedObject.swift
import CoreData
@objc(Slot)
public class Slot: _Slot {
static func request() -> NSFetchRequest {
let request = NSFetchRequest(entityName: Slot.entityName())
request.sortDescriptors = [NSSortDescriptor(key: "startTime", ascending: true)]
return request
}
@3lvis
3lvis / Controller.swift
Created September 18, 2015 14:06
Controller.swift
import UIKit
import DATASource
class SlotsController: UITableViewController {
var networking: NetworkingClient
// MARK - Getters
lazy var dataSource: DATASource = {
let dataSource = DATASource(tableView: self.tableView, fetchRequest: Slot.request(), sectionName: nil, cellIdentifier: SlotCell.Identifier, mainContext: self.networking.data.mainContext, configuration: { cell, item, indexPath in
@3lvis
3lvis / Cell.swift
Created September 18, 2015 14:06
Cell.swift
import UIKit
class SlotCell: UITableViewCell {
static let Identifier = "SlotCellIdentifier"
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.contentView.backgroundColor = UIColor(hex: "28C787")
}