Skip to content

Instantly share code, notes, and snippets.

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: example-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: hello-world.info
http:
@AlvinLaiPro
AlvinLaiPro / kubectl.md
Created July 25, 2021 02:09 — forked from so0k/kubectl.md
Playing with kubectl output

Kubectl output options

Let's look at some basic kubectl output options.

Our intention is to list nodes (with their AWS InstanceId) and Pods (sorted by node).

We can start with:

kubectl get no
@AlvinLaiPro
AlvinLaiPro / lodash-transform.js
Created November 30, 2020 05:41 — forked from robtarr/lodash-transform.js
jscodeshift - replace `_.thing(...)` with `thing(...)` and add `import {thing} from 'lodash'`
export default (fileInfo, api) => {
const j = api.jscodeshift;
const methods = [];
const root = j(fileInfo.source);
const body = root.find(j.Program).get('body', 0).node;
const { comments } = body;
delete body.comments
root.get().node.comments = comments;
@AlvinLaiPro
AlvinLaiPro / remove-unused-imports.js
Created November 23, 2020 07:14 — forked from nemtsov/remove-unused-imports.js
A jscodeshift to remove unused imports
module.exports = (file, api, options) => {
const j = api.jscodeshift;
const printOptions = options.printOptions || {quote: 'single'};
const root = j(file.source);
const requires = {};
const filterAndTransformRequires = path => {
const varName = path.value.local.name;
const scopeNode = path.parentPath.scope.node;
@AlvinLaiPro
AlvinLaiPro / writing-eslint-rule.md
Created May 1, 2019 14:29 — forked from sindresorhus/writing-eslint-rule.md
Gettings started writing a ESLint rule

Gettings started writing a ESLint rule

First, take a look at the ESLint rule documentation. Just skim it for now. It's very long and boring. You can come back to it later.

ESLint rules works on the AST (Abstract Syntax Tree) representation of the code. In short, this is a tree structure that describes the code in a very verbose form. ESLint walks this tree and rules can subscribe to be notified when it hits a specific node type, like a Literal type, which could be the "hello" part of const welcome = "hello";.

Go ahead and play around with some code in AST Explorer (Make sure the parser is espree). It's a great tool!

Here are some good articles on the subject (ignore the scaffolding parts):

Bash

Moving

command description
ctrl + a Goto BEGINNING of command line
ctrl + e Goto END of command line
ctrl + b move back one character
@AlvinLaiPro
AlvinLaiPro / 正则高尔夫
Created December 2, 2018 13:24 — forked from taylortao/正则高尔夫
正则高尔夫
非常有意思的一组正则小游戏,http://regex.alf.nu/
积分规则:匹配左边(一个10分),不匹配右边的(错误一个扣10分),式子长度越短越好,1个字符扣1分。
中间有被难到的题目参考了Gist: https://gist.github.com/Davidebyzero/9221685
我看懂了的,顺便也记录一下我的理解。
Regex: short of regular expression.
Warmup
foo,哈哈,送分题
Anchors
You are deducted one point per character you use, and ten if you match something you shouldn’t.
我写的是ick$,后来发现还有k$,太坏了。。。考察点是:start/end of string anchors.
@AlvinLaiPro
AlvinLaiPro / cloudSettings
Last active January 19, 2019 08:16
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-01-16T07:36:10.774Z","extensionVersion":"v3.2.4"}

Advanced JavaScript Learning Resources

This is a list of advanced JavaScript learning resources from people who responded to this [Tweet][13] and this [Tweet][20].

  • [You Don't Know JS][3]

  • [Frontend Masters courses by Kyle Simpson][12]

  • [@mpjme][6]'s [YouTube videos][5]

@AlvinLaiPro
AlvinLaiPro / what-forces-layout.md
Created October 18, 2017 03:04 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()