Skip to content

Instantly share code, notes, and snippets.

View tkheyfets's full-sized avatar
🥴

Timur Kheyfets tkheyfets

🥴
View GitHub Profile
function toArray(args) {
return Array.prototype.slice.call(args);
}
var uniqID = (function () {
var _uniq = new Date().getTime();
return function () {
return (_uniq++).toString(36);
};
})()
function memoize(fn) {
var slice = Array.prototype.slice,
cache = [];
return function () {
var args = slice.call(arguments),
result = cache[args];
if (!result) {
result = cache[args] = fn.apply(this, args);
}
function get(url) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onload = function() {
if (xhr.status === 200) {
resolve(xhr.response);
} else {
reject(Error(xhr.statusText));
.text-overflowed {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
function extend(Child, Parent) {
Child.prototype = Object.create(Parent.prototype);
Child.prototype.constructor = Child;
return Child;
}
var Message = function (text) {
this.text = text;
};
@tkheyfets
tkheyfets / googlemaps-like-pin.html
Last active March 23, 2016 17:51
GoogleMaps like Pin with only css and html http://output.jsbin.com/yanowi/1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width" />
<title>Google Maps like Pin</title>
<link type="text/css" rel="stylesheet" href="pin.css" />
</head>
<body>
@tkheyfets
tkheyfets / chart.html
Last active March 23, 2016 17:53
Interactive chart with html and css http://jsbin.com/zoginax/5
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" type="text/css" href="main.css" />
<title>CSS Chart</title>
</head>
<body>
<div class="bars-wrapper">
@tkheyfets
tkheyfets / defer.js
Last active March 23, 2016 18:35
Force code to run in next drawing frame
function defer(fn) { return setTimeout(fn, 0); }
const insert = (item, index, array) =>
[...array.slice(0, index),
...item,
...array.slice(index, array.length)];