Skip to content

Instantly share code, notes, and snippets.

View mpharrigan's full-sized avatar

Matthew Harrigan mpharrigan

View GitHub Profile
@mpharrigan
mpharrigan / cost.md
Last active October 7, 2023 00:00
Back-of-the-envelope cost

Assume Craig's CCZ factory and assume you're CCZ-generation limited (i.e. small number of factories).

Wall_time = n_tof * n_cycles * cycle_time
n_cycles = 5.5 * factory_distance

Assume factory_distance of 31 and cycle time of 1us

Wall_time = n_tof * 5.5 * 31 * 1us

Wall_time ~ 1.7e-4 s * n_tof = 2e-9 days * n_tof

@mpharrigan
mpharrigan / matplotlib-rcparams.py
Last active October 27, 2021 18:02
Matplotlib rcParams
%matplotlib inline
from matplotlib import pyplot as plt
import matplotlib
matplotlib.rcParams.update(**{
'axes.titlesize': 14,
'axes.labelsize': 14,
'xtick.labelsize': 12,
'ytick.labelsize': 12,
'legend.fontsize': 12,
set -e
# config: set this to your remote name
remote='origin'
branch_c='-c'
push_f=''
while getopts f flag
do
@mpharrigan
mpharrigan / flatten_dataclass.py
Created July 22, 2021 21:36
flatten dataclass
def _flat_dict(flat_record, record, prefix):
for k, v in record.items():
if isinstance(v, dict):
_flat_dict(flat_record, record[k], prefix+(k,))
else:
flat_record[prefix+(k,)] = v
def flatten(dd):
fd = {}
_flat_dict(fd, dd, tuple())
{
viewer {
pullRequests(first: 10, orderBy: {field: UPDATED_AT, direction: DESC}, states: [MERGED]) {
nodes {
title
number
}
}
}
}
@mpharrigan
mpharrigan / state-tomo.py
Last active January 31, 2019 17:03
State tomography
import functools
import itertools
from operator import mul
import numpy as np
from numpy.linalg import pinv
from pyquil import get_qc, Program
from pyquil.gates import *
from pyquil.operator_estimation import ExperimentSetting, TomographyExperiment, measure_observables
from pyquil.paulis import sI, sX, sY, sZ
@mpharrigan
mpharrigan / clean-notebook-command.sh
Last active January 3, 2019 20:03
Clean jupyter notebooks
# http://timstaley.co.uk/posts/making-git-and-jupyter-notebooks-play-nice/
# https://stedolan.github.io/jq/
jq --indent 1 \
'
(.cells[] | select(has("outputs")) | .outputs) = []
| (.cells[] | select(has("execution_count")) | .execution_count) = null
| .metadata = {"language_info": {"name":"python", "pygments_lexer": "ipython3"}}
| .cells[].metadata = {}
' notebook.ipynb
#CXRLE Pos=-2657,-359
x = 2904, y = 701, rule = B3/S23
2289b4o7b2o$2288bo3bo6bo2bo12b2o$2288bo10bo2b2o11b2o$2289bob2obo4bo2bo
$2292b3o6bo2$2292b3o6bo$2291b2obo4bo2bo$2290bo8bo2b2o$2291b2o6bo2bo$
2292bo7b2o3$2325b2o$2325b2o4$2404b4o7b2o$2319bo5bo77bo3bo6bo2bo12b2o$
2318b3o3b3o76bo10bo2b2o11b2o$2317bo2b2ob2o2bo76bob2obo4bo2bo$2317bo3bo
bo3bo79b3o6bo$2319bobobobo$2407b3o6bo$2316b2ob2o3b2ob2o77b2obo4bo2bo$
2318bo7bo78bo8bo2b2o$2406b2o6bo2bo$2407bo7b2o3$2325bo114b2o$2324b3o
113b2o$2323bo3bo$2322bo5bo$2322bo5bo$2323bo3bo191b4o7b2o$2434bo5bo77bo
3bo6bo2bo12b2o$2323bo3bo105b3o3b3o76bo10bo2b2o11b2o$2322bo5bo103bo2b2o
#!/bin/bash
#SBATCH --job-name=seg/{wd}
#SBATCH --output=stdout.%j
#SBATCH --error=stderr.%j
#SBATCH --time=12:00:00
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=2048
#SBATCH --gres gpu:1
##SBATCH --gres-flags=enforce-binding