Skip to content

Instantly share code, notes, and snippets.

View prescod's full-sized avatar

Paul Prescod prescod

View GitHub Profile
@prescod
prescod / massive_shuffles.py
Created April 7, 2024 17:55
Massive shuffles
from snowfakery.utils.randomized_range import random_range
countries = ["Canada", "Mexico", "United States", "Japan", "China"] * 1_000_000
def shuffle_sequence(sequence):
indexes = random_range(0, len(sequence))
for index in indexes:
yield sequence[index]
@prescod
prescod / gist:b2ec0f6ee88d0b87662d6cf591a1d40a
Created June 3, 2023 03:58
Pandoc auto-markup attempt
<p>Plug-in coding conventions</p>
<p>To ensure custom plug-ins work well with the core toolkit code and
remain compatible with future releases, the DITA Open Toolkit project
recommends that plug-ins use modern development practices and common
coding patterns.</p>
<p>Best practices</p>
<p>Adhering to certain development practices will properly isolate your
code from that of DITA Open Toolkit. This will make it easier to you to
upgrade to new versions of DITA-OT when they are released.</p>
<ul>
@prescod
prescod / gist:70a867012ec4b7e55d01ad415b48b5be
Created June 3, 2023 03:48
Plug-in coding conventions in raw text
Plug-in coding conventions
To ensure custom plug-ins work well with the core toolkit code and remain compatible with future releases, the DITA Open Toolkit project recommends that plug-ins use modern development practices and common coding patterns.
Best practices
Adhering to certain development practices will properly isolate your code from that of DITA Open Toolkit. This will make it easier to you to upgrade to new versions of DITA-OT when they are released.
* Use a properly-constructed DITA-OT plug-in.
* Use a version control system to store your code.
@prescod
prescod / cycles.txt
Created June 13, 2022 09:56
Createable reference cycles in SFDC
['UserProvisioningRequest.ParentId', 'UserProvisioningRequest']
['OrgMetricScanSummary', 'OrgMetricScanSummary.OrgMetricId', 'OrgMetric', 'OrgMetric.LatestOrgMetricScanSummaryId']
['RefundLinePayment', 'RefundLinePayment.AssociatedRefundLinePaymentId']
['PaymentLineInvoice.AssociatedPaymentLineId', 'PaymentLineInvoice']
['FeedComment', 'FeedComment.ThreadParentId']
['NavigationMenuItem.DraftRowId', 'NavigationMenuItem']
['NavigationMenuItem', 'NavigationMenuItem.ParentId']
['ContentFolder', 'ContentFolder.ParentContentFolderId']
['CategoryNode', 'CategoryNode.ParentId']
['ContentVersion.FirstPublishLocationId', 'CollaborationGroup', 'CollaborationGroup.AnnouncementId', 'Announcement', 'Announcement.FeedItemId', 'FeedItem', 'FeedItem.RelatedRecordId', 'ContentVersion']
@prescod
prescod / find_cycles.py
Created June 13, 2022 09:53
Use CumulusCI and NetworkX to find reference cycles
# cci org shell qa --script find_cycles.py
import networkx
from cumulusci.salesforce_api.org_schema import get_org_schema
def look_for_cycles(sf, org_config):
G = networkx.DiGraph()
with get_org_schema(sf, org_config) as org_schema:
Building wheel for fastnumbers (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-u6un7_3p/fastnumbers/setup.py'"'"'; __file__='"'"'/tmp/pip-install-u6un7_3p/fastnumbers/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-yjvat2p7 --python-tag cp38
cwd: /tmp/pip-install-u6un7_3p/fastnumbers/
Complete output (17 lines):
running bdist_wheel
running build
running build_ext
building 'fastnumbers' extension
creating build
$ python
Python 3.6.8 (default, Feb 19 2019, 17:13:58)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.10.44.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ast import literal_eval
>>> literal_eval("100-20")
80
>>>
$ pyenv shell 3.8.0
$ pyenv shell 3.6.8
$ pip install jinja2
Collecting jinja2
Using cached https://files.pythonhosted.org/packages/65/e0/eb35e762802015cab1ccee04e8a277b03f1d8e53da3ec3106882ec42558b/Jinja2-2.10.3-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from jinja2)
Downloading https://files.pythonhosted.org/packages/f0/00/a6aea33f5598b080b86d6b6d1214b51afe3ffa6100b902d5aa465080083f/MarkupSafe-1.1.1-cp36-cp36m-macosx_10_6_intel.whl
Installing collected packages: MarkupSafe, jinja2
Successfully installed MarkupSafe-1.1.1 jinja2-2.10.3
You are using pip version 18.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/Users/pprescod/code/envs/metaci-py/lib/python3.7/site-packages/_pytest/main.py", line 187, in wrap_session
INTERNALERROR> config._do_configure()
INTERNALERROR> File "/Users/pprescod/code/envs/metaci-py/lib/python3.7/site-packages/_pytest/config/__init__.py", line 720, in _do_configure
INTERNALERROR> self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR> File "/Users/pprescod/code/envs/metaci-py/lib/python3.7/site-packages/pluggy/hooks.py", line 308, in call_historic
INTERNALERROR> res = self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/Users/pprescod/code/envs/metaci-py/lib/python3.7/site-packages/pluggy/manager.py", line 92, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/Users/pprescod/code/envs/metaci-py/lib/python3.7/site-packages/pluggy/manager.py", line 86, in <lambda>
File "/Users/pprescod/code/envs/metaci-py/bin/pytest", line 10, in <module>
sys.exit(main())
File "/Users/pprescod/code/envs/metaci-py/lib/python3.7/site-packages/_pytest/config/__init__.py", line 71, in main
config = _prepareconfig(args, plugins)
File "/Users/pprescod/code/envs/metaci-py/lib/python3.7/site-packages/_pytest/config/__init__.py", line 221, in _prepareconfig
pluginmanager=pluginmanager, args=args
File "/Users/pprescod/code/envs/metaci-py/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/Users/pprescod/code/envs/metaci-py/lib/python3.7/site-packages/pluggy/manager.py", line 92, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)