Skip to content

Instantly share code, notes, and snippets.

@pofigizm
pofigizm / 42.js
Created August 8, 2017 19:35
Waiting for define deep property in window object
const waitForProp = (prop, context) => new Promise(resolve => {
if (typeof context[prop] !== 'undefined') {
resolve(context[prop])
return
}
const desc = Object.getOwnPropertyDescriptor(context, prop)
if (desc) {
Object.defineProperty(context, prop, {
set(value) {
@pofigizm
pofigizm / .inputrc
Last active July 21, 2017 12:15
.inputrc
# want vi to be the default editor for readline
set editing-mode vi
# vi settings
$if mode=vi
# normal mode
set keymap vi-command
# "j": beginning-of-history
# "l": backward-char
@pofigizm
pofigizm / esnextbin.md
Last active October 12, 2016 13:03
esnextbin sketch
@pofigizm
pofigizm / fp.js
Last active September 1, 2017 06:57
const pipe = (...args) => val => args.reduce((a,b) => b(a), val);
const foldl = fx => init => arr => [].reduce.call(arr, fx, init);
const fmap = fx => arr => [].map.call(arr, fx);
const arr = [1, 2, 3];
const fx1 = a => a * 2;
const fx2 = a => a - 2;
const fx3 = a => a * a;
const fx4 = (a, b) => a + b;
function sum(value) {
function line(fx) {
while (fx instanceof Function) {
fx = fx.call(null);
}
return fx;
}
function recursion(current, result) {
return function() {
@pofigizm
pofigizm / gist:6f8c3adae7baeb5f2572
Last active August 29, 2015 14:24
Задание №2
/**
* Реализация API, не изменяйте ее
* @param {string} url
* @param {function} callback
*/
function getData(url, callback) {
var RESPONSES = {
'/countries': [
{name: 'Cameroon', continent: 'Africa'},
{name :'Fiji Islands', continent: 'Oceania'},
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
#space {
margin: 20px;
border: 1px solid #aaa;
display: inline-block;
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
.itemslist {
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
.itemslist {
display:inline-block;
background: white;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
html, body {
height: 100%;
margin: 0;
padding: 0;