Skip to content

Instantly share code, notes, and snippets.

@dstuebe
dstuebe / co_workflow.py
Last active August 29, 2015 14:01
Chaining coroutines for number crunching workflows...
TARGETS = 'targets'
class AnalysisWindowComplete(Exception):
"""
Used in coroutine control flow, this is not an error condition.
"""
def coroutine(func):
"""
@dstuebe
dstuebe / optimization pitfalls
Created June 10, 2011 07:40
pit falls using deferred lists and lazy optimization
from twisted.internet import defer
class DoStuff():
def __init_(self):
self.my_stuff = None
@dstuebe
dstuebe / post-checkout
Created February 8, 2012 21:24
Suggested ooici commit hooks to make working with ion-definitions easier
#!/bin/bash
# Check if any submodule has been updated in HEAD after a merge (or
# pull) or a branch checkout. If so, ask if user wants to run
# git-submodule update.
# --Chaitanya Gupta
SCRIPT_NAME=$(basename "$0")
if [[ "$SCRIPT_NAME" = "post-checkout" && "$1" = "$2" || "$3" = "0" ]]; then
@dstuebe
dstuebe / supervisord.conf
Created February 8, 2012 21:07
An example conf file for running rabbit and couch. Carefull, it assumes your user name is dstuebe.
; Sample supervisor config file.
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; sockef file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
[inet_http_server] ; inet (TCP) server disabled by default
@dstuebe
dstuebe / Publisher and Logger
Created June 1, 2012 15:46
Create a data stream and log the content in a subscribed process
###$ bin/pycc --rel res/deploy/r2dm.yml
### To Create a data stream and get some data on the stream copy this and use %paste
from interface.services.dm.ipubsub_management_service import PubsubManagementServiceClient
pmsc = PubsubManagementServiceClient(node=cc.node)
stream_id = pmsc.create_stream(name='pfoo')
pid = cc.spawn_process(name='ctd_test',module='ion.processes.data.example_data_producer',cls='ExampleDataProducer',config={'process':{'stream_id':stream_id}})
pid = cc.spawn_process(name='ctd_test',module='ion.processes.data.stream_granule_logger',cls='StreamGranuleLogger',config={'process':{'stream_id':stream_id}})
@dstuebe
dstuebe / sending_actual_email_script.py
Created June 1, 2012 16:33 — forked from swarbhanu/sending_actual_email_script.py
Script to send an actual email through the user notification service
from interface.objects import DeliveryMode, UserInfo
from pyon.event.event import EventPublisher
#---------------------------------------------------------------------------------
# Create email notification
#---------------------------------------------------------------------------------
rr = pn.resource_registry
@dstuebe
dstuebe / pyon.local.yml
Created June 6, 2012 14:06
Config for user notification email
system:
smtp: True
# This bit is not needed for smtp, but it keeps pyon from complaining about not having a privileged connection
container:
messaging:
server:
primary: amqp
priviledged: amqp
# ----------------------------------------------------------------------------------
@dstuebe
dstuebe / GLOS Query INFO
Last active December 10, 2015 13:08
Query Info from the basex gui using full text and geospatial query
Query: declare namespace gmd="http://www.isotc211.org/2005/gmd"; declare namespace gco="http://www.isotc211.org/2005/gco"; declare namespace gmi="http://www.isotc211.org/2005/gmi"; declare namespace gml="http://www.opengis.net/gml"; declare namespace xs="http://www.w3.org/2001/XMLSchema"; declare function local:FreeTextQueryFunction($sequences, $textsearch) { let $searchTerms := tokenize($textsearch,'\s+') for $val in $sequences where ($val//text() contains text {$searchTerms} all using fuzzy ) return$val }; declare function local:GeoSpatialWithinQueryFunction($sequences, $west, $east, $north, $south) { for $val in $sequences let $bbox := $val//gmd:EX_GeographicBoundingBox let $westB := $bbox/gmd:westBoundLongitude/gco:Decimal let $eastB := $bbox/gmd:eastBoundLongitude/gco:Decimal let $southB := $bbox/gmd:southBoundLatitude/gco:Decimal let $northB := $bbox/gmd:northBoundLatitude/gco:Decimal where ($west <= $westB and $east >= $eastB and $south <= $southB and $north >= $northB) return $val }; declare function
@dstuebe
dstuebe / GO-Station-SingleFT-timeSeries-MultiSensor.xml
Last active December 12, 2015 12:28
Proposed resolution for reference frame
<?xml version="1.0" encoding="UTF-8"?>
<!-- ==================================================
** COMMENTS on namespace specifications:
- gml: using an unversioned namespace has been confirmed to be ok;
the om 1.0 schema defines GML 3.1.1 as the version used
================================================== -->
<om:ObservationCollection
xmlns:om="http://www.opengis.net/om/1.0"
xmlns:gml="http://www.opengis.net/gml"
xmlns:swe="http://www.opengis.net/swe/1.0.1"
@dstuebe
dstuebe / with_gen.py
Created March 12, 2013 02:54
Trying to put a generator inside a with statement. It seems it is not possible.
from exceptions import StopIteration, GeneratorExit
class WithThis(object):
"""
Open is a built in - can't override __exit__ or subclass it so wrap it :-(
"""
def __init__(self,this=None):