Skip to content

Instantly share code, notes, and snippets.

View harleyholt's full-sized avatar

Harley Holt harleyholt

  • Seattle
  • 22:34 (UTC -07:00)
View GitHub Profile
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"externalId": {
"description": "The externalId passed to the service by the caller, if one was provided.",
"type": "string"
},
"id": {
"description": "A unique Id generated by C-SATS.",
@harleyholt
harleyholt / bulk-task-graph.py
Created September 19, 2014 22:25
bulk-task-graph.py
import json
from bigdoor.task.worker.bulk import add_resource_identifier, get_tasks, order_tasks
import networkx as nx
colors = ['red', 'blue', 'green', 'yellow', 'violet']
task_type_colors = {}
def run():
data = json.loads(open('reward.json').read())
@harleyholt
harleyholt / select-from-redshift.sql
Created March 17, 2014 23:39
Retrieves the data we want to get from RedShift.
select
row_type_cd,
row_sub_type_cd,
date_pst,
publisher_id,
site_id,
case
when user_type_cd = 'C' then 'control'
when user_type_cd = 'T' then 'test'
else 'other'
@harleyholt
harleyholt / example-if-template.html
Created October 20, 2011 22:24
Example of Knockout Conditionally Rendered Template
<!-- Example one shows the most verbose way of specifying a template that is only rendered if someObject is defined in the current view model
This information was culled from https://github.com/SteveSanderson/knockout/blob/1.3/src/binding/defaultBindings.js#L445
-->
<script type="text/html" id="sub-example-one">
<h2 data-bind="text: title"></h2>
<p data-bine="text: description"></p>
</script>
<script type="text/html" id="example-one">
@harleyholt
harleyholt / msyq-dump-specific-tables.sh
Created October 14, 2011 21:20
MySQL Dump Specific Tables and Stored Procs
mysqldump <database-name> [<table1> ... <tableN>] --routines > output.sql
@harleyholt
harleyholt / django-stored-procedure.py
Created October 11, 2011 01:59
Django Stored Procedure
from django.db import connections
arguments = ('one', 'two', 'three', '...')
cursor = connections['example-db'].cursor()
try:
cursor.callproc('proc_name', arguments)
results = cursor.fetchall()
finally:
cursor.close()
@harleyholt
harleyholt / data-api-summary-return.js
Created September 26, 2011 17:58
Example Data API Summary Return Object
/**
* Example of a summary only data API return. The returned information contains the aggregate information.
* The site value is the site that we are getting information for (it will not exist if the results are not filtered
* to a specific site)
* The time value contains the start and end of the sampling period while the resolution tells the client what the aggregate
* period is for the client
*/
{
site: example.com,
time: {
@harleyholt
harleyholt / data-api-return.js
Created September 23, 2011 01:03
Example Data API Return Object
/**
* One way of specifying the analytic endpoint data.
* In this scheme, we can have multiple parallel time series returned.
* Includes a summary object which allows us to return aggregated data for the series.
* Includes a meta object which has information about the series (such as the units of measurement).
*
* The time series is specified as an array of values. This series can not be missing any values because it is in
* parallel to the generated time values. The API must take care of filling in any missing values of the time
* series before returning it.
*
@harleyholt
harleyholt / gearman-worker-example.py
Created September 21, 2011 22:38
Example Python Gearman Worker (for python Gearman 2.0)
from gearman import GearmanWorker
# The function that will do the work
def echoer(worker, job):
print job.data
return job.data
# Establish a connection with the job server on localhost--like the client,
# multiple job servers can be used.
worker = GearmanWorker(['127.0.0.1'])
@harleyholt
harleyholt / gearman-client-example.py
Created September 21, 2011 22:30
Example Python Gearman Client (for python Gearman 2.0)
from gearman import GearmanClient
# create a client that will connect to the Gearman server running on
# localhost. The array allows you to specify a set of job servers.
client = GearmanClient(['127.0.0.1'])
# Submit a synchronous job request to the job server and store the
# result.
# This runs the "echo" job on the argument "foo"
result = client.submit_job('echo', 'foo')