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
| <link | |
| rel="stylesheet" | |
| href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" | |
| integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" | |
| crossorigin="anonymous"> | |
| <link | |
| rel="stylesheet" | |
| href="https://ca1.qualtrics.com/apps/applied-predictive-technologies/bootstrap_custom.css"> | |
| <style> |
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
| /* | |
| Paraphrased from RFC 4122: | |
| The formal definition of the UUID string representation is | |
| provided by the following ABNF: | |
| UUID = time-low "-" time-mid "-" | |
| time-high-and-version "-" | |
| clock-seq-and-reserved | |
| clock-seq-low "-" node |
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
| def paint_bucket(image, row, col, new_color): | |
| original_color = image[row][col] | |
| _paint(image, row, col, new_color, original_color) | |
| def _paint(image, row, col, new_color, original_color): | |
| if (row < 0 or | |
| row > len(image) - 1 or | |
| col < 0 or | |
| col > len(image[row]) - 1 or | |
| image[row][col] != original_color): |
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 HashTable { | |
| constructor() { | |
| this.table = []; | |
| this.length = 0; | |
| this.maxLength = 8; | |
| this.maxLoadFactor = 0.75; | |
| } | |
| set(key, value) { |
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 search = 'fiouedblds'; | |
| const strings = ['something random', '_filterOutNonEditableFields', 'abc', 'fiouedblds']; | |
| function findFuzzyMatches(strings, search) { | |
| return strings.filter((string) => isFuzzyMatch(string, search)); | |
| } | |
| function isFuzzyMatch(string, search) { | |
| string = string.toLowerCase(); | |
| search = search.toLowerCase(); |
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 quickSort(arr) { | |
| return quickSortAuxillary(arr, 0, arr.length - 1); | |
| } | |
| function quickSortAuxillary(arr, left, right) { | |
| if (left < right) { | |
| const middle = partition(arr, left, right); | |
| quickSortAuxillary(arr, left, middle - 1); | |
| quickSortAuxillary(arr, middle + 1, right); | |
| } |
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
| -- one customer to many transactions | |
| -- want to select most recent transaction for each customer | |
| select * from customers join transactions on transactions.id = ( | |
| select id from transactions | |
| where transactions.customer_id = customers.id | |
| order by created_at desc | |
| limit 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
| # On local machine | |
| ssh -NL 9000:some-restricted-site.com:80 myCoolServer | |
| # 9000 being the local port, some-restricted-site.com being the site you want to proxy too, | |
| # and myCoolServer being the server that allows connections to some-restricted-site.com | |
| # At this point http://localhost:9000 should resolve to some-restricted-site.com | |
| # To access these from inside docker container: http://docker.for.mac.localhost:9000 |
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
| // Imagine some library that does stuff. | |
| const library = { | |
| makeApiCall, | |
| }; | |
| function makeApiCall() { | |
| return new Promise((resolve, reject) => { | |
| console.log('starting...'); | |
| setTimeout(() => { |
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 PromiseQueue { | |
| constructor({concurrency = 1} = {}) { | |
| this.concurrency = concurrency; | |
| this.queue = []; | |
| this.pendingPromises = 0; | |
| this.push = this.push.bind(this); | |
| this._dequeue = this._dequeue.bind(this); | |
| } |