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
| // An example script consuming an API with various throttling and 429 error | |
| // handling strategies. | |
| // | |
| // Blog post with more context | |
| // https://www.useanvil.com/blog/2021-03-29-throttling-and-consuming-apis-with-429-rate-limits | |
| // | |
| // License: MIT | |
| import fetch from 'node-fetch' | |
| import mapLimit from 'async/mapLimit' |
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
| # copy/import data from heroku postgres to localhost pg database | |
| # useful for copying admin's work on live site into local database to reproduce errors | |
| # https://devcenter.heroku.com/articles/heroku-postgres-import-export | |
| # take heroku pg snapshot and download | |
| heroku pg:backups:capture | |
| heroku pg:backups:download | |
| # load the dump into local postgres database, assuming $DATABASE_URL set locally |
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
| #!/bin/bash | |
| echo 'update brew' | |
| brew update | |
| echo 'upgrade brew' | |
| brew upgrade |
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
| /* | |
| * Useful for check falsy values in object | |
| * Can be helpful for form validation | |
| * Object - The data to be validation | |
| * props - The required properties that cannot be falsy (null, undefined, '', 0) | |
| */ | |
| const validateObject = (obj, props) => { | |
| const valid = _.chain(props) | |
| .map(prop => _.has(obj, prop) && !!obj[prop]) | |
| .without(false) |
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
| alias killport='function _killp(){ lsof -nti:$1 | xargs kill -9 };_killp' | |
| # Running: `killport 3000` will free up port 3000 |
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 StockPrices(prices) { | |
| let profit = -1; | |
| let buy = Infinity | |
| let sell = -Infinity | |
| for (let i = 0; i < prices.length - 1; i++) { | |
| if(prices[i] < buy) { | |
| buy = prices[i] | |
| sell = prices[i + 1] | |
| } else if (prices[i] > sell) { |
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 OddOccurrencesInArray(A) { | |
| const counter = {}; | |
| for (let i of A){ | |
| if(counter[i]) delete counter[i]; | |
| else counter[i] = 1; | |
| } | |
| return +Object.keys(counter)[0]; | |
| } | |
| function binaryGap(N) { | |
| const bina = N.toString(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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" contwelvet="width=device-width"> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/simple-scrollbar.css"> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.css"> | |
| <style> | |
| .sidebar { |
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 doPost(request){ | |
| console.log("GOT here"); | |
| var params = request.parameter; | |
| var text = params.text; //the options provided after the command as a single string | |
| //visit https://api.slack.com/slash-commands/#app_command_handling for available payload sent by slack | |
| var names = text.split(" "); | |
| var firstName = names[0]; | |
| var lastName = names[1]; | |
| addRow(firstName, lastName);//call function to add row as declared below |