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]> | |
# ---------- | |
# | |
# ---------- | |
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
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
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
/* 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
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
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
# -*- coding: utf-8 -*- | |
# | |
# Copyright (c) 2021~2999 - Cologler <[email protected]> | |
# ---------- | |
# check if there has some invisible chars in your file path. | |
# ---------- | |
from typing import * | |
import os | |
import sys |
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) 2021~2999 - Cologler <[email protected]> | |
# ---------- | |
# | |
# ---------- | |
import json | |
import re |
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
# load all partial scripts to caller context. | |
# - for caller, add `. "$(Split-Path $PSCommandPath)\Load-PartialScripts.ps1"`; | |
# - the partial scripts must named `{caller}.{partial}.ps1`; | |
foreach ( | |
$item in $( | |
Get-ChildItem ` | |
-Path $(Split-Path $MyInvocation.PSCommandPath -Parent -Resolve) ` | |
-Filter "$(Split-Path $MyInvocation.PSCommandPath -LeafBase).*$(Split-Path $MyInvocation.PSCommandPath -Extension)" ` | |
| Sort-Object { Split-Path $_ -LeafBase } |