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 / docker_common_commands.sh
Last active February 5, 2019 14:34
To record some of the docker's commands.
# Docker run.
docker run -v $(pwd)/app/libs:/var/task/libs --rm -d -t <name space>/<container's name>:<tag's name, default:latest>
# 執行特定docker's container by name.
docker exec -it $(docker ps -f name=fb_related_pages -q) sh -c "<command something...>"
# 過濾取得特定docker container inspect
docker inspect $(docker ps -f name=<your container's name> -q)
# 刪除volumes
@gotraveltoworld
gotraveltoworld / docker-compose-example.yml
Last active February 6, 2019 16:08
Use docker-compose to build a simple python flask with nginx, connection with unix sock file.
version: '3'
services:
nginx:
container_name: nginx-container
hostname: nginx-flask
build:
context: ./nginx
dockerfile: Dockerfile
restart: always
@gotraveltoworld
gotraveltoworld / object_create.js
Created January 26, 2019 16:13
To explain the Javascript Object.create().
const testOne = {
'attr': 'origin',
}
testTwo = Object.create(testOne); // This is a testOne's inheritance.
console.log(testTwo.attr);
delete testTwo.attr;
console.log(testTwo.attr); // To show 'origin', because this prototype of testTwo is testOne.
@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 / proxies.md
Created January 3, 2019 15:01
Class_of_proxies

Transparent Proxy

  REMOTE_ADDR = Proxy IP 
  HTTP_VIA = Proxy IP 
  HTTP_X_FORWARDED_FOR = Your IP 

Anonymous Proxy

  REMOTE_ADDR = proxy IP
 HTTP_VIA = proxy IP
@gotraveltoworld
gotraveltoworld / DP_Singleton_PHP.php
Created December 14, 2018 16:37
Use the PHP to implement the Singleton Pattern.
<?php
/**
* Design Pattern of the Singleton.
*/
class Singleton
{
private static $instance = null;
/**
* Call this method to get singleton
*
@gotraveltoworld
gotraveltoworld / monogo_aggregate.js
Last active December 11, 2018 07:42
MongoDB's syntax for aggregation.
db.getCollection('logs').aggregate([
{
'$match': {
'number': 0
}
},
{
'$group': {
'_id' : {'id': '$id'},
'items': {
@gotraveltoworld
gotraveltoworld / js_array_sort.js
Created November 28, 2018 03:19
How to use the JS array sort function to sort an array by text(convert to the int index).
// 根據預設排序列表順序的方式把文字轉換成排序的優先序
let positions = ['總經理', '副總', '部長', '主任', '員工'];
let staffs = [
{
'name': '員工1',
'position': '員工'
},
{
'name': '大明',
'position': '總經理'
@gotraveltoworld
gotraveltoworld / scp_upload.sh
Created October 26, 2018 02:47
Use 'git status' to upload files that have modified.
#!/bin/bash
local_path='Your local path' # ex: /home/your_projects/test
remote_path='Your cloud path' # ex: /var/www/api
remote_con='Your ssh connection' # ex: user@192.168.1.1
# Get the content in 'src/', because I only need to upload the content of 'src/' folder.
for file in $(git status --porcelain | grep "src/")
do
file_name=${file/'^M$'/} # Get to a Modified file.
local_file="$local_path$file_name"
remote_file="$remote_path$file_name"
@gotraveltoworld
gotraveltoworld / vt_crawler.js
Last active December 3, 2018 08:57
Use a simple JS function to get some notes of the Voicetube's pronunciation challenge service.
/*
* @Description: Use JS to get notes from future in console(brwoser).
* @Date: 2018-10-18 02:28
* @Author: undefined
*/
/*中文說明
此程式必須要在voicetube的口說挑戰網頁並且已經是登入狀態才能運作,記得根據實際需求改寫開始和結束日期
* startDate = '2018-10-19';
* endDate = '2018-10-20';