Skip to content

Instantly share code, notes, and snippets.

View banyudu's full-sized avatar
🎯
Focusing

Yudu banyudu

🎯
Focusing
View GitHub Profile
@banyudu
banyudu / extract_origin.js
Created December 17, 2017 01:17
Extracts origin from url
const extractOriginFromFullUrl = url => url.split('/', 3).join('/')
extractOriginFromFullUrl('http://www.example.com:8080/abc') // => http://www.example.com:8080
@banyudu
banyudu / global-npm-cli-tools.sh
Last active March 1, 2018 03:21
global npm cli tools
npm install -g \
trymodule \
eslint \
standard \
public-ip-cli \
internal-ip-cli \
is-up-cli \
clipboard-cli \
wifi-password-cli \
gh-home \
{
"Version": "2008-10-17",
"Id": "http better policy",
"Statement": [
{
"Sid": "readonly policy",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket/*"
@banyudu
banyudu / opensslv.h
Created December 31, 2016 03:44
Unable to find 'openssl/opensslv.h'
sudo apt install libssl-dev
@banyudu
banyudu / cors.ts
Created March 18, 2019 05:08
Lambda code of cors service
import axios from 'axios'
export const get = async (event: any, context: any, callback: any) => {
const parameters = Object.keys(event.queryStringParameters)
if (parameters.length !== 1) {
callback(null, {
statusCode: 400
})
}
const url = parameters[0]
@banyudu
banyudu / serverless.yml
Created March 18, 2019 05:11
A simple serverless get api
functions:
get:
handler: handler.get
events:
- http:
method: get
path: /
cors: true
@banyudu
banyudu / remove-prop-types.js
Created May 29, 2019 01:50
Remove props types from js files
const fs = require('fs')
for (let i = 2; i < process.argv.length; i++) {
const filename = process.argv[i]
let content = fs.readFileSync(filename, 'utf-8')
if (/static propTypes = {/.test(content)) {
content = content.replace(/static propTypes = {[^{}]*({[^{}]*})*[^{}]*}\n/, '')
fs.writeFileSync(filename, content)
}
}
@banyudu
banyudu / repos.dot
Last active May 29, 2019 07:22
Graphviz file for backend/frontend/mobile projects
digraph G {
rankdir=TB;
subgraph cluster_0 {
label = "backend";
color = black;
style= "dotted";
backend_v1_1 [label="v1.1" color="grey"];
backend_v1_2 [label="v1.2" color="grey"];
backend_master [label="master" color="grey" style="filled"];
backend_feature_a [label="A" color="coral2" style="filled"];
@banyudu
banyudu / monorepo.dot
Created May 29, 2019 08:46
Mono repo
digraph G {
v1_1 [label="v1.1" color="grey"];
v1_2 [label="v1.2" color="grey"];
master [label="master" color="grey" style="filled"];
feature_a [label="A" color="coral2" style="filled"];
feature_b [label="B" color="deepskyblue2" style="filled"]
mono [label="Mono"]
mono -> tags;
mono -> branches;
branches -> master;
@banyudu
banyudu / lerna_import_vs_tomono.csv
Last active May 29, 2019 08:53
lerna import vs tomono
lerna.js import tomono
导入来源 本地git仓库 远程git仓库
多分支 不支持 导入所有分支
标签 不支持 导入所有标签
导入后更新 不支持 支持
批量导入 不支持 支持