This file contains hidden or 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 httpx | |
| import asyncio | |
| import aiohttp | |
| import os | |
| from fp.fp import FreeProxy | |
| THIS_DIR = os.path.dirname(os.path.realpath(__file__)).replace('\\', '/') |
This file contains hidden or 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
| https://github.com/aio-libs/aiohttp/issues/955 | |
| https://stackoverflow.com/questions/51887784/using-aiohttp-with-proxy | |
| https://superfastpython.com/python-async-requests/#Requests_Block_the_Asyncio_Event_Loop_this_is_bad |
This file contains hidden or 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
| urls = open_file(0, 500) #array of urls | |
| async def fetch_url(i, url, semaphore): | |
| async with semaphore: | |
| async with httpx.AsyncClient() as client: | |
| reply = await client.get(url) | |
| print(f'got {url}') | |
| return i, reply |
This file contains hidden or 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
| str = 'string' | |
| list = [.....] | |
| if not any(list_elem in str for list_elem in list): | |
| do |
This file contains hidden or 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 pandas as pd | |
| import openpyxl | |
| # maybe in loop | |
| for i in data: # let i == [a, b] | |
| df = pd.DataFrame( | |
| [[a, b]], | |
| columns=['Title1', 'Title2'] | |
| ) |
This file contains hidden or 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
| var lengthOfLongestSubstring = function(s, len=undefined) { | |
| // check if all chars same | |
| if (!len) { | |
| if (s.length !== 0) { | |
| const arr = [...s] | |
| const allEqual = arr => arr.every(val => val === arr[0]) | |
| if (allEqual(arr)) { | |
| return 1 | |
| } |
This file contains hidden or 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
| s = "bbbb" | |
| const arr = [...s] | |
| const allEqual = arr => arr.every(val => val === arr[0]) | |
| if (allEqual(arr) { | |
| return true | |
| } |
This file contains hidden or 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
| /* | |
| Write a function to find the longest common prefix | |
| string amongst an array of strings. | |
| If there is no common prefix, return an empty string "". | |
| Example 1: | |
| Input: strs = ["flower","flow","flight"] | |
| Output: "fl" |
This file contains hidden or 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
| /* | |
| nums1.length == m | |
| nums2.length == n | |
| 0 <= m <= 1000 | |
| 0 <= n <= 1000 | |
| 1 <= m + n <= 2000 | |
| -10**6 <= nums1[i], nums2[i] <= 10**6 | |
| */ | |
| var findMedianSortedArrays = function(nums1, nums2) { |
This file contains hidden or 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
| /* | |
| author Oleg Kornilov | |
| [email protected] | |
| Runtime: 2025 ms, faster than 11.72% of JavaScript online submissions for Longest Palindromic Substring. | |
| Memory Usage: 52 MB, less than 12.11% of JavaScript online submissions for Longest Palindromic Substring. | |
| */ | |
| var longestPalindrome = function(s) { |