Skip to content

Instantly share code, notes, and snippets.

View ivan-magda's full-sized avatar
🌏
Working on the way

Ivan Magda ivan-magda

🌏
Working on the way
View GitHub Profile
@ivan-magda
ivan-magda / Networking.playground
Last active July 10, 2016 02:26
Explore an alternative approach to building the networking layer of an app from "Swift Talk #1 episode". In this playground we are searching for photos by a specific tags with Flickr API.
//: Explore an alternative approach to building the networking layer of an app from [Swift Talk #1 episode](https://talk.objc.io/episodes/S01E01-networking).
//: They make use of Swift's generics and structs to end up with simple, testable code.
//:
//: In this playground we are searching for photos by a specific tags with [Flickr API](https://www.flickr.com/services/api/flickr.photos.search.html).
import UIKit
import XCPlayground
//: `Resource` struct, which is generic over the result type. This struct has two properties: the URL of the endpoint, and a parse function. The parse function tries to convert some data into the result:
@ivan-magda
ivan-magda / introrx.md
Created June 5, 2017 10:52 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@ivan-magda
ivan-magda / countries.json
Last active June 26, 2017 04:07
A list of countries in JSON format
{
"AF":"Afghanistan",
"AL":"Albania",
"DZ":"Algeria",
"AS":"American Samoa",
"AD":"Andorra",
"AO":"Angola",
"AI":"Anguilla",
"AQ":"Antarctica",
"AG":"Antigua and Barbuda",
@ivan-magda
ivan-magda / min-char-rnn.py
Created June 9, 2018 08:18 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@ivan-magda
ivan-magda / CoreDataContextObserver.swift
Last active August 6, 2018 06:29
CoreData NSManagedObjectContext observer
import Foundation
import CoreData
public class CoreDataContextObserver {
public typealias ActionCompletionBlock = (NSManagedObject, State) -> Void
public typealias ContextChangeBlock = (Foundation.Notification, [ObjectChange]) -> Void
public struct State: OptionSet {
public let rawValue: Int
@ivan-magda
ivan-magda / MulticastDelegate.swift
Created August 6, 2018 06:29
Multicast delegate in Swift
import Foundation
private final class WeakBox<T: AnyObject> {
weak var value: T?
init(_ value: T) {
self.value = value
}
}
import UIKit
class RootNavigationManager {
private(set) weak var window: UIWindow?
func start(_ window: UIWindow) {
self.window = window
window.rootViewController = navigationController
window.makeKeyAndVisible()
}
@ivan-magda
ivan-magda / ReadWriteLock.swift
Created October 25, 2018 12:20
Swift read write lock
//
// Created by Ivan Magda on 25/10/2018.
// Copyright © 2018 Ivan Magda. All rights reserved.
//
import Foundation
final class ReadWriteLock {
private var rwlock: pthread_rwlock_t = {
var rwlock = pthread_rwlock_t()
@ivan-magda
ivan-magda / um_feed_1.json
Last active March 8, 2019 09:52
UM-Demo: Game-1 feed
[
{
"id":1,
"type": "score",
"time": 0,
"episode": 1,
"episode_time": 0,
"score" : [0,0]
},
{
@ivan-magda
ivan-magda / um_games.json
Last active May 10, 2019 20:19
UM-Demo: Games list
[
{
"id":2,
"poll_id":2,
"type": "poll_started",
"time": 1,
"episode": 1,
"episode_time": 0,
"subject" : {
"title": "Sportscaster",