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) Jean-Charles Lefebvre | |
# SPDX-License-Identifier: MIT | |
import re | |
from collections.abc import Iterable, Mapping, Sequence, Sized | |
__all__ = ["Arty"] | |
_NONE_TYPE = type(None) |
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) Jean-Charles Lefebvre | |
# SPDX-License-Identifier: MIT | |
import contextlib | |
import importlib | |
import importlib.resources | |
import os | |
import re | |
import sqlite3 | |
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
import itertools | |
import threading | |
_datastruct_cache_lock = threading.Lock() | |
_datastruct_cache = {} | |
class DataStruct(object): | |
""" | |
A ``__slots__`` based class that works pretty much like a mutable | |
`collections.namedtuple` |
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 os.path | |
import sublime | |
import sublime_plugin | |
# build 3176: this does not work properly. self.view.set_name() works but it | |
# seems to sort-of "unlinks" the view from its physical file path, so that if | |
# the "Save" command is invoked upon this view, a "Save As" dialog will pop up | |
# even though the view was loaded from an existing file. |
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
#pragma once | |
namespace xx { | |
// A memory stream buffer class compliant with `std::basic_streambuf`. | |
// | |
// Usage example: | |
// | |
// std::vector<char> data; | |
// // ... fill-in *data* here ... |
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 collections import namedtuple | |
from pprint import pprint | |
import sys | |
import timeit | |
class C1: | |
__slots__ = ('a', ) | |
class C2: |
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 | |
import string | |
def name_file(dt): | |
""" | |
Return a name according to the given `datetime.datetime` object. | |
This is how Garmin devices seem to name their activity files, as explained | |
`here <https://forums.garmin.com/forum/into-sports/running/forerunner-220-aa/53766->`_. |
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
// char_type_of: deduce the char type of virtually any literal or | |
// container (C++11 SFINAE at its finest) | |
// Original author: Jean-Charles Lefebvre <[email protected]> | |
// util: an almighty version of std::decay<>, with super powers | |
template <typename T> | |
struct super_decay | |
{ | |
typedef | |
typename std::remove_cv< |
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
template <typename T> | |
struct super_decay | |
{ | |
typedef | |
typename std::remove_cv< | |
typename std::remove_pointer< | |
typename std::remove_reference< | |
typename std::remove_extent< | |
typename std::decay<T>::type>::type>::type>::type>::type type; | |
}; |
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 ctypes as ct | |
from ctypes.wintypes import * | |
import uuid | |
def has_func(ctypes_dll, func_name): | |
if hasattr(ctypes_dll, func_name): | |
return func_name | |
if not func_name.endswith("W") and hasattr(ctypes_dll, func_name + "W"): | |
return func_name + "W" | |
return None |
NewerOlder