Skip to content

Instantly share code, notes, and snippets.

View imnnquy's full-sized avatar
🙃
meh

Quy Nguyen imnnquy

🙃
meh
View GitHub Profile
#!/bin/sh
if [ -f .git/hooks/pre-commit ]; then
read -p "A pre-commit hook has been set up. Do you want to overwrite it? (y/n) " yn
case $yn in
[Yy]*) rm .git/hooks/pre-commit ;;
[Nn]*) exit ;;
esac
fi
#!/bin/sh
set -e
path="$1"
message=$(cat "$path")
echo "$message"
# shellcheck disable=SC2039
if ! [[ $message =~ ^US([0-9]{5})(\s*)* ]]; then
printf '\n\e[1;31mERROR: Your commit message must contain User Story ID\e[0m\n\n'
#!/bin/sh
set -e
# Check style for main and test
./gradlew checkstyleMain
./gradlew checkstyleTest
# Check the exit status from gradle command
if [ $? -eq 0 ]; then
echo "Your code has been validated successfully!"
@imnnquy
imnnquy / rc.local
Created June 11, 2020 07:44
/etc/rc.local
touch /tmp/attach-output.txt
/usr/bin/auto-attach-eip > /tmp/attach-output.txt
@imnnquy
imnnquy / auto_attach_eip_to_instance.sh
Created June 11, 2020 07:43
Auto attach eip to instance
instance_id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
allocated_eip=<elastic ip address>
aws ec2 associate-address --instance-id $instance_id --public-ip $allocated_eip
#!/bin/bash
REVISION=$(aws ecs list-task-definitions --family-prefix $AWS_ECS_CONTAINER_NAME | jq '.taskDefinitionArns[]' | tr -d '"' | tail -1 | rev | cut -d':' -f 1 | rev)
if [ ! -z "$REVISION" ]; then
aws ecs deregister-task-definition \
--region $AWS_DEFAULT_REGION \
--task-definition $AWS_ECS_CONTAINER_NAME:$REVISION \
>> /dev/null
# Prevent ecs to restart the task to update new code
#!/bin/bash
# This is the user data to be added into launch configuration for auto scaling group
env="stg" #TODO: change environment
AWS_ECS_CLUSTER_NAME="cluster-name-$env"
echo ECS_CLUSTER=$AWS_ECS_CLUSTER_NAME >> /etc/ecs/ecs.config
echo ECS_BACKEND_HOST= >> /etc/ecs/ecs.config
echo "ECS_ENABLE_TASK_CPU_MEM_LIMIT=false" >> /etc/ecs/ecs.config
START_TASK_SCRIPT_FILE="/etc/ecs/ecs-start-task.sh"
cat <<- 'EOF' > ${START_TASK_SCRIPT_FILE}
# Set environment variables and store logs to file
<style id="jsbin-css">
#image {
display:none;
width: 340px;
height: 700px;
}
</style>
<img id="image" src="https://c3po-ui.us-west-2.int.expedia.com/media/EXPEDIA_BOOKING_ANDROID_APP/expedia.co.kr_ko_KR/ff1087eb-d4af-4b60-b731-e8733e3bcf78/FlightSearching_1.jpg">
<canvas id="canvas" width="340" height="700">
Your browser does not support the HTML5 canvas tag.
<style id="jsbin-css">
#image {
display:none;
width: 340px;
height: 700px;
}
</style>
<img id="image" src="https://c3po-ui.us-west-2.int.expedia.com/media/EXPEDIA_BOOKING_ANDROID_APP/expedia.co.kr_ko_KR/ff1087eb-d4af-4b60-b731-e8733e3bcf78/FlightSearching_1.jpg">
<canvas id="canvas" width="340" height="700">
Your browser does not support the HTML5 canvas tag.
<style id="jsbin-css">
#image {
display:none;
width: 340px;
height: 700px;
}
</style>
<img id="image" src="https://c3po-ui.us-west-2.int.expedia.com/media/EXPEDIA_BOOKING_ANDROID_APP/expedia.co.kr_ko_KR/ff1087eb-d4af-4b60-b731-e8733e3bcf78/FlightSearching_1.jpg">
<canvas id="canvas" width="340" height="700">
Your browser does not support the HTML5 canvas tag.