Skip to content

Instantly share code, notes, and snippets.

Avatar

Nicolas Carlo nicoespeon

View GitHub Profile
@nicoespeon
nicoespeon / index.ts
Created Apr 25, 2020
Trying to get inferred type of an identifier with @typescript/vfs
View index.ts
import {
createDefaultMapFromNodeModules,
createSystem,
createVirtualTypeScriptEnvironment,
} from "@typescript/vfs";
import * as ts from "typescript";
const fsMap = createDefaultMapFromNodeModules({
target: ts.ScriptTarget.ES2015,
});
@nicoespeon
nicoespeon / result.csv
Last active Jul 5, 2019
Pubweb Social Analysis
View result.csv
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
"contributor";"path";"size"
"Benoit Zohar";"modules/checkout/";19690
"Michael Vial";"modules/results/";13207
"Victor Mus";"modules/search/";6587
"Nicolas Carlo";"modules/route/";5485
"Benoit Zohar";"modules/purchase/";5121
"Nicole Ho";"modules/purchase-confirmation/";4936
"Nicolas Carlo";"modules/partner/";4606
"Nicole Ho";"modules/header/";4437
"Benoit Zohar";"modules/help/";4319
@nicoespeon
nicoespeon / category_pagination.rb
Last active Apr 27, 2017
Per category pagination Jekyll 1.5.1
View category_pagination.rb
# Per-category pagination. Useful for multilingual blogs =)
# It will react, regarding your configuration in `config.yml`:
#
# paginate_per_category: true|false - activate this pagination or keep the
# default one
# default_category: "en" - determine the default category if you
# wish the root pagination to be this one
module Jekyll
module Generators
class Pagination < Generator
@nicoespeon
nicoespeon / observables-second-shot.js
Last active Mar 23, 2017
Blog - Using Observables to make our app work with barcode scanners
View observables-second-shot.js
const MAX_INTERVAL_BETWEEN_EVENTS_IN_MS = 50
const keyCode$ = Rx.Observable.fromEvent(document, "keypress")
.pluck('keyCode')
const keyCodesBuffer$ = keyCode$
// --(43)-(64)----(32)-----(65)-(77)-(13)--->
.buffer(keyCode$.debounce(MAX_INTERVAL_BETWEEN_EVENTS_IN_MS))
// --([43,64])----([32])-----([65,77,13])--->
@nicoespeon
nicoespeon / observables-third-shot.js
Last active Mar 23, 2017
Blog - Using Observables to make our app work with barcode scanners
View observables-third-shot.js
const ENTER_KEY_CODE = 13
const MAX_INTERVAL_BETWEEN_EVENTS_IN_MS = 50
const keyCode$ = Rx.Observable.fromEvent(document, "keypress")
.pluck('keyCode')
const keyCodesBuffer$ = keyCode$
.buffer(keyCode$.debounce(MAX_INTERVAL_BETWEEN_EVENTS_IN_MS))
.filter(isFromScan)
@nicoespeon
nicoespeon / observables-fourth-shot.js
Last active Mar 23, 2017
Blog - Using Observables to make our app work with barcode scanners
View observables-fourth-shot.js
const ENTER_KEY_CODE = 13
const MAX_INTERVAL_BETWEEN_EVENTS_IN_MS = 50
const keyCode$ = Rx.Observable.fromEvent(document, "keypress")
.pluck('keyCode')
const keyCodesBuffer$ = keyCode$
.buffer(keyCode$.debounce(MAX_INTERVAL_BETWEEN_EVENTS_IN_MS))
.filter(isFromScan)
@nicoespeon
nicoespeon / observables-first-shot.js
Last active Mar 22, 2017
Blog - Using Observables to make our app work with barcode scanners
View observables-first-shot.js
const keyCode$ = Rx.Observable.fromEvent(document, "keypress")
// ---(ev)--(ev)--------(ev)--->
.pluck('keyCode')
// ---(43)--(51)--------(13)--->
@nicoespeon
nicoespeon / imperative-first-shot.js
Last active Mar 21, 2017
Blog - Using Observables to make our app work with barcode scanners
View imperative-first-shot.js
const ENTER_KEY_CODE = 13
let keyCodesBuffer = []
document.addEventListener("keypress", (event) => {
const keyCode = event.keyCode
if(keyCode === ENTER_KEY_CODE) {
fillInputWithKeyCodesBuffer()
cleanBuffer()
} else {
@nicoespeon
nicoespeon / imperative-second-shot.js
Last active Mar 21, 2017
Blog - Using Observables to make our app work with barcode scanners
View imperative-second-shot.js
const ENTER_KEY_CODE = 13
const MAX_INTERVAL_BETWEEN_EVENTS_IN_MS = 50
let keyCodesBuffer = []
document.addEventListener("keypress", (event) => {
const keyCode = event.keyCode
if(keyCode === ENTER_KEY_CODE) {
fillInputWithKeyCodesBuffer()
cleanBuffer()
@nicoespeon
nicoespeon / imperative-third-shot.js
Created Mar 21, 2017
Blog - Using Observables to make our app work with barcode scanners
View imperative-third-shot.js
const ENTER_KEY_CODE = 13
const MAX_INTERVAL_BETWEEN_EVENTS_IN_MS = 50
let keyCodesBuffer = []
let cleanBufferTimeout
document.addEventListener("keypress", (event) => {
const keyCode = event.keyCode
stopCleanBufferTimeout()
if(keyCode === ENTER_KEY_CODE) {
You can’t perform that action at this time.