Skip to content

Instantly share code, notes, and snippets.

View pictolearn's full-sized avatar

Pictolearn pictolearn

  • Coimbatore, IN
View GitHub Profile
@pictolearn
pictolearn / pyenv.sh
Last active February 1, 2020 07:13
Python 3 Working with Virtual Environments
# Virtualenv is a tool used to create an isolated Python environment. This environment has its own installation directories that doesn't share libraries with other virtualenv environments (and optionally doesn't access the globally installed libraries either).
# Ensure PYTHON3 is installed
python3 --version
# Create a virtual environment as follows
python3 -m venv ~/Pictolearn/venv
# Activating a virtual environment which was created
source ~/Pictolearn/venv/bin/activate
@pictolearn
pictolearn / cloudformation_vpc.json
Created September 15, 2019 04:54
Cloudformation to create a VPC
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "A VPC environment in two availability zones with an NAT instance.",
"Parameters": {
"envPrefix": {
"Description": "Environment name prefix.",
"Type": "String",
"Default": "Test"
},
"vpcCidr": {
@pictolearn
pictolearn / cloudformation_ec2.yaml
Created September 15, 2019 04:52
cloudformation example for ec2 instance
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/sample-templates-services-us-west-2.html#w1ab2c21c45c15c15
# Amazon EC2 instance in a security group Creates an Amazon EC2 instance in an Amazon EC2 security group.
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'AWS CloudFormation Sample Template EC2InstanceWithSecurityGroupSample:
Create an Amazon EC2 instance running the Amazon Linux AMI. The AMI is chosen based
on the region in which the stack is run. This example creates an EC2 security group
for the instance to give you SSH access. **WARNING** This template creates an Amazon
EC2 instance. You will be billed for the AWS resources used if you create a stack
from this template.'
#!/bin/bash
yum update -y
amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
yum install -y httpd mariadb-server
systemctl start httpd
systemctl enable httpd
usermod -a -G apache ec2-user
chown -R ec2-user:apache /var/www
chmod 2775 /var/www
find /var/www -type d -exec chmod 2775 {} \;
@pictolearn
pictolearn / update_an_item_conditionally.py
Last active June 27, 2022 00:03
conditional update in a DynamoDB table using python
# conditional update
# boto3, an AWS SDK package
# JSON, a text format package that is language independent
# decimal, a precision Handling package
import boto3
# this looks after validation error (throws a statement if the entity already exists)
from botocore.exceptions import ClientError
@pictolearn
pictolearn / Increment_an_atomic_counter.py
Last active March 20, 2024 22:44
increment of atomic counter in DynamoDB using python
# increment of an atomic counter
# boto3, an AWS SDK package
# JSON, a text format package that is language independent
# decimal, a precision Handling package
import boto3
import json
import decimal
@pictolearn
pictolearn / DeleteTable.py
Last active June 17, 2019 06:50
deleting a DynamoDB using a python script
# boto3, an AWS SDK package # Delete an existing Table
import boto3
# resource request service and region are set
dynamodb = boto3.resource('dynamodb', region_name='us-east-1')
input1=input("enter table :\t")
table = dynamodb.Table(input1)
# a function to delete a table
table.delete()
@pictolearn
pictolearn / Update_an_item.py
Last active February 11, 2023 12:34
update an item in a DynamoDB table by running a python script
# update an item in the table
# boto3, an AWS SDK package
# JSON, a text format package that is language independent
# decimal, a precision Handling package
import boto3
import json
import decimal
# Helper class to convert a DynamoDB item to JSON.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
@pictolearn
pictolearn / loadpage.html
Created June 7, 2019 13:42
loadpage.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Page Loaded Dynamically</title>
</head>
<body>
<div>
<h1>Loaded page Dynamically</h1>
<p>Page Loaded Dynamically</p>