Skip to content

Instantly share code, notes, and snippets.

View Preston-Landers's full-sized avatar

Preston Landers Preston-Landers

View GitHub Profile
@Preston-Landers
Preston-Landers / fix-openapi-mdx-blocks.mjs
Created October 30, 2024 19:19
A script meant to un-escape "RAW" blocks in between docusaurus-plugin-openapi and the main docusaurus build - allows using MDX components in OpenAPI spec
/**
* The purpose of this script is to iterate over all the MDX files produced by
* `docusaurus-plugin-openapi` and look for and process "RAW" blocks, which are
* denoted by "# START_RAW" and "# END_RAW" markers. These are blocks of content
* embedded inside OpenAPI descriptions that we want to interpret as "raw"
* (non-escaped) MDX content; usually in order to import and render a custom
* React component inside the OpenAPI description field.
*
* In order to process a RAW block, the script will:
* - Remove the "# START_RAW" and "# END_RAW" markers
@Preston-Landers
Preston-Landers / ChatGPT print hack.md
Last active May 25, 2023 18:39
Tweak ChatGPT CSS to allow better printing of the conversation

ChatGPT print hack

If you want to print a conversation (or PDF) from ChatGPT, as of this writing the CSS makes it cut off everything after the first page.

Here's a simple little hack to enable printing the entire conversation.

Open the Javascript Console (Ctrl-Shift-J) or Developer Tools (Ctrl-Shift-I). Make sure the focus is on the console prompt >.

Paste and run this:

@Preston-Landers
Preston-Landers / issue24_test.py
Created April 8, 2020 14:13
Test of concurrent-log-handler issue 24
import logging
from concurrent.futures.process import ProcessPoolExecutor
from concurrent_log_handler import ConcurrentRotatingFileHandler
class Foo():
def func(self, *args):
print("Called func")
@Preston-Landers
Preston-Landers / test_multiproc_socket_inherit.py
Created December 6, 2016 22:56
Test the ability to inherit sockets in multiprocessing on Windows (Python 3.6)
#!/usr/bin/env python
# -*- coding: utf-8; mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vim: fileencoding=utf-8 tabstop=4 expandtab shiftwidth=4
"""
Test socket inheritance on Windows with multiprocessing.
"""
import time
@Preston-Landers
Preston-Landers / index.html
Created March 14, 2015 16:28
speakur-discussion Element Demo // source http://jsbin.com/jubabubazu/8
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>speakur-discussion Element Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"/>
<meta charset="utf-8">
<script src="http://preston-landers.github.io/speakur-discussion/components/webcomponentsjs/webcomponents.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://www.polymer-project.org/webcomponents.min.js"></script>
<title>JS Bin</title>
</head>
<!--
This is where you should put a basic demo to show off what your element can do!
A good usage example will help others understand what your element is and how
@Preston-Landers
Preston-Landers / pyuac.py
Last active June 16, 2023 04:09
pyuac - elevate a Python process with UAC on Windows
#!/usr/bin/env python
# -*- coding: utf-8; mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vim: fileencoding=utf-8 tabstop=4 expandtab shiftwidth=4
"""
THIS CODE IS OUTDATED! Please use this instead:
https://pypi.org/project/pyuac/
https://github.com/Preston-Landers/pyuac

Keybase proof

I hereby claim:

  • I am Preston-Landers on github.
  • I am planders (https://keybase.io/planders) on keybase.
  • I have a public key whose fingerprint is 1B11 8DEC 1920 CB99 F45E CDA0 6A6F 2667 C8A3 E66F

To claim this, I am signing this object: