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
| #!/usr/local/bin/node | |
| const { execSync, exec, spawn, spawnSync } = require('child_process'); | |
| const { writeFileSync, unlinkSync } = require('fs'); | |
| process.on('uncaughtException', e => LogError(e)); | |
| const config = `/tmp/stunnel-${Date.now()}${Math.random()}.conf`; | |
| const port = parseInt(Math.random() * 20000) + 30000; | |
| let stunnel = null; | |
| const quiet = process.argv.indexOf("---Q") >= 0; | |
| const debug = !quiet && process.argv.indexOf("---D") >= 0; |
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
| window.execEx = function(fn, maxTime) { | |
| return new Promise(function (resolve, reject) { | |
| var timer = setTimeout(function () { | |
| if(timer) { | |
| timer = false; | |
| console.log('reject'); | |
| reject(); | |
| } | |
| }, maxTime); | |
| var f = function() { |
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
| public abstract class EnumClassUtils<TClass> | |
| where TClass : class | |
| { | |
| public static TEnum Parse<TEnum>(string value) | |
| where TEnum : struct, TClass | |
| { | |
| return (TEnum) Enum.Parse(typeof(TEnum), value); | |
| } |
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 SHAKE_THRESHOLD = 800; | |
| var last_update = 0; | |
| var x = y = z = last_x = last_y = last_z = 0; | |
| if (window.DeviceMotionEvent) { | |
| window.addEventListener('devicemotion', deviceMotionHandler, false); | |
| } else { | |
| alert('本设备不支持devicemotion事件'); | |
| } |
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
| let eventEmitter = require("events").EventEmitter; | |
| class EvHandler extends eventEmitter { | |
| constructor(process) { | |
| super(); | |
| let listener = this.onMessage.bind(this); | |
| process.on("message", listener); | |
| let clear = () => { | |
| this.cbs = null; | |
| this.removeAllListeners(); |
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 k = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1000]; | |
| var w = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety', 'Hundred', 'Thousand']; | |
| var wl = {}; | |
| var i, j, k, o; | |
| for (i = 0; i < w.length; i++) { | |
| wl[k[i].toString()] = w[i]; | |
| } | |
| var mx = 1000; |
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
| /* | |
| I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace | |
| so it's better encapsulated. Now you can have multiple random number generators | |
| and they won't stomp all over eachother's state. | |
| If you want to use this as a substitute for Math.random(), use the random() | |
| method like so: | |
| var m = new MersenneTwister(); |
NewerOlder