Skip to content

Instantly share code, notes, and snippets.

View shmidt's full-sized avatar

Dima Shmidt shmidt

View GitHub Profile
@avdyushin
avdyushin / storage.swift
Last active August 28, 2023 14:35
CoreData stack for iOS 9 and iOS 10 using Swift 3
//
// Storage.swift
//
// Created by Grigory Avdyushin on 30.06.16.
// Copyright © 2016 Grigory Avdyushin. All rights reserved.
//
import UIKit
import CoreData
@martinhoeller
martinhoeller / NSStackView+Animations.swift
Last active August 7, 2024 12:29
An NSStackView extension for animated hiding/showing of views
//
// NSStackView+Animations.swift
//
// Created by Martin Höller on 18.06.16.
// Copyright © 2016 blue banana software. All rights reserved.
//
// Based on http://prod.lists.apple.com/archives/cocoa-dev/2015/Jan/msg00314.html
import Cocoa
@gonzalezreal
gonzalezreal / SearchResultsViewController.swift
Created June 12, 2016 19:27
RxSwift slides – Code for the search sample
class SearchResultsViewController: UITableViewController {
// MARK: - Properties
private let viewModel: SearchResultsViewModelType
private let disposeBag = DisposeBag()
// MARK: - Initialization
init(viewModel: SearchResultsViewModelType = SearchResultsViewModel()) {
@jpmhouston
jpmhouston / NSManagedObject+JPHClone.h
Last active May 19, 2017 18:46
NSManagedObject+JPHClone
//
// NSManagedObject+Clone.h
// TResActivityLog
//
// Created by Pierre Houston on 2016-05-30.
// Copyright © 2016 Resilience software. All rights reserved.
//
// When no context provided, uses [NSManagedObjectContext MR_defaultContext].
// Note, I was going to add unique prefix "jph_" to these category method names,
// but currently I've left those out.
@joshuadutton
joshuadutton / NSFetchRequest+Extensions.swift
Created April 15, 2016 15:23
Functional Core Data in Swift
import Foundation
import CoreData
extension NSFetchRequest {
func withPredicate(format: String, arguments: [AnyObject]? = nil) -> NSFetchRequest {
return withPredicate(NSPredicate(format: format, argumentArray: arguments))
}
func andPredicate(format: String, arguments: [AnyObject]? = nil) -> NSFetchRequest {
@williballenthin
williballenthin / strings.py
Last active July 14, 2022 21:10
Extract ASCII and Unicode strings using Python.
import re
from collections import namedtuple
ASCII_BYTE = " !\"#\$%&\'\(\)\*\+,-\./0123456789:;<=>\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\]\^_`abcdefghijklmnopqrstuvwxyz\{\|\}\\\~\t"
String = namedtuple("String", ["s", "offset"])
@kumabook
kumabook / Observable.swift
Last active March 12, 2022 06:47
Observer pattern with swift protocol extension
import Foundation
public protocol Observer: Equatable {
associatedtype EventType
func listen(_ event: EventType)
}
public protocol Observable {
associatedtype ObserverType: Observer
associatedtype EventType
@preble
preble / NSTextStorageSubclass.swift
Created February 9, 2016 04:45
Base subclass of NSTextStorage in Swift
import Cocoa
@objc
class SomeTextStorage: NSTextStorage {
private var storage: NSMutableAttributedString
override init() {
storage = NSMutableAttributedString(string: "", attributes: nil)
super.init()
@agrippa1994
agrippa1994 / playground.swift
Created January 4, 2016 22:05
Bonjour Discovery OS X iOS
import Foundation
import XCPlayground
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
extension NSData {
func castToCPointer<T>() -> T {
let mem = UnsafeMutablePointer<T>.alloc(sizeof(T.Type))
self.getBytes(mem, length: sizeof(T.Type))
return mem.move()
@alyssaq
alyssaq / 1. Install python3.7 & pip3.md
Last active April 11, 2023 02:13
Python3.7 setup on Mac 10.14 (Mojave)
  1. Install Python 3.7.x from https://www.python.org/downloads/ or via homebrew.
$ brew install python3   # Installed at /usr/local/Cellar/python3

Check that python3 has been installed by running it at the terminal:

$ python3
>>> Python 3.7.2
  1. Download get-pip.py from https://bootstrap.pypa.io/get-pip.py and install (this should already be installed if python was installed from python.org or homebrew):