Skip to content

Instantly share code, notes, and snippets.

@chinasaur
chinasaur / notebook.ipynb
Last active February 28, 2023 19:28
SegCLR CSV ZIP access.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chinasaur
chinasaur / find_target.py
Created August 26, 2021 03:10
CachedTargetFinder
class CachedTargetFinder:
def __init__(self, mask: np.ndarray, daf: np.ndarray):
assert np.isfortran(mask)
assert np.isfortran(daf)
mask_indices = np.flatnonzero(mask.ravel(order='F'))
daf_sort = np.argsort(-daf.ravel(order='F')[mask_indices])
self.daf_indices = mask_indices[daf_sort]
def find_target(self, mask: np.ndarray) -> Optional[Tuple[int, int, int]]:
@chinasaur
chinasaur / fafb-ffn1-cloudvolume-point-lookups.ipynb
Created September 30, 2019 17:09
FAFB-FFN1 CloudVolume point lookups.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chinasaur
chinasaur / clean_paperpile.py
Last active October 3, 2023 05:00
Remove paperpile hyperlinks from PDF
# Basically seems to work to strip all paperpile links from the text
# and references section, while leaving rest of links intact.
import pdfrw # https://github.com/pmaupin/pdfrw/tree/master/pdfrw
pdf = pdfrw.PdfReader('input_path.pdf')
for page in pdf.pages:
if not page.Annots:
continue
nopaperpile = pdfrw.objects.pdfarray.PdfArray()
@chinasaur
chinasaur / README.md
Last active August 29, 2015 14:16 — forked from jaredwinick/README.md
Z-Order Curve with Query... now in BLUE!

Copied from jaredwinick's gist to replace red with blue. Makes the visualization friendly for protanopic viewers (strong red colorblindness, about 1% of the male population).

Z-Order curves are used to encode multiple dimensions to one dimension while maintaining locality. This feature makes them useful for indexing multidimensional data such as geospatial data. In BigTable-like systems (Accumulo, HBase, Cassandra a z-order curve index can translate a bounding box query to a single range scan. As this example shows, sometimes the locality properties of the curve are very good and few points outside the bounding box are scanned. Other times though, many points outside the bounding box are scanned if using a single range.

This example was inspired by Mike Bostock's Quadtree example

@chinasaur
chinasaur / Handcoded
Created September 13, 2013 04:45
Matlab profiling comparison for SOCP program stuffing
time calls line
1 function [ecos_c, ecos_G, ecos_h, dims, ecos_A, ecos_b] = cbp2ecos_2norm(dict, data, lambda, noisesigma, radii, theta)
2 % RADII, THETA must be column vectors
3
1000 4 ndict = size(dict, 2) / 3;
1000 5 ldata = length(data);
6
7
8 % Cone constraints in conventional order (ecos_G in particular will have to
9 % be arranged to match these conventions)
@chinasaur
chinasaur / Pandora Daemon Client.json
Created December 6, 2012 23:00
pianod Pandora Daemon Client configuration for NetIO Controller
{
"type": "NetIOConfiguration",
"version": 1.3,
"connections": [
{
"name": "pianod",
"host": "192.168.0.110",
"port": 4445,
"initialsend": "user user passwd",
"timeout": "4.0"