Skip to content

Instantly share code, notes, and snippets.

View phobal's full-sized avatar
🏠
WFH

phobal phobal

🏠
WFH
View GitHub Profile

delete all node_modules folder in your pc, also you can assign a folder, just instead of .

$ find . -name \"node_modules\" -type d -prune -exec rm -rf '{}' \;
const a = {
a: 'a'
};
const obj = {
getThis: () => this,
getThis2 () {
return this;
}
};
@phobal
phobal / styled-components-ts.ts
Last active December 8, 2020 02:39
在 styled-components 中使用 TS 示例
import styled from 'styled-components'
export const Wrapper = styled.div<{ paddingLeft?: number }>`
padding: 28px 20px 0
${(props) => (props?.paddingLeft === 0 ? 0 : props?.paddingLeft || 32)}px;
min-height: 500px;
box-shadow: 0px 2px 4px 0px rgba(110, 122, 125, 0.3);
border-radius: 2px;
`
@phobal
phobal / forAwaitOf.js
Created September 25, 2020 08:23
使用 for await ...of 实现倒计时功能
// 在线 demo: https://repl.it/@phobal/forAwaitOf#index.js
let i = 60;
const items = Array(i)
.fill()
.map((_, i) => (i + 1) * 1000);
function somethingAsync(time) {
return delay(time).then(() => Promise.resolve(i--));
@phobal
phobal / socks5-zsh.sh
Last active September 25, 2020 08:26
如何让 Mac 终端走 SS 代理
# cd ~/.zshrc 添加如下配置
# 终端使用科学上网配置
# 开启,这里的端口号根据系统上 SS 软件的端口号为准
alias ss='export all_proxy=socks5://127.0.0.1:1086'
# 关闭
alias unss='unset all_proxy'
# source .zshrc
# 需要使用的时候执行 ss
@phobal
phobal / x-switch.js
Created September 5, 2019 14:02
x-switch 配置
{
// Use IntelliSense to learn about possible links.
// Type `rule` to quick insert rule.
// 输入 rule 来快速插入规则
// For more information, visit: https://github.com/yize/xswitch
"proxy": [
// gitlab IP 代理
[
"http://172.16.17.29",
"http://172.16.11.30:3001"
@phobal
phobal / tsconfig.json
Last active February 4, 2024 08:27
tsconfig.json 配置项说明
{
"compilerOptions": {
/* 基本选项 */
"target": "es5", // 指定 ECMAScript 目标版本: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'("ESNext"表示最新的ES语法,包括还处在stage X阶段)
"module": "commonjs", // 指定使用模块: 'commonjs', 'amd', 'system', 'umd' or 'es2015'
"lib": [], // 指定要包含在编译中的库文件
"allowJs": true, // 允许编译 javascript 文件
"checkJs": true, // 报告 javascript 文件中的错误
"jsx": "preserve", // 指定 jsx 代码的生成: 'preserve', 'react-native', or 'react'
"declaration": true, // 生成相应的 '.d.ts' 文件
@phobal
phobal / json
Created July 22, 2019 08:56
geojson
{
"type": "FeatureCollection",
"name": "55-geojson",
"crs": {
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"features": [
@phobal
phobal / convert-params.js
Last active September 25, 2020 08:29
类似 query-string 的简单实现
const elements = {
name: 'phobal',
dd: null,
age: 18,
sex: undefined,
};
let params = []
Object.keys(elements).forEach((key) => {
if (elements[key]) {
params.push(`${key}=${elements[key]}`)
@phobal
phobal / sketch.sh
Created December 29, 2018 03:02
free use sketch
#!/bin/bash
date 0102030405
# open /Applications/Sketch.app
open /Applications/Sketch.app
# open ~/Downloads/Sketch.app
ntpdate -u time.apple.com