Skip to content

Instantly share code, notes, and snippets.

View thecraftman's full-sized avatar
🙂
Available

Ore-Aruwaji Tola thecraftman

🙂
Available
View GitHub Profile
@thecraftman
thecraftman / ref.yaml
Last active July 16, 2021 19:32
ref intrinsic function
Properties:
InstanceType: t2.micro
SecurityGroups:
- !Ref EC2SecurityGroup
EC2SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: "Enable HTTP on 80"
SecurityGroupIngress:
- IpProtocol: tcp
@thecraftman
thecraftman / equal.yaml
Last active July 16, 2021 18:25
Equal function
Fn::Equals
# Returns true if two values are equal else it will return false.
- Syntax: Fn:Equals: [value_1, value_2]
- short syntax: !Equals[value_1, value_2]
Example:
UserProdCondition:
!Equals [!Ref EnvironmentType, prod]
@thecraftman
thecraftman / add.yaml
Created July 16, 2021 13:51
Add function
Fn::And
- Fn:::And acts as an AND operator
- Minimum number of a condition is 2
- Maximum number of a condition is 10
- syntax: Fn:And: [condtion]
@thecraftman
thecraftman / generator5.py
Created July 2, 2021 11:56
Python Generators from a list comprehension.
# list comprehension
my_nums = (x*x for x in [1, 2, 3, 4, 5])
print my_nums
for num in my_nums:
print num
@thecraftman
thecraftman / generator4.py
Last active July 2, 2021 11:54
Generating from list comprehension
# list comprehension
my_nums = [x*x for x in [1, 2, 3, 4, 5]]
print my_nums
for num in my_nums:
print num
@thecraftman
thecraftman / generator3.py
Last active July 4, 2021 21:18
Python Generator
def square_numbers(nums):
for i in nums:
yield(i*i)
my_nums = square_numbers([1, 2, 3, 4, 5])
for num in my_nums:
print num
@thecraftman
thecraftman / generator2.py
Last active July 4, 2021 21:17
Python Generators
def square_numbers(nums):
for i in nums:
yield(i*i)
my_nums = square_numbers([1, 2, 3, 4, 5])
print next(my_nums)
print next(my_nums)
print next(my_nums)
print next(my_nums)
@thecraftman
thecraftman / generator1.py
Last active July 4, 2021 21:18
Python Generators
def square_numbers(nums):
for i in nums:
yield(i*i)
my_nums = square_numbers([1, 2, 3, 4, 5])
print next(my_nums)
@thecraftman
thecraftman / generator.py
Last active July 4, 2021 21:19
Python generator
def square_numbers(nums):
for i in nums:
yield(i*i)
my_nums = square_numbers([1, 2, 3, 4, 5])
print my_nums
@thecraftman
thecraftman / list.py
Last active July 4, 2021 21:19
Python Generators - why to use them and the benefits you receive
def square_numbers(nums):
result = []
for i in nums:
result.append(i*i)
return result
my_nums = square_numbers([1,2,3,4,5])
# my_nums = [x * x for x in [1,2,3,4,5]]