Boto is the Amazon Web Services (AWS) SDK for Python, which allows Python developers to write software that makes use of Amazon services like S3 and EC2. Boto provides an easy to use, object-oriented API as well as low-level direct service access

 We will be using three different python modules. 
  1. boto3
  2. datetime
datetime module contains classes and methods for manipulating dates and times

#!/usr/bin/python
import boto3
import datetime

# Calculate timeLimit for EBS Snapshots
time_limit = datetime.datetime.now() - datetime.timedelta(days=7)
# ec2 object creation
ec2client = boto3.client('ec2')


# This function is used to retrive the ec2 instances from the given region
def get_ec2_instances():
    instance_list = ec2client.describe_instances()
    # Return Instances List
    return instance_list


# This function is used to retrive the volumes list by instance id
def get_volumes_by_instance_id(instance_id):
    volume_filters = [{"Name": "attachment.instance-id", "Values": [instance_id]}]
    volume_list = ec2client.describe_volumes(Filters=volume_filters)
    return volume_list


# This function is used to retrive the snapshots by volume id
def get_ebs_snapshots_by_volume_id(volume_id):
    snapshot_filters = [{"Name": "volume-id", "Values": [volume_id]}]
    snapshot_list = ec2client.describe_snapshots(Filters=snapshot_filters)
    return snapshot_list


instance_list_info = get_ec2_instances()
for ec2_reservation in instance_list_info["Reservations"]:

    for ec2_instance in ec2_reservation["Instances"]:

        volume_list_info = get_volumes_by_instance_id(ec2_instance["InstanceId"])

        for volume_info in volume_list_info["Volumes"]:

            snapshot_list_info = get_ebs_snapshots_by_volume_id(volume_info["VolumeId"])

            for snapshot_info in snapshot_list_info["Snapshots"]:

                if snapshot_info['StartTime'].date() >= time_limit.date():

                    print("Instance  ID  :", ec2_instance["InstanceId"])
                    print("Volume    ID  :", volume_info["VolumeId"])
                    print(snapshot_info['SnapshotId'], snapshot_info['StartTime'].date())
In  this is post, I have given very simple examples for learning salesforce Apex Triggers concepts.
Apex Triggers saves lots of time involving in automating complex businuess process

Examples


  1. Use case 1:

  • when account is inserted, automatically contact also created for that account.

trigger insertContact on Account (after insert)
{
Contact cont = new Contact();
cont.LastName = Trigger.new[0].name;
cont.AccountId = Trigger.new[0].ID;
insert cont;
}

  • Explanation:

Above one is a simple trigger to insert contact when you create account. the text which is mentioned in green color is trigger name. And text which is mentioned in red color is event name.

Trigger.New is a context variable. which returns a list of new records of the sobjects which we are going to insert into the database.




  1. Use Case 2:

  • Create a trigger on opportunity that throws error if Amount is less than 5000

trigger op_trigger1 on Opportunity (Before Insert, Before Update)
{
    for(Opportunity a : Trigger.New)
{
    if(a.Amount < 5000)
   a.addError('Amount can not be less then 5k');
}
}
  • Explanation:

Above one is a simple trigger which fires if Opportunity values is less than 5000 k. This is trigger triggers every time when record is created and updated



  1. Use Case 3:

  • If a New record is created, Amount should not be less than 5k If an Existing record is being updated , Amount should not be less than 3k

trigger opp_trigger2 on Opportunity (Before Insert, Before Update)
{
   for(Opportunity a : Trigger.New)
{
   if(Trigger.isInsert && a.Amount < 5000)
   a.addError('Amount can not be less than 5k');
   else if(Trigger.isUpdate && a.Amount < 3000)
   a.addError('Amount can not be less than 3k');
    }
}



4. Use Case 4:

  • Create a contact record on New Opportunity Insert
trigger opp_trigger3 on Opportunity (After Insert)
{
    Contact c = new Contact();
   for(Opportunity o : Trigger.New)
{
   c.AccountID = o.AccountID;
   c.FirstName = 'Oppertunity';
   c.LastName = 'Owner';
   insert c;
   }
}













This is a simple c language project using structures  concept.Basic bank operations 
are implemented in this simple project there will be a menu driven option for the
user based on the user selection operations will be done.

 

