Skip to content

Instantly share code, notes, and snippets.

View edjafarov's full-sized avatar

Eldar Dzhafarov edjafarov

View GitHub Profile
@edjafarov
edjafarov / index.js
Last active August 29, 2015 14:07
requirebin sketch
var splitPolygon = require("split-polygon")
var glmatrix = require("gl-matrix")
var mat4 = glmatrix.mat4
var trimesh = grid_mesh({width:100,height:100});
var result = "";
result+='<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512"version="1.1">';
result+=renderComplex(trimesh.faces, trimesh.positions, {
view: mat4.lookAt(mat4.create(), [5, 10, 20], [5,0,0], [2,0,2]),
@edjafarov
edjafarov / index.js
Created October 14, 2014 07:12
requirebin sketch
var bunny = require("bunny")
var mat4 = require("gl-matrix").mat4
var render = require("svg-3d-simplicial-complex")
var result = "";
result +='<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512"version="1.1">';
result +=render(bunny.cells, bunny.positions, {
view: mat4.lookAt(mat4.create(), [5, 10, 20], [0,2,0], [0,1,0]),
projection: mat4.perspective(mat4.create(),
Math.PI/4.0,
@edjafarov
edjafarov / gist:08d0d236008b34ea339d
Last active August 29, 2015 14:10
common Actions
var Emitter = require('events').EventEmitter;
var Actions = {
create: function(actionName){
var sequence = [];
sequence.push([function(result){
this.emit(result);
}]);
Actions[actionName] = function(params){
params._emitted = false;
params.emit = function(result){
The Grail: React based Isomorph apps framework
Since Nodejs came into my life the idea of architecture that would allow me to build SPA apps that would render on server as well as on client. With Grail, Reactjs and React router this is possible right now without any side effects and with any kind of backend API.
https://github.com/edjafarov
eldar.djafarov.com
ua.linkedin.com/in/edjafarov
фоточка
https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-xpf1/t31.0-8/10369001_1385006371760316_9052772355397827709_o.jpg
@edjafarov
edjafarov / index.js
Created April 23, 2015 14:03
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var Emitter = require('component-emitter');
var ItemsStore = Emitter({
data: [{
name: "Skynet",
description: "Superior artificial intelligence"
}],
init: function(context){
@edjafarov
edjafarov / index.js
Created April 24, 2015 06:06
requirebin sketch
var PromisePipe = require('promise-pipe')();
PromisePipe.use('add', function(data, context, num){
return data + num;
})
var result = PromisePipe().add(5).then(think(1000)).add(10).then(showResult);
@edjafarov
edjafarov / index.js
Created August 10, 2015 13:16
requirebin sketch
var console = require("consoleit");
var PromisePipe = require("promise-pipe")();
var action = PromisePipe();
action(1).then(showResult);
function showResult(result){
console.log(result)
}
@edjafarov
edjafarov / index.js
Last active August 29, 2015 14:27
requirebin sketch
var console = require("consoleit");
var PromisePipe = require("promise-pipe")();
PromisePipe.use('reverse', function reverse(data){
if(!Array.isArray(data)) return Promise.reject(new Error('Data is not an Array'));
return data.reverse();
});
PromisePipe.use('map', function map(data, context, mapFunction){
if(!Array.isArray(data)) data = [data];
@edjafarov
edjafarov / index.js
Created August 15, 2015 06:59
requirebin sketch
var console = require("consoleit");
var work = require('webworkify');
var PromisePipe = require("promise-pipe")();
if(typeof(window) !== "undefined"){
var w = work(require('index.js'));
w.addEventListener('message', function (ev) {
console.log(ev.data);
});
@edjafarov
edjafarov / echoHttpRequest.js
Last active September 25, 2015 07:35
worker-test
module['exports'] = function(hook){
var Promise = require('promise');
var globalHandler = {};
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
module.exports = {
ClientToHookStream: function Stream(hookUrl, fetchFn){
var fetchFn = fetchFn || fetch;
var StreamHandler=null;
return {