{
"name": "theptrk",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
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
| # find | |
| find -name '* SOME_SPECIFIER.SOME_EXTENSION' | |
| # find and delete | |
| find -name '* SOME_SPECIFIER.SOME_EXTENSION' -delete | |
| # example 1: delete all files to end in `"space"1.JPG` | |
| find -name '* 1.JPG' -delete |
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
| const express = require('express') | |
| const app = express() | |
| const PORT = process.env.PORT || 3000 | |
| app.get('/', (req, res) => res.send('Hello World!')) | |
| app.listen(PORT, () => console.log(`Example app listening on port ${PORT}!`)) |
Its likely more natural for you to type at the bottom of the file so with normal Go we move the cursor to the bottom before reading from the date command.
# bash_profile.sh
alias did="vim +'normal Go' +'r!date' ~/did.txt"
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
| (function { | |
| window.addEventListener('online', doSomething); | |
| window.addEventListener('offline', doSomething); | |
| })() | |
| // @returns: String { "online", "offline" } | |
| function doSomething() { | |
| returns navigator.onLine; | |
| } |
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
| --- /dev/null | |
| +++ b/my_file.txt | |
| @@ -0,0 +1,3 @@ | |
| +Dear Abby | |
| +I met a new person today | |
| +It was a good day |
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
| // TODO TEST | |
| // given [3,4,5,6,7,8,9,1,2] | |
| // return 7 | |
| const test1 = [3,4,5,6,7,8,9,1,2] | |
| const test2 = [8,9,1,2,3,4,5,6,7] | |
| const findk = list => { | |
| if (list[0] < list[list.length-1]) { | |
| return 0; | |
| } |
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
| const phoneNumberMnemonics = (phoneNumber) => { | |
| const letters = ["0", "1", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"] | |
| const numbers = phoneNumber.split(''); | |
| const results = []; | |
| const wipStack = [ | |
| { wip: '', remaining: numbers } | |
| ]; | |
| while (wipStack.length > 0) { | |
| let [wip, remainingNumbers] = wipStack.pop(); | |
| if (remainingNumbers.length > 0) { |
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
| const test1 = [ | |
| [1] | |
| ]; | |
| const test2 = [ | |
| [1, 2], | |
| [3, 4] | |
| ]; | |
| const test3 = [ | |
| [1, 2, 3], | |
| [4, 5, 6], |
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
| // Part 1 | |
| // write an array mapping function that can be passed into reduce | |
| const mapping = (transform) => (acc, val) => acc.concat([transform(val)]); | |
| // write an array filtering function that can be passed into reduce | |
| const filtering = (predicate) => (acc, val) => predicate ? acc.concat([val]): acc; | |
| // Part 2 | |
| // abstract out the "reduce" logic | |
| const concat = (acc, val) => acc.concat([val]); |