Skip to content

Instantly share code, notes, and snippets.

View darkerego's full-sized avatar

Darkerego darkerego

View GitHub Profile
async def main():
coroutine1 = do_some_work(1)
coroutine2 = do_some_work(2)
coroutine3 = do_some_work(4)
tasks = [
asyncio.ensure_future(coroutine1),
asyncio.ensure_future(coroutine2),
asyncio.ensure_future(coroutine3)
]
@wenweixu
wenweixu / height_binary_tree.py
Last active November 11, 2020 09:30
Hackerrank Height of a Binary Tree Python solution
def height(root):
# condition to stop recursion
if root == None:
return -1
# divide and conquer
depth_left = height(root.left)
depth_right = height(root.right)
depth = max(depth_left, depth_right) + 1
# return the final result
return depth
async def main():
coroutine1 = do_some_work(1)
coroutine2 = do_some_work(2)
coroutine3 = do_some_work(4)
tasks = [
asyncio.ensure_future(coroutine1),
asyncio.ensure_future(coroutine2),
asyncio.ensure_future(coroutine3)
]
#!/bin/bash
# A sample firewall shell script
IPT="/sbin/iptables"
SPAMLIST="blockedip"
SPAMDROPMSG="BLOCKED IP DROP"
SYSCTL="/sbin/sysctl"
BLOCKEDIPS="/root/scripts/blocked.ips.txt"
 
# Stop certain attacks
echo "Setting sysctl IPv4 settings..."