Skip to content

Instantly share code, notes, and snippets.

View codexponent's full-sized avatar
🍱
I just want some furikake in my life.

Sulabh Shrestha codexponent

🍱
I just want some furikake in my life.
View GitHub Profile
@codexponent
codexponent / programmer.gif
Last active March 17, 2021 13:53
A programmer
programmer.gif
@codexponent
codexponent / crontab
Created February 27, 2021 11:43
Running a simple bash script every minute
* * * * * /home/azureuser/start.sh >> /var/log/cronlogs/sample.log 2>&1
@codexponent
codexponent / start.sh
Created February 27, 2021 11:41
Bash script to know if the app service is running or not.
#!/bin/bash
ps -aux | grep -v grep | grep app.py > /dev/null
if [ $? -eq 0 ]; then
echo "$(date +'%Y-%m-%d') $(date +'%T') 200,Success,Process is Running"
else
echo "$(date +'%Y-%m-%d') $(date +'%T') 500,Error,Process is not Running"
fi
@codexponent
codexponent / app.py
Created February 27, 2021 11:35
Simple Flask Application
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return "Hello World!"
if __name__ == '__main__':
app.run()
@codexponent
codexponent / strict_encode.py
Created February 6, 2021 11:58
Strictly Encoding to Base64
import base64
data = open("script.sh", "rb").read()
encoded = base64.b64encode(data)
print(encoded)
@codexponent
codexponent / mount.sh
Last active February 6, 2021 09:32
Mounting the Azure File Share with Azure Virtual Machine
#!/bin/sh
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
sudo apt update
sudo apt install cifs-utils
mkdir data
az login
resourceGroupName="<your-resource-group>"
@codexponent
codexponent / starttmux.sh
Last active January 28, 2021 13:11 — forked from todgru/starttmux.sh
Start up tmux with custom windows, panes and applications running
#!/bin/sh
#
# Setup a work space called `work` with two windows
# first window has 3 panes.
# The first pane set at 65%, split horizontally, set to api root and running vim
# pane 2 is split at 25% and running redis-server
# pane 3 is set to api root and bash prompt.
# note: `api` aliased to `cd ~/path/to/work`
#
session="work"
@codexponent
codexponent / lethargicpanda.py
Created October 30, 2020 10:36
Lethargic Panda in Action
import os
import subprocess
from random import randrange
print('\tLethargic Panda\t')
print('Lethargic Panda is not working and now your instance is deprecated and will not work ....')
process = subprocess.Popen("aws ec2 describe-instances --filters 'Name=tag:Name,Values=AutoScaling' --query Reservations[*].Instances[*].[InstanceId] --output text", shell=True, stdout=subprocess.PIPE)
output, error = process.communicate()
instance_lists = list(output.decode("utf-8").split("\n"))[0:-1]
lethargic_panda = randrange(2)
@codexponent
codexponent / EC2TemplatePolicy1.json
Created October 30, 2020 09:03
Policy for Association of Elastic IP and S3 Read Access
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeAddresses",
"ec2:AllocateAddress",
"ec2:DescribeInstances",
"ec2:AssociateAddress",
@codexponent
codexponent / bashscript.sh
Created October 30, 2020 07:19
Script to install CodeDeploy agent and associate Elastic IP
#!/bin/bash
sudo yum update -y
sudo yum install ruby -y
sudo yum install wget -y
cd /home/ec2-user
wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
sudo service codedeploy-agent start
aws ec2 disassociate-address --public-ip <Your Allocated IPv4 Address> --region us-east-1