#参考资料
###下载单个文件,默认将输出打印到标准输出中(STDOUT)中
curl http://www.centos.org
| // 判断当前访问者的客户端设备类型、操作系统及浏览器类型 | |
| function jupmBrowserType() { | |
| var browser = { | |
| versions: function () { | |
| var u = navigator.userAgent, app = navigator.appVersion; | |
| return { // 客户端浏览器版本信息 | |
| trident: u.indexOf('Trident') > -1, // IE内核 | |
| webKit: u.indexOf('AppleWebKit') > -1, // 苹果、谷歌内核 | |
| mobile: !!u.match(/AppleWebKit.*Mobile.*/), // 是否为移动终端 | |
| android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, // android终端或者uc浏览器 |
#参考资料
###下载单个文件,默认将输出打印到标准输出中(STDOUT)中
curl http://www.centos.org
| var lastTime = 0; | |
| var prefixes = 'webkit moz ms o'.split(' '); //各浏览器前缀 | |
| var requestAnimationFrame = window.requestAnimationFrame; | |
| var cancelAnimationFrame = window.cancelAnimationFrame; | |
| var prefix; | |
| //通过遍历各浏览器前缀,来得到requestAnimationFrame和cancelAnimationFrame在当前浏览器的实现形式 | |
| for( var i = 0; i < prefixes.length; i++ ) { | |
| if ( requestAnimationFrame && cancelAnimationFrame ) { |
| #!/usr/bin/python | |
| # -*- coding: UTF-8 -*- | |
| import json | |
| def readHarFile(): | |
| hostList = [] | |
| outputPath = '' | |
| filePath = raw_input('输入文件路径+名字:') |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"> | |
| <title>移动端图片压缩上传demo</title> | |
| <style> | |
| *{margin: 0;padding: 0;} | |
| li{list-style-type: none;} | |
| a,input{outline: none;-webkit-tap-highlight-color:rgba(0,0,0,0);} |
| #!/usr/bin/env bash | |
| set -x | |
| # Clear Application Saved States JetBrains | |
| rm -rfv ~/Library/Saved\ Application\ State/com.jetbrains.* | |
| # PhpStorm | |
| rm -fv /usr/local/bin/pstorm | |
| rm -rfv ~/Library/Preferences/WebIde?0 | |
| rm -rfv ~/Library/Caches/WebIde?0 |
| { | |
| // The plugin looks for a .jsbeautifyrc file in the same directory as the | |
| // source file you're prettifying (or any directory above if it doesn't exist, | |
| // or in your home folder if everything else fails) and uses those options | |
| // along the default ones. | |
| // Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options | |
| // Documentation: https://github.com/einars/js-beautify/ | |
| "html": { | |
| "allowed_file_extensions": ["htm", "html", "xhtml", "shtml", "xml", "svg"], |
| /** | |
| * 判断浏览器是否支持某一个CSS3属性 | |
| * @param {String} 属性名称 | |
| * @return {Boolean} true/false | |
| * @version 1.0 | |
| */ | |
| function supportCss3(style) { | |
| var prefix = ['webkit', 'Moz', 'ms', 'o'], | |
| i, |
大体的思路是,部分API的兼容性请参照caniuse:
blob对象,或者是file对象,将图片转化为data uri的形式。canvas,在页面上新建一个画布,利用canvas提供的API,将图片画入这个画布当中。canvas.toDataURL(),进行图片的压缩,得到图片的data uri的值步骤1当中,在进行图片压缩前,还是对图片大小做了判断的,如果图片大小大于200KB时,是直接进行图片上传,不进行图片的压缩,如果图片的大小是大于200KB,则是先进行图片的压缩再上传:
| function Middleware() { | |
| this.cache = []; | |
| this.options = null; // 缓存options | |
| } | |
| Middleware.prototype.use = function (fn) { | |
| if (typeof fn !== 'function') { | |
| throw 'middleware must be a function'; | |
| } | |
| this.cache.push(fn); |