Skip to content

Instantly share code, notes, and snippets.

@joshua24322
joshua24322 / PosixErrorCodes.php
Created August 12, 2021 07:44 — forked from nelsonsar/PosixErrorCodes.php
Posix error codes as class of constants. From here: http://fxr.watson.org/fxr/source/sys/errno.h
<?php
class PosixErrorCode
{
const EPERM = 1; /* Operation not permitted */
const ENOENT = 2; /* No such file or directory */
const ESRCH = 3; /* No such process */
const EINTR = 4; /* Interrupted system call */
const EIO = 5; /* Input/output error */
const ENXIO = 6; /* Device not configured */
@joshua24322
joshua24322 / UISearchBar+Extension.swift
Last active September 24, 2019 18:16
UISearchBar category and extension for conveniently customize the text fields within search bar. Via test confirm, compatible from iOS 9 to iOS 13
//
// UISearchBar+Extension.swift
//
import UIKit
extension UISearchBar {
var dtXcode: Int {
if let dtXcodeString = Bundle.main.infoDictionary?["DTXcode"] as? String {
@joshua24322
joshua24322 / CurrentSSID.swift
Last active October 4, 2019 17:41
Get current SSID by CF-based APIs
// https://forums.developer.apple.com/thread/50302
func getSSID() -> [String] {
guard let interfacesName = CNCopySupportedInterfaces() as? [String] else { return [String()] }
return interfacesName.compactMap({ (name) in
guard let info = CNCopyCurrentNetworkInfo(name as CFString) as? [String: AnyObject] else { return nil }
guard let ssid = info[kCNNetworkInfoKeySSID as String] as? String else { return nil }
return ssid
})
}
@joshua24322
joshua24322 / UIAlertControllerExtension.swift
Last active May 8, 2019 10:17
This's sample extension for UIAlertController to show customized message and fixable use the completion handler, useful to any UIViewController Class
/**
This is flexible to deal the completion handler.
* gist: https://gist.github.com/joshua24322/2b48a026452e1184fce85ef68f18014e
*/
import Foundation
import UIKit
extension UIViewController {