Skip to content

Instantly share code, notes, and snippets.

View greggjaskiewicz's full-sized avatar
:shipit:
🦸🏼‍♂️

greg jaskiewicz greggjaskiewicz

:shipit:
🦸🏼‍♂️
View GitHub Profile
@greggjaskiewicz
greggjaskiewicz / nodeMCU_DH11.cpp
Created September 5, 2020 21:03
nodeMCU DH11 and display
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <DHT.h>
#include <DHT_U.h>
int D0 = 16;
int D1 = 5;
int D2 = 4;
int D3 = 0;
@greggjaskiewicz
greggjaskiewicz / snippet.m
Created February 13, 2020 13:22
reachability changed notification network status convenience unwrapped
+ (GCNetworkReachabilityStatus)statusFromNotification:(NSNotification *)notification {
NSNumber *statusNumber = notification.userInfo[kGCNetworkReachabilityStatusKey];
if (statusNumber == nil) {
return GCNetworkReachabilityStatusNotReachable;
}
GCNetworkReachabilityStatus status = [statusNumber intValue];
return status;
//
// ReachabilityUpdater.h
//
//
// Created by Gregg Jaskiewicz on 10/04/2018.
// Copyright © 2018 . All rights reserved.
//
#import <Foundation/Foundation.h>
@greggjaskiewicz
greggjaskiewicz / ReachabilityUpdater.h
Created February 13, 2020 13:17
ReachabilityUpdater
//
// ReachabilityUpdater.h
//
//
// Created by Gregg Jaskiewicz on 10/04/2018.
// Copyright © 2018 . All rights reserved.
//
#import <Foundation/Foundation.h>
@greggjaskiewicz
greggjaskiewicz / NavigationControllerFeedback.swift
Created February 21, 2019 10:28
UINavigationController doesn't send any feedback to view controllers, when they are about to appear on screen - if they are already in the stack. This solves this little problem.
//
// NavigationControllerFeedback.swift
// AmpetronicApp
//
// Created by Gregg Jaskiewicz on 21/02/2019.
// Copyright © 2019 Gregg Jaskiewicz. All rights reserved.
//
import Foundation
@greggjaskiewicz
greggjaskiewicz / TimeIntervalConsts.swift
Created January 22, 2019 20:39
TimeInterval extension with literal intervals commonly needed
extension TimeInterval {
static var second: TimeInterval { return 1 }
static var minute: TimeInterval { return 60 }
static var hour: TimeInterval { return 60 * self.minute }
static var day: TimeInterval { return 24 * self.hour }
static var week: TimeInterval { return 7 * self.day }
}
@greggjaskiewicz
greggjaskiewicz / AppVersion.swift
Last active December 8, 2018 17:40
AppVersion object in Swift
//
// AppVersion.swift
//
// Created by Gregg Jaskiewicz on 08/12/2018.
// Copyright © 2018 Gregg Jaskiewicz Clear Prop Ltd. All rights reserved.
//
import Foundation
public struct AppVersion: Comparable {
@greggjaskiewicz
greggjaskiewicz / intToHexColour.swift
Created July 12, 2017 14:00
how to convert int to hexadecmal colour value in swift 3
let hexColour = String(colour, radix: 16, uppercase: true)
let hexColourString = "000000\(hexColour)"
let range = hexColourString.index(hexColourString.endIndex, offsetBy: -6)..<hexColourString.endIndex
let hexHashColourString = hexColourString[range]
let textAttributeValue = "{font color='#\(hexHashColourString)'}{*font}"
@greggjaskiewicz
greggjaskiewicz / xmlDocument.swift
Created July 11, 2017 08:16
creating simple xml document using NSXML in swift 4
import Cocoa
let node1 = XMLElement(name: "first", stringValue: "Donnie")
let node2 = XMLElement(name: "last", stringValue: "Duck")
let nameNode = XMLElement(name: "name")
nameNode.addChild(node1)
nameNode.addChild(node2)
import Foundation
struct TypeOneStruct {
    let foo1: Int
    let foo2: Int
    let bar1: Bool
}
struct TypeTwoStruct {
    let fooString: String