read plist -> xml file
defaults read -app Terminal | plutil -convert xml1 -o plist.xml -r -- -
| /** | |
| * @param {number[][]} matrix | |
| * @param {number} target | |
| * @return {boolean} | |
| */ | |
| var searchMatrix = function(matrix, target) { | |
| if (matrix.length === 0) return false | |
| let filteredRows = getFilteredRows(matrix, target) | |
| let filteredCols = getFilteredCols(matrix, target) |
read plist -> xml file
defaults read -app Terminal | plutil -convert xml1 -o plist.xml -r -- -
| # filter rows in a file by line number / position | |
| awk | |
| # filter rows in a file by regex | |
| grep | |
| # filter cols in a file | |
| awk | |
| # transform rows by regex |
| /* | |
| Notes: | |
| DataSource | |
| - a stream of data | |
| - hasNext(), getNext() | |
| - examples: Location, Transactions, Contacts, ... | |
| - an algorithm's output is a DataSource | |
| Transaction |
| type Methods = 'get' | 'post'; | |
| interface Req { | |
| data: object; | |
| method: Methods; | |
| url: string; | |
| foo?: number | |
| } | |
| class Req implements Req { |
| #!/usr/bin/env bash | |
| set -ex | |
| PROJECT=$1 | |
| mkdir $PROJECT && cd $PROJECT | |
| yarn init -y | |
| yarn add -D @babel/cli @babel/core @babel/preset-env @babel/preset-flow | |
| yarn add @babel/polyfill | |
| echo "{\"presets\": [\"@babel/preset-env\", \"@babel/preset-flow\"]}" | jq >> .babelrc | |
| mkdir src |
| # add to your ~/.bash_profile or startup script | |
| jazzygif () { ffmpeg -i "$1" -vf scale=-1:-1 -r 10 -f image2pipe -vcodec ppm - | convert -delay 5 -layers Optimize -loop 0 - "$2"; } | |
| # here's how you run it (assumes that pug.mp4 is in current working directory) | |
| jazzygif pug.mp4 pug.gif | |
| # or, specify paths to files | |
| jazzygif ~/Desktop/pug.mp4 ~/Documents/pugs/pug.gif |
| // The "favoriteNumber" key returns a value that Int | String. Normalize the response. | |
| val json1 = Json.parse( | |
| """ | |
| |{ | |
| |"name": "Albert", | |
| |"age": 32, | |
| |"favoriteNumber": 42 | |
| |} | |
| """.stripMargin) |
| // given: Array.prototype.forEach, derive: | |
| // 1. reduce | |
| // 2. concat | |
| // 3. map | |
| // 4. filter | |
| // 5. flatten | |
| // 6. flatMap | |
| const reduce = (xs, f, z) => { | |
| var acc = z |