Skip to content

Instantly share code, notes, and snippets.

View priore's full-sized avatar

Prioregroup.com priore

View GitHub Profile
@lobotony
lobotony / swatmd.py
Created May 11, 2022 17:15
waits for wdavdaemon_enterprise processes and kills them. run with sudo.
#!/usr/bin/env python3
import psutil
import time
def logDebug(msg):
print(time.ctime() + " " + msg)
while True:
count = 0
@oxlb
oxlb / xcode-uninstall.sh
Created July 23, 2020 06:25
SH file to uninstall Xcode from MacOS
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf /Applications/Xcode.app
rm -rf ~/Library/Caches/com.apple.dt.Xcode
rm -rf ~/Library/Developer
rm -rf ~/Library/MobileDevice
rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist
@eneko
eneko / dealloc-breakpoint.md
Last active January 3, 2024 02:24
Xcode UIViewController dealloc breakpoint

Xcode deinit breakpoint for UIViewController

This breakpoint provides an easy way to track view controller deinitialization (deallocation) in UIKit-based applications. This can help finding memory leaks caused by retain cycles preventing view controllers from being deinitialized when dismissed or popped.

From Cédric Luthi's tweet in 2017:

Useful Xcode breakpoint. When you dismiss a controller and you don’t hear the pop sound (or see the log), you probably have a retain cycle.

@susanstevens
susanstevens / iphone-popover.md
Last active September 8, 2023 02:25
How to Create a Popover on iPhone

How to Create a Popover on iPhone

Storyboard set up

Add your view controllers in storyboard. In the Size Inspector, change the simulated size of the popover view controller to "Freeform". This doesn't change the popover's size when you run the app, but it does make it easier to lay out subviews correctly.

storyboard

When adding the segue between view controllers, select "Present as Popover".

@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
}
@norsez
norsez / Date+ISO8601.swift
Created June 21, 2017 05:18
Swift 3: Date <-> ISO 8601 String conversion
extension Date {
static func ISOStringFromDate(date: Date) -> String {
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.timeZone = TimeZone(abbreviation: "GMT")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"
return dateFormatter.string(from: date).appending("Z")
}
@celian-m
celian-m / SessionDelegate.swift
Created January 13, 2017 16:33
Perform client side certificate check
import Foundation
public struct IdentityAndTrust {
public var identityRef:SecIdentity
public var trust:SecTrust
public var certArray:NSArray
}
public func extractIdentity(certData:NSData, certPassword:String) -> IdentityAndTrust {
@zwang
zwang / two lines title for navigationbar.swift
Created October 20, 2016 01:00
two lines title for navigationbar
//http://stackoverflow.com/questions/2422383/uinavigationbar-multi-line-title
private func setupTitleView() {
let topText = NSLocalizedString("key", comment: "")
let bottomText = NSLocalizedString("key", comment: "")
let titleParameters = [NSForegroundColorAttributeName : UIColor.<Color>(),
NSFontAttributeName : UIFont.<Font>]
let subtitleParameters = [NSForegroundColorAttributeName : UIColor.<Color>(),
NSFontAttributeName : UIFont.<Font>]
@insidegui
insidegui / WebCacheCleaner.swift
Created September 14, 2016 23:12
Clear WKWebView's cookies and website data storage, very useful during development.
import Foundation
import WebKit
final class WebCacheCleaner {
class func clean() {
HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)
print("[WebCacheCleaner] All cookies deleted")
WKWebsiteDataStore.default().fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in
@kaleksandrov
kaleksandrov / global-protect.sh
Last active April 19, 2024 03:46
Simple script that starts and stops GlobalProtect.app on Mac OSX.
#!/bin/bash
case $# in
0)
echo "Usage: $0 {start|stop}"
exit 1
;;
1)
case $1 in
start)