Skip to content

Instantly share code, notes, and snippets.

View Nautigsam's full-sized avatar

Aurélien Bertron Nautigsam

View GitHub Profile
@Nautigsam
Nautigsam / sinon-handle-throw.js
Created March 4, 2020 12:47
Use case where it could be useful to explicit how to handle an error thrown with a Sinon stub
const o = {
edit(cb) {
console.log('EDIT')
return Promise.resolve(false)
.then(cb)
}
}
function run() {
console.log('RUN')
Computer Information:
Manufacturer: Unknown
Model: Unknown
Form Factor: Laptop
No Touch Input Detected
Processor Information:
CPU Vendor: GenuineIntel
CPU Brand: Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz
CPU Family: 0x6
After Bit
Alexandre Astier
At0mium
At0mium - Ancienne chaîne
Attention, ça glyphe !
Axolot
Bad Lip Reading
Bazar du Grenier
benzaie
BenzaieLive
@Nautigsam
Nautigsam / loopCall.js
Created April 28, 2016 14:41
Show the use of loopCall, which call a function (here failedFunc) and return a promise immadiately or after maxCount tries in case of error.
var failedFunc = () => Promise.reject()
var maxCount = 3;
(function loopCall (maxCount, count) {
if (count == undefined) count = 0
return failedFunc()
.catch((err) => {
count++
if (count == maxCount) return Promise.reject(err)
return loopCall(maxCount, count)
})
@Nautigsam
Nautigsam / chronometer.js
Created March 17, 2016 18:31
ES2015 chronometer
'use strict'
let it=(function*(){
let i=1
while(1){
yield new Promise((resolve)=>{
setTimeout(()=>{
resolve(i++)
},1000)
})
}
@Nautigsam
Nautigsam / lollerskates.rb
Last active December 1, 2015 17:57
Print a fancy rolling guy in your terminal.
# 340 characters
def s; sleep 0.2 end
alias p puts
while 1 do
l="LOL"
e=' '
a="\e[H\e[2J#{e*8}/\\o\n#{e*9}/\\/\n#{e*8}/\\\n#{e*7}/ \\\n"+e*6+(l+e)*2+"\n:-D LOLLERSKATES :-D"
s()
p a
a[15..16]=" _"