Skip to content

Instantly share code, notes, and snippets.

View sweet-zone's full-sized avatar
🎯
Focusing

DarkZone sweet-zone

🎯
Focusing
View GitHub Profile
@sweet-zone
sweet-zone / jumpjump.js
Created January 1, 2018 15:16
跳一跳刷分 Nodejs 版
const crypto = require('crypto')
const axios = require('axios')
const url = 'https://mp.weixin.qq.com/wxagame/wxagame_settlement'
const sessionId = 'your session id'
function getActionData(key, content, iv) {
const clearEncoding = 'utf8'
const cipherEncoding = 'base64'
let cipherChunks = []
/**
* 加密解密
*/
var crypto = require('crypto');
var _p = {};
/**
<!DOCTYPE html>
<!-- xlsx.js (C) 2013-present SheetJS http://sheetjs.com -->
<!-- vim: set ts=2: -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>JS-XLSX Demo</title>
</head>
<body>
<pre>
@sweet-zone
sweet-zone / mid.js
Created May 31, 2017 06:18
中间件
const app = {
callback (ctx) {
console.log(ctx)
},
use (fn) {
app.middleware = app.middleware || []
app.middleware.push(fn)
},
function _LazyMan(name) {
this.tasks = [];
var self = this;
var fn =(function(n){
var name = n;
return function(){
console.log("Hi! This is " + name + "!");
self.next();
}
@sweet-zone
sweet-zone / promise-sequence.js
Created February 15, 2017 07:57
promise 顺序执行
// promise 和 reduce
(function() {
function sequenceTasks(tasks) {
function recordValue(results, value) {
results.push(value);
return results;
}
@sweet-zone
sweet-zone / promise-all.js
Created February 15, 2017 07:56
Promise.all 同时执行多个任务
// http://stackoverflow.com/questions/30362733/handling-errors-in-promise-all
// https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise/all
(function() {
function randomNum(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
function upload(file) {
return new Promise(function(resolve, reject) {
@sweet-zone
sweet-zone / nodownload.js
Created February 15, 2017 05:01
Download file using nodejs
/**
* nodejs下载文件
*/
var fs = require('fs');
var url = require('url');
var http;
/**