Skip to content

Instantly share code, notes, and snippets.

View jtyjty99999's full-sized avatar

Adams jtyjty99999

  • Tencent
  • Shenzhen China
View GitHub Profile
@jtyjty99999
jtyjty99999 / parseUrl
Created March 25, 2014 05:27
另类解析url
function parseURL(url) {
var a = document.createElement('a');
a.href = url;
return {
source: url,
protocol: a.protocol.replace(':',''),
host: a.hostname,
port: a.port,
query: a.search,
params: (function(){
<!doctype html>
<html>
<head>
<!-- Run in full-screen mode. -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Make the status bar black with white text. -->
<meta name="apple-mobile-web-app-status-bar-style" content="black">
var urlparse = require('url').parse
, http = require('http')
, fs = require('fs');
function upload(url, uploadfile, callback) {
var urlinfo = urlparse(url);
var options = {
method: 'POST',
host: urlinfo.host,
path: urlinfo.pathname
var http = require('http'),
url = require('url'),
path = require('path'),
fs = require('fs'),
config = require('./config.js')
var PORT = config.PORT;
var server = http.createServer(function (request, response) {
response.setHeader("Server", "ICBUNBSERVER");
var url = require("url");
var fs = require("fs");
var path = require("path");
var mime = require("./mime").types;
var config = require("./config");
var utils = require("./utils");
var zlib = require("zlib");
var staticHandler = function () {};
var nodeStatic = require('node-static').Server;
var request = require("request");
var dns = require("dns");
var fileServer = new nodeStatic("./");
var http = require("http");
var httpServer = http.createServer(function(req, res) {
req.addListener('end', function() {
fileServer.serve(req, res, function(err, result) {
if (err && (err.status === 404)) {
@jtyjty99999
jtyjty99999 / color
Last active July 18, 2017 02:11
控制台输出彩色字符
/**
* 获得带颜色转义字符的控制台输出模板.
* @param {String}tmpl 包含标签的模板字符串
* @param {boolean}isBright 是否高亮,default false
* @return {String}
* @public
*/
function getRichTmpl(tmpl, isBright){
if(typeof tmpl == 'object'){ return tmpl; }
@jtyjty99999
jtyjty99999 / worker.js
Created August 11, 2014 03:49
跨域webworker
function XHRWorker(url, ready, scope) {
var oReq = new XMLHttpRequest();
oReq.addEventListener('load', function() {
var worker = new Worker(window.URL.createObjectURL(new Blob([this.responseText])));
if (ready) {
ready.call(scope, worker);
}
}, oReq);
oReq.open("get", url, true);
oReq.send();
@jtyjty99999
jtyjty99999 / save as
Created September 23, 2014 04:38
save as
function saveAs(blob, filename) {
var type = blob.type;
var force_saveable_type = 'application/octet-stream';
if (type && type != force_saveable_type) { // 强制下载,而非在浏览器中打开
var slice = blob.slice || blob.webkitSlice;
blob = slice.call(blob, 0, blob.size, force_saveable_type);
}
var url = URL.createObjectURL(blob);
var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
@jtyjty99999
jtyjty99999 / iebase64.js
Created September 23, 2014 07:58
ie base64
var x= new ActiveXObject("Msxml2.XMLHTTP.6.0");
x.onreadystatechange=function(){
if(x.readyState<4)return;
var xml_dom = new ActiveXObject("MSXML2.DOMDocument");
var tmpNode = xml_dom.createElement("tmpNode");
tmpNode.dataType = "bin.base64";
tmpNode.nodeTypedValue = x.responseBody;
base64string=tmpNode.text.replace(/\n/g,"");
document.write("<img src=\"data:image/bmp;base64,"+base64string+"\">")