Skip to content

Instantly share code, notes, and snippets.

View msalvadores's full-sized avatar

Manuel Salvadores msalvadores

View GitHub Profile
@msalvadores
msalvadores / gist:1212562
Created September 12, 2011 21:47
Java class to export Protege 3 database backend.
package ncbo.proto;
import java.io.FileInputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Properties;
import edu.stanford.smi.protegex.owl.database.creator.OwlDatabaseCreator;
import edu.stanford.smi.protegex.owl.model.OWLModel;
@msalvadores
msalvadores / gist:1006138
Created June 3, 2011 10:18
python-find-occurrences-of-strings-from-a-reference-file-within-an-input-file
#stackoverflow answer http://stackoverflow.com/questions/6225590/python-find-occurrences-of-strings-from-a-reference-file-within-an-input-file
def count_line_occurrences(ref_list,input_list):
line_counter = {}
# Initialization
for ref_line in ref_list:
ref_line = ref_line.rstrip()
line_counter[ref_line] = 0
for input_line in input_list:
input_line = input_line.rstrip()
@msalvadores
msalvadores / gist:925093
Created April 18, 2011 09:57
Data example for 4sr tutorial
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix def: <http://foo.com/def/> .
@prefix id: <http://foo.com/id/> .
############################################################
##### RDFS SCHEMA
############################################################
######## rdfs:subClassOf hierarchy
@msalvadores
msalvadores / gist:889157
Created March 27, 2011 12:21
my git/github cheat sheet
" author: Manuel Salvadores http://msalvadores.me "
" My notes on using git/github "
#---- workflow on remote public forked repositories ----
#checkouts master branch from a forked github repo
git clone <git path to my forked repo>
#adds origin for futures merges/pulls
git remote add <name_origin> <git path to original repo>
@msalvadores
msalvadores / change_tag_beautifulsoup.py
Created March 13, 2011 13:08
How to change tag name with BeautifulSoup.
"""
author: Manuel Salvadores (msalvadores@gmail.com)
Code sample in answer from Stack Overflow:
http://stackoverflow.com/questions/5289189/how-to-change-tag-name-with-beautifulsoup/5289523#5289523
"""
import BeautifulSoup
if __name__ == "__main__":
data = """
"""
Sample code to traverse RDF list with RDFLIB.
author: Manuel Salvadores (msalvadores@gmail.com)
rdf containers are a pain in general, quite annoying to handle them.
To get all the authors for a given article like in your case you could do
something like the code I am posting below.
@msalvadores
msalvadores / gist:851417
Created March 2, 2011 18:25
code to get all var names hanging from a rasqal_expression
/*
code to get all var names hanging from a rasqal_expression
author: Manuel Salvadores (msalvadores@gmail.com)
*/
static void get_var_names(rasqal_expression *e,GList **list_vars) {
GList *l = *list_vars;
if (!e) return;
if (e->literal != NULL) {
rasqal_literal *lit = e->literal;