This file contains hidden or 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
| class Node { | |
| var val: (Int, Int) | |
| var next: Node? | |
| init(_ val: (Int, Int)) { | |
| self.val = val | |
| } | |
| } | |
| class LinkedList { |
This file contains hidden or 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
| let dict: [Float : String] = [ | |
| 18.0: "ff0000", | |
| 20.0: "00ff00", | |
| 21.0: "0000ff" | |
| ] | |
| let encoder = JSONEncoder() | |
| encoder.outputFormatting = [.prettyPrinted, .sortedKeys] | |
| let encoded = try! encoder.encode(dict) | |
| let jsonText = String(decoding: encoded, as: UTF8.self) |
This file contains hidden or 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 Dictionary : Encodable /* where Key : Encodable, Value : Encodable */ { | |
| public func encode(to encoder: Encoder) throws { | |
| assertTypeIsEncodable(Key.self, in: type(of: self)) | |
| assertTypeIsEncodable(Value.self, in: type(of: self)) | |
| if Key.self == String.self { | |
| // Since the keys are already Strings, we can use them as keys directly. | |
| var container = encoder.container(keyedBy: _DictionaryCodingKey.self) | |
| for (key, value) in self { | |
| let codingKey = _DictionaryCodingKey(stringValue: key as! String)! |
This file contains hidden or 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
| TAGS="TODO:|FIXME:|WARNING:" | |
| ERRORTAG="ERROR:" | |
| find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$|($ERRORTAG).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"| perl -p -e "s/($ERRORTAG)/ error: \$1/" |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <body> | |
| <script> | |
| var localfile = "/etc/passwd" | |
| var xhr = new XMLHttpRequest(); | |
| xhr.onreadystatechange = function() { | |
| if (xhr.readyState == 4) { | |
| alert(xhr.responseText); | |
| } |
This file contains hidden or 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 | |
| class ViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| let webView = UIWebView(frame: view.bounds) | |
| view.addSubview(webView) | |
| if let filePath = Bundle.main.path(forResource: "hack", ofType: "html") { |
This file contains hidden or 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 MediaPlayer | |
| class ViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| let volumeView = MPVolumeView(frame: CGRect(x: 100, y: 100, width: 100, height: 100)) | |
This file contains hidden or 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 application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
| NotificationCenter.default.addObserver(self, selector: Selector(("volumeDidChange:")), name: NSNotification.Name(rawValue: "AVSystemController_SystemVolumeDidChangeNotification"), object: nil) | |
| return true | |
| } | |
| func volumeDidChange(notification: NSNotification) { | |
| let volume = notification.userInfo!["AVSystemController_AudioVolumeNotificationParameter"] as! Float | |
| // Volume at your service |
This file contains hidden or 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
| @interface Queue() | |
| @property (nonatomic, strong) NSMutableArray<id> *array; | |
| @end | |
| @implementation Queue | |
| - (instancetype)init { | |
| self = [super init]; |
This file contains hidden or 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
| @interface Queue<ObjectType> : NSObject | |
| - (void)enqueue:(ObjectType)value; | |
| - (ObjectType)dequeue; | |
| @end |
OlderNewer