View ripple-tx-validation-check-memo.md
// submit tx:
submitTx(signedTx, (err, res) => {
  if (err) throw err;
  // Check if `engine_result` is "tesSUCCESS": 
  if (res.engine_result !== "tesSUCCESS") {
    // the tx's failed immediately.
    return;
  }
  const txhash = res.tx_json.hash;
View ripple-understand-rippled-book_offers-request-response.md

Ripple: Understand rippled book_offers request & response

Request example (on TestNet)

{
  "id": 4,
  "command": "book_offers",
  "taker": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
  "taker_gets": {
    "currency": "XRP"
View WsClient.js
/*
websocket client module (supports either NodeJS and browser)
NOTE:
`browserify` makes this websocket client lib browser-compatible.
# Usage
```
const onmessage = function(e) {
console.log("onmessage:", e);
View RpcClient.js
// Simple JSON RPC Client
const request = require("request");
const requestAsync = require("request-promise");
// const axios = require("axios");
module.exports = class RpcClient {
constructor({
url,
jsonrpc = "2.0",
View getCounterwalletAddress.js
/*
* Usage:
* $ node ./getCounterwalletAddress.js "<livenet_or_testnet>" <derived_index> "<passphrase of 12 words>"
*/
const network = process.argv[2]; // "testnet" or "livenet"
const index = process.argv[3]; // derived address's index
const passphrase = process.argv[4]; // passphrase
// Mnemonic function inspired by:
// Mnemonic.js v. 1.0.0
View headlesschrome-puppeteer-example.js
const puppeteer = require('puppeteer');
const evaluateFn = async() => {
// const title = document.title; // by pure js
const title = $("title").text(); // by jquery
return {
title,
// width: document.documentElement.clientWidth,
// height: document.documentElement.clientHeight,
View read-write-transform-stream-example.js
const fs = require("fs");
const { Transform } = require('stream');
// upperCase transformer:
const upperCaseTr = new Transform({
transform(chunk, encoding, callback) {
this.push(chunk.toString().toUpperCase());
callback();
}
});
View markdown-for-blogger-monokai-like-code-highlight.html
<html>
...
<!-- for markdown -->
<script src="//cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<link rel='stylesheet' href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/styles/monokai.min.css" />
<script src='//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/highlight.min.js'></script>
<script
src="//code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha256-3edrmyuQ0w65f8gfBsqowzjJe2iM6n0nKciPUp8y+7E="
View async-await-sleep-loop.js
const sleep = msec => new Promise(resolve => setTimeout(resolve, msec));
async function hoge() {
var ret = "";
for (let len = 2, i = 0; i < len; i++) {
console.log("hoge loop ...");
ret += await foo();
}
return "HOGE!" + ret;
}
View localforage.example.js
<script src="node_modules/localforage/dist/localforage.nopromises.min.js">
// $ npm install --save localforage
</script>
<script>
const dbname = "mydb";
const opts = {
driver: localforage.INDEXEDDB, // localforage.WEBSQL, or localforage.LOCALSTORAGE
name: dbname
};
console.log("creating instance with opts:", opts);