Skip to content

Instantly share code, notes, and snippets.

View ivanbatic's full-sized avatar
🚀

Ivan Batić ivanbatic

🚀
  • Belgrade, Serbia
View GitHub Profile
@ivanbatic
ivanbatic / github-rxjs-api-demo.js
Created October 10, 2017 06:40
Rx github fetch demo
const btnEl = document.getElementById("fetchButton");
const userList = document.getElementById("show_list");
const seriesInput = document.getElementById("series");
// Here we can push new rate limit reset times
const rateLimitReset = new Rx.ReplaySubject(1);
// Countdowns derived from reset times
const resetTicker = rateLimitReset
.map(time => Math.ceil(time - Date.now() / 1000))
@ivanbatic
ivanbatic / json-autocompletion.js
Created November 7, 2016 06:30
Given a possibly invalid JSON content and a caret position, determines the structure path that leads to it
const filePath = "whole-genome.json";
const esprima = require("esprima");
const fs = require("fs");
const wholeGenome = fs.readFileSync(filePath, "utf8");
console.time("whole-genome");
console.time("tokenizer");
const tokens = esprima.tokenize(wholeGenome, {loc: true});
console.timeEnd("tokenizer");
@ivanbatic
ivanbatic / typescript-async-await-demo.ts
Last active January 12, 2021 21:55
Typescript async/await demo
"use strict";
class Cheese {
private state = "hard";
public async melt() {
console.log("Melting...");
return new Promise((resolve) => {
setTimeout(() => {
this.state = "melted";
@ivanbatic
ivanbatic / ng2-jspm-config.json
Created August 7, 2015 00:57
Jspm config for Angular2
System.config({
"baseURL": "/",
"defaultJSExtensions": true,
"transpiler": "typescript",
"typescriptOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs"
},
"paths": {