Skip to content

Instantly share code, notes, and snippets.

@liqiang372
liqiang372 / main.js
Created April 26, 2018 03:01
comparison of lazy evaluation
const _ = require('lodash');
const t = require('transducers.js');
const arrayofRandoms = randomCeil => length =>
Array.from({length: length}, (v, i) =>
Math.floor(Math.random() * randomCeil));
const arrOfMillion = arrayofRandoms(100)(1e6);
const tripleIt = (el) => el * 3;
@liqiang372
liqiang372 / dummy_file.js
Last active February 9, 2017 23:27
for enhui study
var x = 1;
console.log("whatever")
@liqiang372
liqiang372 / preview.css
Created October 14, 2016 05:12
Add github markdown style to quiver preview mode
h1,h2{padding-bottom:.3em;border-bottom:1px solid #eee}*{font-size:16px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";line-height:1.5;word-wrap:break-word}blockquote,dl,ol,p,pre,table,ul{margin-top:0;margin-bottom:16px}h1,h2,h3,h4,h5,h6{margin-top:24px;margin-bottom:16px;line-height:1.25}h1{font-size:2em}h2{font-size:1.5em}h3{font-size:1.25em}h4{font-size:1em}h5{font-size:.875em}h6{font-size:.85em;color:#777}pre{padding:16px;overflow:auto;font-size:85%;line-height:1.45;background-color:#f7f7f7;border-radius:3px}pre *{background:#f7f7f7}a{color:#4078c0;text-decoration:none}a:hover{text-decoration:underline}code::after,code::before{letter-spacing:-.2em;content:"\00a0"}
function Pubsub() {
this.events = {};
}
Pubsub.prototype.publish = function(event, args) {
if (!this.events[event]) {
return false;
}
var subscribers = this.events[event];
// This is the object that once its state changes,
// it will notify all the observers.
function Observable() {
this.observersList = [];
}
Observable.prototype.addObserver = function(observer) {
this.observersList.push(observer);
}
Observable.prototype.removeObserver = function (observer) {
var self = this;
@liqiang372
liqiang372 / andtestfile.js
Last active February 9, 2017 22:10
get cursor position on web
// this is a test file indeed