View example-create-shorthash.js
/**
* Create a short hash to **roughly** specify the accessed user's identity.
* The generated hash could be immutable only when either user's IP address and access date are same.
*
* CAUTION:
* NEVER use it for generate unique ID, it could NOT be unique!
*/
const crypto = require("crypto");
var text = "2018/04/01 xxx.xxx.xxx.xxx"; // "<Date> <IP>"
View example-read-write-mysql-blob.js
/*
DDL:
CREATE TABLE `bindata` (
`id` INT NOT NULL AUTO_INCREMENT,
`data` BLOB,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
*/
const fs = require("fs");
View example-data-uri-image-write-read.js
const fs = require('fs');
const dataUri = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
const outputFilename = "output";
writeImage(dataUri, outputFilename);
readImage(outputFilename + ".png");
function writeImage(dataUri, outputFilename) {
const regex = /^data:.+\/(.+);base64,(.*)$/;
View generate-keypair-pem-by-openssl.md

Generate a private/public key pem file

# First, create a file as random seed, written as you like:
$ echo "<input_many_charactors_for_random_seed>" > random.txt

# Generate a private key:
$ openssl genrsa -rand random.txt 2048 > private.pem

# Generate a public key from above private key:
View background.js
console.log("background");
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.create({
'url': chrome.extension.getURL('popup.html')
}, function(tab) {
// Tab opened.
});
});
View q-reader.js
/**
QRcode reader library
@author: akirattii <tanaka.akira.2006@gmail.com> (http://mint.pepper.jp)
@dependencies:
+ jquery
+ vue.js
+ jsqrcode
- https://github.com/LazarSoft/jsqrcode
View purejs-fire-event-example.js
const el = document.qeurySelector("#input-x");
// Fire `input` event:
el.dispatchEvent(new Event('input', {
'bubbles': true,
'cancelable': true
}));
// or
View server.js
/*
Run server by forever with `--killSignal=SIGTERM`:
```
$ forever --killSignal=SIGTERM start ./server.js
```
Now `gracefulShutdown` function is called when you stop the server by `forever stop`:
```
View form-validator.js
/*
Simple Form Validator
@dependencies: vue.js, bootstrap4
@see: https://gist.github.com/akirattii/83937626062fc38f8f1ac5c91f172e72
# Usage
Code html:
First, load `FormValidator` after vue loaded:
```
View example-call-bitcoind.js
//
// An example of a bitcoind JSON RPC request.
//
// Example request of curl:
// $ curl --data-binary '{"jsonrpc": "1.0", "id":"hoge", "method": "getblockhash", "params": [9999] }' http://rpc:rpc@127.0.0.1:18332/
//
const URL = "http://rpc:rpc@127.0.0.1:18332"; // bitcoind testnet. user:"rpc", password:"rpc"
const RpcClient = require("./rpc-client.js");