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 fs = require("fs"); | |
const shuffle = (array) => { | |
let currentIndex = array.length, | |
randomIndex; | |
// While there remain elements to shuffle... | |
while (currentIndex != 0) { | |
// Pick a remaining element... | |
randomIndex = Math.floor(Math.random() * currentIndex); |
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
import { ethers } from 'ethers' | |
class RpcApi { | |
constructor({ endpoint, address, abi }) { | |
this._endpoint = endpoint | |
this._address = null | |
this._abi = null | |
this._id = 0 | |
if (abi && address) this.setContract({ address, abi }) |
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
Debian with Popobox v1.0 | |
原文链接:http://pear.xiaojiublog.net/2013/11/debian-with-popobox-v1-0/ | |
## 部分内容由 felix021 修正、简化 ## | |
1: 制作Debian系统 | |
mkdir chroot && cd chroot | |
sudo debootstrap --foreign --arch=armel wheezy debian http://ftp.debian.org/debian | |
打包: |
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 chart = highchart(this.el, opts).highcharts(); | |
var svg = chart.getSVG(); | |
request | |
.post('/image') | |
.send({ | |
xml: svg | |
}) | |
.set('Accept', 'application/json') | |
.end(function(err, res) { | |
if(err) throw err; |
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
/** | |
* Simple MySQL Pool | |
* | |
* @author 老雷<[email protected]> | |
*/ | |
var util = require('util'); | |
var events = require('events'); | |
var mysql = require('mysql'); | |
var debug = require('debug')('my:mysql'); |
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 events=function(){ | |
this.map={}; | |
}; | |
events.prototype={ | |
emit:function(eventname,args){ | |
if(this.map[eventname]){ | |
this.map[eventname].forEach(function(fn){ | |
fn.apply(this,args); | |
}); | |
} |