text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
#!/usr/bin/env python3
"""
Utility functions for lecture_downloader package.
"""
import os
import re
import json
import time
import shutil
import asyncio
import tempfile
import subprocess
from pathlib import Path
from typing import List, Dict, Optional, Tuple, Union
try:
import imageio_ffmpeg as ffmpeg_lib
except... | lightkey2/lecture-downloader | lecture_downloader/utils.py | .py | 53175380c2df47f7 | 7.15 | 1 |
"""libranet_logging.logconfig."""
from __future__ import annotations # make | in typing work in Python 3.8
import logging
import logging.config
import operator
import os
import sys
import logging_tree
from libranet_logging.utils import ensure_dir, is_interactive_shell, strtobool
from libranet_logging.validate impo... | libranet/libranet-logging | src/libranet_logging/logconfig.py | .py | 4713d98adaa4e9c8 | 7.24 | 2 |
"""libranet_logging.loglevel."""
import functools as ft
import logging
def create_loglevel(level_name="", level_num=0):
"""Create a custom loglevel.
Defining your own levels is possible, but should not be necessary, as the existing levels
have been chosen on the basis of practical experience. However, i... | libranet/libranet-logging | src/libranet_logging/loglevel.py | .py | ce0dee27056eea31 | 7.24 | 2 |
"""libranet_logging.utils."""
import logging
import os
import pathlib as pl
import typing as tp
import logging_tree
# @click.command()
# @click.argument("path", envvar="PYTHON_LOG_CONFIG", required=False, type=click.Path(exists=False))
# def print_logging_tree(path) -> None:
# """Initializes the logging and prin... | libranet/libranet-logging | src/libranet_logging/utils.py | .py | d9604d1a1a5a4ab2 | 7.24 | 2 |
"""libranet_logging.yaml.
In pyyaml 5.1 some incompatibilies were introduced with regard to ``yaml.load``
to make it more safe by default.
please see:
- https://github.com/yaml/pyyaml/blob/master/CHANGES
- https://github.com/yaml/pyyaml/pull/257
- https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Depr... | libranet/libranet-logging | src/libranet_logging/yaml.py | .py | ed6994433bae1ff4 | 7.24 | 2 |
# pylint: disable=missing-function-docstring
"""conftest.py - custom pytest-plugins.
For more information about conftest.py, please see:
- https://docs.pytest.org/en/latest/writing_plugins.html
- https://pytest-flask.readthedocs.io/en/latest/tutorial.html
"""
import os
import pathlib as pl
import pytest
@pytes... | libranet/libranet-logging | tests/conftest.py | .py | 35703fab5c75a6cc | 7.74 | 2 |
# pylint: disable=import-outside-toplevel
# pylint: disable=missing-function-docstring
"""Testing of module libranet_logging.loglevel."""
import logging
import pytest
def test_create_invalidloglevel(env):
from libranet_logging.loglevel import create_loglevel
level_num = "a"
with pytest.raises(ValueErro... | libranet/libranet-logging | tests/test_loglevel.py | .py | b89a907cdc87f791 | 7.74 | 2 |
#!/usr/bin/env python3
"""Memory-to-instructions sweep.
Reads a dump of the agent's stored memories and the personal
copilot-instructions.md file, then reports which memory facts are likely
already covered in the instructions and which are memory-only rules that
should be promoted into the file.
Usage:
python3 sw... | zkoppert/dotfiles | .copilot/skills/memory-sweep/sweep.py | .py | 0138f188461b0675 | 7.15 | 1 |
#!/usr/bin/env python3
"""Unit tests for sweep.py."""
import tempfile
import unittest
from pathlib import Path
from sweep import (
Memory,
classify,
extract_quoted_phrases,
extract_tokens,
parse_memories,
run_sweep,
)
class TestParseMemories(unittest.TestCase):
def test_parses_basic_bloc... | zkoppert/dotfiles | .copilot/skills/memory-sweep/tests.py | .py | 0b193058b722eded | 7.65 | 1 |
#!/usr/bin/env python3
"""Check PR/issue body for rendering issues after upload to GitHub.
Detects hard-wrapped paragraphs, split links, split tables, and truncation.
"""
import argparse
import json
import re
import subprocess
import sys
def fetch_body(args: argparse.Namespace) -> str:
if args.file:
wit... | zkoppert/dotfiles | .copilot/skills/pr-body-render-check/check.py | .py | 93da6ae2793d40e2 | 7.15 | 1 |
#!/usr/bin/env python3
"""Scaffold and verify the demo artifacts + demo marker for the record-demo skill.
Thin wrapper around `pr-marker` (the single source of truth for marker paths) so
this skill never re-derives the per-branch path encoding. Three subcommands:
init create the per-branch demo artifacts d... | zkoppert/dotfiles | .copilot/skills/record-demo/scaffold.py | .py | 655772414205246d | 7.15 | 1 |
#!/usr/bin/env python3
"""Lint text against Zack's writing-style hard rules.
These rules come from ~/.copilot/copilot-instructions.md under
"Writing Style > Hard Rules" and from explicit user feedback captured
in Copilot Memory. The linter catches the mechanical, easy-to-detect
violations so they cannot slip into exte... | zkoppert/dotfiles | .copilot/skills/validate-style/lint.py | .py | 5440456d07819698 | 7.15 | 1 |
#!/usr/bin/env python3
"""Open iTerm with a validated Copilot resume command ready to run."""
from __future__ import annotations
import argparse
import json
import os
import re
import shlex
import subprocess
import sys
import uuid
from pathlib import Path
from typing import Any
SESSION_ID_PATTERN = re.compile(
r... | zkoppert/dotfiles | scripts/resume_accessibility_session.py | .py | 753500b7a4fbbbba | 7.15 | 1 |
#!/usr/bin/env python3
"""Regression tests for the babysit-prs launchd wrapper."""
from __future__ import annotations
import json
import os
import subprocess
import tempfile
import unittest
from pathlib import Path
class BabysitPrsWrapperTest(unittest.TestCase):
"""Exercise the wrapper with an isolated home dir... | zkoppert/dotfiles | test_babysit_prs_wrapper.py | .py | 7a6387b666850517 | 7.65 | 1 |
"""
Outage Notice Configuration for Montana Mesonet Dashboard
This module loads the site-wide outage notice that the dashboard shows as a
modal on page load. The notice is driven by ``outage.json`` at the root of the
mesonet-dashboard repository, which is fetched at runtime from raw
GitHub - the same approach used for... | mt-climate-office/mesonet-dashboard | app/mdb/utils/outage.py | .py | 0fb988f9a1a4a04c | 7.24 | 2 |
#!/usr/bin/env python3
import boto3
import sys
import os
def get_current_account_id():
"""Retrieves the current AWS account ID."""
try:
sts_client = boto3.client('sts')
caller_identity = sts_client.get_caller_identity()
return caller_identity['Account']
except Exception as e:
... | alpha-prosoft/alpha-deploy-lib | scripts/login.py | .py | 3c4d532c6911fd88 | 7 | 0 |
# -*- coding: utf-8 -*-
"""
单元测试:验证 issue 过滤逻辑和跨环境统计一致性
测试场景覆盖:
1. PR 应被正确识别并排除
2. closed 状态 issue 应被排除
3. 字数为 0 的 issue 应被排除
4. 图片数量异常的 issue 应被排除
5. 正常 open issue 应通过过滤
6. 换行符归一化(\\r\\n → \\n)
7. 跨平台统计一致性
"""
import sys
import os
import unittest
from unittest.mock import MagicMock, patch
# 确保可以导入 scripts 模块
sys.pat... | bingdu748/Laboratory_of_Mad_Scientist | scripts/test_utils.py | .py | 2438ec2c619d0db3 | 7.65 | 1 |
# -*- coding: utf-8 -*-
"""
公共工具模块
认证、时间格式化、字数统计、图片统计
"""
import os
import re
import sys
import json
import logging
import platform
from datetime import datetime, timedelta, timezone
import github
# 配置日志
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
stream=s... | bingdu748/Laboratory_of_Mad_Scientist | scripts/utils.py | .py | f172d8541da0e7d6 | 7.15 | 1 |
#!/usr/bin/env python
# Created:2026.02.06
from pathlib import Path
import argparse
import hashlib
import pytools
def decode(b: bytes) -> str:
"""读取文件并尝试解码"""
s = ""
for i in ["utf8", "gbk", "utf32", "utf16"]:
try:
s = b.decode(i)
break
except UnicodeDecodeError:
... | YouLanjie/my-test | python/dir2txt.py | .py | 2dc410c14e5d700a | 7.15 | 1 |
#!/usr/bin/python
"""
本程序由ai生成
"""
import os
import re
import sys
from fuzzywuzzy import fuzz
from collections import defaultdict
class UnionFind:
def __init__(self, size):
self.parent = list(range(size))
def find(self, x):
if self.parent[x] != x:
self.parent[x] = self.find(s... | YouLanjie/my-test | python/find_duplicates.py | .py | 8dc081d827e6a416 | 7.15 | 1 |
#!/usr/bin/env python
# Created:2026.06.07
# 用来打谱(特别是五线谱)的辅助脚本
from pathlib import Path
import argparse
import math
import re
import sys
import pytools
def reverse_process(content: list[str]):
"""将txt谱转为简谱(统一改为0-9上下加点模式),用于检查"""
ret : list[str] = []
hint_up = ""
hint_down = ""
is_inconfig = False
... | YouLanjie/my-test | python/gen_music_synth_str.py | .py | 4a6a3fa7c1a81119 | 7.15 | 1 |
#!/usr/bin/env python
# Created:2026.04.18
# ai生成(比libcaca效果好)
"""
img2txt - 将图片转换为终端彩色字符画(使用半块字符 ▀)
依赖: Pillow (pip install Pillow)
用法: python img2txt.py <图片路径> [输出宽度(字符列数)]
"""
import sys
from PIL import Image
def ansi_truecolor(fg_rgb=None, bg_rgb=None):
"""生成 ANSI 真彩色转义序列 (前景/背景)"""
codes = []
if fg_... | YouLanjie/my-test | python/img2txt.py | .py | 2391bd54e4e8065a | 7.15 | 1 |
#!/usr/bin/env python
from pathlib import Path
import json
import re
import subprocess
import argparse
import shutil
import requests
try:
import readline
del readline
except ModuleNotFoundError:
pass
# 设置请求头
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML... | YouLanjie/my-test | python/music_download.py | .py | f9bc481c1e3f7513 | 7.15 | 1 |
#!/usr/bin/python
"""python常用函数合集"""
from pathlib import Path
import sys
import datetime
import copy
import json
def print_err(s:str):
"""从stderr打印输出"""
print(s, file=sys.stderr)
def _get_char_width(c:str) -> int:
if ord(c) <= 127:
return 1
if c in "“”‘’❲❳…":
# 非ASCII字符但是仍旧1字符宽度
... | YouLanjie/my-test | python/pytools.py | .py | 242f293f488812c7 | 7.15 | 1 |
#!/usr/bin/env python
# Created:2025.11.29
"""
分割全一卷的txt小说文件(一般来自轻小说文库)
转自blogs
"""
import re
import argparse
import json
import html
from pathlib import Path
import pytools
def seperate_str(pattern: re.Pattern, content: str):
"""分割字符串为dict"""
groups : dict[tuple, list[str]] = {}
last_match = None
he... | YouLanjie/my-test | python/split_novel.py | .py | 8e58ba23c8f526e5 | 7.15 | 1 |
#!/usr/bin/env python
# 简陋的todo程序
from pathlib import Path
import json
import argparse
import time
def get_args() -> argparse.Namespace:
"""获取参数"""
parser = argparse.ArgumentParser(description="简陋的todo程序")
parser.add_argument("-d", "--delete", type=int, default=[], action="append", help="删除任务")
parser... | YouLanjie/my-test | python/todo.py | .py | 1e596228c92faa52 | 7.15 | 1 |
#!/usr/bin/env python
# Created:2026.07.10
"""
检查目录下是否有重复文件(just for fun)
最好还是自己去找rdfind这样的工具吧
"""
import sys
import time
import pickle
import hashlib
import argparse
from dataclasses import dataclass
from pathlib import Path
@dataclass
class File:
"""文件数据"""
path:Path
size:int = 0
md5:str = ""
de... | YouLanjie/my-test | python/uniq_files.py | .py | 951f054ea766ec2a | 7.15 | 1 |
#!/usr/bin/env python
# coding=utf-8
import redis
# redis key
REDIS_KEY = "magnets"
# redis 地址
REDIS_HOST = "localhost"
# redis 端口
REDIS_PORT = 6379
# redis 密码
REDIS_PASSWORD = None
# redis 连接池最大连接量
REDIS_MAX_CONNECTION = 20
class RedisClient:
def __init__(self, host=REDIS_HOST, port=REDIS_PORT, password=REDIS_... | farfarfun/funmovie | notemovie/database/core_redis.py | .py | 306741bbef0362cf | 7 | 0 |
import requests
from bs4 import BeautifulSoup
from tqdm import tqdm
from notemovie.database.job import add_magnet
from notemovie.utils import thunder2magnet
def web1(index_start=90, index_end=110):
"""
http://www.mzzfree.com/feed/
:return:
"""
def url2movie(url):
try:
respons... | farfarfun/funmovie | notemovie/library/get_magnet.py | .py | 0cd778ea2f90ad09 | 7 | 0 |
import codecs
import socket
import time
from collections import deque
from multiprocessing import Process, cpu_count
from threading import Thread
import bencoder
from notemovie.database.job import add_magnet
from notemovie.magnet.utils import get_logger, get_nodes_info, get_rand_id, get_neighbor
BOOTSTRAP_NODES = [
... | farfarfun/funmovie | notemovie/magnet/crawler.py | .py | 2b378116e1348d86 | 7 | 0 |
import json
from http.client import HTTPConnection
from notemovie.database.job import get_magnets as _get_magnets
SAVE_PATH = ".\\torrents"
SAVE_PATH = '/Users/liangtaoniu/workspace/MyDiary/notechats/notemovie/notemovie/magnet/torrents'
STOP_TIMEOUT = 60
MAX_CONCURRENT = 16
MAX_MAGNETS = 10
ARIA2RPC_ADDR = "127.0.0.... | farfarfun/funmovie | notemovie/magnet/magnet_to_torrent_aria2c.py | .py | 7a330c5a37fe9058 | 7 | 0 |
import codecs
import os
from pprint import pprint
from bencoder import bdecode
TORRENT_SAVE_PATH = "torrents"
class ParserTorrent:
def __init__(self, torrent):
self.meta_info = self.get_meta_info(torrent)
@staticmethod
def get_meta_info(torrent):
"""
返回解码后的 meta info 字典
... | farfarfun/funmovie | notemovie/magnet/parse_torrent.py | .py | 0ba882594ce59515 | 7 | 0 |
import logging
import os
from socket import inet_ntoa
from struct import unpack
# 每个节点长度
PER_NODE_LEN = 26
# 节点 id 长度
PER_NID_LEN = 20
# 节点 id 和 ip 长度
PER_NID_NIP_LEN = 24
# 构造邻居随机结点
NEIGHBOR_END = 14
# 日志等级
LOG_LEVEL = logging.INFO
def get_rand_id():
"""
生成随机的节点 id,长度为 20 位
"""
return os.urandom(PER... | farfarfun/funmovie | notemovie/magnet/utils.py | .py | d0f9d8ececb04c52 | 7 | 0 |
import os
from notetool.database import SqliteTable
from notetool.tool.time import now2unix
def verifyProxyFormat(proxy):
"""
检查代理格式
:param proxy:
:return:
"""
import re
verify_regex = r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5}"
_proxy = re.findall(verify_regex, proxy)
return Tr... | farfarfun/funproxy | noteproxy/database.py | .py | 66cc8e48d870de08 | 7 | 0 |
import json
import re
import secrets
from datetime import datetime, timezone
from flask import current_app, jsonify, request
from flask_login import current_user
from app.api import bp
@bp.route("/queue-details")
def queue_details():
"""Return the number of tasks in queue, and details on tasks currently runnin... | gfitzp/fitzflix | app/api/api.py | .py | 4d2ef144764e6b72 | 7.15 | 1 |
"""Shared plumbing for the Sonarr and Radarr import webhooks."""
import functools
import json
import os
import urllib3
from flask import current_app, jsonify, request
from app.api.auth import authenticate_api_request
def import_event_webhook(service):
"""Wrap a webhook handler with authentication and import-e... | gfitzp/fitzflix | app/api/arr.py | .py | 1ec9a5059614a9f8 | 7.15 | 1 |
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField
from wtforms.validators import ValidationError, DataRequired, Email, EqualTo
from app.models import User
class LoginForm(FlaskForm):
"""Sign in."""
email = StringField("Email", validators=[DataRequired()... | gfitzp/fitzflix | app/auth/forms.py | .py | 01b280df2d758952 | 7.15 | 1 |
"""Film awards from Wikidata.
Award wins (P166) and nominations (P1411) for the library's films,
matched through the IMDb (P345) or TMDB (P4947) ids Fitzflix already
stores — Wikidata carries both. Wikidata is the sanctioned source:
TMDB has no awards API, IMDb's is paid-license only. Access follows
Wikidata's guideli... | gfitzp/fitzflix | app/awards.py | .py | b3e7906726cd81f8 | 7.15 | 1 |
"""Idempotent provisioning of the AWS pieces Fitzflix depends on.
`flask aws provision` drives this. Each step reports what it found and
only creates or updates what's missing, so running it against an already
configured account is safe — existing lifecycle rules and notification
configurations are always preserved an... | gfitzp/fitzflix | app/aws_setup.py | .py | c11f1ea71c2addd7 | 7.15 | 1 |
"""The Criterion Collection spine catalog (the videos/routes split's strangler split from
app.videos).
Wikidata is the source: two SPARQL queries (individual releases and
collector's sets) merge into a day-cached release list keyed by spine,
which the weekly refresh task applies to the library — marking owned
films' r... | gfitzp/fitzflix | app/criterion_catalog.py | .py | bc02c3c75371fed1 | 7.15 | 1 |
"""The landing page's "On Criterion24/7 now" card.
whatsonnow.criterionchannel.com is the Channel's own public now-playing
page for its 24/7 feed: the current film's title, a More link to the
film's info page, and a server-rendered countdown to the next film
(complete with a literal </snap> typo, so parsing stays leni... | gfitzp/fitzflix | app/criterion_now.py | .py | 747c929192b48b8c | 7.15 | 1 |
"""The "since you liked…" strip: taste-scored suggestions after a
positive rating.
What's left of the old /rate elicitation drive (retired for the
Recommendations page, #235): the session's last-response marker and
the enjoyment picks it unlocks on the just-rated film's movie page —
unseen candidates sharing features ... | gfitzp/fitzflix | app/elicitation.py | .py | 2af08f03061dc2f3 | 7.15 | 1 |
from threading import Thread
from flask import current_app
from flask_mail import Message
from app import mail
def send_async_email(app, msg):
"""Function to send email asynchronously using an application thread."""
with app.app_context():
mail.send(msg)
def build_message(subject, sender, recipie... | gfitzp/fitzflix | app/email.py | .py | c6cab3cf7fb14701 | 7.15 | 1 |
"""Nightly estimate pre-warming for the shared score source's tmdb lane.
Glenn's call (Aug 2026): the TMDB API costs nothing but latency, so
spend a nightly budget warming the enriched payloads tomorrow's
browsing will want — the filmographies of the people his taste
profile ranks highest, plus TMDB's popular and top-... | gfitzp/fitzflix | app/estimate_warm.py | .py | 6d4fd64fef070f93 | 7.15 | 1 |
"""Name that Frame (GitHub #52): the pre-extracted frame pool.
The game never runs ffmpeg at play time. A nightly task keeps a pool
of single frames — one per pooled movie — extracted from each film's
best library copy at a random moment, and the game page draws from
the pool. Frames are named by opaque tokens (the fi... | gfitzp/fitzflix | app/frames.py | .py | edb046579908a480 | 7.15 | 1 |
"""Letterboxd RSS sync: each user's public feed polls into their
diary, hands-free.
The feed is Letterboxd's advertised account surface (their real API is
invite-gated): the latest ~50 diary/review items, each carrying a TMDB
id, the watched date, the rewatch flag, the like, the half-star rating
when one was given, an... | gfitzp/fitzflix | app/letterboxd.py | .py | 2ae359687415e550 | 7.15 | 1 |
from datetime import datetime
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileRequired
from wtforms import (
BooleanField,
DateField,
HiddenField,
IntegerField,
PasswordField,
RadioField,
SelectField,
SelectMultipleField,
StringField,
SubmitField,
T... | gfitzp/fitzflix | app/main/forms.py | .py | c5b74169ea068286 | 7.15 | 1 |
"""Name that Frame (GitHub #52): the guessing game itself.
Rounds draw from the pre-extracted pool (app/frames.py) — the page
never touches ffmpeg. Three difficulties, per Glenn's issue: Easy
serves only films the current user has rated, with four choices;
Hard (slug "difficult") serves the whole pooled library with e... | gfitzp/fitzflix | app/main/game.py | .py | 6936bc3c13cec58c | 7.15 | 1 |
"""Shared helpers for the main blueprint's route modules (the routes.py split's
slice f): the verdict/ladder plumbing every rating surface uses, the
admin gate, and the quality-threshold read."""
from datetime import date, datetime
from flask import (
current_app,
jsonify,
flash,
redirect,
url_for... | gfitzp/fitzflix | app/main/helpers.py | .py | 07eda6d5c3a5f6b8 | 7.15 | 1 |
import os
from flask import (
current_app,
send_from_directory,
)
# flask.Markup was removed in Flask 2.4; import from its actual home
from app.main import bp
@bp.route("/apple-touch-icon-precomposed.png")
@bp.route("/apple-touch-icon.png")
def androidPng():
"""Serve the touch icon at the fixed paths ... | gfitzp/fitzflix | app/main/routes.py | .py | 886b3f34ac48e516 | 7.15 | 1 |
"""Plex library refresh + trash emptying, safely.
Replaces the external cron that curl'd refresh and emptyTrash for
hardcoded section ids, guarded by checking one mount per section. The
guard is the whole point: if a section's directory is missing (an SMB
mount dropped), a scan marks everything missing and emptying th... | gfitzp/fitzflix | app/plex_library.py | .py | 264b71f0297292a1 | 7.15 | 1 |
"""Remote playback on the living-room Apple TV via Plex Companion.
GDM discovery is dead in this network — the Plex server lives on the
DMZ VLAN and never hears the players' broadcasts, so /clients is
permanently empty and there is no discovery step. Each USER carries
their own player instead (User.plex_player_address... | gfitzp/fitzflix | app/plex_player.py | .py | 74532d8b4861d801 | 7.15 | 1 |
"""Plex ↔ Fitzflix watchlist sync: one account-level watchlist,
kept converged from both ends.
Plex watchlists live on the plex.tv ACCOUNT (the discover API), not
the local server, so the sync pairs the configured PLEX_TOKEN's
account with the Fitzflix user whose plex_username matches it. Each
run is a two-way reconci... | gfitzp/fitzflix | app/plex_watchlist.py | .py | ef4a3157b794ad3c | 7.15 | 1 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/05/05 15:44
# @Author : niuliangtao
# @Site :
# @File : EmailClient.py
# @Software: PyCharm
import datetime
# encoding: utf-8
import json
import random
import re
import string
import time
from time import sleep
from urllib.parse import urlencode
... | farfarfun/funblog | noteblog/utils/brush/EmailClient.py | .py | cda4f2594bab6e52 | 7 | 0 |
# encoding:utf-8
import json
import time
import requests
from lxml import etree
class TempEmail:
"""临时邮箱
使用http://24mail.chacuo.net/10分钟邮箱,
监听并返回收到的邮件内容,用以接受验证码
"""
def __init__(self):
self.headers = {
'Pragma': 'no-cache',
'Origin': 'http://24mail.chacuo.net',
... | farfarfun/funblog | noteblog/utils/brush/TempEmail.py | .py | 127db4d0f35ddb0a | 7 | 0 |
# coding:utf-8
"""
算法utils
"""
from random import shuffle
__all__ = [
'bubble_sort', # 冒泡排序法
'insertion_sort', # 插入排序法
'selection_sort', # 选择排序法
'quick_sort', # 快速排序法
'bogo_sort', ... | farfarfun/funblog | noteblog/utils/fzutils/algorithm_utils.py | .py | fe09f0e2e7729ebf | 7 | 0 |
# coding:utf-8
'''
@author = super_fazai
@File : celery_utils.py
@connect : superonesfazai@gmail.com
'''
"""
celery常用函数
"""
from time import time
from celery import Celery
from celery.utils.log import get_task_logger
from .common_utils import _print
from .time_utils import fz_set_timeout
__all__ = [
'init_c... | farfarfun/funblog | noteblog/utils/fzutils/celery_utils.py | .py | 05ab202c97d4a50b | 7 | 0 |
# coding:utf-8
'''
@author = super_fazai
@File : json_utils.py
@Time : 2016/7/25 09:43
@connect : superonesfazai@gmail.com
'''
import re
from ..common_utils import json_2_dict
__all__ = [
'read_json_from_local_json_file', # 从本地json文件读取json, 并以dict返回
'nonstandard_json_str_handle',... | farfarfun/funblog | noteblog/utils/fzutils/data/json_utils.py | .py | f736691afea3c69d | 7 | 0 |
# coding:utf-8
'''
@author = super_fazai
@File : list_utils.py
@Time : 2016/8/4 11:46
@connect : superonesfazai@gmail.com
'''
__all__ = [
'unique_list_and_keep_original_order', # 从列表中删除重复的元素, 同时保留其原始顺序
'list_remove_repeat_dict', # list 子元素为dict的去重
'list_remove_r... | farfarfun/funblog | noteblog/utils/fzutils/data/list_utils.py | .py | dc7f21cfdfc1527f | 7 | 0 |
# coding:utf-8
"""
pickle 对象utils
"""
from pickle import loads
from ..common_utils import _print
__all__ = [
'deserializate_pickle_object', # 反序列化pickle对象
'serialize_obj_item_2_dict', # 将序列化对象的子对象强转为dict类型
]
def deserializate_pickle_object(pickle_object, logger=None, defa... | farfarfun/funblog | noteblog/utils/fzutils/data/pickle_utils.py | .py | 70f041c0ed8bfb75 | 7 | 0 |
# coding:utf-8
import smtplib
from gc import collect
from email.mime.text import MIMEText
__all__ = [
'FZEmail', # 邮件对象
]
class FZEmail(object):
"""
邮件obj
目前支持: qq邮箱 [qq邮箱设置开启smtp, 并获得授权码]
用法: eg:
_ = FZEmail(user='2939161681@qq.com', passwd='smtp授权码or密码')
... | farfarfun/funblog | noteblog/utils/fzutils/email_utils.py | .py | 1f719fe7c5166f6b | 7 | 0 |
#!/usr/bin/env python3
"""
Convert Bob Jonkman's candidate listings to a format we can consume
Paul "Worthless" Nijjar, 2022-08-22
"""
import csv, re
import unicodedata
import datetime
from html import unescape
NO_WARD="N/A"
mergedict = {}
# ===== FUNCTIONS ======
def slugify(value):
""" Normalizes strings. F... | CivicTechWR/WRvotes | scripts/obsolete/sync_poliblog.py | .py | 6fce1998fc8c2880 | 7.35 | 4 |
# encoding: utf-8
'''
author: Taehong Kim
email: peppy0510@hotmail.com
'''
import os
import subprocess
import sys
import time
try:
from .wininstance import get_current_real_cwd
except Exception:
from wininstance import get_current_real_cwd
class KakaoTalk():
exe_path = 'assets\\kakaotalk\\KakaoTalkN... | peppy0510/PyWinStartup | source/base/kakaotalk.py | .py | 3e61c48e94270c86 | 7.3 | 3 |
# encoding: utf-8
'''
author: Taehong Kim
email: peppy0510@hotmail.com
'''
from pathlib import Path
class PowerShell():
patched = False
patching = False
def __init__(self):
pass
def run_patch(self):
if self.patching:
return
self.patching = True
paths ... | peppy0510/PyWinStartup | source/base/powershell.py | .py | 7ef19df66597bacd | 7.3 | 3 |
# encoding: utf-8
'''
author: Taehong Kim
email: peppy0510@hotmail.com
'''
from .coordination import Coordination
class Rectangle():
def __init__(self, offset_x, offset_y, finish_x, finish_y):
self.offset = Coordination(offset_x, offset_y)
self.finish = Coordination(finish_x, finish_y)
@... | peppy0510/PyWinStartup | source/base/rectangle.py | .py | b7ecb68e5807da91 | 7.3 | 3 |
# encoding: utf-8
'''
author: Taehong Kim
email: peppy0510@hotmail.com
'''
import operator
import pywintypes # noqa # pre-load dll for win32com
import screeninfo
import win32api
from .coordination import Coordination
from .rectangle import Rectangle
class ScreenShown():
def __init__(self, offset_x, offset_... | peppy0510/PyWinStartup | source/base/screens.py | .py | 08e892e88f6a8224 | 7.3 | 3 |
# encoding: utf-8
'''
author: Taehong Kim
email: peppy0510@hotmail.com
'''
import os
import pywintypes # noqa # pre-load dll for win32com
from win32com.client import Dispatch
class ShortCut():
@classmethod
def get_user_path(self):
return os.path.expanduser('~')
@classmethod
def get_use... | peppy0510/PyWinStartup | source/base/shortcut.py | .py | a9c0825d20047d0e | 7.3 | 3 |
# encoding: utf-8
'''
author: Taehong Kim
email: peppy0510@hotmail.com
'''
import operator
import os
import psutil
import time
import win32api
import win32con
import win32gui
import win32process
import wx
from .kakaotalk import KakaoTalk
from .nateon import NateOn
from .powershell import PowerShell
from presets im... | peppy0510/PyWinStartup | source/base/startupwatcher.py | .py | 0edcfc7e495833ff | 7.3 | 3 |
# encoding: utf-8
'''
author: Taehong Kim
email: peppy0510@hotmail.com
'''
import os
import psutil
import sys
def has_process_authority(p):
try:
p.cwd()
p.name()
except Exception:
return False
return True
def get_current_process():
pid = int(os.getpid())
for p in psut... | peppy0510/PyWinStartup | source/base/wininstance.py | .py | 2adf166942d63863 | 7.3 | 3 |
# encoding: utf-8
'''
author: Taehong Kim
email: peppy0510@hotmail.com
'''
import ctypes
import sys
import winreg
CMD = 'C:\\Windows\\System32\\cmd.exe'
FOD_HELPER = 'C:\\Windows\\System32\\fodhelper.exe'
PYTHON_CMD = 'python'
REG_PATH = 'Software\\Classes\\ms-settings\\shell\\open\\command'
DELEGATE_EXEC_REG_KEY... | peppy0510/PyWinStartup | source/base/winuac.py | .py | ab4427e0c33610d6 | 7.3 | 3 |
# encoding: utf-8
'''
author: Taehong Kim
email: peppy0510@hotmail.com
'''
import keyboardex as keyboard
import mido
# import pyautogui
import threading
import time
# pyautogui.press('a')
# pyautogui.typewrite('quick brown fox')
# for i in range(10):
# pyautogui.hotkey('alt', 'ctrl', 'shift', 'w')
# pyautogui... | peppy0510/PyWinLayout | source/base/miditokey.py | .py | 0cc503779a1bd7ac | 7.35 | 4 |
# encoding: utf-8
'''
author: Taehong Kim
email: peppy0510@hotmail.com
'''
import os
from win32com.client import Dispatch
class ShortCut():
@classmethod
def get_user_path(self):
return os.path.expanduser('~')
@classmethod
def get_user_startmenu_path(self, name=None):
path = os.p... | peppy0510/PyWinLayout | source/base/shorcut.py | .py | 9d8e09babdd7311c | 7.35 | 4 |
# encoding: utf-8
'''
author: Taehong Kim
email: peppy0510@hotmail.com
'''
import os
import psutil
import sys
def has_process_authority(p):
try:
p.cwd()
p.name()
except Exception:
return False
return True
def get_current_process():
pid = int(os.getpid())
for p in psut... | peppy0510/PyWinLayout | source/base/wininstance.py | .py | dc771abc95903380 | 7.35 | 4 |
# encoding: utf-8
'''
author: Taehong Kim
email: peppy0510@hotmail.com
'''
import operator
import os
import time
import win32api
import win32con
import win32gui
import win32process
from .coordination import Coordination
from .rectangle import Rectangle
from .screens import ScreenShown
from .screens import get_scre... | peppy0510/PyWinLayout | source/base/winlayout.py | .py | 023e490762d2a15d | 7.35 | 4 |
"""Objects for making requests to the API."""
from typing import Any, Dict, List, NamedTuple, Optional
from pydantic import BaseModel
class IssueLinkRequest(NamedTuple):
"""Issue to add to a task annotation."""
issue_key: str
url: str
confidence_score: Optional[float] = None
def as_dict(self) ... | evergreen-ci/evergreen.py | src/evergreen/api_requests.py | .py | 05789fd1be1937e9 | 7.24 | 2 |
# -*- encoding: utf-8 -*-
"""Task representation of evergreen."""
from __future__ import absolute_import
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional
from evergreen.util import (
parse_evergreen_date,
parse_evergreen_datetime,
parse_evergreen_short_datetime,
)
if TYPE_CHECKING:
fro... | evergreen-ci/evergreen.py | src/evergreen/base.py | .py | 784363d8fd4da60a | 7.24 | 2 |
# -*- encoding: utf-8 -*-
"""Commit Queue representation of evergreen."""
from __future__ import absolute_import
from typing import TYPE_CHECKING, Any, Dict, List
from evergreen.base import _BaseEvergreenObject, evg_attrib
if TYPE_CHECKING:
from evergreen.api import EvergreenApi
class CommitQueueItem(_BaseEver... | evergreen-ci/evergreen.py | src/evergreen/commitqueue.py | .py | 0795ee9a9aaceac8 | 7.24 | 2 |
# -*- encoding: utf-8 -*-
"""Get configuration about connecting to evergreen."""
from __future__ import absolute_import
import os
from collections import namedtuple
from typing import Dict, Optional
import yaml
EvgAuth = namedtuple("EvgAuth", ["username", "api_key"])
OidcConfig = namedtuple("OidcConfig", ["issuer", ... | evergreen-ci/evergreen.py | src/evergreen/config.py | .py | bd4009350f91ab7b | 7.24 | 2 |
# -*- encoding: utf-8 -*-
"""Host representation of evergreen."""
from __future__ import absolute_import
from typing import TYPE_CHECKING, Any, Dict
from evergreen.base import _BaseEvergreenObject, evg_attrib, evg_datetime_attrib
if TYPE_CHECKING:
from evergreen.api import EvergreenApi
from evergreen.build i... | evergreen-ci/evergreen.py | src/evergreen/host.py | .py | c1790dfbc5468607 | 7.24 | 2 |
"""Representation of evergreen manifest."""
from __future__ import absolute_import
from typing import TYPE_CHECKING, Any, Dict, Optional
from evergreen.base import _BaseEvergreenObject, evg_attrib
if TYPE_CHECKING:
from evergreen.api import EvergreenApi
class ManifestModule(_BaseEvergreenObject):
"""Repre... | evergreen-ci/evergreen.py | src/evergreen/manifest.py | .py | 6636e6cd12b0aa1b | 7.24 | 2 |
# -*- encoding: utf-8 -*-
"""OIDC token management for Evergreen API authentication."""
from __future__ import absolute_import
import json
import os
import time
from typing import TYPE_CHECKING, Optional
import jwt
import requests
import structlog
from evergreen.config import OidcConfig
if TYPE_CHECKING:
from e... | evergreen-ci/evergreen.py | src/evergreen/oidc.py | .py | 4c8e374f7efe5021 | 7.24 | 2 |
# -*- encoding: utf-8 -*-
"""Evergreen representation of a project."""
from __future__ import absolute_import
from typing import TYPE_CHECKING, Any, Dict
from evergreen.base import _BaseEvergreenObject, evg_attrib
from evergreen.version import Version
if TYPE_CHECKING:
from evergreen.api import EvergreenApi
cl... | evergreen-ci/evergreen.py | src/evergreen/project.py | .py | 50963752cb537849 | 7.24 | 2 |
# -*- encoding: utf-8 -*-
"""Evergreen representation of a user's permissions."""
from __future__ import absolute_import
from enum import Enum
from typing import TYPE_CHECKING, Any, Dict
from evergreen.base import _BaseEvergreenObject, evg_attrib
if TYPE_CHECKING:
from evergreen.api import EvergreenApi
class P... | evergreen-ci/evergreen.py | src/evergreen/resource_type_permissions.py | .py | 2ea7a20aa5ee4fce | 7.24 | 2 |
# -*- encoding: utf-8 -*-
"""Task representation of evergreen."""
from __future__ import absolute_import
from datetime import timedelta
from enum import IntEnum
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional
from evergreen.api_requests import IssueLinkRequest, MetadataLinkRequest
from... | evergreen-ci/evergreen.py | src/evergreen/task.py | .py | 20fb06c71b1443b7 | 7.24 | 2 |
# -*- encoding: utf-8 -*-
"""Stats representation of evergreen."""
from __future__ import absolute_import
from typing import TYPE_CHECKING, Any, Dict
from evergreen.base import _BaseEvergreenObject, evg_attrib, evg_date_attrib
if TYPE_CHECKING:
from evergreen.api import EvergreenApi
class TaskReliability(_Base... | evergreen-ci/evergreen.py | src/evergreen/task_reliability.py | .py | c6525114a06e1058 | 7.24 | 2 |
# -*- encoding: utf-8 -*-
"""Test representation of evergreen."""
from __future__ import absolute_import
from typing import TYPE_CHECKING, Any, Dict, Iterable
from evergreen.base import _BaseEvergreenObject, evg_attrib, evg_datetime_attrib
if TYPE_CHECKING:
from evergreen.api import EvergreenApi
class Logs(_Ba... | evergreen-ci/evergreen.py | src/evergreen/tst.py | .py | 0ff36f3f49faa975 | 7.24 | 2 |
# -*- encoding: utf-8 -*-
"""Representation of users having an evergreen role."""
from typing import TYPE_CHECKING, Any, Dict
from evergreen.base import _BaseEvergreenObject, evg_attrib
if TYPE_CHECKING:
from evergreen.api import EvergreenApi
class UsersForRole(_BaseEvergreenObject):
"""Representation of a ... | evergreen-ci/evergreen.py | src/evergreen/users_for_role.py | .py | aab6534ddfe0bac2 | 7.24 | 2 |
"""Unit tests for src/evergreen/alias.py."""
from evergreen.alias import DisplayTaskAlias, VariantAlias
class TestVariantAlias(object):
def test_get_attributes(self, sample_version_alias):
alias = VariantAlias(sample_version_alias, None)
assert alias.variant == sample_version_alias["Variant"]
... | evergreen-ci/evergreen.py | tests/evergreen/test_alias.py | .py | 575898d86071762c | 7.74 | 2 |
import pickle
from copy import copy
from evergreen.base import _BaseEvergreenObject
class TestPickleSupport(object):
def test_can_pickle_copy_support(self, sample_task):
"""Tests that a copy of the base evergreen object can be pickled"""
original = _BaseEvergreenObject(sample_task, None)
... | evergreen-ci/evergreen.py | tests/evergreen/test_base.py | .py | 8e77cf059b5df869 | 7.24 | 2 |
# -*- encoding: utf-8 -*-
"""Unit tests for src/evergreen/host.py."""
from __future__ import absolute_import
from evergreen.commitqueue import CommitQueue
class TestCommitQueue(object):
def test_get_attributes(self, sample_commit_queue):
commit_queue = CommitQueue(sample_commit_queue, None)
asser... | evergreen-ci/evergreen.py | tests/evergreen/test_commitqueue.py | .py | 368b1a4003438075 | 7.74 | 2 |
# -*- encoding: utf-8 -*-
"""Unit tests for src/evergreen/host.py."""
from __future__ import absolute_import
from datetime import datetime
from unittest.mock import MagicMock
from evergreen.host import Host
class TestHost(object):
def test_get_attributes(self, sample_host):
host = Host(sample_host, None... | evergreen-ci/evergreen.py | tests/evergreen/test_host.py | .py | 0fb27b4b023e8fed | 7.74 | 2 |
# -*- encoding: utf-8 -*-
"""Unit tests for src/evergreen/manifest.py."""
from __future__ import absolute_import
from evergreen.manifest import Manifest
class TestManifest(object):
def test_get_attributes(self, sample_manifest):
manifest = Manifest(sample_manifest, None)
assert manifest.id == sam... | evergreen-ci/evergreen.py | tests/evergreen/test_manifest.py | .py | b4a0b397909d606e | 7.74 | 2 |
# -*- encoding: utf-8 -*-
"""Unit tests for src/evergreen/host.py."""
from __future__ import absolute_import
from evergreen.patch import Patch
class TestPatch(object):
def test_get_attributes(self, sample_patch):
patch = Patch(sample_patch, None)
assert patch.description == sample_patch["descript... | evergreen-ci/evergreen.py | tests/evergreen/test_patch.py | .py | 246392a004ec5e0d | 7.74 | 2 |
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = []
# ///
"""Fetch GitHub Actions run summary and failed logs for debugging."""
import argparse
import json
import subprocess
import sys
def gh(*args: str, repo: str | None = None, allow_failure: bool = False) -> str:
cm... | JoshKarpel/dotfiles | claude/skills/debug-gha/scripts/debug-run.py | .py | af321b5d0f058595 | 7.15 | 1 |
#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.10"
# ///
"""Fetch GitHub PR review comments and metadata via GraphQL.
Auto-detects the PR from the current branch. Outputs structured markdown
to stdout for Claude to consume.
"""
import argparse
import json
import subprocess
import sys
GRAPHQL_QUERY = ... | JoshKarpel/dotfiles | claude/skills/handle-pr-review/scripts/fetch-pr-comments.py | .py | e1f91173baeb6a46 | 7.15 | 1 |
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = []
# ///
"""
Summarize a speedscope JSON profile (produced by austin2speedscope) into a
readable report of hotspots, showing self-time and inclusive-time per function.
Usage:
uv run profile_speedscope.py profile.json
u... | JoshKarpel/dotfiles | claude/skills/optimize-python/scripts/profile_speedscope.py | .py | 2665b30d1def8abf | 7.15 | 1 |
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# ///
import argparse
import bisect
import json
import re
import shutil
import subprocess
import sys
from collections import Counter, defaultdict
from dataclasses import dataclass
from pathlib import Path
DESCRIPTION = """\
Fold a samply prof... | JoshKarpel/dotfiles | claude/skills/optimize-rust/scripts/profile_report.py | .py | 336befa4deb26dc6 | 7.15 | 1 |
"""
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | farfarfun/funkeras | example/retinanet/tests/backend/test_common.py | .py | 5583dbc365d4d62f | 7.74 | 2 |
from fabric.api import *
import fabric.contrib.project as project
import os
import shutil
import sys
import SocketServer
from pelican.server import ComplexHTTPRequestHandler
# Local path configuration (can be absolute or relative to fabfile)
env.deploy_path = 'output'
DEPLOY_PATH = env.deploy_path
# Remote server co... | macbre/faroese-planet | planet/fabfile.py | .py | ec16983dc24b447b | 7.24 | 2 |
import time
import functools
from django.db import connection, reset_queries
from django.http import HttpResponseRedirect
from urllib.parse import urlencode, urlparse, urlunparse, parse_qsl
def remember_last_query_params(url_name, query_params):
"""Stores the specified list of query params from the last time thi... | karilint/cradle_of_mankind | app/cradle_of_mankind/decorators.py | .py | 038f7a5b2c8dbe1f | 7 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.