Skip to content

Instantly share code, notes, and snippets.

View xiaok's full-sized avatar

yixin xiaok

  • tokyo, Japan
View GitHub Profile
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);
@0x62
0x62 / RpcApi.js
Created September 4, 2021 13:42
Hacky workaround
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 })
@ShenXuGongZi
ShenXuGongZi / Popobox-debian
Created November 13, 2013 02:54
泡泡云 29元安炸那个debian
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
打包:
@chemzqm
chemzqm / client.js
Created October 23, 2013 10:44
后端导出svg为png到前端, image.js为express路由,rasterize.js为phantomjs运行文件,client.js为前端发送请求生成png文件请求的代码
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;
@leizongmin
leizongmin / simple-mysql-pool.js
Created August 14, 2013 07:13
简单的MySQL连接池
/**
* Simple MySQL Pool
*
* @author 老雷<[email protected]>
*/
var util = require('util');
var events = require('events');
var mysql = require('mysql');
var debug = require('debug')('my:mysql');
@xiaojue
xiaojue / events.js
Created November 27, 2011 04:53
nodejs custom events
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);
});
}