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
| function go(func){ | |
| let gen = func() | |
| function next(data){ | |
| if(!data.done) data.value.next(dt => next(gen.next(dt))) | |
| } | |
| return next(gen.next()) | |
| } |
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 http = require('http'); | |
| const fs = require('fs'); | |
| const parseUrl = require('url').parse; | |
| const extname = require('path').extname; | |
| const joinPath = require('path').join; | |
| const Mimes = { | |
| ".html": "text/html", | |
| ".css": "text/css", | |
| ".js": "application/x-javascript", |
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
| function ttkUpload(file, token, cb){ | |
| // file = input[type=file] | |
| var url = "http://up.imgapi.com/"; | |
| var fd = new FormData(), xhr = new XMLHttpRequest(); | |
| var f = file.files[0]; | |
| fd.append('file', f); | |
| fd.append('Token', token); | |
| xhr.open("POST", url, true); | |
| xhr.onreadystatechange = function(){ | |
| if(xhr.readyState == 4 && xhr.status == 200){ |
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 tty = require('tty'); | |
| var styles = { | |
| 'bold': ['\033[1m', '\033[22m'], | |
| 'italic': ['\033[3m', '\033[23m'], | |
| 'underline': ['\033[4m', '\033[24m'], | |
| 'inverse': ['\033[7m', '\033[27m'], | |
| 'black': ['\033[30m', '\033[39m'], | |
| 'red': ['\033[31m', '\033[39m'], | |
| 'green': ['\033[32m', '\033[39m'], |
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/bin/nodejs | |
| function showHelp(){ | |
| console.log('Usage: ipnum [ip] ...'); | |
| } | |
| function convert(ip){ | |
| if(typeof ip !== 'string') return false; | |
| if(!/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(ip)) return false; |