suweya / suweya.github.io Goto Github PK
View Code? Open in Web Editor NEWdaily repo
daily repo
echo $SHELL
Mac默认的shell是bash
oh my zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
首先查看主题地址:https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
sudo vim .zshrc
修改ZSH_THEME
查看所有的alias alias
添加alias alias cls='clear'
上面这样添加只是临时的,重启iTerm就没了
要永久保存就要在~/.zshrc 的文件末尾添加alias
clone zsh-autosuggestions
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
update .zshrc & add plugins
plugins=(zsh-autosuggestions git)
修改提示文字颜色
cd ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
vim zsh-autosuggestions.zsh
查找ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE
修改 ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=10'
brew install zsh-syntax-highlighting
.zshrc
文件,在文件末尾加入下面一行source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source ~/.zshrc
coreutils
brew install coreutils
// 继承抽象方法
function inherit(parent, child) {
function F() {};
F.prototype = parent.prototype;
var f = new F();
f.constructor = child;
child.prototype = f;
}
function Parent(name) {
this.name = name;
this.colors = ["BLUE"];
}
Parent.prototype.getName = function() {
console.log(this.name);
};
function Child(name, age) {
Parent.call(this, name);
this.age = age;
}
inherit(Parent, Child)
var child1 = new Child('suweya', 18)
浏览器缓存是前端优化一个重要的手段,今天在查看项目缓存的时候发现了一个问题,总结记录一下。
首先先把我发现的问题抛出来吧
看上图是一个vendor.17e42c484553da3d4116.js
脚本文件,没有配置强缓存的expires和cache-control
而刷新的话是直接from memory cahce
,也就是说它配置的是协商缓存,而没有发起请求验证。
expires的值是一个绝对时间,是http1.0的功能。如果浏览器的时间没有超过这个expires的时间,代表缓存还有效,命中强缓存,直接从缓存读取资源。不过由于存在浏览器和服务端时间可能出现较大误差,所以在之后http1.1提出了cache-control。
协商缓存是无法减少请求数的开销的,但是可以减少返回的正文大小。一般来说,对于勤改动的html文件,使用协商缓存是一种不错的选择
简单说是贪婪匹配与非贪婪匹配的区别。
比如说匹配输入串A: 101000000000100
使用 1.*1 将会匹配到1010000000001, 匹配方法: 先匹配至输入串A的最后, 然后向前匹配, 直到可以匹配到1, 称之为贪婪匹配。
使用 1.*?1 将会匹配到101, 匹配方法: *匹配下一个1之前的所有字符, 称之为非贪婪匹配。
所有带有量词的都是非贪婪匹配: .*?, .+?, .{2,6}? 甚至 .??
function Parent(name) {
this.name = name;
this.colors = ['red', 'blue', 'green']
}
Parent.prototype.getName = function() {
console.log(this.name)
}
function Child(name, age) {
// 这是第一次调用
Parent.call(this, name)
this.age = age
}
// 这是第二次调用,我们要优化的就是这里
Child.prototype = new Parent()
Child.prototype.constructor = Child
var child = new Child('a', 1)
这是JS中最常见的继承方式
但是存在一个问题那就是Parent构造函数会被执行两次,此时child、Child.prototype和child.__proto__中都会存在color属性,如何避免Parent构造函数执行两次呢,就看看下面的继承方式吧。
function Parent(name) {
this.name = name
this.colors = ['red', 'blue', 'green']
}
Parent.prototype.getName = function() {
console.log(this.name)
}
function Child(name, age) {
// 这是第一次调用
Parent.call(this, name)
this.age = age
}
function F() {}
F.prototype = Parent.prototype
Child.prototype = new F()
Child.prototype.constructor = Child
var child1 = new Child('a', 1)
var Utils = (function (win) {
function createPrototype(origin) {
function F() {}
F.prototype = origin
return new F()
}
function extend(child, parent) {
var proto = createPrototype(parent.prototype)
proto.constructor = child
child.prototype = proto
}
return {
extend: extend
}
})(window)
module.exports = {
"globals": {
"$": true,
"jQuery": true
}
}
module.exports = {
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.$': 'jquery',
'window.jQuery': 'jquery'
})
]
}
document.addEventListener('DOMContentLaoded', function() {
// DOM Parse End
}, false)
window.onload = function() {
// all file download & parsed
}
DOM的渲染会等DOM树全部解析完才会开始,那么把js放在body下面和head不是一样的吗。但是现代浏览器都有预渲染的机制,也就是说浏览器可以渲染不完整的dom,那么我们把js放在body下面就可以预先渲染js之前的dom,然后js执行完成之后才会触发DOMContentLoaded
事件,接着浏览器下载图片等各种资源,下载完成后就会触发window.onload
事件
原来在生成SSH密钥的时候设置了密码,导致了现在GIt使用时都要输入密码,这就很烦了,下面的办法就可以让你去除密钥的密码了。
openssl rsa -in ~/.ssh/id_rsa -out ~/.ssh/id_rsa_new
mv id_rsa id_rsa_new
mv id_rsa_new id_rsa
chmod 600 id_rsa
"emmet.includeLanguages": {
"javascript": "javascriptreact"
},
"emmet.triggerExpansionOnTab": true
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.