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
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) | |
] |
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 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 |
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
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) | |
] |
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 | |
# 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..." |