Skip to content

Instantly share code, notes, and snippets.

View ryanlid's full-sized avatar
🎯
Focusing

ryanlid ryanlid

🎯
Focusing
View GitHub Profile
@ryanlid
ryanlid / m.js
Created September 12, 2016 16:34
判断浏览器的 ua ,如果是移动端,链接跳转至子目录
(function () {
if (navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)) {
location.href = 'm/index.html#type'
}
})();
@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 / 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 / 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 / index.html
Created March 30, 2017 01:23
移动端 header
<!DOCTYPE html >
<html>
<head lang="zh-CN">
<meta charset="UTF-8">
<!-- 优先使用 IE 最新版本和 Chrome -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<!-- 为移动设备添加 viewport -->
<meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<!-- 添加到主屏后的标题(iOS 6 新增) -->
<meta name="apple-mobile-web-app-title" content="">
@ryanlid
ryanlid / cloudSettings
Last active March 18, 2022 13:25
Visual Studio Code Sync Settings Gist
{"lastUpload":"2022-03-18T13:25:24.317Z","extensionVersion":"v3.4.3"}
@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 {