Skip to content

Instantly share code, notes, and snippets.

View otymartin's full-sized avatar
💭
Don't Think Poor 🧠💭

MBO otymartin

💭
Don't Think Poor 🧠💭
View GitHub Profile
@otymartin
otymartin / asyncAwaitTransaction.swift
Last active October 22, 2021 16:51
Firestore Swift Transaction using Async Await
/// CLOSURE EXAMPLE
func transactionExample(completion: (Result<Any, Error>) -> Void) {
let sfReference = db.collection("cities").document("SF")
db.runTransaction({ (transaction, errorPointer) -> Any? in
let sfDocument: DocumentSnapshot
do {
try sfDocument = transaction.getDocument(sfReference)
} catch let fetchError as NSError {
@otymartin
otymartin / heyJude.swift
Last active October 19, 2019 03:43
Hey Jude by @VojtaStavik
var heyJude = ""
for verse in 0..<4 {
heyJude += "Hey Jude, don't "
switch verse {
case 0, 3:
heyJude += "make it bad\nTake a sad song and make it better"
case 1:
heyJude += "be afraid\nYou were made to go out and get her"
case 2:
@otymartin
otymartin / removeAudio.swift
Created March 28, 2019 15:45
Remove Audio
func removeAudio(_ completion: @escaping RemoveAudioResponse) {
let fileManager = FileManager.default
let composition = AVMutableComposition()
let sourceAsset = AVURLAsset(url: self)
let compositionVideoTrack = composition.addMutableTrack(withMediaType: AVMediaType.video, preferredTrackID: kCMPersistentTrackID_Invalid)
@otymartin
otymartin / tokenValidationError.swift
Created May 15, 2018 00:33
Error Validating Token
20:28:40.290 💙 INFO MessagingManager.fetchAccessToken():163 - New Token👑
20:28:56.646 ❤️ ERROR MessagingManager.initializeClient():101 - Error Domain=signal.sdk.domain.error Code=102 "Error validating token." UserInfo={kTCHErrorMsgKey=Error validating token., NSLocalizedDescription=Error validating token.}
0x16ef9b000 | 05/14/20:28:56.702 | DEBUG | 6 | TNHttpTransportClient | ~TNHttpTransportClient - begin
0x16ef9b000 | 05/14/20:28:56.702 | DEBUG | 6 | TNHttpTransportClient | ~TNHttpTransportClient - end
20:28:56.734 💙 INFO MessagingManager.fetchAccessToken():163 - New Token👑
20:29:11.837 ❤️ ERROR MessagingManager.initializeClient():101 - Error Domain=signal.sdk.domain.error Code=102 "Error validating token." UserInfo={kTCHErrorMsgKey=Error validating token., NSLocalizedDescription=Error validating token.}
0x16f13f000 | 05/14/20:29:11.873 | DEBUG | 18 | TNHttpTransportClient | ~TNHttpTransportClient - begin
0x16f13f000 | 05/14/20:29:11.874 | DEBUG | 18
@otymartin
otymartin / timer.swift
Created March 12, 2018 04:19
Playground Timer
//: A UIKit based Playground for presenting user interface
import UIKit
import AVFoundation
import PlaygroundSupport
let arcPoint = CGPoint(x: 170, y: 200)
func BezierPath(center: CGPoint) -> CGPath {
@otymartin
otymartin / Diamond.swift
Created October 25, 2017 18:02
Diamond
import UIKit
class Diamond: NSObject {
//MARK: - Canvas Drawings
/// Page 1
class func drawDiamond(frame targetFrame: CGRect = CGRect(x: 0, y: 0, width: 50, height: 50), resizing: ResizingBehavior = .aspectFit) {
// Created by Caleb Davenport on 7/14/17.
import UIKit
final class ActionSheetPresentationController: UIPresentationController {
// MARK: - Properties
private var dimmingView: UIView!
var http = require('http');
var url = require('url');
function webhook(urlStr, data, cb) {
var postData = JSON.stringify(data);
var options = url.parse(urlStr);
options.method = 'POST';
options.headers = {'Content-Type': 'application/json', 'Content-Length': postData.length};