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 => { |
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)); | |
}; |
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)); |
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; |
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; | |
} |
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 |
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/ |
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); |
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> |
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