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 paginate = (items, page = 1, perPage = 10) => { | |
const offset = perPage * (page - 1); | |
const totalPages = Math.ceil(items.length / perPage); | |
const paginatedItems = items.slice(offset, perPage * page); | |
return { | |
previousPage: page - 1 ? page - 1 : null, | |
nextPage: (totalPages > page) ? page + 1 : null, | |
total: items.length, | |
totalPages: totalPages, |
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
// get all Zoom participants | |
Object.values(document.getElementsByClassName('participants-ul')[0].getElementsByClassName('participants-item__display-name')).map(item => item.innerText).join(',') | |
// Remove sidebar wol.jw.org | |
document.getElementById('secondaryNavContent').style.display = 'none' | |
document.getElementsByClassName('articlePositioner')[0].style.margin = '0px' |
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
import React from 'react' | |
import { IAsyncAppDispatch } from 'my-package' | |
export interface IHandlers { | |
onSuccess: IAsyncAppDispatch['onSuccess'] | |
onError: IAsyncAppDispatch['onError'] | |
} | |
export interface DefaultFormProps { | |
handlers?: IHandlers |
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
12_streams git:(main) ✗ node 8_kb_data.js | |
read chunk <Buffer 4e 61 6d 65 2c 41 67 65 2c 4c 6f 63 61 74 69 6f 6e 0a 42 75 64 64 79 2c 35 2c 4e 65 77 20 59 6f 72 6b 0a 4c 75 63 6b 79 2c 32 2c 4c 6f 73 20 41 6e 67 ... 8287 more bytes> | |
stop reading | |
12_streams git:(main) ✗ node 16_kb_data.js | |
read chunk <Buffer 4e 61 6d 65 2c 41 67 65 2c 4c 6f 63 61 74 69 6f 6e 0a 42 75 64 64 79 2c 35 2c 4e 65 77 20 59 6f 72 6b 0a 4c 75 63 6b 79 2c 32 2c 4c 6f 73 20 41 6e 67 ... 17332 more bytes> 17382 | |
stop reading | |
➜ 12_streams git:(main) ✗ node 128_kb_data.js | |
read chunk <Buffer 4e 61 6d 65 2c 41 67 65 2c 4c 6f 63 61 74 69 6f 6e 0a 42 75 64 64 79 2c 35 2c 4e 65 77 20 59 6f 72 6b 0a 4c 75 63 6b 79 2c 32 2c 4c 6f 73 20 41 6e 67 ... 65486 more bytes> 65536 |
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
function closureRequest() { | |
let success = false, error = false, data = null; | |
const dispatch = async (fn) => { | |
try { | |
data = await fn(); | |
success = true; | |
error = false; | |
} catch { | |
success = false; |
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
version: '3.3' | |
services: | |
postgres: | |
image: postgres | |
restart: always | |
environment: | |
POSTGRES_DB: ${POSTGRES_DB} | |
POSTGRES_USER: ${POSTGRES_USER} | |
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} | |
ports: |
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
import express from "express" | |
const app = express (); | |
app.get("/events",(req, res) => { | |
res. setHeader ("Content-Type", "text/event-stream"); | |
res.setHeader ("Cache-Control", "no-cache"); | |
res.setHeader ("Connection","keep-alive"); | |
// Clean headers | |
res.flushHeaders(); |
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 transform = new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }) | |
async function readUserInput(): Promise<number> { | |
const buffer = new Uint8Array(1024); | |
const bytesRead = await Deno.stdin.read(buffer); | |
const input = new TextDecoder().decode(buffer.subarray(0, Number(bytesRead))); | |
if (Number.isNaN(Number(input))) { | |
throw new Error('No bytes read'); | |
} |
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
[ | |
{ | |
"details": { | |
"summary": "An Elo-type rating model for players and teams of variable strength", | |
"p": "The Elo rating system, which was originally proposed by Arpad Elo for chess, has become one of the most important rating systems in sports, economics and gaming nowadays. Its original formulation is based on two-player zero-sum games, but it has been adapted for team sports and other settings. In 2015, Junca and Jabin proposed a kinetic version of the Elo model..." | |
}, | |
"link": "https://arxiv.org/abs/2109.15046" | |
} | |
] |
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
private async requestWithRetry( | |
query: string, | |
username: string, | |
retryDelay: number = 1000, // Set the delay between retries (in milliseconds) | |
) { | |
const tokens = [ | |
Deno.env.get("GITHUB_TOKEN1"), | |
Deno.env.get("GITHUB_TOKEN2"), | |
]; | |
const maxRetries = tokens.length |
OlderNewer