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
struct CaesarCipher { | |
enum Operation { | |
case encode | |
case decode | |
} | |
let charTable: [Character] | |
private func crypt(text: String, shift: Int, operation: Operation) -> String { | |
var result: [Character] = [] |
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
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
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
[ | |
{ | |
"name":"Afghanistan", | |
"dial_code":"+93", | |
"code":"AF" | |
}, | |
{ | |
"name":"Åland Islands", | |
"dial_code":"+358", | |
"code":"AX" |
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
// | |
// Data+hash.swift | |
// HashTools | |
// | |
// Created by dede.exe on 17/09/18. | |
// Copyright © 2018 dede.exe. All rights reserved. | |
// | |
import Foundation |
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 Foundation | |
import MobileCoreServices | |
extension Data { | |
enum MimeType : Int { | |
case imageJPEG = 0xff | |
case imagePNG = 0x89 | |
case applicationPDF = 0x25 | |
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
{ "name":"Jose", "age":33, "height": 1.70, "weigh":70 } |
NewerOlder