Skip to content

Instantly share code, notes, and snippets.

Michael Bradley michaelsbradleyjr

Block or report user

Report or block michaelsbradleyjr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View send-to-iter.js
/* 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 Aug 8, 2019
Using IxJS batch with EventEmitter / RxJS Observable
View another.js
/* 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;
View machine.js
const machind = Machine({
id: 'command',
context: {},
initial: 'starting',
states: {
starting: {
type: 'parallel',
states: {
A: {
initial: 'starting',
View machine.js
/* 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
View gist:3655ab9242fb97aa00a6db8c4178491d
$ cd dapps/templates/demo
$ embark test
Compiling contracts
Compilation done
SimpleStorage
1) should set constructor value - [0 gas]
2) set storage value - [0 gas]
View ObservableDeployment.js
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";
View test-error.md
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)
View transactions-pagination.txt
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
View test_app_results.txt
$ 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 {
View proxy.diff
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');
You can’t perform that action at this time.