This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
get_time_cands () { | |
local HOUR=3600 | |
local DAY=$(( $HOUR * 24 )) | |
local WEEK=$(( $DAY * 7 )) | |
PIVOT_WEEK=$(( ( $(date +"%s") - $DAY * 4 ) / $WEEK * $WEEK + $DAY * 4 + $WEEK - 9 * $HOUR )) | |
local AVA_DATES=( $(( $PIVOT_WEEK )) $(( PIVOT_WEEK + $DAY * 2 )) $(( $PIVOT_WEEK + $DAY * 4 )) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Args | |
REPOSITORY=$1; | |
CONTEXT='DOCKER_BUILD_CONTEXT'; | |
PROFILE='AWS_PROFILE'; | |
REGION='REGION'; | |
# Check args | |
if [ ${#REPOSITORY} -eq 0 ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
CHECK_INV=600 | |
REMOTE_USER='remote_user' | |
REMOTE_PORT=22 | |
REMOTE_HOST='example.com' | |
DST_PORT=22 | |
SRC_PORT=2222 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will update the kubectl config(default at ~/.kube/config) | |
aws eks update-kubeconfig --region <region code> --name <cluster name> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/", methods=['GET']) | |
def sleep(): | |
os.popen('sleep 10 &') # 沒有 & 就不會放背景執行,雖然依然會立刻回傳,但 python 會開一個 bash 等它的輸出,關掉服務就會直接終止 job | |
return 'sleep!' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -e | |
role=$1 | |
mfa_arn=$2 | |
profile=$3 | |
temp_profile=tf_temp | |
if [ -z $role ]; then echo "no role specified"; exit 1; fi | |
if [ -z $mfa_arn ]; then echo "no mfa arn specified"; exit 1; fi | |
if [ -z $profile ]; then echo "no profile specified"; exit 1; fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "CREATE DATABASE sampledb" | PGPASSWORD=password psql -h localhost -U user | |
# or | |
cat your.sql | PGPASSWORD=password psql -h localhost -U user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.1' | |
services: | |
postgres: | |
image: 'postgres:13.2' | |
container_name: postgres | |
ports: | |
- 5432:5432 | |
environment: | |
POSTGRES_USER: postgres |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.service; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.security.core.userdetails.User; | |
import org.springframework.security.core.userdetails.UserDetails; | |
import org.springframework.security.core.userdetails.UserDetailsService; | |
import org.springframework.security.core.userdetails.UsernameNotFoundException; | |
import org.springframework.security.crypto.password.PasswordEncoder; | |
import org.springframework.stereotype.Service; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.config; | |
import com.example.service.impl.AppUserDetailsService; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | |
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
import org.springframework.security.config.annotation.web.builders.WebSecurity; | |
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | |
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | |
import org.springframework.security.crypto.password.PasswordEncoder; |