View gist:ac1304e61380de22045105520e6007d6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const Rx = require('rxjs'); | |
const createStore = (reducer, initialState = {}) => { | |
const action$ = new Rx.Subject(); | |
let currentState = initialState; | |
const store$ = action$.startWith(initialState).scan(reducer).do( | |
state => { |
View gist:2b8e30ef03fb69f26f9a038e6199b71c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Rx = require('../../'); | |
const fs = require('fs'); | |
const t = require('transducers-js'); | |
const R = require('ramda'); | |
const _ = require('lodash'); | |
const mappingReducer = f => reducer => (result, input) => { | |
//console.log('enter mappingReducer', result, input); | |
return reducer(result, f(input)); | |
}; |
View gist:39a10055509fd3e7b193f72b03b831dd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Rx = require('../../'); | |
const fs = require('fs'); | |
const t = require('transducers-js'); | |
const source = Rx.Observable.range(1, 10000); | |
const increment = x => x + 1; | |
const isEven = x => (x % 2 === 0); | |
const startTime = new Date(); | |
const transducer = t.comp(t.map(increment), t.filter(isEven)); |
View gist:29af75aeca49b88b7ce866c83eb3c481
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.flatMap = function(lambda) { | |
return [].concat.apply([], this.map(lambda)); | |
}; | |
const r = [1, 2, 3].flatMap(x => { | |
var arr = new Array(x); | |
for (var i=0; i<arr.length; ++i) { | |
arr[i] = x; | |
} | |
return arr; |
View applicative
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.ap = function(wrappedVals) { | |
var results = []; | |
this.map( (f)=> { | |
const mr = wrappedVals.map(f); | |
results = results.concat(mr); | |
}); | |
return results; | |
} |
View 0_reuse_code.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
View gist:aa87a28adfb00220f169
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p ~/Downloads | |
cd ~/Downloads | |
sudo yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker | |
wget -O v1.8.1.2.tar.gz https://github.com/git/git/archive/v1.8.1.2.tar.gz | |
tar -xzvf ./v1.8.1.2.tar.gz | |
cd git-1.8.1.2/ |
View storm with publish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mqtt = require('mqtt'); | |
var port = 1883; | |
var host = 'localhost'; | |
var options = { | |
username: 'my_username', | |
password: 'my_password', | |
clientId: 'my_client_id' | |
}; | |
var client = mqtt.createClient(port, host, options); |
View dev.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *> | |
ServerName xxx.xxx.com | |
DocumentRoot "/var/www/html" | |
DirectoryIndex index.php | |
SetEnv XXX_ENV "development" | |
</VirtualHost> |
View .htaccess
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DirectoryIndex index.php | |
RewriteEngine on | |
RewriteCond $1 !^(index\.php|img|style|js|robots\.txt|favicon\.ico) | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA] |
NewerOlder