import hashlib# Hash pairs of items recursively until a single value is obtained
def merkle(hashList):| // connect() is a function that injects Redux-related props into your component. | |
| // You can inject data and callbacks that change that data by dispatching actions. | |
| function connect(mapStateToProps, mapDispatchToProps) { | |
| // It lets us inject component as the last step so people can use it as a decorator. | |
| // Generally you don't need to worry about it. | |
| return function (WrappedComponent) { | |
| // It returns a component | |
| return class extends React.Component { | |
| render() { | |
| return ( |
| const Rx = require('rx') | |
| const action$ = new Rx.Subject() | |
| const initState = 0 | |
| const reducer = (state, action) => { | |
| switch (action.type) { | |
| case 'INC': | |
| return state + action.payload | |
| default: | |
| return state |
| import { createStore, applyMiddleware } from 'redux' | |
| import thunk from 'redux-thunk'; | |
| function reducer(state, action) { | |
| if (typeof state === 'undefined') { | |
| return 0 | |
| } | |
| switch (action.type) { | |
| case 'INCREMENT': |
| const reducer = ((state = 0, action) => { | |
| switch (action.type) { | |
| case 'INCREMENT': return state + 1 | |
| case 'DECREMENT': return state - 1 | |
| default: return state | |
| } | |
| }) | |
| const initialState = { | |
| count: 0 |
| /** | |
| this is from the Redux createStore() | |
| /** | |
| * Interoperability point for observable/reactive libraries. | |
| * @returns {observable} A minimal observable of state changes. | |
| * For more information, see the observable proposal: | |
| * https://github.com/tc39/proposal-observable | |
| */ | |
| function observable() { | |
| const outerSubscribe = subscribe |
import hashlib# Hash pairs of items recursively until a single value is obtained
def merkle(hashList):| namespace Sagas | |
| { | |
| using System; | |
| using System.Collections.Generic; | |
| class Program | |
| { | |
| static ActivityHost[] processes; |
| # update the host | |
| apt-get update && apt-get upgrade -y # && apt-get dist-upgrade -y && apt-get autoremove --purge -y && apt-get autoclean -y | |
| # https://www.stgraber.org/ | |
| # install linux containers | |
| sudo apt-get install lxc | |
| # list all containers and view their current status | |
| sudo lxc-ls -f |
| /** | |
| * echo server | |
| * | |
| */ | |
| var net = require('net'), | |
| port = 5000, | |
| unixsocket = '/tmp/echo.sock'; | |
| var log = function(who, what) { |
| /** | |
| * Deep diff between two object, using lodash | |
| * @param {Object} object Object compared | |
| * @param {Object} base Object to compare with | |
| * @return {Object} Return a new object who represent the diff | |
| */ | |
| function difference(object, base) { | |
| function changes(object, base) { | |
| return _.transform(object, function(result, value, key) { | |
| if (!_.isEqual(value, base[key])) { |