Skip to content

Instantly share code, notes, and snippets.

View gotraveltoworld's full-sized avatar
:octocat:
Keeping mind to learn Anything!

traveler gotraveltoworld

:octocat:
Keeping mind to learn Anything!
View GitHub Profile
@gotraveltoworld
gotraveltoworld / remove_duplicates.js
Last active January 5, 2024 04:53
How to remove duplicates in JS.
// Reference: https://codepen.io/macmladen/pen/XBwgEa/
let arr = [1, 2, 3, 4, 5, 1, 2 ,3, 4, 5];
// Set, this is a simple and plain method.
[...new Set(arr)];
// filter, a built-in method based on the filter function.
arr.filter((item, index) => arr.indexOf(item) === index);
// Retrieve the duplicate values
arr.filter((item, index) => arr.indexOf(item) !== index);
@gotraveltoworld
gotraveltoworld / imeExample.vue
Last active December 6, 2021 16:38
To show the 'v-model' compositionstart and compositionend.
<script src="https://unpkg.com/vue@2.5.16/dist/vue.js"></script>
<div id="app">
<p>the input is: <span class="name">{{result}}</span></p>
<input type="text"
:value=result
@input="compositionend"
@compositionstart="compositionstart($event)"
@compositionend="compositionend($event)"
/>
</div>
@gotraveltoworld
gotraveltoworld / json_pp.md
Last active August 15, 2019 06:57
How prettify JSON using Command basing on Mac

How to use the one command to copy JSON prettify JSON.

  1. echo '{"test1": 1, "test2": true}' | json_pp => To show the result.
  2. echo '{"test1": 1, "test2": true}' | json_pp | pbcopy => To copy into paste note
@gotraveltoworld
gotraveltoworld / git_command.md
Last active August 13, 2019 02:29
How to rewrite the message of git commit.
@gotraveltoworld
gotraveltoworld / nodejsPath.js
Last active June 25, 2019 05:11
To memo the NodeJS's path library(include syntax and functions).
// Nodejs's Path built-in library.
let path = require('path');
// Get dir's path.
let dirPath = path.dirname('/xx/yy/zz.js');
console.log('dirPath', dirPath);
// Get join's path.
let joinPath = path.join(__dirname, '/xx');
console.log('joinPath', joinPath);
@gotraveltoworld
gotraveltoworld / Static_Class_method.py
Last active May 19, 2019 17:41
To show the Static_Class_method.
class First(object):
def member1(self, n):
return n
@classmethod
def member2(cls, n):
# Call the static member.
n += cls.member3(n)
# Call the normal member.
n += cls.member1(cls, n)
@gotraveltoworld
gotraveltoworld / AWSLambda_py3.6_Dockerfile
Last active April 1, 2019 21:17
The basic example of AWS Lambda(Python 3.6).
FROM lambci/lambda:build-python3.6
WORKDIR /var/task
ENV WORKDIR /var/task
# Make the dir and to install all packages into packages/
RUN mkdir -p packages/ && \
pip install uuid -t packages/
# Copy initial source codes into container.
@gotraveltoworld
gotraveltoworld / JS_setTimeout.js
Created March 12, 2019 16:22
To practice the JS setTimeout: 測試迴圈內 "i" 的結果,這題要研究var 和 let 之間的關係(重點在全域綁定和區域綁定), let vs var
// 測試迴圈內 "i" 的結果,這題要重新研究var 和 let 之間的關係(重點在全域綁定和區域綁定)
for (var i = 0; i < 10; i ++) {
setTimeout(function() {
console.log(i);
}, 10);
}
for (let i = 0; i < 10; i ++) {
setTimeout(function() {
console.log(i);
}, 10);
@gotraveltoworld
gotraveltoworld / kubectl_commands.md
Last active February 8, 2019 14:02
Commom kubectl statements.

Show pods info.

  kubectl get pods

Show all pods.

  kubectl get pods --show-all

Get specify pod's decribe.

@gotraveltoworld
gotraveltoworld / first_pod.yaml
Created February 7, 2019 14:58
To build my first pod.yaml.
# first_pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: k8s-pod-nodejs
labels:
app: webserver
spec:
containers:
- name: k8s-pod-nodejs