This file contains 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
// house of the dragon (use it on imdb.com from console) | |
fetch('https://www.imdb.com/title/tt11198330/episodes?season=1').then(r => r.text()).then(text => { | |
const html = document.createRange().createContextualFragment(text); | |
const episodes = [...html.querySelectorAll('.ipl-rating-star.small .ipl-rating-star__rating')].map((node, ep) => ({ep: ep + 1, rating: +node.innerHTML})); | |
console.log(JSON.stringify(episodes, null, 2)); | |
}) |
This file contains 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 eslint output here replace ` to ' before copying to avoid js error | |
str = ``; | |
str.split(/\n/) | |
// get rules from the lines containing warning or error | |
.map(t => { | |
const match = t.match(/^\s+(\d+\:\d+).+\s+([0-9@_\/\-a-zA-Z]+)$/); | |
return match && match[2]; | |
}) |
This file contains 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, '') | |
})); |
This file contains 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 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 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 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 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 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 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 |
NewerOlder