Skip to content

Instantly share code, notes, and snippets.

@surr-name
surr-name / EventEmitter_question.js
Last active February 6, 2018 00:42
what will be order of numbers
const EventEmitter = require('events');
const emiter_1 = new EventEmitter;
const emiter_2 = new EventEmitter;
process.nextTick(()=>console.log(0));
setTimeout(()=>console.log(1), 0);
setImmediate(()=>console.log(2));
" syntax enable
syntax on
set background=light
let g:solarized_termcolors=256
colorscheme solarized
if &diff
colorscheme github
endif
const findSubsetBorders = (function(){
function findSubsetBorders ( set, str ) {
const
max = set.length - 1,
strl = str.length,
low = findLowBorder( set, 0, max, str, strl);
return {
start : low,
@surr-name
surr-name / movingAverage.js
Last active September 6, 2016 10:21
Moving Average
function Constr ( length ) {
if ( typeof length !== 'number' ) throw(
SyntaxError('length must be a Number')
);
this.length = length;
this._length = length - 1;
this._bin = new Array(this.length);
this._pointer = -1;
html, body {
background-color : black;
color : lightgreen;
}
@surr-name
surr-name / random.js
Created January 17, 2016 16:10
promise wrapped ( with progress ) get random bytes from /dev/random
var
Q = require('q'),
fs = require('fs');
function get ( o ) {
var requiredLength, SOURCE;
if ( typeof o === 'object' ) {
/**
* @param {...Array} sorted arrays
* @returns {Array} intersection of the arrays
*/
function intersection () {
var arrays = [].slice.call(arguments),
pointers = arrays.map(function(){return 0}),
min = arrays[0][0],
result = [],
/**
* do the array b includes all elements from the array a
*
* @param {Array} a
* @param {Array} b
* @param {Boolean} [unsorted=false] are the arrays unsorted
*
* @returns {Boolean}
*/
function bIncludesA ( a, b, unsorted ) {
@surr-name
surr-name / event.js
Last active December 31, 2015 10:39 — forked from azproduction/event.js
yet another EventManager
// Yet Another Event Manager (Pub/Sub)
//
// all listeners are executed in context of a instance of the EventManager
/**
* @constructor
*
* @param {Boolean} [doDebug] to do 'console.error' for errors of 'listeners' or not.
*/
@surr-name
surr-name / flickr_bookmarklet_obf.js
Last active December 14, 2015 09:39
shri home work, flickr image viewer bookmarklet.
javascript:(function(){function G(){d?f(d,"opacity",0,animateDuration,function(){d.parentNode.removeChild(d);p.style.opacity=unactiveKnobOpacity;d=""}):(f(q,"opacity",0,animateDuration,function(){q.parentNode.removeChild(q);q=""}),document.body.onkeypress=M,document.body.onkeydown=wasOnkeydown,document.body.style.overflow="auto")}function y(b,c){var a={position:"fixed",zIndex:"9985",opacity:unactiveKnobOpacity,cursor:"pointer"};switch(b){case "listLeft":a.top="50%";a.left="1%";a.color="gray";a.fontSize="80px";break;case "close":a.top="3%";a.right="3%";a.color="red";a.fontSize="50px";break;case "listRight":a.top="50%",a.right="1%",a.color="gray",a.fontSize="80px"}a=r("div",a,c);a.onmouseover=function(){a.style.opacity=activeKnobOpacity};a.onmouseout=function(){a.style.opacity=unactiveKnobOpacity};return a}function H(){z();1!=imagesList[e].s?A(imagesList[e].s,H):n=s("c");h=0<e?s("l"):"";k=e<imagesList.length-1?s("r"):""}function A(b,c){0==b?(m='<img src="http://l.yimg.com/g/images/progress/balls-24x12-black.gif