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
language: python | |
dist: xenial | |
python: | |
- '3.8' | |
- '3.9' | |
before_install: | |
- pip install poetry poetry-dynamic-versioning | |
install: | |
- poetry install |
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
def setup_proc_timeout(timeout: float, basedir: str, prefix: str=''): | |
''' | |
setup process timeout; | |
dump traceback from all threads to `basedir` if timeout. | |
''' | |
import os | |
import datetime | |
import atexit | |
import faulthandler |
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
/* Copyright (c) 2020~2999 - Cologler <[email protected]> */ | |
/** | |
* Run a function exactly one time. | |
* | |
* @param fn {Function} | |
*/ | |
function once(fn) { | |
let called; | |
let value; |
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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Runtime.ConstrainedExecution; | |
using System.Runtime.InteropServices; | |
using System.Security.Permissions; | |
using Microsoft.Win32.SafeHandles; | |
// backup for https://www.codeproject.com/Articles/38959/A-Faster-Directory-Enumerator |
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
using System; | |
using System.IO; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.InteropServices; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace Utils | |
{ |
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
# -*- coding: utf-8 -*- | |
# | |
# Copyright (c) 2020~2999 - Cologler <[email protected]> | |
# ---------- | |
# | |
# ---------- | |
from ctypes import windll, create_unicode_buffer, c_wchar_p, sizeof | |
from string import ascii_uppercase |
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
with SqliteDict('./c.db', encode=json.dumps, decode=json.loads, autocommit=True) as db: | |
with contextlib.closing(SqliteDictLoader(db)) as sdloader: | |
db['a'] = {'b': 2, 'c': { | |
'$ref': 'sqlitedict://./k' | |
}} | |
db['k'] = {'f': 'feji'} | |
loader = Loader() | |
loader.loaders.append(sdloader) | |
c = jsonref.loads(json.dumps(db['a']), loader=loader) |
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
# -*- coding: utf-8 -*- | |
# | |
# Copyright (c) 2020~2999 - Cologler <[email protected]> | |
# ---------- | |
# tinydb storage with atomic write. | |
# ---------- | |
import os | |
import json | |
from contextlib import suppress |
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
# base-on https://zhuanlan.zhihu.com/p/104046487 | |
# clean patchs | |
Get-ChildItem -Path TCLS/patchs | Remove-Item | |
# clean Cross | |
Get-ChildItem -Path Cross | Where-Object -Property Name -NE -Value 'Apps' | Remove-Item –Recurse -Force | |
Get-ChildItem -Path Cross/Apps | Where-Object -Property Name -NE -Value 'Apps' | Remove-Item –Recurse -Force | |
# mark readonly. |
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
function getGlobal() { | |
if (typeof globalThis !== 'undefined') { | |
return globalThis; | |
} else if (typeof window !== 'undefined') { | |
return window; // browser | |
} else if (typeof global != 'undefined') { | |
return global; // node | |
} else { | |
throw Error('unknown'); | |
} |