Skip to content

Instantly share code, notes, and snippets.

View artemgurzhii's full-sized avatar

Artem Hurzhii artemgurzhii

View GitHub Profile
@artemgurzhii
artemgurzhii / xhr.js
Last active November 18, 2016 23:58
Promise XMLHttpRequest function
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));
}
@artemgurzhii
artemgurzhii / EventEmitter.js
Last active February 26, 2019 15:21
Event Emitter
class EventEmitter {
constructor() {
this.events = {};
}
on(event, func) {
if(this.events[event]) {
this.events[event].push(func);
} else {
this.events[event] = [func];
@artemgurzhii
artemgurzhii / math.c
Last active November 23, 2016 12:37
Recreation of native CLang log() and pow() functions which works with decimals.
#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;
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);
});
@artemgurzhii
artemgurzhii / README.md
Last active November 14, 2018 07:56
Intersection Observer API usage example on LazyLoadImages
@artemgurzhii
artemgurzhii / index.js
Last active December 24, 2017 13:25
JS dynamic Code Splitting
import {
Router
} from './helpers/router/lib';
const router = new Router({
mode: 'history',
root: '/'
});
router
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
@artemgurzhii
artemgurzhii / README.md
Created September 16, 2019 12:44
Train words

I'm using this program to improve my skills in different languages

How

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.

Usage

perl learn-languages.pl some-path.txt some-other-path/file.txt

Mine files are written in the following format