Skip to content

Instantly share code, notes, and snippets.

View FiumeHoo's full-sized avatar

Harmoni FiumeHoo

  • Chengdu, China
View GitHub Profile
@FiumeHoo
FiumeHoo / Algorithm.js
Last active May 24, 2023 08:37
Algorithm
// 欧几里得算法:求两个正整数的最大公约数,a >= b
function gcd(a, b) {
if (b === 0) {
return a
}
return gcd(b, a % b)
}
// String 相关
// 格式化金额
const thousandNum = num => num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') // 小数后三位也会被添加 ,
const money = thousandNum(1232453535) // '1,232,453,535'
const formatMoney = (money) => money.replace(new RegExp(`(?!^)(?=(\\d{3})+${money.includes('.') ? '\\.' : '$'})`, 'g'), ',')
formatMoney('123456789.123') // '123,456,789.123'
const currencyFormat = num => num.toString().replace(/\B(?=(\d{3})+(?=\.)(?!\d))/g, ',') // 只格式化小数点前的数字
var CryptoJS = require('crypto-js')
var request = require('request-promise')
/*
* npm install crypto-js request-promise request
* node wx_t1t_hack.js
*/
// export function testEncription(msg, fullKey) {
// var fullKey = fullKey.slice(0, 16)
@FiumeHoo
FiumeHoo / rAF.js
Created November 13, 2017 02:53 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];