Skip to content

Instantly share code, notes, and snippets.

DECLARE @PractitionerList TABLE(PracticionerID INT)
DECLARE @PractitionerID INT
INSERT @PractitionerList(PracticionerID)
SELECT PracticionerID
FROM Practitioner
WHILE(1 = 1)
BEGIN
function to_pos($pos, $str) {
$text_width = ($str -replace '\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])','').Length
$rpos = $host.UI.RawUI.WindowSize.Width - $text_width + 1
$bot = $host.UI.RawUI.WindowSize.Height
$setloc = switch ($pos) {
"UL" { "`e[1;1f" }
"UR" { "`e[1;${rpos}f" }
"LL" { "`e[${bot};1f" }
"LR" { "`e[${bot};${rpos}f" }
"L" { "`e[1G" }
@pfmoore
pfmoore / strip_ansi.ps1
Created October 26, 2020 09:47
Strip ANSI escape characters from a string
param ([String]$s)
$s -replace '\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])',''
@pfmoore
pfmoore / sql.py
Created September 22, 2020 20:59
A SQL query runner using Pandas
# A SQL query runner using Pandas
# pip install pandas tabulate sqlalchemy
import pandas as pd
from tabulate import tabulate
# import sqlite3
df = pd.read_sql(
"select name, downloaded, serial from projects limit 20",
@pfmoore
pfmoore / metadata.py
Created June 22, 2020 14:56
Python packaging metadata parser
import re
import json
from email.message import EmailMessage
from email import message_from_string
class InvalidMetadata(Exception):
pass
SINGLE_USE = [
"Metadata-Version",
@pfmoore
pfmoore / Minecraft Building Gadgets
Last active April 11, 2020 20:12
Minecraft Building Gadgets
Some buildings for Direwolf20's "Building Gadgets" copy/paste gadget.
@pfmoore
pfmoore / gist:5fc59e04905c6f944b4e99a3d8ef7705
Created March 19, 2020 12:44
pip test failures with new resolver
FAIL tests/functional/test_check.py::test_basic_check_broken_dependency
FAIL tests/functional/test_check.py::test_check_complicated_name_broken
FAIL tests/functional/test_check.py::test_basic_check_broken_dependency_and_missing_dependency
FAIL tests/functional/test_check.py::test_check_complicated_name_missing
FAIL tests/functional/test_check.py::test_check_development_versions_are_also_considered
FAIL tests/functional/test_check.py::test_basic_check_missing_dependency
FAIL tests/functional/test_check.py::test_check_complicated_name_clean
FAIL tests/functional/test_check.py::test_check_considers_conditional_reqs
FAIL tests/functional/test_download.py::test_basic_download_should_download_dependencies
FAIL tests/functional/test_install.py::test_pep518_with_extra_and_markers
@pfmoore
pfmoore / CandidateIReqInterface.txt
Created March 12, 2020 14:08
Notes on the interface between Candidate and InstallRequirement
Thoughts on the interface between a Candidate and an InstallRequirement.
The Candidate will hold a pip Link object as its "identifier" of the
distribution file/directory it represents. So it needs to be able to
say "Give me the (unique) InstallRequirement that's representing this
Link". I'd suggest that the interface has internally a Link->InstallRequirement
dictionary.
Creating the InstallRequirement needs a "parent" InstallRequirement from
which the options:
Lifecycle of an InstallRequirement
==================================
Three types of InstallRequirement:
* A specifier, something like "pip>=19.0" or just "pip".
* A location, which could be:
- A URL - https://example.com/wheels/foo-1.0-py3-none-any.whl
- A directory - D:\Wheels\foo-1.0-py3-none-any.whl
- A VCS URL - git+https://github.com/pypa/pip
@pfmoore
pfmoore / resolver.md
Last active March 10, 2020 21:05
New pip resolver announcement

A new resolver for pip [PRELIMINARY DRAFT]

The pip developers are in the process of rolling out a new resolver for pip (refer to the funded work here?). As part of that work, there will be some major changes to how pip determines what to install, based on package requirements.

What will change

The most significant changes to the reolver will be:

  • It will no longer install a combination of packages that is mutually inconsistent. At the moment, it is