Skip to content

Instantly share code, notes, and snippets.

View verebes1's full-sized avatar

David verebes1

View GitHub Profile
import network
import socket
import time
import struct
from machine import Pin
NTP_DELTA = 2208988800
host = "pool.ntp.org"
@verebes1
verebes1 / UIApplication+AppVersion.swift
Created October 30, 2019 13:15 — forked from ashleymills/UIApplication+AppVersion.swift
UIApplication extension to get app version / build
extension UIApplication {
class func appVersion() -> String {
return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
}
class func appBuild() -> String {
return Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
}
@verebes1
verebes1 / Data+PrettyPrint.swift
Created March 20, 2019 17:01 — forked from cprovatas/Data+PrettyPrint.swift
Pretty print JSON string from Data in Swift 4.1 (especially useful printing to Xcode console)
import Foundation
extension Data {
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription
guard let object = try? JSONSerialization.jsonObject(with: self, options: []),
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]),
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil }
return prettyPrintedString
}
@verebes1
verebes1 / Network.swift
Created March 15, 2019 15:00 — forked from ankitthakur/Network.swift
Swift Network Request
public class Network:NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLSessionDataDelegate {
internal static let sharedInstance = Network()
fileprivate var networkParams:Array<NetworkParams> = Array()
fileprivate func networkCall(_ request:URLRequest, completionBlock:@escaping NetworkCompletionBlock)
{
let configurationId = String(format: "Network%d", arc4random())
let configuration = URLSessionConfiguration.background(withIdentifier: configurationId)
configuration.timeoutIntervalForRequest = request.timeoutInterval
@verebes1
verebes1 / ThemeManager.swift
Created July 11, 2018 17:28 — forked from durul/ThemeManager.swift
ThemeManager.swift
//
// ThemeManager.swift
import UIKit
import Foundation
/// Enum Theme Manager
/// - Note: https://github.com/durul/DRL-Theme-Manager
enum Theme: Int {
@verebes1
verebes1 / ThemeManager.swift
Created July 10, 2018 20:26 — forked from abhimuralidharan/ThemeManager.swift
A guide on how to create a theme manager class in swift so that the code is flexible and the developer can change the theme colour anytime with ease.
//
// ThemeManager.swift
// ProjectThemeTest
//
// Copyright (c) 2017 Abhilash
//
import UIKit
import Foundation