Skip to content

Instantly share code, notes, and snippets.

View michaelsbradleyjr's full-sized avatar
💭
Dip trip, flip fantasia 🎺

Michael Bradley michaelsbradleyjr

💭
Dip trip, flip fantasia 🎺
View GitHub Profile
/* global setTimeout */
(async () => {
const [iter, send, done] = (() => {
let promise;
let resolve;
const queue = [];
const setPromise = () => {
promise = new Promise(res => { resolve = res; });
@michaelsbradleyjr
michaelsbradleyjr / another.js
Last active September 2, 2019 20:37
Using IxJS batch with EventEmitter / RxJS Observable
/* global require setTimeout */
const {Subject} = require('rxjs');
const {tap: rxTap} = require('rxjs/operators');
const {AsyncIterableX: {from: ixFrom}} = require('ix/asynciterable');
const randomInt = (min, max) => Math.floor(Math.random() * (max + 1 - min)) + min;
const timer = ms => new Promise(resolve => setTimeout(resolve, ms));
const timedEffect = async (ms, effect) => { await timer(ms); effect(); };
const triangleNumber = n => n * (n + 1) / 2;
@michaelsbradleyjr
michaelsbradleyjr / machine.js
Last active August 2, 2019 17:16
Generated by XState Viz: https://xstate.js.org/viz
const machind = Machine({
id: 'command',
context: {},
initial: 'starting',
states: {
starting: {
type: 'parallel',
states: {
A: {
initial: 'starting',
@michaelsbradleyjr
michaelsbradleyjr / machine.js
Last active August 2, 2019 00:57
Generated by XState Viz: https://xstate.js.org/viz
/* global Machine XState actions assign interpret raise send sendParent
setTimeout spawn window */
// in starting, want services to initially go to checking and if not auto start then go to stopped
// in starting, want failed to have a null event that checks if can fail; if it's okay to fail then go to stopped but don't send STOP event, otherwise send STOP event
// in running, want services to initially go to checking and if stopped then go to stopped otherwise go to running
// in runnin, when services goes to running should invoke the someserviceRunner which setups up duplex comm
// maybe can use null event with guard in starting/running instead of an explicit checking state but uncertain
// about interaction w/ invoke and entry, i.e. if null event condition is true then will invoke and/or entry not happen? need to experiment
$ cd dapps/templates/demo
$ embark test
Compiling contracts
Compilation done
SimpleStorage
1) should set constructor value - [0 gas]
2) set storage value - [0 gas]
import { Subject, fromEventPattern, merge } from "rxjs";
import { takeUntil } from "rxjs/operators";
// Implementation
// see: https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#deploy
// -----------------------------------------------------------------------------
const CONFIRMATION = "confirmation";
const CONTRACT = "contract";
const ERROR = "error";
@michaelsbradleyjr
michaelsbradleyjr / test-error.md
Created March 30, 2019 01:37
test error output
embark-dapp-test-contracts: (node:3228) UnhandledPromiseRejectionWarning: Error: async.auto task `AnotherStorage` has a non-existent dependency `SimpleStorage` in SimpleStorage
embark-dapp-test-contracts:     at D:\a\1\s\node_modules\async\dist\async.js:1553:23
embark-dapp-test-contracts:     at arrayEach (D:\a\1\s\node_modules\async\dist\async.js:1299:9)
embark-dapp-test-contracts:     at D:\a\1\s\node_modules\async\dist\async.js:1551:9
embark-dapp-test-contracts:     at D:\a\1\s\node_modules\async\dist\async.js:1322:11
embark-dapp-test-contracts:     at baseForOwn (D:\a\1\s\node_modules\async\dist\async.js:1352:20)
embark-dapp-test-contracts:     at Object.auto (D:\a\1\s\node_modules\async\dist\async.js:1534:5)
embark-dapp-test-contracts:     at auto (D:\a\1\s\packages\embark\src\lib\modules\deployment\index.js:95:19)
embark-dapp-test-contracts:     at nextTask (D:\a\1\s\node_modules\async\dist\async.js:5324:14)
Navigated to the Transactions Explorer
Also applies to transactions widget in the Explorers Overview
21 blocks on the chain
have blocks #21 to #12 inclusive because fetched 10 blocks
#21 has 7 txs, #20 to #12 inclusive have 1 tx each
auto estimate #11 - #1 inclusive have 1 tx each and #0 has 0 tx
this.numberOfTxs should be 27
$ embark test
Compiling contracts
/Users/michael/repos/embark/test_dapps/packages/test_app/.embark/app/contracts/simple_storage_test.sol:25:17: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
function test(uint x) public {
^----^
/Users/michael/repos/embark/test_dapps/packages/test_app/.embark/app/contracts/simple_storage_test.sol:25:3: Warning: Function state mutability can be restricted to pure
function test(uint x) public {
modified src/lib/modules/blockchain_process/proxy.js
@@ -6,13 +6,25 @@ const {chain} = require('stream-chain');
const cloneable = require('cloneable-readable');
const constants = require('../../constants.json');
const express = require('express');
+const fs = require('../../core/fs');
const {parser} = require('stream-json');
-const proxyMiddleware = require('http-proxy-middleware');
const pump = require('pump');
const utils = require('../../utils/utils');