Skip to content

Instantly share code, notes, and snippets.

@shakyaabiral
shakyaabiral / run_ecs_task.sh
Created January 29, 2020 23:22
Run Ecs Task get log and exit code
run_ecs_task(){
COMMAND="$1"
ClUSTER="$2"
TASKDEF="$3"
TASK_INFO=$(aws ecs run-task \
--region ap-southeast-2 \
--cluster "$CLUSTER" \
--task-definition "$TASKDEF" \
--overrides '{"containerOverrides": [{"name": "'"$CONTAINERNAME"'", "command": ["sh", "-c", "'"$COMMAND"'"]}]}')
TASK_ARN=$(echo "$TASK_INFO" | jq --raw-output ".tasks[0].taskArn")
@shakyaabiral
shakyaabiral / ftpdownload.py
Created September 13, 2018 04:40
Python Download file from ftp
from ftplib import FTP
import os
with FTP('FTP_HOSTNAME') as ftp:
ftp.login('FTP_USERNAME', 'FTP_PASS')
ftp.cwd('[DIRECTORYNAME_IN_FTP_SERVER]') # navigate to desired directory in ftp server
filenames = ftp.nlst() # gives you a list of of files in the current directory
localfilepath = os.path.join('path','to','local','filename') # filename with complete path to where you would like to download the file
with open(localfilepath, 'wb') as local_file:
ftp.retrbinary('RETR [SOURCE_FILE_NAME]', local_file.write) # replace [SOURCE_FILE_NAME] with name of the file in ftp server that you want to download
@shakyaabiral
shakyaabiral / bumpversion.php
Last active August 17, 2023 16:06
Bumpversion for php application
<?php
/*
* Creates a VERSION file if not exists in current directory.
* Version should be in the format. {Major.Minor.Patch}
* Patch has a suffix -dev for non release version
* Usage:
* php bumpversion.php [options]
* options:
* --version [part] (required)
@shakyaabiral
shakyaabiral / redis_dump.py
Last active September 11, 2023 13:27
Python Script to dump or load data using redis
"""
Install the following requirements into your virtual environemnt
`pip install click redis`
Usage:
To load data into redis
python redis_dump.py load [filepath]
To dump data into redis
python redis_dump.py dump [filepath] --search '*txt'