Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Sick jonathansick

View GitHub Profile
@jonathansick
jonathansick / query.graphql
Last active Nov 16, 2020
GitHub GraphQL repo commit history query
View query.graphql
{
repository(name: "sickvim", owner: "jonathansick") {
ref(qualifiedName: "master") {
target {
... on Commit {
id
history(first: 5) {
pageInfo {
hasNextPage
}
@jonathansick
jonathansick / mockregistry.py
Created Aug 15, 2019
Using the MockRegistryApi
View mockregistry.py
# In unit tests =====================================
from kafkit.registry.sansio import MockRegistryApi
# The Avro schema that you'll be testing with
schema = {}
# The MockRegistryApi works just like the RegistryApi, but doesn't
# do any network requests.
registryclient = MockRegistryApi()
@jonathansick
jonathansick / newtopics.py
Last active Aug 15, 2019
Creating Kafka topics
View newtopics.py
from confluent_kafka.admin import AdminClient, NewTopic
default_num_partitions = 1
default_replication_factor = 3
client = AdminClient({
'bootstrap.servers': 'url...'
})
# First list existing topics
@jonathansick
jonathansick / gal_radii_pb.py
Last active Oct 2, 2017 — forked from PBarmby/gal_radii_pb.py
Compute deprojected galactocentric distance using astropy.coordinates. (By @PBarmby)
View gal_radii_pb.py
from astropy.coordinates import ICRS, Distance, Angle
from astropy import units as u
import numpy as np
def correct_rgc(coord, glx_ctr=ICRS('00h42m44.33s +41d16m07.5s'),
glx_PA=Angle('37d42m54s'),
glx_incl=Angle('77.5d'),
glx_dist=Distance(783, unit=u.kpc)):
"""Computes deprojected galactocentric distance.
@jonathansick
jonathansick / vospaceio.py
Created Dec 9, 2013
Example of a high-level python API to VOSpace.
View vospaceio.py
#!/usr/bin/env python
# encoding: utf-8
"""
File I/O using CANFAR's VOSpace.
2013-05-24 - Created by Jonathan Sick
"""
import os
import time
@jonathansick
jonathansick / gist:5232875
Created Mar 24, 2013
Swarping an image to match another
View gist:5232875
# Say the target fits image is image1.fits, you want to align image2.fits to its pixel frame
ln -s image1.fits image2_reg.head
swarp image2.fits -IMAGEOUT_NAME image2_reg.fits -COMBINE N -RESAMPLE Y
# the resampled+aligned image2 will be image2_reg.resample.fits
# May be other flags that need to be set; I've pipelined this so I forget how to do a barebones case!
@jonathansick
jonathansick / jsick.py
Created Nov 29, 2012 — forked from dfm/jsick.py
for jsick
View jsick.py
#!/usr/bin/env python
import numpy as np
import emcee
class ProbWrapper(object):
def __init__(self, f):
super(ProbWrapper, self).__init__()
self._f = f
@jonathansick
jonathansick / watcher.py
Created Sep 2, 2012
Run make whenever a LaTeX file is modified (using Python watchdog)
View watcher.py
import subprocess
import os
import time
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
class ChangeHandler(FileSystemEventHandler):
"""React to modified .tex files."""
@jonathansick
jonathansick / pygrtf.sh
Created Jun 7, 2012
Pygmentize to RTF and Copy
View pygrtf.sh
#!/bin/bash
# From http://emptysquare.net/blog/syntax-highlighting-with-pycharm-pygments-and-keynote/
/usr/local/bin/pygmentize -f rtf -O "style=friendly,fontface=Courier Bold" "$1" | pbcopy
@jonathansick
jonathansick / milesizer.py
Created Jun 6, 2012
Download MILES spectra and associate metadata.
View milesizer.py
#!/usr/bin/env python
# encoding: utf-8
"""
Download MILES spectra and associate metadata.
2012-05-25 - Created by Jonathan Sick
"""
import os
from StringIO import StringIO
You can’t perform that action at this time.