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 primenumber(x) | |
temp = true | |
for i in 2..x/2 | |
if x%i == 0 | |
temp = false | |
break | |
end | |
end | |
if temp == true | |
puts "#{x} is a Prime Number" |
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
# This Script will help you to find the top 3 ips from which is traffic is coming to your servers | |
# Assuming log file is in this format "<IP Address> <Time Stamp> <url requested> <Rest Service Call Method > < Response>" | |
def file_operations(file) | |
str = Array.new | |
temp = Array.new | |
File.open(file).each do |line| | |
str << line.match(" ").pre_match | |
end | |
str.uniq.each do |a| | |
temp << "#{str.count(a.chomp)} #{a}" |
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 rotatearray | |
puts "How Many time to rotate the array in clock wise" | |
times = gets.chomp.to_i | |
a = [] | |
puts "Enter the size of array" | |
size = gets.chomp.to_i | |
puts "Enter the values into array one by one" | |
for i in 0..size-1 | |
i = gets.chomp.to_i | |
a << i |
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
#!/bin/bash | |
# Name of the autosacling group need to replaced with keyworkd in the script | |
autoscaling_name=`aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[].[AutoScalingGroupName]' --output=text | grep -i <Name of the autosacling group>` | |
echo $autoscaling_name | |
launchconfig_name=`aws autoscaling describe-auto-scaling-groups --auto-scaling-group-name $autoscaling_name --output=json | grep -m1 LaunchConfigurationName | cut -d ":" -f 2| sed 's/"//g'` | |
echo $launchconfig_name | |
security_group_id=`aws autoscaling describe-launch-configurations --launch-configuration-names $launchconfig_name | grep sg- |awk '{print $1}'| sed 's/"//g'` | |
echo $security_group_id | |
amiid=`aws autoscaling describe-launch-configurations --launch-configuration-names $launchconfig_name | grep ami |cut -d ":" -f 2 | sed 's/"//g'| sed 's/,//g'` | |
echo $amiid |