This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @flow */ | |
import request from 'request' | |
const promiseWrapper = (r: request): ((data: any) => Promise<Object>) => | |
(data: any): Promise<Object> => new Promise((resolve: any, reject: any) => { | |
r(data, (error: any, response: any, body: any) => { | |
if (error) reject(error) | |
else resolve(body) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "24b47a79-c124-40ac-8bd0-25ae5ea24767", | |
"created_date": "28.10.2016", | |
"lastmodified_date": "28.10.2016", | |
"data": { | |
"step_0": { | |
"declarationType": "1", | |
"declarationYear1": "2015" | |
}, | |
"step_1": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "edfd42c4-ba78-47da-8a8c-5924a017e807", | |
"created_date": "05.12.2016", | |
"lastmodified_date": "05.12.2016", | |
"data": { | |
"step_0": { | |
"changesYear": "2016" | |
}, | |
"step_1": { | |
"lastname": "Посвистак", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "3371ace7-177b-44d6-ba2a-53e023f740be", | |
"created_date": "30.10.2016", | |
"lastmodified_date": "30.10.2016", | |
"data": { | |
"step_0": { | |
"declarationType": "1", | |
"declarationYear1": "2015" | |
}, | |
"step_1": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let input = [ | |
"1 1 1 0 0 0", | |
"0 1 0 0 0 0", | |
"1 1 1 0 0 0", | |
"0 0 2 4 4 0", | |
"0 0 0 2 0 0", | |
"0 0 1 2 4 0" | |
] | |
let scanner = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "3371ace7-177b-44d6-ba2a-53e023f740be", | |
"created_date": "30.10.2016", | |
"lastmodified_date": "30.10.2016", | |
"data": { | |
"step_0": { | |
"declarationType": "1", | |
"declarationYear1": "2015" | |
}, | |
"step_1": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// link to declaration.json – https://public-api.nazk.gov.ua/v1/declaration/41462809-89e2-4ad9-a9c9-54bb258541df | |
// usage: node declaration_example.js | |
'use strict'; | |
var fs = require('fs'); | |
function init() { | |
let file = fs.readFileSync('declaration.json'); | |
let json = JSON.parse(file); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// somewhere in your class | |
// where you have declared instance of UIImageView as _imageView | |
func test() { | |
UIImage.getRemote(path: "path_to_image", default: "image_name") {[weak self] value in | |
DispatchQueue.main.async {[weak self] in | |
guard let s = self else { return } | |
s._imageView.image = value | |
s._imageView.sizeToFit() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NSDate { | |
class func relativeTimeInString(value: NSTimeInterval) -> String { | |
func getTimeData(value: NSTimeInterval) -> (count: Int, suffix: String) { | |
let count = Int(floor(value)) | |
let suffix = count != 1 ? "s" : "" | |
return (count: count, suffix: suffix) | |
} | |
let value = -value | |
switch value { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension NSUserDefaults { | |
func removeAllKeys(except except: [String]? = nil) { | |
guard let appDomain = NSBundle.mainBundle().bundleIdentifier else { return } | |
let defaults = NSUserDefaults.standardUserDefaults() | |
var dict: [String: AnyObject]? | |
if let except = except { |