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 * as _ from "lodash" | |
| /** This is how DataTypes are serialized. */ | |
| export type DataType = | |
| | { type: "string" } | |
| | { type: "number" } | |
| | { type: "boolean" } | |
| | { type: "literal"; value: string | number | boolean } | |
| | { type: "array"; inner: DataType } | |
| // Tuple types are not quite working yet. |
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
| ❯❯❯ ios_webkit_debug_proxy -d | |
| ss.add_server_fd(3) | |
| Listing devices on :9221 | |
| ss.add_fd(4) | |
| ss.add_server_fd(5) | |
| ss.remove_server_fd(5) | |
| ss.recv fd=4 len=981 | |
| ss.add_server_fd(5) | |
| ss.add_fd(9) | |
| wi.send_packet[174]: |
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
| ❯❯❯ ios_webkit_debug_proxy -d | |
| ss.add_server_fd(3) | |
| Listing devices on :9221 | |
| ss.add_fd(4) | |
| ss.add_server_fd(5) | |
| ss.remove_server_fd(5) | |
| ss.recv fd=4 len=981 | |
| ss.add_server_fd(5) | |
| ss.add_fd(9) |
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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Label</key> | |
| <string>com.demo.daemon.plist</string> | |
| <key>RunAtLoad</key> | |
| <true/> |
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
| type state = int; | |
| type action = | |
| | Inc | |
| | IncBy int | |
| | Dec | |
| | DecBy int | |
| | Reset; | |
| let update state action => |
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 rec nth l n => | |
| switch l { | |
| | [] => None | |
| | [h, ...t] => n === 0 ? Some h : nth t (n - 1) | |
| }; | |
| let x = nth [0, 1, 2, 3] 999; /* option int: None */ | |
| switch x { | |
| | Some i => print_int i |
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 nth l n = | |
| if n < 0 then invalid_arg "List.nth" else | |
| let rec nth_aux l n = | |
| match l with | |
| | [] -> failwith "nth" | |
| | a::l -> if n = 0 then a else nth_aux l (n-1) | |
| in nth_aux l n |
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 rec firstN n l => | |
| switch (n, l) { | |
| | (0, _) => [] | |
| | (_, []) => [] | |
| | (n, [h, ...t]) => [h, ...firstN (n - 1) t] | |
| }; | |
| firstN 2 [1, 2, 3, 4, 5]; /* => list int: [1, 2] */ |
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 rec firstN n l => | |
| if (n === 0 || List.length l === 0) { | |
| [] | |
| } else { | |
| let h = List.hd l; | |
| let t = List.tl l; | |
| List.append [h] (firstN (n - 1) t) | |
| }; | |
| firstN 2 [1, 2, 3, 4, 5]; /* => list int: [1, 2] */ |
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
| type result 'a = {mutable list: list 'a}; | |
| let firstN (n: int) (l: list 'a) :list 'a => { | |
| let result: result 'a = {list: []}; | |
| let start = 0; | |
| let stop = min (n - 1) (List.length l - 1); | |
| for i in start to stop { | |
| result.list = List.append result.list [List.nth l i] | |
| }; | |
| result.list |