Skip to content

Instantly share code, notes, and snippets.

View eMahtab's full-sized avatar
💭
مهتاب

Mahtab Alam eMahtab

💭
مهتاب
View GitHub Profile
@eMahtab
eMahtab / securely copying-war-from-s3-with-user-keys.json
Created October 15, 2017 17:24
Securely Copying-war-from-s3-with-user-keys using CloudFormation
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template VPC_with_PublicIPs_And_DNS: Sample template that creates a VPC with DNS and public IPs enabled. Note that you are billed for the AWS resources that you use when you create a stack from this template.",
"Parameters": {
"KeyPair": {
"Description": "Name of the keypair to use for SSH access",
"Type": "String"
},
"BucketName" : {
"Description" : "Name of bucket containing application war",
@eMahtab
eMahtab / copying-war-from-private-s3-with-iam.json
Created October 15, 2017 16:24
Securely copying the files from S3 with EC2 IAM role with Cloudformation
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template VPC_with_PublicIPs_And_DNS: Sample template that creates a VPC with DNS and public IPs enabled. Note that you are billed for the AWS resources that you use when you create a stack from this template.",
"Parameters": {
"KeyPair": {
"Description": "Name of the keypair to use for SSH access",
"Type": "String"
},
"BucketName" : {
"Description" : "Name of bucket containing application war",
@eMahtab
eMahtab / copying-war-from-s3.json
Created October 15, 2017 13:59
Amazon Linux Bootstrapping EC2 instance with UserData and cloud-init
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template VPC_with_PublicIPs_And_DNS: Sample template that creates a VPC with DNS and public IPs enabled. Note that you are billed for the AWS resources that you use when you create a stack from this template.",
"Parameters": {
"KeyPair": {
"Description": "Name of the keypair to use for SSH access",
"Type": "String"
},
"BucketName" : {
"Description" : "Name of bucket containing application war",
@eMahtab
eMahtab / amazon-linux-userdata.json
Created October 15, 2017 10:17
Complete Cloudformation template for Installing Apache web server on Amazon Linux with UserData
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template VPC_with_PublicIPs_And_DNS: Sample template that creates a VPC with DNS and public IPs enabled. Note that you are billed for the AWS resources that you use when you create a stack from this template.",
"Parameters": {
"KeyPair": {
"Description": "Name of the keypair to use for SSH access",
"Type": "String"
}
},
@eMahtab
eMahtab / installing-tomcat-7-on-amazon-linux-ami
Last active October 6, 2022 13:23
Installing Tomcat 7 on Amazon Linux AMI through UserData
#!/bin/bash -v
sudo yum update -y
sudo yum install -y tomcat7-webapps tomcat7-docs-webapp tomcat7-admin-webapps
sudo service tomcat7 start
# Copying a war to /usr/share/tomcat7/webapps directory
@eMahtab
eMahtab / lambda-permission.json
Created October 14, 2017 07:20
Role for lambda execution
Policy document for basic lambda execution. Create a role and attach this policy, then assign that role to the lambda.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Builds a VPC w/ INET Gateway and 3 public subnets. **WARNING** This template creates Amazon EC2 instance(s). You will be billed for the AWS resources used if you create a stack from this template.",
"Resources" : {
"VPC" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
@eMahtab
eMahtab / Array.forEach_is_synchronous.js
Created July 7, 2017 18:15
Yes Array.forEach is synchronous but be careful when you write async code inside forEach function body.
var fs = require('fs');
fs.readFile('users.json',function(err,data){
var users = JSON.parse(data).results.slice(0,100);
console.log("Users "+users.length);
users.forEach(function(user,index){
var prefix = index+1;
fs.writeFile('users/user_'+prefix+'.json',JSON.stringify(user),function(err){
if(err){
@eMahtab
eMahtab / always-define-the-encoding-of-your-page.html
Created June 13, 2017 05:29
Always define the character encoding scheme for your page
<!DOCTYPE html>
<html>
<meta charset="ISO-8859-1">
<!-- It should have been
<meta charset="UTF-8"> -->
<!-- there is no code to represent ← in ISO-8859-1 character set
for showing the ← character correctly we have to use UTF-8
UTF-8 represents ← with code -->
@eMahtab
eMahtab / Dockerfile
Last active May 3, 2017 07:13
Python-Flask-Hello-World-Dockerfile
FROM python:3.5
RUN pip install Flask==0.11.1
RUN useradd -ms /bin/bash admin
USER admin
COPY app /app
WORKDIR /app
CMD ["python", "app.py"]