Here's a SPARQL query that counts all statements (triples) in a repository.
Note that this can be a long running query. For me it took took 21 seconds to count the statements in a repository with 30 million triples.
An example SPARQL query that can help you assemble the hierarchy of classes in an ontology.
Source: I found this query within the web console of Stardog as one of the sample queries they provide in a drop-down list of options.
Recently I completed a little study incorporating Spring for Stardog into a Spring Boot web app, with successful results. Here's how.
Stardog is a Java based RDF repository server (a.k.a. triple-store and more), which supports the RDF graph data model; SPARQL query language; property graph model and Gremlin graph traversal language; HTTP and SNARL protocols for remote access and control; OWL 2 and user-defined rules for inference and data analytics; virtual graphs; geospatial query answering; and programmatic interaction via several languages and network interfaces. At this point, I don't have a lot of experience with Stardog, but I've been experimenting with it to see what I can learn. As part of my study, I recently incorporated Stardog Spring into a Spring Boot web app - taking notes along the way. Here's my notes on how I got it setup and working successfully.
Download and Install Stardog
For my local development environment on Mac OS, I installed Stardog 5 BETA (Community Edition).
You can download Stardog at www.stardog.com. Once you've downloaded it, unzip the archive to a destination directory. I'm put mine in /Users/cburleson/stardog
Next you need to set the STARDOG_HOME environment variable. You can do this by adding an export line to your .bash_profile.
Add the following line:
Save changes made to .bash_profile by hitting Control+o (that’s an o as in otter), ENTER, then exit out of nano by hitting Control+X.
Note that changes made .bash_profile will require the shell to be restarted or a new shell to spawn.
stardog-license-key.bin into the STARDOG_HOME location. Then you can start the Stardog server to test your installation.
If everything is working properly, you should get the following response.
Note that there is an ERROR in this response, but I think it just has to do with the fact that I'm using the Community edition and not an enterprise edition (see: this support issue).
Still, the server is running and can be accessed in a web browser at
You can also check the server status with the following command:
Now, that you've tested the installation, you can stop the server with the following command.
Add the Stardog Maven Repo to pom.xml
In order to get the required dependencies, you need to add the Stardog public maven repository to your repositories defined in the Maven POM (pom.xml). Here's how that section looks in my file:
Add Stardog Dependencies to pom.xml
Now, we can add the required dependencies. Notice that even though I installed Stardog 5 BETA, I'm using a different version number for various dependencies (still, it works).
Notice that I've got stardog-spring-batch commented in the file, but commented out. I put it in the file incase I decide to use it in the future, but for now, I don't need it.
Create or Edit Spring Application Context File
I prefer using pure Java only configuration for Spring, but I had trouble with this one, so opted to use the XML configuration. I created the following file inside of
Notice that the data importer bean is going to look for an RDF file in the classpath, which should exist in
I got that file from the source project for stardog-spring, which you can find on GitHub at: https://github.com/stardog-union/stardog-spring
You could use any RDF file that you want to have auto-loaded into the Stardog repository.
Make the applicationContext.xml Available to Your Spring Boot App
In order for your Spring Boot app to recognize and load the applicationContext.xml, you'll need to add an annotation to the main application class (the one with a Java main() method)...
The annotation you'll need to add is:
My main application class looks like this:
Create an EmbeddedProvider Java Class
The applicationContext.xml file references an EmbeddedProvider class. There is no EmbeddedProvider exposed by the stardog-spring library, but I found one in the stardog-spring source code at
You'll need to create this class in your project and make sure that you reference the package and class properly for the embeddedProvider bean in your applicationContext.xml file.
Use the Spring for Stardog SnarlTemplate in a Controller
For a quick acid test, I created a simple Spring Controller that gets executed when you hit the path
/test in a web browser.
Here's the simple test controller I created, which logs output from a SPARQL query to the console.
How to Use the SnarlTemplate
The Spring Programming section of the documentation on the Stardog website provides some good information. However, if you want to see some actual code examples, you might want to refer to the TestDataSourceFactory.java class on GitHub. That's where I learned how to execute the query shown in my TestController using a SimpleRowMapper.
Test the App
Now you should be able to run your Spring Boot application and hit the TestController (/test in your browser). When you hit the URL, you should see the following output logged to the console, which shows that you've successfully configured and used Spring for Stardog. As you can see, five triples were returned from the given LIMIT 5 SPARQL query...
In this post, I showed how I used Spring for Stardog in a Spring Boot web app. With some minor variation, these instructions could probably be useful for any Spring app and not just a Spring Boot web app.
There is also some useful information in the QUICKSTART.txt file on GitHub that you might find useful, so be sure to check it out.
Some very rough notes I took while learning to create an Atlassian Confluence plugin. Perhaps, I'll clean these notes up a bit when I create my next plugin.
Install the Atlassian SDK
Create the Plugin Skeleton
Navigate to the directory on your system where you'd like to create your plugin. The command we are about to run will create a folder with the plugin directories inside.
Create directory /Users/cburleson/repos/test-conf-plugin
cd into the directory
The first time, Maven will download a bunch of packages.
Now you need to define some things:
You will then be prompted to confirm:
Maven will download some more stuff.
Open eclipse and switch to the /repos workspace
The basic skeleton for your Atlassian JIRA plugin is created in a new
Feel free to take a moment to explore the different files created by the Atlassian SDK before you continue.
Change to the
myPlugin directory and enter the following command:
DO NOT FORGET TO USE CTRL-D TO SHUT THE atlas-run execution down gracefully!
This will download a bunch of stuff (Maven) and then run the product with your plugin installed.
Go find your plugin in the manage page:
Import Into Eclipse IDE
Import > Eisting Maven Projects and find the project with the pom.xml file.
Preferences > Maven
Add a new Installation and point to: /Applications/Atlassian/atlassian-plugin-sdk-6.2.14/apache-maven-3.2.1
Set Maven user settings so that the Global settings point to: /Applications/Atlassian/atlassian-plugin-sdk-6.2.14/apache-maven-3.2.1/conf/settings.xml
Open the atlassian-plugin.xml file in your favourite editor.
Locate the end of the <web-resource>...</web-resource> section in the file and enter the following:
Open the file /src/main/resources/myConfluenceMacro.properties and add the following line at the bottom of the file:
Create the Java file in that package...
This is the minimum skeleton your Macro will require to implement the confluence Macro class and display a Macro object in Confluence.
In your terminal window, change directory back to the top directory for your plugin (eg
Run the command:
You should see a confirmation message
Monitor the window where confluence was run originally and confirm that QuickReload finished loading. You should see a confirmation message:
Here I got a stack trace error.
I created the file:
Important to REFRESH THE WORKSPACE after creating new files.
Then fun atlas-mvn-package again - and all was cool...
Now you can try adding the Macro to a test page in Confluence (you'll need to make a new Confluence Space and Page before you can test it out so go ahead and do that first).
Now, you will allow the user to specify their name using a parameter to learn about how parameters can be set, and used.
Open the atlassian-plugin.xml file in your favourite editor.
<parameters/> element within the
<xhtml-macro> element you created in the first part of this tutorial.
<parameters/> element with the following:
This specifies that the parameter is called 'Name' and is of type 'string'. You can find the full list of types under the Parameters heading in the macro module documentation
Now modify the execute method in the Java class so it looks like this:
REFRESH THE PROJECT and then execute atlas-mvn package.
Press CTRL-D to shut down the atlas-run session gracefully.
A cheatsheet for common Linux / Unix commands.
Change File Permissions
|chmod +x filename.ext||Give execute access to a file.|
|sudo chmod -R 777 workspace||-R means RECURSIVE|
|sudo chown -R basejump workspace||Take ownership of a file.|
basejump (user) and workspace (directory)
Compress or Extract Files
|tar -zxvf file.tar.gz||To extract one or more members from an archive:|
tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
Compress an entire directory or single file.
-c: Create an archive.
Create an Alias for a Common Command
|alias p=<command>||Create shortcut aliases to common commands.|
alias p="open /x/yx/z" to open a particular directory in Finder
Execute Command as Root User
|sudo <command>||Execute command as the root user.|
|sudo !!||Execute the last command as root user. |
(!!) represents the last command you just tried to run, but couldn't because of permission issues.
Execute Task in Background
|./startTest.sh &||Start the execution in the background, which will allow you to kill your SSH terminal without killing the process itself.|
Find Large Files
find . -size +10000000c -print
|Prints out the names of all files with size > 10mb.|
sudo du -sm *
|Examine the size of the directories under /.|
You can then navigate into any given subdirectory and execute dm -sm * again to see which subdirectories are the largest.
Inspect Disk Space and Usage
|df -h||Inspect disk space and usage (in MB or GB)|
Work with Environment Variables
|printenv||Prints all currently set environment variables and values.|
Remove a File
|mv||Rename a file|
|rm||Remove a file|
|rm -f||Forcefully remove a file|
|rm -i||Interactively remove a file|
If you are not certain about removing files that match a pattern you supply, it is always good to run rm interactively (rm –i) to prompt before every removal.
|mv <oldDirName> <newDirName>||Rename a directory. Be aware: this is actually a move command. So, you're just moving the directory from one name to another in the same path.|
|rmdir||Remove an empty directory|
|rm -rf <dirName>|
Forcefully remove a directory recursively.
Remove the f switch to be prompted for each sub-directory and file inside.
|cp -rf present/directory /desire/directory|
Copy an entire directory, its subdirectories, and files.
Remove the f switch to be prompted for each sub-directory and file inside.
|su - <username>||Switch to the given user, loading their profile.|
You may have to use sudo su - <username>.
|su||Without a username means to just switch to root user.|
|whoami||"Who Am I?" Prints the current user.|
View a File
|cat||Used for viewing files that are not very long; it does not provide any scroll-back.|
|tac||Used to look at a file backwards, starting with the last line.|
|less||Used to view larger files because it is a paging program; it pauses at each screenful of text, provides scroll-back capabilities, and lets you search and navigate within the file. Note: Use / to search for a pattern in the forward direction and ? for a pattern in the backward direction. Press Q to quit.|
|tail||Used to print the last 10 lines of a file by default. You can change the number of lines by doing -n 15 or just -15 if you wanted to look at the last 15 lines instead of the default.|
|head||The opposite of tail; by default it prints the first 10 lines of a file.|
The UNIX/Linux philosophy is to have many simple and short programs (or commands) cooperate together to produce quite complex results, rather than have one complex program with many possible options and modes of operation. In order to accomplish this, extensive use of pipes is made; you can pipe the output of one command or program into another as its input.
In order to do this we use the vertical-bar, |, (pipe symbol) between commands as in:
$ command1 | command2 | command3
The above represents what we often call a pipeline and allows Linux to combine the actions of several commands into one. This is extraordinarily efficient because command2 and command3 do not have to wait for the previous pipeline commands to complete before they can begin hacking at the data in their input streams; on multiple CPU or core systems the available computing power is much better utilized and things get done quicker. In addition there is no need to save output in (temporary) files between the stages in the pipeline, which saves disk space and reduces reading and writing from disk, which is often the slowest bottleneck in getting something done.
An example SPARQL query filtering for resources within a given date range (between two given dates).
To automatically serve static resources with Spring Boot (e.g. when using spring-boot-starter-web), you can simply place the static resources in one of several paths that Spring Boot automatically recognizes as a static file paths.
Following are paths that will are recognized as static file paths:
You can then access the resources at:
So, for example, given the following resource at the following location...
You could fetch the file with the following URL:
What are the most popular database management systems? DB-Engines Ranking provides a list that's updated monthly. You can look at the complete ranking or filter by types like Relational DBMS, Key-value stores, Document stores, Graph DBMS, RDF stores, Search engines, and more.
For a ranked list of popular databases, check out the DB-Engines Ranking page on the DB-Engines site, a knowledge base of relational and NoSQL database management systems.
Most Popular RDF Stores as of April 2017
Following, for example, is a list of popular RDF Stores as calculated in April 2017.
The site calculates popularity monthly using the following general parameters (see also: Method of calculating the scores of the DB-Engines Ranking):
- Number of mentions on websites, measured as number of results in search engines queries on Google, Bing and Yandex (searching for <system name> together with the term database, e.g. "Oracle" and "database").
- General interest in the system, as determined by the frequency of searches in Google Trends.
- Frequency of technical discussions about the system, as determined by the number of related questions and the number of interested users on Stack Overflow and DBA Stack Exchange.
- Number of job offers, in which the system is mentioned on leading job search engines Indeed and Simply Hired.
- Number of profiles in professional networks, in which the system is mentioned in popular professional networks LinkedIn and Upwork.
- Relevance in social networks, as per a count of the number of Twitter tweets, in which the system is mentioned.
Logging with Spring Boot is dead simple. Everything's pretty much setup and ready to go. In this post, I provide some quick and simple tips to get your Spring Boot logs rolling.
About Logging Dependencies
If you use the ‘Starters’, Logback will be used with appropriate routing included to ensure that dependent libraries that use Java Util Logging, Commons Logging, Log4J or SLF4J will all work correctly. Let's suppose, for example, that you're using the web starter in your Maven pom.xml file, as shown below.
Generally you won’t need to change any logging dependencies and the Spring Boot defaults will work just fine. That is to say, you don't need to add any additional dependencies to the POM for logging. You can verify this by printing a tree representation of your project dependencies. On the command line, change to your project directory and executing the following command.
Notice that the Spring Boot starter already includes dependencies for logging...
Configure Log Levels
The easiest way to configure logging levels is in the application.properties file. If you don't already have one, create an application.properties file in the root of the resources folder. Then, simply prefix Java packages and classes with logging.level as shown below. Notice that you can configure the root logger at a specific level first, then get more specific with other loggers.
Put Logging Code in Your Classes
Now, we can use SLF4J for logging. Here's how.
Add the following to the imports section of your java code:
Add the following at the top of your class in the global section (just under the line that declares your class public class Whatever extends Whatever). Change the name of the class (MyClassName) in the getLogger method call, of course. Name it the same as the class you're dropping this code into.
To test quickly, you can throw some logging statements in your code somewhere where you know they'll be fired right away when you run your app. For example:
The default log configuration will echo messages to the console as they are written. If your terminal supports ANSI, color output will be used to aid readability.
Log to a File
If you want to write log files in addition to the console, you can set a logging.file or logging.path property in your application.properties. For example...
Using SLF4J over Log4j
Now, if you want to use SLF4 over Log4j 2, and a log4j configuration file, the setup is a little different. In your Maven, POM, you must exclude
spring-boot-starter-logging and then add a dependency for
spring-boot-starter-log4j2 as shown below.
Then you need to have a log4j2.xml file on the classpath; for example - in
src/main/resources. Here's a simple log4j2.xml file example.
As you can see, logging from your Spring Boot application is piece of cake. Of course, there's a lot more that you can do as your requirements dictate. For more information, take a look at Logging, in the Spring Boot Reference Guide.
- Logging, in the Spring Boot Reference Guide
A macro for Atlassian Confluence that mimics a Bootstrap 3 Panel.
This is a simple macro I developed that mimics the Bootstrap 3 Panel. The macro takes an optional Title, an optional Style, and a rich text macro body. It renders results as shown in the examples section below.
I did this as a learning exercise in preparation to do a more sophisticated plugin for Confluence. You might find the code useful if your doing something similar. You can find the source code in the following public repository on GitHub:
- Atlassian Confluence 6.0.5
- Google Chrome Version 57.0.2987.98 (64-bit) on Mac OS
If you find any issues, please open an issue on GitHub.
The current version of the macro that I've got deployed here in this wiki is attached. If you want to try it out, you can upload the jar through Manage add-ons in the Confluence admin area.
|Java Archive panelMacro-1.0.0-SNAPSHOT.jar||Mar 25, 2017 by Cody Burleson|
MIT License Copyright (c) 2017 Cody Burleson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This page is a never-ending work-in-progress where I've decided to capture handy little tips for enhancing workflow in WebStorm. Shoot me an email if you know of any other handy little things that I can add to this list.
Put cursor at end of red text object name and click CTRL + SPACE (auto-complete) and select the object from the pop-up context menu.
Select code, then CMD + /
Did you know that Emmet's built-in to WebStorm? Emmet takes the snippets idea to a whole new level: you can type CSS-like expressions that imply the HTML structure you want, press Tab, and then WebStorm spits out the desired HTML.
Here's a simple example of a basic expression in the Emmet syntax. Try typing the following in an HTMl page in WebStorm:
At the end of the expression, just hit the Tab key. WebStorm will use Emmet to parse the text and spit out the intended HTML which, in this case, will be an unordered list with 5 list items (shown below):
For details, you can refer to the Emmet Documentation, but for convenience, I'm including the most common stuff below. There's a lot more to it though, so if you like what you see here, be sure to RTFM.
You can use
> operator to nest elements inside each other:
+ operator to place elements near each other, on the same level:
* operator you can define how many times element should be outputted:
Parenthesises are used by Emmets’ power users for grouping subtrees in complex abbreviations:
If you’re working with browser’s DOM, you may think of groups as Document Fragments: each group contains abbreviation subtree and all the following elements are inserted at the same level as the first element of group.
You can nest groups inside each other and combine them with multiplication
ID and CLASS
In CSS, you use elem#id and elem.class notation to reach the elements with specified id or class attributes. In Emmet, you can use the very same syntax to add these attributes to specified element:
You can use
[attr] notation (as in CSS) to add custom attributes to your element:
* operator you can repeat elements, but with
$ you can number them. Place
$ operator inside element’s name, attribute’s name or attribute’s value to output current number of repeated element:
You can use multiple
$ in a row to pad number with zeroes:
You know - that filler text that designers use when they can't think of real words that are relevant to a design...
Holy Shit Example
Here's a crazy example to give you an idea of what you can accomplish if you get bad ass with Emmet.
Here's how to avoid tracking page views in Google Analytics when you're logged in as an administrative or other specific user.
This solution presupposes that your Google Analytics tracking snippet is pasted into the field labelled "At end of the HEAD" in the Custom HTML section in the Confluence Administration Area as shown below...
Before modification, your Google Analytics tracking code should look something like this.
Now, to avoid tracking pages for an administrative user (or any particular user or set of users, for that matter), you can wrap the ga() function calls in an IF check. In the following code, we use the Confluence AJS object to determine whether or not the authenticated user is an administrative user. If that's true, we do not reach the ga() functions and thus, the pageview is not tracked. In all other cases, however, the pageview will be tracked.
You could use console.log statements to test this in your local browser.
If you want to avoid logging page views for specific users, you can check for specific user names with AJS.params.remoteUser.
In my digital journal, I've kept a page called "Bucket List", but I've kicked it out in favor of a new title: "Goals".
I've learned that the language you use and the story you tell yourself is fundamentally important to what you actually achieve and do. And maybe it goes even deeper than that. Maybe it's not just the language you use, but the personal meaning that you've ascribed to the concepts in that language. The Merriam-Webster online dictionary defines a bucket list as a list of things that one has not done but wants to do before dying. That's how I think of it too, but there's something about the concept for me that is far more forgiving than a list of goals. I think of the bucket list as a list of frilly things or nice-to-dos - just icing on the cake of life, which you never have to eat. Nobody's going to hold it against you if you don't do the things that are on your bucket list - not even yourself. Death is your deadline, after all.
I don't think that works for me, so instead, I've decided to change the title of my Bucket List to "Goals". The meaning of the two concepts are entirely different to me. Goals are much more real. For me, a goal implies a stronger intent to achieve it. A goal begs an action plan. A goal begs to be SMART:
- Specific (and Significant)
- Measurable (and Meaningful)
- Attainable (and Action-oriented)
- Realistic, Relevant (and Rewarding)
- Time-Based (and Time-bound or Trackable)
To me, the things on a bucket list are just ideas. Possibilities. Opportunities. I'd rather think of them as "draft goals". They're worth writing down. But give them any careful thought and they might just as easily fall off the list as get prioritized and planned. So, now I have my list of goals - some prioritized and planned. Some SMART. Some, just draft ideas. But I don't have a bucket list anymore.
There are simply things I've done, things I will do, and things I might do - goals I've achieved, goals I will achieve, and then all the things that might or might not become goals. If they become goals, they'll get an action plan and evaluation against the principles of SMART. If they don't make it to that point, then they probably are just frilly ideas that don't deserve to stay on the list.
This week, I've been listening to the audiobook, Benjamin Franklin: An American Life by Walter Iscaacson. My favorite part, so far is where he recounted thirteen virtues that Benjamin Franklin recorded in his autobiography. I think Ben Franklin wrote these in 1726, at the mere age of twenty.
- Temperance. Eat not to dullness; drink not to elevation.
- Silence. Speak not but what may benefit others or yourself; avoid trifling conversation.
- Order. Let all your things have their places; let each part of your business have its time.
- Resolution. Resolve to perform what you ought; perform without fail what you resolve.
- Frugality. Make no expense but to do good to others or yourself; i.e., waste nothing.
- Industry. Lose no time; be always employ'd in something useful; cut off all unnecessary actions.
- Sincerity. Use no hurtful deceit; think innocently and justly, and, if you speak, speak accordingly.
- Justice. Wrong none by doing injuries, or omitting the benefits that are your duty.
- Moderation. Avoid extremes; forbear resenting injuries so much as you think they deserve.
- Cleanliness. Tolerate no uncleanliness in body, cloaths, or habitation.
- Tranquillity. Be not disturbed at trifles, or at accidents common or unavoidable.
- Chastity. Rarely use venery but for health or offspring, never to dullness, weakness, or the injury of your own or another's peace or reputation.
- Humility. Imitate Jesus and Socrates.
- Benjamin Franklin: An American Life by Walter Iscaacson
- Ben Franklin Autobiography, Page 38, from The Electric Ben Franklin.
- The Benjamin Franklin Method: How to (Actually) Learn to Write, Charles Chu on Medium