Skip to content

Instantly share code, notes, and snippets.

View tgamblin's full-sized avatar

Todd Gamblin tgamblin

View GitHub Profile
#!/usr/bin/python3
#
# Run `fix-emails` to change the format of emails in the macOS
# clipboard from Apple Mail to Outlook or vice versa.
#
# You can't copy/paste emails between them by default because their
# formats are different.
#
# Apple mail emails are comma-separated and always use quotes:
# "Last, First" <name@gmail.com>, ...
#!/usr/bin/env python
import re
import time
import contextlib
@contextlib.contextmanager
def timeit():
start = time.time()
try:
@tgamblin
tgamblin / fix-emails
Last active March 27, 2022 21:17
fix-emails: change emails in the macOS clipboard to/from Apple Mail/Outlook
#!/usr/bin/python
#
# Run `fix-emails` to change the format of emails in the macOS
# clipboard from Apple Mail to Outlook or vice versa.
#
# You can't copy/paste emails between them by default because their
# formats are different.
#
# Apple mail emails are comma-separated and always use quotes:
# "Last, First" <name@gmail.com>, ...
@tgamblin
tgamblin / full_index_patches.py
Last active March 3, 2022 00:28
Replace GitHub patch URLs and sha256's with ?full_index=1 URLs and new sha256's
#!/usr/bin/env spack-python
import os
import tempfile
import spack.patch
import spack.repo
import spack.util.crypto
from spack.util.executable import which
@tgamblin
tgamblin / gist:83eba3c6d27f90d9fa3afebfc049ceaf
Created March 13, 2021 01:35
Diffing specs by ASP facts in Spack
#!/usr/bin/env spack-python
from pprint import pprint
from spack.spec import Spec
from spack.solver.asp import SpackSolverSetup
specs = [
Spec("openblas +ilp64 +shared").concretized(),
Spec("openblas ~ilp64 +shared").concretized(),
Spec("openblas +ilp64 ~shared").concretized(),
@tgamblin
tgamblin / release.sh
Last active February 11, 2021 03:35
Get cards from github project
#!/bin/sh
version="$1"
docurl() {
curl \
-u "tgamblin:$(cat ~/.github/analysis-token)" \
-H 'Accept: application/vnd.github.inertia-preview+json' \
"$@"
}
@tgamblin
tgamblin / download.py
Last active February 8, 2021 18:20
Use spack to download some source code
#!/usr/bin/env spack-python
import os
import tempfile
from spack.spec import Spec
from spack.stage import DIYStage
import llnl.util.filesystem as fs
# concrtize a spec of what you want to build.
spec = Spec("hdf5 @1.10.2").concretized()
@tgamblin
tgamblin / yaml-json.py
Created October 31, 2016 12:08
Compare speed of YAML and JSON
#!/usr/bin/env spack-python
import os
import yaml
import json
import tempfile
import shutil
from timeit import timeit
import spack.util.spack_yaml as syaml
@tgamblin
tgamblin / simple-nvd-stats.py
Created February 24, 2015 07:56
Simple NVD stats parser
#!/usr/bin/env python
# Simple NVD Stats, showing vulnerabilities by OS.
# Run on data from https://nvd.nist.gov/download.cfm
# by Todd Gamblin
import re
import subprocess
from contextlib import closing
class Entry(object):