textmate – Parerga und Paralipomena http://www.michelepasin.org/blog At the core of all well-founded belief lies belief that is unfounded - Wittgenstein Tue, 22 Oct 2013 01:09:29 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.11 13825966 Textmate bundle for Turtle and Sparql http://www.michelepasin.org/blog/2013/08/13/textmate-bundle-for-turtle-and-sparql/ Tue, 13 Aug 2013 17:07:34 +0000 http://www.michelepasin.org/blog/?p=2392 I recently ran into the Textmate bundle for Turtle, an extension for the Textmate osx editor aimed at facilitating working with RDF and SPARQL. If you happen to be using these technologies, well I’d suggest you take a look at the following post.

The Resource Description Framework is a general-purpose language for representing information which is widely used on the web in order to encode metadata in a machine-interoperable format.

Turtle, the terse RDF Triple Language, is a textual syntax for RDF which aims at human readability and compactness (among other things).
This is what it looks like:


@prefix rdf: 
@prefix rdfs: 
@prefix xsd: .
@base 

:MotorVehicle a rdfs:Class.

:PassengerVehicle a rdfs:Class;
   rdfs:subClassOf :MotorVehicle.

:Person a rdfs:Class.

xsd:integer a rdfs:Datatype.

:registeredTo a rdf:Property;
   rdfs:domain :MotorVehicle;
   rdfs:range  :Person.

:myLittleCar a PassengerVehicle