/*Simple c project using structures*/
#include<stdio.h>
#include<conio.h>
void creation();
void deposit();
void withdraw();
void bal();
int a=0,i = 101;
struct bank
{
int no;
char name[20];
float bal;
float dep;
}s[20];
void main()
{
int ch;
while(1)
{
clrscr();
printf("\n*********************");
printf("\n BANKING ");
printf("\n*********************");
printf("\n1-Creation");
printf("\n2-Deposit");
printf("\n3-Withdraw");
printf("\n4-Balance Enquiry");
printf("\n5-Exit");
printf("\nEnter your choice");
scanf("%d",&ch);
switch(ch)
{
case 1: creation();
break;
case 2: deposit();
break;
case 3: withdraw();
break;
case 4: bal();
break;
case 5: exit(0);
defalut: printf("Enter 1-5 only");
getch();
}
}
}
void creation()
{
printf("\n*************************************");
printf("\n ACCOUNT CREATION ");
printf("\n*************************************");
printf("\nYour Account Number is :%d",i);
s[a].no = i;
printf("\nEnter your Name:");
scanf("%s",s[a].name);
printf("\nYour Deposit is Minimum Rs.500");
s[a].dep=500;
a++;
i++;
getch();
}
void deposit()
{
int no,b=0,m=0;
float aa;
printf("\n*************************************");
printf("\n DEPOSIT ");
printf("\n*************************************");
printf("\nEnter your Account Number");
scanf("%d",&no);
for(b=0;b<i;b++)
{
if(s[b].no == no)
m = b;
}
if(s[m].no == no)
{
printf("\n Account Number : %d",s[m].no);
printf("\n Name : %s",s[m].name);
printf("\n Deposit : %f",s[m].dep);
printf("\n How Much Deposited Now:");
scanf("%f",&aa);
s[m].dep+=aa;
printf("\nDeposit Amount is :%f",s[m].dep);
getch();
}
else
{
printf("\nACCOUNT NUMBER IS INVALID");
getch();
}
}
void withdraw()
{
int no,b=0,m=0;
float aa;
printf("\n*************************************");
printf("\n WITHDRAW ");
printf("\n*************************************");
printf("\nEnter your Account Number");
scanf("%d",&no);
for(b=0;b<i;b++)
{
if(s[b].no == no)
m = b;
}
if(s[m].no == no)
{
printf("\n Account Number : %d",s[m].no);
printf("\n Name : %s",s[m].name);
printf("\n Deposit : %f",s[m].dep);
printf("\n How Much Withdraw Now:");
scanf("%f",&aa);
if(s[m].dep<aa+500)
{
printf("\nCANNOT WITHDRAW YOUR ACCOUNT HAS MINIMUM BALANCE");
getch();
}
else
{
s[m].dep-=aa;
printf("\nThe Balance Amount is:%f",s[m].dep);
}
}
else
{
printf("INVALID");
getch();
}
getch();
}
void bal()
{ int no,b=0,m=0;
float aa;
printf("\n*************************************");
printf("\n BALANCE ENQUIRY ");
printf("\n*************************************");
printf("\nEnter your Account Number");
scanf("%d",&no);
for(b=0;b<i;b++)
{
if(s[b].no == no)
m = b;
}
if(s[m].no==no)
{
printf("\n Account Number : %d",s[m].no);
printf("\n Name : %s",s[m].name);
printf("\n Deposit : %f",s[m].dep);
getch();
}
else
{
printf("INVALID");
getch();
}
}







Hi Friends Learning core java is a first step in to java programming we are confused what topics are come under core java section and core java is very essential for building logic's  for every high end applications,so i listed all topics in table format.  



Basic Java

OOPS Concepts

Advanced Topics of java
 Learn introduction Objects and Class String handling
Know features of java Polymorphism Exception handling
Setting class path Constructor Multithreading
Know About Data Types This reference Synchronization
Write basic program Garbage collection Enumeration
Variable rules Java modifiers Auto Boxing and Un Boxing
Operators in java Inheritance Java I/O stream

Aggregation Serialization

Command line arguments Generics

Packages Collection framework

Abstraction Java Networking

interfaces Applets

Nested class AWT and Swings
Setting Classpath for Java








Java is freely available on Oracle's Website. Download the latest version of JDK (Java Development Kit) on your operating system. Install JDK on your machine. Once you have installed Java on your machine you would need to set environment variable to point to correct installation directory. 

PROCEDURE:

   Assuming that you have installed Java in C:\ Program files/ Java / JDK directory

Step 1:Right click on my computer and select properties.
















Step 2:Go to the Advance System Settings tab.

 











Step 3:Click on Environment Variables button.

 























Step 4: Now alter the path variable so that it also contains the path to JDK installed
           directory.

 





















 Step 5: Select path and click on edit and past class path.Click on ok button.
 Step 6: Now go to command prompt and type java and javac, If you successfully
            make it you will see commands acknowledge.
 Step 7: That's it your done!














Hi friends to day i will guide you how to write and compile c program in Linux/Unix terminals. In order to execute c program in windows operating system first we have 
to install it,But it is not the case in Linux/Unix , By default compilers installed in it.

 Procedure

1.pico programname.c           2.gcc programname    3.whatis compilername
2.whereis compilername        4.mv name name1       5. ./output.c                 
6.ls                                        5.exit                                                                                                                                

1.Open Linux terminal: 

First you have to open Linux or  Unix they are many Linux flavors are  available.
Am using  backtrack Linux in oracle VM Virtual box.

1.1.Use whatis command for knowing about gcc 
1.2.Use whereis command for locate compiler.









----->Type pico wish.c


       






2.Write program and Save it:

  ----->Type program name and save it.[save options find in bottom]







 ------> Press Y and press enter.

3.Check Once:
















4.Compile program with GCC:

4.1.Compile program with gcc compiler like bellow

 

4.2.Out put name is a.out we can rename it.

5.See Result: 

5.1. Type ./a.out command to see output.








6.We can rename this output name: 
 

6.1. Type mv a.out wish press enter.












6.2 Type ./wish to see output.