Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Sick jonathansick

View GitHub Profile
View tarballs.md

EUPS distrib binary "tarball" products

The EUPS distrib facility (eups distrib ...) has support for packaging and publishing binary builds in a package format called "tarballs". Unlike the "eupspkg" (source) package format that was the sole DM published product format, "tarballs" are inherently tied to the microarchitecture and ABI of a platform. As there are currently multiple supported "stack" build platforms, a means of coordinating multiple independent binary builds from identical sources is needed both to ensure consistency of product versions across platforms and

View did-you-know-re.py
from sre_parse import Pattern, SubPattern, parse as sre_parse
from sre_compile import compile as sre_compile
from sre_constants import BRANCH, SUBPATTERN
class Scanner(object):
def __init__(self, tokens, flags=0):
subpatterns = []
pat = Pattern()
@jhoblitt
jhoblitt / graph.sh
Created Nov 12, 2015
Build a graph of the EUPS product dependencies
View graph.sh
git clone https://github.com/lsst-sqre/build-graph.git
cd build-graph/
wget https://raw.githubusercontent.com/lsst/versiondb/master/manifests/b1780.txt
virtualenv deps
. deps/bin/activate
pip install -r requirements.txt
./deps.py b1780.txt
View change-resource-record-sets.json
{
"Comment": "A new CNAME for jsick's Read the Docs documentation.",
"Changes": [
{
"Action": "CREATE",
"ResourceRecordSet": {
"Name": "docs.lsst.codes.",
"Type": "CNAME",
"SetIdentifier" : "Read the Docs",
"Weight": 10,
@PBarmby
PBarmby / make_latex_unc_tab.py
Created Jan 5, 2015
Deals with making a LaTeX table with uncertainties and correct number of significant figures
View make_latex_unc_tab.py
from astropy.table import Table, Column, join, vstack
from uncertainties import ufloat
import astropy.units as u
def uncert_str(tab_row, col_name, value_fmt):
''' format tab_row[col_name] single table row in LaTeX $num \pm unc$ format
input: tab_row: single row from an astropy table
col_name: name of column to be extracted and formatted
value_fmt: format for string output
output:
@cmod
cmod / minimal_fb_messenger.css
Last active Dec 6, 2019
Minimal Facebook Messenger for Fluid
View minimal_fb_messenger.css
/*
Minimal Facebook Messenger
==========================
1. Make a Fluid (http://fluidapp.com/) instance of https://facebook.com/messages/
1. a. (You need to buy the paid version of Fluid to modify UserStyles)
2. Apply the below CSS as a Userstyles stylesheet
3. Like magic, you can now message without all the cruft of Full Facebook
@jonathansick
jonathansick / pypi_checklist.md
Last active Aug 29, 2015
A checklist for uploading to PyPI, because I always forget.
View pypi_checklist.md

First time:

python setup.py register

Uploading a new version:

python setup.py check
@PBarmby
PBarmby / gal_radii_pb.py
Created Mar 4, 2014
Computes deprojected galactocentric distances
View gal_radii_pb.py
from astropy.coordinates import ICRS, Galactic, Distance, Angle
from astropy import units as u
import math as mt
import numpy as np
from astropy.table import Table, Column
# inspired by
#http://idl-moustakas.googlecode.com/svn-history/r560/trunk/impro/hiiregions/im_hiiregion_deproject.pro
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 for an object at coord,
@gruber
gruber / Liberal Regex Pattern for Web URLs
Last active Nov 17, 2020
Liberal, Accurate Regex Pattern for Matching Web URLs
View Liberal Regex Pattern for Web URLs
The regex patterns in this gist are intended only to match web URLs -- http,
https, and naked domains like "example.com". For a pattern that attempts to
match all URLs, regardless of protocol, see: https://gist.github.com/gruber/249502
# Single-line version:
(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|s
@hest
hest / gist:8798884
Created Feb 4, 2014
Fast SQLAlchemy counting (avoid query.count() subquery)
View gist:8798884
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
You can’t perform that action at this time.