Skip to content

Instantly share code, notes, and snippets.

import PlaygroundSupport
import Foundation
import Combine
// MARK: - Network Controller
protocol NetworkControllerProtocol: class {
typealias Headers = [String: Any]
func get<T>(type: T.Type,
url: URL,
@cupnoodle
cupnoodle / IAPHelper.swift
Created July 21, 2020 09:51
In app purchase helper class
// Created by Soulchild on 21/07/2020.
// Copyright © 2020 fluffy. All rights reserved.
//
import Foundation
import StoreKit
// Need to install the TPInAppReceipt library first
import TPInAppReceipt
@abhi21git
abhi21git / ExtensionURLRequest.swift
Last active February 19, 2024 12:23
Swift cURL Printer
//
// ExtensionURLRequest.swift
//
// Created by Abhishek Maurya on 16/07/20.
// Copyright © 2020. All rights reserved.
//
import Foundation
extension URLRequest {
@fmo91
fmo91 / FunctionalNetworkingLayer.swift
Last active July 19, 2020 00:24
Toy Networking Layer with functional operators
import Foundation
import PlaygroundSupport
enum NetworkError: Error {
case generic
}
precedencegroup PipeAssociativity {
associativity: left
}
@cprovatas
cprovatas / Data+PrettyPrint.swift
Created May 23, 2018 15:52
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
}
@Pulimet
Pulimet / AdbCommands
Last active October 7, 2024 00:58
Adb useful commands list
Hi All!
I've recently launched a tool that wraps many of the commands here with a user interface. This desktop application is currently available for macOS. There's a roadmap outlining planned features for the near future.
Feel free to request any features you'd like to see, and I'll prioritize them accordingly.
One of the most important aspects of this application is that every command executed behind the scenes is displayed in a special log section. This allows you to see exactly what’s happening and learn from it.
Here's the link to the repository: https://github.com/Pulimet/ADBugger
App Description:
ADBugger is a desktop tool designed for debugging and QA of Android devices and emulators. It simplifies testing, debugging, and performance analysis by offering device management, automated testing, log analysis, and remote control capabilities. This ensures smooth app performance across various setups.
@TheCodedSelf
TheCodedSelf / RxSwiftBindToButton.swift
Created May 13, 2017 17:16
RxSwift: Bind to button taps
import UIKit
import RxSwift
import RxCocoa
let button = UIButton()
button.rx.tap.bind {
print("button tapped")
}
@fmo91
fmo91 / ReusableViewEnum.swift
Last active August 16, 2017 20:39
Protocol extension to help using UITableView protocols in a better way.
protocol ReusableViewEnum {}
extension ReusableViewEnum where Self: RawRepresentable, Self.RawValue == Int {
static var all: [Self] {
var index = 0
var allItems = [Self]()
while let item = Self(rawValue: index) {
allItems.append(item)
index += 1
}
@shaps80
shaps80 / cURL+Request.swift
Last active August 15, 2024 09:46
Generates a cURL command representation of a URLRequest in Swift.
import Foundation
extension URLRequest {
/**
Returns a cURL command representation of this URL request.
*/
public var curlString: String {
guard let url = url else { return "" }
var baseCommand = #"curl "\#(url.absoluteString)""#
@fmo91
fmo91 / LoadingButton.swift
Created October 4, 2016 17:08
Simple UIButton subclass that can show a customizable loading message
//
// LoadingButton.swift
// LoadingButton
//
// Created by Fernando Ortiz on 4/10/16.
// Copyright © 2016 Fernando Martín Ortiz. All rights reserved.
//
import UIKit