This file contains 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/python | |
from ruamel import yaml | |
with open("/node.yaml") as f: | |
config = yaml.safe_load(f) |
This file contains 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 boto3 | |
def get_instance_name(fid): | |
""" | |
When given an instance ID as str e.g. 'i-1234567', return the instance 'Name' from the name tag. | |
:param fid: | |
:return: | |
""" | |
ec2 = boto3.resource('ec2') | |
ec2instance = ec2.Instance(fid) |
This file contains 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
def pretty(d, indent=0): | |
for key, value in d.iteritems(): | |
print '\t' * indent + str(key) | |
if isinstance(value, dict): | |
pretty(value, indent+1) | |
else: | |
print '\t' * (indent+1) + str(value) | |
pretty(a, indent=3) |
This file contains 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
FROM ubuntu:16.04 | |
ENV TZ=Australia/Melbourne | |
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | |
RUN dpkg-reconfigure --frontend noninteractive tzdata |
This file contains 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 subprocess | |
def run(command): | |
my_env = os.environ.copy() | |
print(command) | |
return subprocess.check_output(command, shell=True, env=my_env) |
This file contains 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
function docker_exe { | |
d=($(docker ps | grep -v fluentd | grep -v nginx | grep befit | awk '{print $1}')) | |
for m in ${d[@]} | |
do | |
docker exec -it $m $1 | |
done | |
} |
This file contains 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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 smtplib | |
server = smtplib.SMTP('mail.aws.something.local', '25') | |
#Next, log in to the server | |
server.login("befit-smtp-dev@aws.local", "DNUkWP3yrg3zEP4STLESGzDuejeW9wtZ") | |
msg = "Hello again !" # The /n separates the message from the headers | |
server.sendmail("sid@from_email.com", "siddarth.vijapurapu@to_eamil.com", msg) |
This file contains 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
#### Port remote host to local tunnel | |
ssh -L <local_port>:<local_host>:<remote_port> <remote_host> -N | |
ssh -L 6677:localhost:5432 bishop -N | |
#or | |
ssh -L 55477:localhost:22 remotehost -N |
This file contains 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
find /file/or/directory/path -type f -exec sed -i "s/find_string/replacement_string/g" {} + | |
# Example | |
find /home/befitting1/code/befit_ecs/df/Dockerfile_locally -type f -exec sed -i "s/%%PROXY%%/$PROXY/g" {} + |