The Intersection Observer API provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document's viewport. Polyfill can be founded here. PS: Stolen from sample-media-pwa created by @paullewis.
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 XHR(url) { | |
return new Promise((resolve, reject) => { | |
let request = new XMLHttpRequest(); | |
request.open('GET', url, true); | |
request.send(null); | |
request.addEventListener('readystatechange', () => { | |
if (request.status === 200) { | |
if (request.readyState === 4) { | |
resolve(JSON.parse(request.response)); | |
} |
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
class EventEmitter { | |
constructor() { | |
this.events = {}; | |
} | |
on(event, func) { | |
if(this.events[event]) { | |
this.events[event].push(func); | |
} else { | |
this.events[event] = [func]; |
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
#include <stdio.h> | |
#include <math.h> | |
#define MYLOG_N 12 | |
#define MTPOW_N 30 | |
#define EXP_VAL 2.718281828459045090795598298427648842334747314453125 | |
double cfrac_log(double x, unsigned int n) { | |
if (x < 0) { | |
return NAN; |
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 DateHelper from './modules/dateHelper'; | |
const dataInit = new DateHelper(); | |
const _timeAgoElems = document.querySelectorAll('.time-ago-in-words'); | |
[..._timeAgoElems].forEach(elem => { | |
const time = elem.querySelector('time'); | |
time.textContent = dataInit.timeAgoInWords(time.dataset.time); | |
}); |
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 { | |
Router | |
} from './helpers/router/lib'; | |
const router = new Router({ | |
mode: 'history', | |
root: '/' | |
}); | |
router |
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
require 'digest' | |
class Block | |
attr_reader :index, :hash | |
def initialize(index:, timestamp: Time.now, data:, previous_hash:) | |
@data = data | |
@index = index | |
@timestamp = timestamp | |
@previous_hash = previous_hash |
All of the diacritic characters(czech, slovak, etc languages) are replaced with their analogues from the latin abc. š -> s; ě -> e
So you don't have to worry about perfect character matching.
perl learn-languages.pl some-path.txt some-other-path/file.txt
Mine files are written in the following format