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
| ps -A | grep node | sed 's/\([0-9]*\).*/\1/' | xargs kill -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
| function sing() { | |
| const verses = []; | |
| for (let i = 99; i > 1; i--) { | |
| verses.push( | |
| `${i} bottles of beer on the wall, ${i} bottles of beer.`, | |
| `Take one down and pass it around, ${i-1} bottle${i-1 > 1 ? 's' : ''} of beer on the wall.` | |
| ); | |
| } | |
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
| head -1000 some.csv | awk -F";" '{print $1}' | grep keyword |
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
| [1,2,2,1,3,3,4,5,5,0,0,6,7,6,7].reduce((acc, next) => acc ^ next, 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 Queue = require('then-queue'); // async queue that doesn't care what order you call push and pop. | |
| const queue = new Queue(); | |
| // push sends to the first waiting `pop` if available, otherwise it acts as a buffer | |
| listenToNewMessages(message => queue.push(message)); | |
| async function* MessagesGenerator() { | |
| try { | |
| while (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
| // server.js | |
| const io = require('socket.io')(1234); | |
| const Board = require('./board'); | |
| const game = new Board({size: 15, mineChance: 0.3}); | |
| const PLAYER_PREFIX = 'p-'; | |
| const players = {}; | |
| const cellsToReveal = []; | |
| let counter = 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
| // codewars exercise | |
| const str = 'As2{Be4C5[BCo3(CO2)3]2}4Cu5'; | |
| function parseMolecule(formula) { | |
| const BRACKET_OPENER_REGEXP = /\[|\{|\(/; | |
| const BRACKET_CLOSER_REGEXP = /\]|\}|\)/; | |
| const VALID_ATOM_REGEXP = /^[A-Z][a-z]?$/; | |
| const MULTIPLIER_REGEXP = /^\d+/; | |
| function createGroup(parent = {}) { |
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
| $$('._2TMjc').map(item => item.innerText).reduce((acc, next) => acc + +next.match(/\/(\d*)/)[1], 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 LABELS = ['year', 'day', 'hour', 'minute', 'second']; | |
| function formatDuration (seconds) { | |
| if (seconds === 0) return 'now'; | |
| let minutes = seconds / 60 >> 0; | |
| let hours = minutes > 59 ? minutes / 60 >> 0 : 0; | |
| let days = hours > 23 ? hours / 24 >> 0 : 0; | |
| const years = days > 364 ? days / 365 >> 0 : 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 data = [...document.querySelectorAll('.ui-table-row')].map(row => ({ | |
| market: row.querySelector('.table-first-name').innerText, | |
| units: +row.querySelector('[data-etoro-automation-id=portfolio-overview-table-cell-container-units]').innerText.split('\n')[0].replace(/,/g, ''), | |
| avgOpen: +row.querySelector('[data-etoro-automation-id=portfolio-overview-table-cell-container-open-rate]').innerText, | |
| invested: +row.querySelector('[data-etoro-automation-id=portfolio-overview-table-cell-container-invested]').innerText.slice(1).replace(/,/g, ''), | |
| pl$: +row.querySelector('[data-etoro-automation-id=portfolio-overview-table-cell-container-container-profit]').innerText.replace(/[<,$]/g, ''), | |
| plPercent: +row.querySelector('[data-etoro-automation-id=portfolio-overview-table-cell-container-gain]').innerText.replace(/[<,%]/g, ''), | |
| value: +row.querySelector('[data-etoro-automation-id=portfolio-overview-table-cell-container-equity]').innerText.replace(/[<,$]/g, '') | |
| })); |