This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getWindowsList() { | |
let options = CGWindowListOption(arrayLiteral: .optionOnScreenOnly) | |
let windowListInfo = CGWindowListCopyWindowInfo(options, CGWindowID(1)) | |
let infoList = windowListInfo as! [[String: Any]] | |
let windowList = infoList.filter { (($0["kCGWindowLayer"] as? Int) ?? -1) == 0 } | |
for window in windowList { | |
print(window["kCGWindowOwnerName"]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Foundation | |
let image = UIImage(named: "example.jpg") | |
let imageData = image!.jpegData(compressionQuality: 0.75) | |
let date = Date() | |
let dateFormatter = DateFormatter() | |
dateFormatter.dateFormat = "yyyy-MM-dd" | |
let dateString = dateFormatter.string(from: date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// FocusView.swift | |
// CustomNavigation | |
// | |
// Creating a CustomFocusView | |
// This code shows how to implement a custom view that can be focused in tvOS | |
// Just set this class as an UIView's custom class | |
// | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
// | |
//Left trim | |
// | |
std::string trim_left(const std::string& str) | |
{ | |
const std::string pattern = " \f\n\r\t\v"; | |
return str.substr(str.find_first_not_of(pattern)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension URLRequest { | |
public func curl(pretty:Bool = false) -> String { | |
var data : String = "" | |
let complement = pretty ? "\\\n" : "" | |
let method = "-X \(self.httpMethod ?? "GET") \(complement)" | |
let url = "\"" + self.url?.absoluteString ?? "" + "\"" | |
var header = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum SignalTrap { | |
typealias SignalHandler = @convention(c)(Int32) -> Void | |
static func handle(signal:Int32, action: @escaping SignalHandler) { | |
typealias SignalAction = sigaction | |
var sigAction = sigaction() | |
sigAction.__sigaction_u = unsafeBitCast(action, to: __sigaction_u.self) | |
sigaction(signal, &sigAction, nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// StringMaskFormatter.swift | |
// StringMaskFormatter | |
// | |
// Created by dede.exe on 10/07/16. | |
// It's totally base on article : "http://vojtastavik.com/2015/03/29/real-time-formatting-in-uitextfield-swift-basics/" | |
// And I don't mind if the original author should allow me(or not) to publish it :)... But I'll keep the reference | |
// | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Darwin | |
let handle = dlopen("/usr/lib/libc.dylib", RTLD_NOW) | |
let sym = dlsym(handle, "random") | |
let functionPointer = UnsafeMutablePointer<() -> CLong>(sym) | |
let result = functionPointer.memory() | |
println(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// No Security | |
{ | |
"rules": { | |
".read": true, | |
".write": true | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UITextField+MaskPattern.swift | |
// MaskedTextField | |
// | |
// Created by dede.exe on 10/07/16. | |
// | |
// It's totally base on article : "http://vojtastavik.com/2015/03/29/real-time-formatting-in-uitextfield-swift-basics/" | |
// And I don't mind if the original author allow me to publish it :)... But I'll keep the reference | |
// I modified the original implementation to keep it as an Extension... | |
// |
NewerOlder