Skip to content

Instantly share code, notes, and snippets.

View abargnesi's full-sized avatar

Tony Bargnesi abargnesi

View GitHub Profile
@abargnesi
abargnesi / recv_gitter.sh
Created February 3, 2016 03:44
Receive gitter room chat log in chronological order
#!/usr/bin/env bash
#
# Retrieves chat messages in chronological order for a Gitter room.
# Each chat message is outputted per line and is formatted like:
#
# (sent) username: text
#
if [ $# -ne 2 ]; then
echo "Retrieves gitter room's chat log in chronological order." 1>&2
@abargnesi
abargnesi / name_error_tts.js
Created January 14, 2016 20:30
Using watson TTS for ruby name error.
var watson = require('watson-developer-cloud');
var fs = require('fs');
var exec = require('child_process').exec;
var text_to_speech = watson.text_to_speech({
username: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
password: 'xxxxxxxxxxxxxxxxx',
version: 'v1'
});
var fetch = require('node-fetch');
var FormData = require('./form-data');
var form = new FormData();
form.append('file', fs.createReadStream("/home/tony/projects/openbel/openbel-api/full_abstract1.bel"));
fetch('http://next.belframework.org/api/datasets', {
method: 'POST',
body: form
}).then(function(res) { console.log(res.json()); });
@abargnesi
abargnesi / app-config.rb
Created December 2, 2015 22:10
Read ruby "configuration" script using instance_eval.
module Configuration
def self.configured_components
@components
end
def self.component(key)
return unless block_given?
@components ||= {}
@components[key] = yield
{
"evidence": {
"bel_statement": "a(\"cyclic AMP\") increases r(HGNC:AR)",
"citation": {
"type": "PubMed",
"name": "J Clin Endocrinol Metab 2003 Sep 88(9) 4043-54",
"id": "12970260",
"date": "",
"authors": [
--------------------------------------------------------------------
| s |
====================================================================
| <http://www.openbel.org/bel/namespace/affy-probeset> |
| <http://www.openbel.org/bel/namespace/entrez-gene> |
| <http://www.openbel.org/bel/namespace/chebi> |
| <http://www.openbel.org/bel/namespace/disease-ontology> |
| <http://www.openbel.org/bel/namespace/mesh-diseases> |
| <http://www.openbel.org/bel/namespace/mgi-mouse-genes> |
| <http://www.openbel.org/bel/namespace/rgd-rat-genes> |
@abargnesi
abargnesi / UsingJena.java
Last active November 13, 2015 05:43
SPARQL ftw!
package org.openbel.resource_reasoner;
import org.apache.jena.query.*;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ResIterator;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.update.UpdateAction;
import org.apache.jena.update.UpdateFactory;
import org.apache.jena.update.UpdateRequest;
import org.apache.jena.vocabulary.RDF;
@abargnesi
abargnesi / InferExactMatch_byPrefLabel.sparql
Created November 10, 2015 17:07
Infer exactMatch using case-insensitive string match on prefLabel
Select
PREFIX belv: <http://www.openbel.org/vocabulary/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
# Bind ?namespaceConceptScheme to the URI of the namespace resource whose concepts you would like equivalenced via concept type and case-insensitive string match.
@abargnesi
abargnesi / hardwire>examples>bar>def.rb
Last active November 4, 2015 19:57
plugin proof of concept
module Hardwire::Plugins
module Bar
class BarPlugin
include Hardwire::PluginDefinition
def self.plugin_file_path
__FILE__
@abargnesi
abargnesi / loader.c
Created October 26, 2015 02:02
Load an RDF file into a SQLite database without journaling.
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <librdf.h>
#include <raptor2.h>
/* function prototypes */
int main(int argc, char *argv[]);