Skip to content

Instantly share code, notes, and snippets.

View yorickshan's full-sized avatar
🎯
Focusing

Shan Yinlong yorickshan

🎯
Focusing
View GitHub Profile
@yorickshan
yorickshan / tailwindcss.md
Created March 27, 2023 09:09
Tailwind CSS 组件
### 1. Install ESLint & Prettier extensions for VSCode
Optional - Set format on save and any global prettier options
### 2. Install Packages
```
npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-config-airbnb-base eslint-plugin-node eslint-config-node
```
echo "export const host = '"`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`"';" > ./env.ts
@yorickshan
yorickshan / mac-setup-redis.md
Last active November 15, 2022 02:42 — forked from tomysmile/mac-setup-redis.md
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis // or redis-server
let clientIp
$.getJSON("https://api.ipify.org/?format=json", function(e) {
clientIp = e.ip;
});
// linux 获取内网地址
ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"
// mac 获取内网地址
ipconfig getifaddr en0

Object.prototype.toString()

var toString = Object.prototype.toString;

toString.call(new Date); // [object Date]
toString.call(new String); // [object String]
toString.call(Math); // [object Math]

//Since JavaScript 1.8.5

[element]:first-child 的着眼点在于 first-child

p:first-child先找到第一个子元素, 再看它是不是 p 元素, 是则匹配成功, 否则匹配失败

[element]:first-of-type 的着眼点在于 element

p:first-of-type直接去匹配子元素中的第一个 p 元素

类似选择器 :last-child 和 :last-of-type、:nth-child(n) 和 :nth-of-type(n) 也可以这样去理解

方法一: 两个行内元素都设置 vertical-align:middle;

方法二: 两元素设置浮动

方法三:不对齐原因是基线不对齐; 如果第一个div没有文字 加个字就可以