Skip to content

Instantly share code, notes, and snippets.

View akirattii's full-sized avatar

Akira TANAKA akirattii

View GitHub Profile
@akirattii
akirattii / app.js
Created November 27, 2017 03:34
Example: Server-Sent Event (SSE) + expressjs
/*
0) start node app:
$ node app.js
1) start stream listening:
browse to http://localhost:3000/
2) stop stream listening:
browse to http://localhost:3000/stop
*/
@akirattii
akirattii / .bash_profile
Last active November 14, 2017 04:18
Basic of .bashrc and .bash_profile
source ~/.bashrc
@akirattii
akirattii / how-to-use-jquery-ui-with-browserify.md
Last active September 8, 2017 01:14
How to use `jquery` & `jquery-ui` as npm package to `browserify`.

Install jquery & jquery-ui:

$ npm install --save jquery jquery-ui

Install deamdify:

$ npm install --save-dev deamdify
@akirattii
akirattii / check-ripple-address-seed.js
Created August 12, 2017 09:28
Ripple: How to check if a ripple address (also seed) is valid or not
const crypto = require('crypto');
const hashjs = require('hash.js');
const baseCodec = require('base-x');
const codec = baseCodec("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"); // for ripple
// npm install --save ripple-keypairs ripple-binary-codec ripple-hashes
const Keypairs = require('ripple-keypairs');
// const Binary = require('ripple-binary-codec');
const {
computeBinaryTransactionHash
} = require('ripple-hashes');
@akirattii
akirattii / ShiftJISHankakuKanaToUnicode.js
Last active October 2, 2019 16:30
NodeJS: Shift_JISな半角カナのファイルを一行づつ読み込んで内容を正常に出力
const fs = require("fs");
const readline = require('readline');
const iconv = require('iconv-lite');
const readStream = fs.createReadStream("./shift_jis.txt", { encoding: "binary" });
const rl = readline.createInterface(readStream, {});
rl.on('line', function(line) {
// Shift_JIS => unicode:
console.log("line:", iconv.decode(new Buffer(line, "binary"), "Shift_JIS"));
@akirattii
akirattii / npm-install.sh
Created August 7, 2017 08:41
Use vue.js on Chrome extension development
npm install vue@csp --save
@akirattii
akirattii / select-where-in-field.sql
Created August 3, 2017 23:58
SQL: SELECT Result ordering of query "SELECT - WHERE - IN"
-- Use `ORDER BY FIELDS(<column>, <value>, <value>, ...)`
SELECT * FROM tbl
WHERE id IN (3, 1, 2)
ORDER BY FIELD(id, 1, 2, 3);
-- Returns records ordered by id ASC (order is id:1, id:2, id:3)
@akirattii
akirattii / master.js
Last active July 21, 2017 07:39
NodeJS: Clustering process using external js file (worker.js)
const cluster = require('cluster');
const numCPUs = require('os').cpus().length;
var tasks = [
"Dusting",
"Sweeping",
"Vacuuming",
"Washing dishes",
"Feeding pets",
"Doing laundry",
@akirattii
akirattii / ripple-cli.js
Last active April 19, 2018 13:41
Ripple: JSON RPC commandline tool for rippled. By just one command, you can invisible-sign locally for secure then submit signed tx immediately.
#!/usr/bin/env node
/**
* Ripple CLI tool
*
* The MIT License (MIT)
* Copyright (c) 2017 akirattii <tanaka.akira.2006@gmail.com> (http://mint.pepper.jp)
*/
/**
# Usage & example:
@akirattii
akirattii / CheckReCAPTCHA.js
Created June 29, 2017 05:11
reCAPTCHA middleware of express.js
/**
* reCAPTCHA checking middleware
*
* Usage:
* ```
* var checkReCAPTCHA = require("../middleware/CheckReCAPTCHA.js").checkReCAPTCHA;
* router.post('/hoge',
* checkReCAPTCHA(),
* function(req, res, next) {
* //