Jiangweixian, a front-end engineer
jiangweixian / cheatsheets Goto Github PK
View Code? Open in Web Editor NEWa cheatsheets app based on github
Home Page: https://jwxomcs.vercel.app
License: MIT License
a cheatsheets app based on github
Home Page: https://jwxomcs.vercel.app
License: MIT License
Jiangweixian, a front-end engineer
axios.interceptors.response.use(
function(response) {
// Any status code that lie within the range of 2xx cause this function to trigger
// Do something with response data
return response;
},
function(error) {
// Any status codes that falls outside the range of 2xx cause this function to trigger
// Do something with response error
const { config } = error
axios({ ...config, headers: { ...config.headers } })
return Promise.reject(error);
}
);
nvm alias default node
safe-area指的是真正内容显示区域。safe-area-inset-top是否有数值取决于
webview
,例如浏览器中safe-area-inset-top
可能就用不到
ip7 or below
指的是status-bar
部分。ipx or above
指的是刘海部分,包括status-bar
ipx or above
指的是下面的全面屏导航条lazy
的加载方式style
两个使用className={[styles.a, styles.b]}
而不是{ ...styles.a, ...styles.b }
git reset --hard <commit>
好处在于可以tsconfig的include可以支持补充类型
const ts = require('gulp-typescript')
const tsProject = ts.createProject('./tsconfig.json')
// use tsProject.src()
默认中心点 (0, 0, 0)
屏幕是一块8*8的栅栏, (0, -4, 0)代表的是屏幕最下边缘
相同的逻辑还表现在长度和宽度上面, 目前threejs 1unit代表的pixel数值还不太确定
in nuxt.config.ts
{
...
css: ['nprogress/nprogress.css']
...
}
alfred@4 self-use awesome workflows
拼音缩写翻译。可以在这里预览效果
https://github.com/TheColdVoid/nbnhhsh
http://www.packal.org/workflow/timezones-2
就是那个控制亮屏时间的小工具
http://www.packal.org/workflow/caffeinate-control
几种字符串类型的快速切换
https://github.com/gillibrand/alfred-change-case
快速的连接airpods(不知道新的macos支不支持快速切换)
https://github.com/jasonshanks/alfred-workflow-toggle-airpods
在finder中打开iterm,或者在iterm打开finder。和当前focus的finder or iterm窗口有关
https://github.com/LeEnno/alfred-terminalfinder
use wechat in alfred
https://github.com/MustangYM/WeChatExtension-ForMac
switch windows like context
https://github.com/mandrigin/AlfredSwitchWindows
encode with hash md5 etc..
https://github.com/willfarrell/alfred-hash-workflow
lorem words
https://www.packal.org/workflow/lorem-ipsum-0
show website info
https://github.com/leozhang2018/alfred-httpstat
show cheatsheet of command
https://github.com/cs1707/tldr-alfred
search emoji by word and content
https://github.com/sindresorhus/alfred-emoj
show color
http://www.packal.org/workflow/colors
devdocs search,搜索体验可能比不上dash,但是开源免费。
https://github.com/yannickglt/alfred-devdocs
show current ip info
https://github.com/zenorocha/alfred-workflows#ip-address-v120--download
open project in vscode
需要配置文件夹路径所在位置,可以通过设置变量方式实现 https://juejin.im/post/5d880368e51d4561c41fb906
show tranlate result in alfred
需要配合alfred-google-translate-config使用,国内请使用translate.cn,请关闭voice
设置trc en&zh-CN
复制通过cmd c
https://github.com/xfslove/alfred-google-translate
命令行的方式杀死软件
https://cloud.githubusercontent.com/assets/398893/14360276/6d2a33ba-fcaa-11e5-8fa5-4d3703a8129f.png
search pkg in alfred,支持多个平台比如npm等。
https://github.com/willfarrell/alfred-pkgman-workflow
base64
https://github.com/willfarrell/alfred-encode-decode-workflow/raw/master/screenshots/encode.png
https://github.com/willfarrell/alfred-encode-decode-workflow/raw/master/screenshots/encode.png
jamstack 是静态网站生成技术或者方案。提倡在build过程中获取api数据,并生成静态页面。和
spa
在使用过程中交互数据完全来自api
不同。同时jamstack
可以是混合的,例如一部分页面数据是通过build
中获取api
生成的,另外一部分也可以是页面交互动态变化的。其静态部分类似SSR
在第一次点击进行渲染类似。
\
无法直接定义
global.d.ts
。假设存在package rematch
,定义了namespace rematch
,那么可以在可以创建文件rematch.d.ts
,通过以下方式定义全局。
declare global {
export interface xx = {}
namespace NodeJS {
interface ProcessEnv {
NODE_ENV: boolean;
}
}
}
export {};
git remote add upstream https://github.com/original-repo/goes-here.git
git fetch upstream
git rebase upstream/master
refs: https://medium.com/@topspinj/how-to-git-rebase-into-a-forked-repo-c9f05e821c8a
setting
https://cards-dev.twitter.com/validator
, input you github repo urlpwd|pbcopy
Option Command C
npm
无法在npm.org 上删除一个包,只能够弃用。这种情况下,你仍旧可以下载,但是会在命令行看到错误信息。
npm deprecate [email protected] "balaba"
BUG: 理论上不指定版本能够deprecate全部版本,但是并没有成功
软优化,可以便于用于联系owner
npm owner add npm styled-cssgg // 添加npm作为owner
npm owner remove <username> styled-cssgg // 移除自己
setDownloading(true);
html2canvas(document.querySelector("#WEBGRADIENTS") as HTMLElement, {
onclone: () => {
setDownloading(false);
}
})
.then(canvas => {
// link是通过document创建的a标签
link.download = "pixel-crash.png";
link.href = canvas.toDataURL();
link.click();
})
.then(() => {
// do something
});
sudo nginx -s stop && sudo nginx
重启ngix// Add a request interceptor
axios.interceptors.request.use(
function(config) {
// Do something before request is sent
return config;
},
function(error) {
// Do something with request error
return Promise.reject(error);
}
);
// Add a response interceptor
axios.interceptors.response.use(
function(response) {
// Any status code that lie within the range of 2xx cause this function to trigger
// Do something with response data
return response.data;
},
function(error) {
// Any status codes that falls outside the range of 2xx cause this function to trigger
// Do something with response error
return Promise.reject(error);
}
);
Math.random() * 0xffffff
import dynamic from 'next/dynamic'
const S = dynamic(() => import('path'), { ssr: false })
ctrl+a
ctrl+e
ctrl+w
ctrl+u
in .zshrc
bindkey "\e\e[D" backward-word
bindkey "\e\e[C" forward-word
ctrl + <- or alt + <-
ctrl + -> or alt + ->
nvm alias default <node-version>
config zsh once and forever
plugins=(
git
z
zsh-autosuggestions
git-open
history
sudo
copyfile
copydir
git-extras
common-aliases
zsh-syntax-highlighting
osx
)
{
"skipLibCheck": true,
}
sudo scutil --set HostName "centauri"
渐变可以设置天空颜色。以下列举渐变的常见用法。
css
在html
上设置渐变sips -Z <size> <imagepath>
HOMEBREW_NO_AUTO_UPDATE=1 brew install <pkg>
Command Control space
Command Shift .
Fn+F5
在没有类型检查的
js
下相对容易,这里主要讨论的是ts
。
主要有两种方式。
因为命名空间合并的规则,同名的function
和namespace
定义会合并
export function a() {}
export namespace a {
export const b = b;
}
但是function
的写法无法在使用react.forwardref
之后和namespace
一起使用
in a.tsx
export const a = () => {};
in index.tsx
import { a as innera } from "./a";
import { b } from "./b";
type Innera = typeof innera;
interface a extends Innera {
b: typeof b;
}
const a = innera as a;
a.b = b;
export default a;
brew install unrar
unrar -x <path.rar>
npm --registry https://registry.npm.taobao.org install express
只是用h3 title
简单的两列布局
code
简单列出了第一步和第二步的文字
目前quote由于和h3 title没有办法很好的区分, 所以用法待定
强调的陈述说明
scene.toJSON()
配合 ObjectLoader 重现 threejs 网站的有用<mesh rotation={[]}>
设置旋转{
"include": ["xx.d.ts"]
}
关于更换appleid,官方其实讲的比较清楚的建议是,实现你应该退出你的所有账号。然后再登陆。如果你不小心在没有退出之后就更换了你appleid。可能会遇到无法删除mac上面的iCloud账号。
更换新的appleid
推出mac账号重新登陆
如果遇到iCloud无法重新登陆,且删除之后提示icloud已经存在。可以通过
defaults delete MobileMeAccounts
useTrail
npm run <script-in-dir> --prefix <dir>
为解决
brew update
在国区太慢的原因。但是并不推荐这么做,因为Github
加入了2FK
,更好的方式还是通过Surge
代理网络。
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
brew update --verbose
检查是否成功
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
git remote set-url origin https://github.com/homebrew/homebrew-cask
在[email protected]支持生成静态网站,同时也支持利用jamstack技术。因为这部分和SSR的某部分很像。
const IndexPage = ({ data }: { data?: number }) => {
return (
<Layout title="Home | Next.js + TypeScript Example">
<h1>Hello Next.js 👋</h1>
<p>
<Link href="/about">
<a>About {data}</a>
</Link>
</p>
</Layout>
)
}
export const getStaticProps: GetStaticProps = async () => {
return {
props: { data: 1 }
}
}
Command | Description |
---|---|
next build && next export |
生成静态页面 |
Command | Description |
---|---|
npm install server && cd out && serve -p 9000 |
预览 |
which node
sudo rm -rf /usr/local/bin/node
refs: nvm-sh/nvm#1184
allow pc
端同意手机的请求chro/ls
(charles会提示)下载证书, 安卓和iOS不同方式, 但是都需要信任证书有时你需要模拟真实环境才能够进行调试。特别是对于
hybrid
页面,以及客户端可能或许对ip
页面进行限制。以至于你不得不通过真实的的路由地址访问开发环境。
brew install nginx
config nginx in /usr/local/etc/nginx/nginx.config
server {
listen 80;
server_name 线上地址;
#charset koi8-r;
#access_log logs/host.access.log main;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
location / {
proxy_pass http://127.0.0.1:3000;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
charles(optional)
设置代理服务器主机名(ip), 设置服务器端口(8888)
{
"target": ["es2018"]
}
只和其他平台是否遵循通用的
web
协议有关
navigator.share({
title: document.title,
text: 'Hello World',
url: 'https://developer.mozilla.org',
}); // 分享MDN的URL
https://developer.mozilla.org/zh-CN/docs/Web/API/Navigator/share
React.HTMLAttributes<HTMLElement>
document.documentElement.style.setProperty('--color', '#52c41a')
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.