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 os | |
os.environ["PYTHONBREAKPOINT"] = "IPython.embed" | |
pd.read_excel("./accounts.xlsx") | |
breakpoint() |
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 datetime as dt | |
def weeknum(date): | |
# 如果新年的第一天就是星期天的话 | |
# 直接通过天数的差异算 weeknum | |
# 规则是: | |
# 1. 每满 7 天,周数加 1 | |
# 2. 如果有余数,或余数就为 0(本身是 sunady 的情况)也加 1 | |
# 最终数学公式就是:floor division 7, plus 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
In [17]: from __future__ import braces | |
File "<ipython-input-17-6d5c5b2f0daf>", line 1 | |
from __future__ import braces | |
^ | |
SyntaxError: not a chance |
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
from selenium import webdriver | |
from webdriver_manager.chrome import ChromeDriverManager | |
D = None | |
def google(keyword): | |
D.get(f"https://www.google.com.hk/search?q={keyword}") | |
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 helium as H | |
from selenium import webdriver | |
from webdriver_manager.chrome import ChromeDriverManager | |
def main(): | |
opts = webdriver.ChromeOptions() | |
opts.add_argument("--no-first-run") | |
opts.add_argument("--no-service-autorun") | |
opts.add_argument("--no-default-browser-check") |
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 pyperclip | |
import json | |
def object2json_and_copy_it_to_clipboard(obj): | |
""" | |
convert any object jsonable(if need), and dumps it | |
copy to clipboard | |
""" | |
if hasattr(obj, "__dict__"): |
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
#!/usr/bin/python | |
import os | |
def save_path(): | |
import datetime as dt | |
from pathlib import Path | |
# file-naming | |
# https://softwareengineering.stackexchange.com/questions/61683/standard-format-for-using-a-timestamp-as-part-of-a-filename |
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
# docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-chrome:4.1.0-20211209 | |
from selenium import webdriver | |
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | |
driver = webdriver.Remote("http://127.0.0.1:4444/wd/hub", DesiredCapabilities.CHROME) | |
driver.get("http://www.google.com") | |
driver.save_screenshot("test.png") | |
driver.quit() |
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 datetime as dt | |
from collections import namedtuple | |
SUNDAY = "Sunday" | |
yearweek = namedtuple("yearweek", ["year", "week"]) | |
def get_weekday(date: dt.date) -> str: | |
""" |
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
const MiddlewarePipeline = () => { | |
const _middlewares = [] | |
return { | |
apply: middleware => _middlewares.push(middleware), | |
run: function run (middlewares) { | |
if (!middlewares) { | |
// set for first time call `run` | |
middlewares = _middlewares |