Skip to content

Instantly share code, notes, and snippets.

View spmallette's full-sized avatar

stephen mallette spmallette

View GitHub Profile
@spmallette
spmallette / curl
Created March 29, 2012 11:49
OrientDB and Rexster
curl -X POST http://localhost:8182/graphs/orientdbsample/vertices
curl -X POST http://localhost:8182/graphs/orientdbsample/vertices
curl -X POST "http://localhost:8182/graphs/orientdbsample/edges?_outV=6:0&_inV=6:1&_label=friend"
curl -X POST "http://localhost:8182/graphs/orientdbsample/edges?_outV=6:0&_inV=6:1&_label=pal"
curl -X POST "http://localhost:8182/graphs/orientdbsample/edges?_outV=6:0&_inV=6:1&_label=buddy"
>curl -X POST -d "script=g.createManualIndex('somev', Vertex.class) "http://localhost:8182/graphs/orientdbsample/tp/gremlin
{"results":["MANUAL[somev:Vertex]"],"success":true,"version":"0.8","queryTime":194.52165}
>curl -X POST -d "script=g.createManualIndex('otherv', Vertex.class)" http://localhost:8182/graphs/orientdbsample/tp/gremlin
{"results":["MANUAL[otherv:Vertex]"],"success":true,"version":"0.8","queryTime":82.164353}
>curl -X POST -d "script=g.idx('otherv')" http://localhost:8182/graphs/orientdbsample/tp/gremlin
{"results":["MANUAL[otherv:OrientVertex]"],"success":true,"version":"0.8","queryTime":111.784319}
>curl -X POST -d "script=g.idx('somev')" http://localhost:8182/graphs/orientdbsample/tp/gremlin
@spmallette
spmallette / gist:2369515
Created April 12, 2012 17:37
Custom Bound Score Attribute
set identity_insert score_attribute on
insert into score_attribute(score_attribute_id, roi_campaign_id, score_attribute_name, score_attribute_description,
score_attribute_key, score_attribute_command, score_attribute_binding)
values (10, null, 'Articles Published Custom', 'bah', 'articlesPublishedCustomBound', 'SELECT drmi.provider_id, COUNT(DISTINCT drmi.media_item_id) AS ct FROM media_item AS mi JOIN provider_media_item AS drmi ON (drmi.media_item_id = drmi.media_item_id) JOIN provider AS dr ON (dr.provider_id = drmi.provider_id) JOIN roi_campaign_project AS rcp ON (rcp.project_id = dr.project_id) WHERE rcp.roi_campaign_id = :roiCampaignId AND mi.media_item_sort_date < :hx GROUP BY drmi.provider_id', 'stat_custom_1')
set identity_insert score_attribute off
go
insert into score_score_attribute
values (1, 10)
go
insert into roi_campaign_score_weight
select distinct affiliateddr.provider_id, affiliateddr.provider_name_first, affiliateddr.provider_name_last,
affiliateddr.primary_addr_line_1, affiliateddr.primary_addr_line_2, affiliateddr.primary_addr_city,
affiliateddr.primary_addr_realm, affiliateddr.primary_addr_zip, affiliateddr.provider_default_score as iv_score,
affiliateddr.provider_phone, affiliateddr.provider_fax, affiliateddr.provider_email,
affiliateddr.provider_profile_selected as leader, affiliateddr.provider_profile_respondent as respondent,
affiliateddr.provider_profile_media as author, affiliateddr.provider_profile_clinical_trial as clinical_trial,
os.org_site_id, o.org_name, os.org_site_addr_line_1, os.org_site_addr_line_2,
os.org_site_city, os.org_site_realm, os.org_site_zip, guy.provider_id as buddyid,
guy.provider_name_first as guy_first, guy.provider_name_last as guy_last, guy.primary_addr_line_1 as guy_line_
@spmallette
spmallette / gist:2491417
Created April 25, 2012 17:14
For Tran - Blow away Ct and Pubs
begin transaction tx
delete from provider_media_item
where author_set_id in (134, 136, 137, 226, 227, 290)
delete from clinical_trial_link
where clinical_trial_id in (select clinical_trial_id from clinical_trial
where clinical_trial_set_id in (143, 145, 236, 237, 238, 290))
delete from clinical_trial_sponsor
where clinical_trial_id in (select clinical_trial_id from clinical_trial
@spmallette
spmallette / gist:2653629
Created May 10, 2012 14:46
duplicate pubmed ids
select dr.provider_id, dr.provider_name_first, dr.provider_name_last,
drid.provider_identifier_identity
from provider_identifier drid
inner join provider dr on (dr.provider_id = drid.provider_id)
where dr.project_id = 38 and drid.identifier_type_id = 7 and drid.provider_identifier_identity in (
select drid.provider_identifier_identity
from provider dr
inner join provider_identifier drid on (drid.provider_id = dr.provider_id)
where project_id = 38 and drid.identifier_type_id = 7
group by drid.provider_identifier_identity
@spmallette
spmallette / gist:2662216
Created May 11, 2012 20:28
graph resource with features
{
"version": "0.8",
"name": "tinkergraph",
"graph": "mocktinkertransactionalgraph[vertices:6 edges:6 directory:data/graph-example-1]",
"features": {
"allowBooleanProperty": true,
"ignoresSuppliedIds": false,
"supportsTransactions": false,
"allowSelfLoops": true,
"allowFloatProperty": true,
\,,,/
(o o)
-----oOOo-(_)-oOOo-----
gremlin> g = TinkerGraphFactory.createTinkerGraph()
==>tinkergraph[vertices:6 edges:6]
gremlin> g.createKeyIndex("name", Vertex.class)
==>null
gremlin> g.getVertices("name", "marko")
==>v[1]
SELECT DISTINCT
aus.author_set_id,
aus.author_set_name,
m.media_id,
rcp.roi_campaign_id
INTO #T_MEDIA_AUTHOR_SET
FROM media m
INNER JOIN media_item mi ON (mi.media_id = m.media_id)
INNER JOIN provider_media_item drmi ON (drmi.media_item_id = mi.media_item_id)
INNER JOIN author_set aus ON (aus.author_set_id = drmi.author_set_id)
@spmallette
spmallette / gist:2888507
Created June 7, 2012 12:17
cassandra start/stop and gremlin
gremlin> conf = new BaseConfiguration()
==>org.apache.commons.configuration.BaseConfiguration@301abf87
gremlin> conf.setProperty("storage.backend", "cassandra")
==>null
gremlin> conf.setProperty("storage.hostname", "127.0.0.1")
==>null
gremlin> g = TitanFactory.open(conf)
==>standardtitangraph[cassandra]
gremlin> g.createKeyIndex("someid", Vertex.class)
==>null