Skip to content

Instantly share code, notes, and snippets.

View dylanzenner's full-sized avatar

kubedweller dylanzenner

  • Singlewire Software
View GitHub Profile
AWSTemplateFormatVersion: '2010-09-09'
Resources:
queue1:
Type: AWS::SQS::Queue
Properties:
QueueName: "queue1"
queue2:
Type: AWS::SQS::Queue
Properties:
QueueName: "queue2"
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::LanguageExtensions'
Parameters:
QueueNames:
Type: CommaDelimitedList
Description: A list of SQS queue Names.
Default: 'queue-1, queue-2, queue-3'
Resources:
Fn::ForEach::Subscription:
- QueueName
Fn::ForEach::UniqueLoopName:
- Identifier
- - Value1 //collection
- Value2
- 'OutputKey':
OutputValue
Fn::ForEach::UniqueLoopName:
- Identifier
- !Ref ListOfValues
@dylanzenner
dylanzenner / sort_dict_by_value_v1.py
Created August 22, 2022 00:47
Python Tricks: Sort dictionary By Value
from typing import Dict
from collections import Counter
def most_frequent_char(s: str) -> Dict:
mapping = Counter(s)
return dict(sorted(mapping.items(), key=lambda item: item[1]))
@dylanzenner
dylanzenner / reverse_linked_list_v2.py
Created August 20, 2022 17:24
LeetCode Daily: A Microsoft Journey
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
if not head:
return head
if not head.next:
@dylanzenner
dylanzenner / reverse_linked_list_v1.py
Created August 20, 2022 17:03
LeetCode Daily: A Microsoft Journey
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
cur = head
prev = None
while cur:
@dylanzenner
dylanzenner / two_sum_v2.py
Last active August 20, 2022 03:50
LeetCode Daily: A Microsoft Journey - Part 1
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
hashmap = {}
for i in range(len(nums)):
complement = target - nums[i]
if complement in hashmap:
return [hashmap[complement], i]
hashmap[nums[i]] = i
@dylanzenner
dylanzenner / two_sum_v1.py
Last active August 20, 2022 03:50
LeetCode Daily: A Microsoft Journey - Part 1
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
for i in range(len(nums)):
for j in range(len(nums[1:])):
if nums[i] + nums[j] == target and i != j:
return [i, j]