The termite library in question, in a nutshell, provides a bunch of snippets and query mechanisms that make it easier to work with Turtle RDF and related technologies.
More precisely, here’s the official features breakdown:

  • Language grammar for Turtle and SPARQL 1.1
  • Powerful (!) auto-completion (live-aggregated)
  • Documentation for classes and roles/properties at your fingertips (live-aggregated)
  • Interactive SPARQL query scratchpad
  • Some snippets (prefixes and document skeleton)
  • Solid syntax validation
  • Commands for instant graph visualization of a knowledge base (requires Graphviz and Raptor)
  • Conversion between all common RDF formats
  • Example

    In order to query a SPARQL endpoint (eg DBPedia) just type this in and run it (apple-R):

    
    #QUERY <http://dbpedia.org/sparql>                    
    SELECT DISTINCT ?s ?label                             
    WHERE {                                               
        ?s <http://dbpedia.org/property/season> ?o .      
    }  
    

    Obviously you can query any endpoint, e.g. data.nature.com:

    
    
    #QUERY <http://data.nature.com/sparql>
    
    PREFIX bibo:<http://purl.org/ontology/bibo/>
    PREFIX dc:<http://purl.org/dc/elements/1.1/>
    PREFIX dcterms:<http://purl.org/dc/terms/>
    PREFIX foaf:<http://xmlns.com/foaf/0.1/>
    PREFIX npg:<http://ns.nature.com/terms/>
    PREFIX npgg:<http://ns.nature.com/graphs/>
    PREFIX npgx:<http://ns.nature.com/extensions/>
    PREFIX owl:<http://www.w3.org/2002/07/owl#>
    PREFIX prism:<http://prismstandard.org/namespaces/basic/2.1/>
    PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
    PREFIX sc:<http://purl.org/science/owl/sciencecommons/>
    PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
    PREFIX void:<http://rdfs.org/ns/void#>
    PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
    
    
    SELECT *                            
    WHERE {                                                
        ?doi a npg:Article . 
        ?doi dc:title ?title .
        ?doi prism:publicationDate ?date
    } 
    limit 100 
    
    

    And this is just the tip of the iceberg. Autocompletion, visualisations etc… it may be the Textmate-Semantic Web swiss army knife you’ve been looking for.

     

     

     

     

    ]]>
    2392
    Python debugging and Textmate http://www.michelepasin.org/blog/2010/02/12/python-debugging-and-textmate/ Fri, 12 Feb 2010 13:23:29 +0000 http://magicrebirth.wordpress.com/?p=546 I’ve never realized that among the many things Textmate does well there’s also python debugging. Well, to be precise Textmate doesn’t do much as it just relies on python’s default debugger, called PDB. Ok, probably PDB isn’t the cutting edge debugger you’re looking for, but it’s worth a try imho.

    Nothing to install in order to try: just open up a python script with textmate, hit cmd+shift+D and a debug-terminal window will open. The essential commands for Pdb are (the first letter is the one to digit):

  • s(tep): Execute the current line, stop at the first possible occasion (either in a function that is called or on the next line in the current function).
  • r(eturn): Continue execution until the current subroutine returns.
  • n(ext): Continue execution until the next line in the current function is reached or it returns.
  • p(rint) expression: Evaluate the expression in the current context and print its value.
  • a(rgs): Print the argument list of the current function.
  • q(uit): Quit from the debugger
  • c(ont(inue)): Instead of quitting, Continue execution, only stop when a breakpoint is encountered.
  • A nice and clear crash course of Pbd can also be found here.

    OTHER TEXTMATE TIPS AND TRICKS:

  • PdbTextMateSupport is a plugin that gives you a more powerful debugger within Textmate: a detailed description of its (simple) installation is here.
  • a nice post about 10 cool TextMate tips: most of them are HTML/CSS related, but worth checking out!
  • Textmate basic tutorial. This is a must for everyone who wants to use TextMate seriously (available also in Japanese!)
  • Three plugins that’ll make textmate shine even more: Project Plus (adds extra functionalities to the project drawer), GetBundles (a better version of the old GetBundle), Ack In Project (a much faster ‘search in project’ function).
  • Nice screencast on how to use the Math bundle
  • ]]>
    546
    TextMate Basics Tutorial http://www.michelepasin.org/blog/2009/02/26/textmate-basics-tutorial/ Thu, 26 Feb 2009 15:28:57 +0000 http://magicrebirth.wordpress.com/?p=78 TextMate software “brings Apple’s approach to operating systems into the world of text editors. By bridging UNIX underpinnings and GUI, TextMate cherry-picks the best of both worlds to the benefit of expert scripters and novice users alike.” If you are using Textmate this tutorial will show you around the basic features of TextMate and also some of the most advanced ones!

    picture-1

     

    ]]>
    78
    pysmell – Python auto-complete – works with TextMate too! http://www.michelepasin.org/blog/2009/02/15/pysmell-python-auto-complete-works-with-textmate-too/ http://www.michelepasin.org/blog/2009/02/15/pysmell-python-auto-complete-works-with-textmate-too/#comments Sun, 15 Feb 2009 17:34:09 +0000 http://magicrebirth.wordpress.com/2009/02/15/pysmell-python-auto-complete-works-with-textmate-too/ One of the reasons that kept me away (sigh) from TextMate is the lack of autocompletion support.. especially in Python. Seems like those days have ended – I just downloaded and installed Pysmell, and it works great!!!

    The instructions are very clear, you install it, dbl click the TextMate bundle file and you’re already half way through. Just remember that you always need to generate a a PYSMELLTAGS file from your project, and put it at the root level so that TextMate finds it:


    cd /root/of/project
    pysmell .

    For example, I wanted to add the django package to my ‘tags’ library:

    [mac]@ego:/Library/Python/2.5/site-packages/django>pysmell . -o ~/PYSMELLTAGS.djangolib

    And generate tags for the standard Python lib:

    [mac]@ego:/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5>pysmell *.py -o ~/PYSMELLTAGS.stndlib

    Then I just moved these files to the root of my python project.. and it magically works!

    picture-22

    >>>

    At first sight, the main drawbacks seem to be:

    1) the ‘tags’ file you generate needs to be put into the project directory, not really handy if you have multiple projects.. (or if you say – update a library)

    2) it may be slow (of course, depending on the size of the TAGS file you generate)

    However – it’s great stuff, can’t wait to test it further!!!!

     

    ]]>
    http://www.michelepasin.org/blog/2009/02/15/pysmell-python-auto-complete-works-with-textmate-too/feed/ 6 67