Skip to content

Instantly share code, notes, and snippets.

View durul's full-sized avatar

durul dalkanat durul

View GitHub Profile
@katychuang
katychuang / remove_brew-mongo_osx.sh
Last active August 3, 2024 16:45
remove mongodb that was installed via brew
#!/usr/bin/env sh
# first check to see if mongo service is running. you can't delete any files until the service stops so perform a quick check.
launchctl list | grep mongo
# NOTE: the pipe | symbol means the commands on the right performs on the output from the left
# grep is a string search utility. `grep mongo` means search for the substring mongo
# use the unload command to end the mongo service. this is required to 'unlock' before removing the service.
# first look for the file to delete
MONGO_SERVICE_FILE=$(ls ~/Library/LaunchAgents/*mongodb*)
@JaviLorbada
JaviLorbada / FRP iOS Learning resources.md
Last active June 17, 2024 06:08
The best FRP iOS resources.

Videos

@skreutzberger
skreutzberger / getICloudUserID.swift
Last active August 31, 2018 04:13
get iCloud User ID
import CloudKit
/// async gets iCloud record ID object of logged-in iCloud user
func iCloudUserIDAsync(complete: (instance: CKRecordID?, error: NSError?) -> ()) {
let container = CKContainer.defaultContainer()
container.fetchUserRecordIDWithCompletionHandler() {
recordID, error in
if error != nil {
print(error!.localizedDescription)
complete(instance: nil, error: error)
@skreutzberger
skreutzberger / calliCloudUserIDAsync.swift
Created November 27, 2015 09:07
use iCloudUserIDAsync
import CloudKit
iCloudUserIDAsync() {
recordID, error in
if let userID = recordID?.recordName {
print("received iCloudID \(userID)")
} else {
print("Fetched iCloudID was nil")
}
}
@cmoulton
cmoulton / Custom HTTP Headers with Swift and Alamofire.swift
Last active July 15, 2022 12:37
Custom HTTP Headers with Swift 3 or 4 and Alamofire 4.0-4.7: See https://grokswift.com/custom-headers-alamofire4-swift3/ for explanations
// MARK: - Adding a header to a single request
func doRequestWithHeaders1() {
let headers: HTTPHeaders = [
"X-Mashape-Key": MY_API_KEY,
"Accept": "application/json"
]
Alamofire.request("https://mashape-community-urban-dictionary.p.mashape.com/define?term=smh", headers: headers)
.responseJSON { response in
debugPrint(response)
import UIKit
class MyView: UIView {
fileprivate var myPreviewInteraction: Any? = nil
init() {
super.init(frame: CGRect.zero)
if #available(iOS 10.0, *) {
myPreviewInteraction = UIPreviewInteraction(view: self)
@raulriera
raulriera / Cacher.swift
Created December 7, 2016 14:40
Code sample for Medium article about Caching and Protocols
public protocol Cachable {
var fileName: String { get }
func transform() -> Data
}
final public class Cacher {
let destination: URL
private let queue = OperationQueue()
public enum CacheDestination {
import Foundation
import UIKit
// Usage Examples
let shadowColor = Color.shadow.value
let shadowColorWithAlpha = Color.shadow.withAlpha(0.5)
let customColorWithAlpha = Color.custom(hexString: "#123edd", alpha: 0.25).value
enum Color {