This file contains hidden or 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
| /***************************************************************** | |
| * onMessage from the extension or tab (a content script) | |
| *****************************************************************/ | |
| chrome.runtime.onMessage.addListener( | |
| function(request, sender, sendResponse) { | |
| if (request.cmd == "any command") { | |
| sendResponse({ result: "any response from background" }); | |
| } else { | |
| sendResponse({ result: "error", message: `Invalid 'cmd'` }); | |
| } |
This file contains hidden or 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
| // How long it will take for finding your mining block | |
| // will be known from your 'hashrate' and the latest block's 'difficulty': | |
| etm = eth.getBlock("latest").difficulty / miner.hashrate; // estimated time in seconds | |
| Math.floor(etm / 3600.) + "h " + Math.floor((etm % 3600) / 60) + "m " + Math.floor(etm % 60) + "s"; | |
| // 1h 3m 30s | |
| // ref. https://ethereum.gitbooks.io/frontier-guide/content/mining_with_geth.html |
This file contains hidden or 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
| pragma solidity ^0.4.7; | |
| // ======================================================= | |
| // クラウドセール・コントラクトのおおまかな処理 | |
| // ======================================================= | |
| // + コンストラクタで独自コインの総量などを決定 | |
| // | |
| // + 出資者からの資金提供と引き換えに独自コインを渡す | |
| // |
This file contains hidden or 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
| pragma solidity ^0.4.7; | |
| // # テスト用パラメータ | |
| // | |
| // ## テスト・シチュエーション | |
| // - 受益者(臣民4)に利益供与(コインを送金)するかどうかを議会で決めます | |
| // | |
| // ## 登場人物のアドレス | |
| // - 初代皇帝(emperor): accounts[0] 0x4a1c11eaec40197beb6e8607ee61953e7d6d8731 | |
| // - 臣民1(subject1): accounts[1] 0x5855a19b64e1068a1edc39bb817647e16a1c57e7 |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Zaif WebSocket Stream API Example</title> | |
| </head> | |
| <body> | |
| <button id="btn-start">start</button> |
This file contains hidden or 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 Step = require("step"); | |
| function asyncFn(str, cb) { | |
| setTimeout(function() { | |
| let err = null; | |
| let result = " Hello " + str; | |
| return cb(err, result); // error-first style callback | |
| }, 1000); | |
| } |
This file contains hidden or 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 Step = require("step"); | |
| function genRandomError() { | |
| let i = Math.floor(Math.random() * 2) + 1; | |
| if (i === 1) { | |
| return Error("Error occured!"); | |
| } | |
| return "Success"; | |
| } |
This file contains hidden or 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 express = require('express'); | |
| var app = express(); | |
| // response header for sever-sent events | |
| const SSE_RESPONSE_HEADER = { | |
| 'Connection': 'keep-alive', | |
| 'Content-Type': 'text/event-stream', | |
| 'Cache-Control': 'no-cache', | |
| 'X-Accel-Buffering': 'no' | |
| }; |
This file contains hidden or 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
| { | |
| "libs": [ | |
| "browser", | |
| "jquery" | |
| ], | |
| "dontLoad": [ | |
| "node_modules/**", | |
| "**/*/bundle.js", | |
| "**/*/extlib/**" | |
| ], |
This file contains hidden or 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 Step = require("step"); | |
| Step( | |
| // | |
| // ** 1st Step: | |
| // | |
| function() { | |
| console.log("### 1st Step:"); | |
| let arr = ["aaa", "bbb", "ccc"]; | |
| let err, result; |