Skip to content

Instantly share code, notes, and snippets.

View longnguyen2508's full-sized avatar
😐

Long Nguyen longnguyen2508

😐
View GitHub Profile
@apieceofbart
apieceofbart / test.js
Last active January 18, 2024 17:14
Async testing with jest fake timers and promises
PLEASE CHECK THIS REPO WITH THE EXAMPLES THAT YOU CAN RUN:
https://github.com/apieceofbart/async-testing-with-jest-fake-timers-and-promises
// Let's say you have a function that does some async operation inside setTimeout (think of polling for data)
function runInterval(callback, interval = 1000) {
setInterval(async () => {
const results = await Promise.resolve(42) // this might fetch some data from server
callback(results)
}, interval)
@lodestone
lodestone / eoc.rb
Created August 27, 2012 19:25
Using `EOC` in ruby code scripts.
# Using <<`EOC` in the manner lets you run a longer script from within Ruby easily.
print <<`EOC`
echo "This one is for the bitches"
echo "This ones is too"
EOC