Skip to content

Instantly share code, notes, and snippets.

View ryanlid's full-sized avatar
🎯
Focusing

ryanlid ryanlid

🎯
Focusing
View GitHub Profile
@ryanlid
ryanlid / webpack.config.js
Created October 28, 2016 05:38 — forked from learncodeacademy/webpack.config.js
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
var add = function(a,b){
return a + b;
};
/* 方法调用模式 */
// 创建myObject,它有一个 value 属性和一个 increment 方法。
// increment方法接受一个可选的参数。如果参数不是数字,那么默认使用数字1。
var myObject = {
value :0,
increment:function(inc){
this.value +=typeof inc ==='number'? inc:1;
@ryanlid
ryanlid / throw.js
Created November 4, 2016 03:23
异常处理
var add = function (a, b) {
if (typeof a !== 'number' || typeof b !== 'number') {
throw{
name: 'TypeError',
message: 'add needs numbers'
};
}
return a + b;
};
@ryanlid
ryanlid / apply.js
Last active November 5, 2016 00:47
函数 Apply调用模式
// apply 方法让我们构建一个参数数组传递给调用函数。它也允许我们选择this的值,apply方法接收两个参数,第一个是要绑定给this的值,第2个是一个参数数组。
var add = function(a,b){
return a+b;
}
var array = [];
var sum =add.apply(null,array);
console.log(sum); // sum == 7
@ryanlid
ryanlid / .editorconfig
Last active May 2, 2017 11:19
EditorConfig是一套用于统一代码格式的解决方案
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@ryanlid
ryanlid / node-install.sh
Created June 30, 2017 15:28
ubuntu install node 6.x
#!/bin/sh
sudo curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt update
sudo apt -y upgrade
sudo apt -y autoremove
@ryanlid
ryanlid / base.css
Created July 3, 2017 06:49
基本样式表
* {
box-sizing: border-box;
}
*:before,
*:after {
box-sizing: border-box;
}
body {
@ryanlid
ryanlid / index.html
Created September 22, 2017 15:19
启用HTTPS访问,禁用HTTP访问提示页
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>The HTTP access had been disabled!</title>
</head>
@ryanlid
ryanlid / google-fonts-proxy
Created November 17, 2017 02:34 — forked from gaoyifan/google-fonts-proxy
google-fonts-proxy
server {
listen 80;
listen 443;
listen [::]:80;
listen [::]:443;
server_name fonts.lug.ustc.edu.cn;
access_log /var/log/nginx/revproxy_access.log;
error_log /var/log/nginx/revproxy_error.log;