Instantly share code, notes, and snippets.

🏠
something's happening!

# Aahnik Daw aahnik

🏠
something's happening!
Created July 13, 2020 14:47
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
 # General Term (x ** power)/factorial(power) # where power ranges from 0 to n-1 if the series has n terms def factorial(num): # recursive function if num == 0: # base case return 1 else: return num * factorial(num - 1)
Created July 14, 2020 08:20
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 sum(n): if n == 1: return 1 else: return n + sum(n+1)
Created July 17, 2020 05:20
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 power(a,b): if b == 0: return 1 else: return power(a,b-1) * a
Last active September 14, 2020 12:20
sum of n natural numbers for loop python
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 sum(n): s = 0 for i in range(1,n+1): s += n print(s) sum(10)# would print 55
Last active September 24, 2020 09:01
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
 # aahnik 2020 def recursive_binary_search(arr, lo, hi, ele): # Returns index of ele in arr if present, else -1 # arr is our list # lo is lower/left pointer # hi is higher/right pointer # ele is element to search if hi >= lo: # possibility that ele exists
Last active November 1, 2020 12:19
Description for Unscripted Impulse ui desc aahnik daw description
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
 Unscripted Impulse is a podcast of conversations between two friends Aahnik and Navoneel on various topics ranging from Science to History to fiction to Literature to JEE to Coding to Consciousness to Evolution to Indology to Everything about Existence and Reality ... I am Aahnik: ;FreeThinkerSeekerYogi, I ❤️ CODING ; PHYSICS ; MATH, astikaAtheist, FollowingDharma, NoReligion Visit my Website: https://aahnik.github.io Read my articles on Medium: https://medium.com/@aahnik Twitter: https://twitter.com/AahnikD Facebook: https://www.facebook.com/aahnik.daw
Last active November 10, 2020 07:09
Ubuntu records 30s .webm screencasts in Videos Folder via Ctrl+Shift+Alt+R, automatically convert them to GIF in Pictures Folder, and delete video file

# Make GIF ScreenCasts of 30s

Ubuntu records 30s .webm screencasts in Videos Folder via Ctrl+Shift+Alt+R, automatically convert them to GIF in Pictures Folder, and delete video file

Make sure to have `ffmpeg` installed

• Save the `toGIF.sh` in your Videos folder, link
• make it executable `chmod +x ~/Videos/toGIF.sh`
• Go to Settings ---> Keyboard Shortcuts ---> New ShortCut
• Set a new shortcut like this
Last active November 11, 2020 17:57
Using user data dir in selenium. Using a session. Reuse saved cookies. sample_code_selenium_using_user_data_dir.py
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
 from selenium import webdriver from selenium.webdriver.chrome.options import Options session_path = 'path/of/folder/' chrome_driver_path = 'path/of/chrome-driver-executable' url = 'url' chrome_options = Options() chrome_options.add_argument(f'--user-data-dir={session_path}')
Created November 16, 2020 11:35
Jai shree async ... Showing the power of async. ( Idea from https://youtu.be/R4Oz8JUuM4s )
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
 import aiohttp import asyncio from timer import timer async def fetch(): base = 'https://httpbin.org/get' async with aiohttp.ClientSession() as session: async with session.get(url=base) as response:
Created December 13, 2020 06:06
Search a substring in a list of strings;Python | Finding strings with given substring in list;search a query in a list of strings;re;list comprehension;filter;lambda;re.search
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
 # search a query in a list of strings import re my_list = ['Horrible donkey', 'irritable monkey', 'international idiot'] search_for = 'd' # list comprehension