Posts By ---

Fuseki 1.1.x defaults to JSON-LD

Just wanted to note this, for anyone else struggling.

Fuseki 1.0.x used to return a proprietary JSON format for RDF when running DESCRIBE or CONSTRUCT queries. After switching to Fuseki 1.1.2 it defaults to JSON-LD.

If you want to upgrade, without making all your applications handle JSON-LD, then use “json-rdf” as the output format.

Example:
Old: http://localhost:3030/data/?query=YOUR_QUERY_HERE&output=json
New: http://localhost:3030/data/?query=YOUR_QUERY_HERE&output=json-rdf

The offending code in github:

ResponseOps.put(shortNamesModel, contentOutputJSON, WebContent.contentTypeJSONLD) ;

Last straw

Tldr: uninstalled Facebook app today, because it now makes sounds by default when I tap on something. 

It’s been a long time coming. The inevitable, however slow, withdrawal from  Facebook. At one point I was finding 20 new friends a day on Facebook. I was posting pictures, writing entries, and making comments. 

Then at some point there was no one left to friend. Everyone I knew, or had once known, was now my friend. However small our interaction had once been, a simple common friend or a shared photo was all that had been need for a friendship on Facebook. 

But now the only new friends I was making were the ones I was making in real life. And that wasn’t 10 per day, or even 10 per month. 

I posted less, and when I did I had higher expectations. Easily squashed because no one saw my post. Or cared. Why would they? Fewer and fewer posts were about anything meaningful. The only things left were funny cat videos and advertising. 

Then one day the chat feature disappeared. 

A simple message left in its wake. A message telling me, that I needed another app. One that would bother me more, drawing on my attention, forcing me to sell my soul so I could once again send that old high school friend a private message, not shared with the entire world, to ask if they would meet up when I came to their country next Monday. 

And today. With the regular Facebook app taunting me about messages that can only be read if I install just one more app, and otherwise only selling me how to loose weight by end of spring, now with a new annoying clicking sound…it’s life ended, by a long touch, a squirming wiggle followed by the enevitable touch of the round blue x. 

Force jersey to gzip application/json

So I’ve spent far too many hours today getting jersey to server application/json compressed with gzip. I found a number of tutorials online, followed them all. Upgraded jersey and grizzly to the newest release. Read about encoding in the jersey manuals. Enabled compression in 3 different ways. Yet still, jersey wouldn’t server the application/json resource gzipped.

The main problem was that none of the other guides specified that you had to force every response to use gzip as the encoding.

@GET
@Produces("application/json")
public Response getIt() {
    return Response.ok("{'json':'yay'}")
        .encoding("gzip") //forces gzip encoding
        .build();
}

You can enable compression as much as you like, but if you want application/json to work, you have to force it. Change your mime type to text/plain and jersey will happily compress just about anything, but change it back to application/json again and you’re out of luck.

To enable compression in general you’ll have to add get the compression config from the listeners.

for (NetworkListener networkListener : httpServer.getListeners()) {
    CompressionConfig compressionConfig = networkListener.getCompressionConfig();
    compressionConfig.setCompressionMode(CompressionConfig.CompressionMode.ON);
    compressionConfig.setCompressableMimeTypes("*/*"); // the mime types to compress
}

And if we put that all together we get something like this:

ResourceConfig resourceConfig = new ResourceConfig(MyResource.class);
resourceConfig.register(GZipEncoder.class);
HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer("UriBuilder.fromUri("http://0.0.0.0/").port(getPort(9998)).build(), resourceConfig)
for (NetworkListener networkListener : httpServer.getListeners()) {
    CompressionConfig compressionConfig = networkListener.getCompressionConfig();
    compressionConfig.setCompressionMode(CompressionConfig.CompressionMode.ON);
    compressionConfig.setCompressableMimeTypes("*/*"); // the mime types to compress
}
httpServer.start();

404 Not Found

(null)

With my terrible habit of leaving email unread if I feel I need to reply or do something about them, I have now accumulated 404 unread emails. Often I will also not read email if it’s advertising or spam, and then it just gets buried under new email before I get the chance to delete it.

Outlook for Mac v15.6 is unstable

One single empty email would cause Outlook to segfault on every start up.

Now it only segfaults 3 times a week, until today, when it actually crashed while crashing with the Microsoft Error Reporting half way open. After i force quit Outlook I realised how long it had been unresponsive for:

Process: Microsoft Outlook (Outlook) [13054]
Path: /Applications/Microsoft Outlook.app/Contents/MacOS/Microsoft Outlook
Architecture: i386
Parent: launchd [1]
UID: 501
Task size: 47277 pages
CPU Time: 1.476s
Note: Unresponsive for 6989 seconds before sampling

Yes. 6989 seconds. That’s almost 2 hours.

EDIT 1

Another crash today, this time its a segfault.

Microsoft Error Reporting log version: 2.0

Error Signature:
Exception: EXC_BAD_ACCESS
Date/Time: 2015-02-26 14:50:41 +0000
Application Name: Microsoft Outlook
Application Bundle ID: com.microsoft.Outlook
Application Signature: OPIM
Application Version: 15.6.150113
Crashed Module Name: Microsoft Outlook
Crashed Module Version: 15.6.150113
Crashed Module Offset: 0x005b4dc2
Blame Module Name: Microsoft Outlook
Blame Module Version: 15.6.150113
Blame Module Offset: 0x005b4dc2
Application LCID: 1033
Extra app info: Reg=en Loc=0x0409
Crashed thread: 22

 

EDIT 2

Third crash today, another segfault.

 

Error Signature:
Exception: EXC_BAD_ACCESS
Date/Time: 2015-02-26 15:10:09 +0000
Application Name: Microsoft Outlook
Application Bundle ID: com.microsoft.Outlook
Application Signature: OPIM
Application Version: 15.6.150113
Crashed Module Name: OutlookCore
Crashed Module Version: 15.6.150113
Crashed Module Offset: 0x000a0b50
Blame Module Name: OutlookCore
Blame Module Version: 15.6.150113
Blame Module Offset: 0x000a0b50
Application LCID: 1033
Extra app info: Reg=en Loc=0x0409
Crashed thread: 0

Would you build software like you would build a house?

Imagine a world where software development was done the same way as building a house, or a bridge, or a factory.

Every key stroke required three men and a crane.

Every compile took 3 days, unless the weather was bad.

Every test was executed manually by a a team of 15 people, who would write up a report that would be available 14 days later.

Pushing to git required seven trucks to transport the code, and there is a strike this month so you’ll have to wait a while.

And finally, if you want to deploy to your server. That’s going to cost 200 000 $ in fees for applications and attorneys.

Generate an XSD from Java

This is not your usual generate code. Instead of generating an XSD based on Java classes, I wanted to generate an XSD from my Java code. The below code requires Apache XML Beans.

import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.impl.xb.xsdschema.*;

import java.io.IOException;
import java.math.BigInteger;


public class Test {
     public static void main(String[] args) throws IOException, IllegalAccessException, InstantiationException, XmlException {

           // Start by parsing in a base schema
           SchemaDocument parse = SchemaDocument.Factory.parse(
                       "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" +
                                   "</xs:schema>\n");

           // Add a new element to the schema
           TopLevelElement topLevelElement = parse
                       .getSchema()
                       .addNewElement();

           topLevelElement.setName("YourTopElementName");

           LocalElement localElement = topLevelElement
                       .addNewComplexType()
                       .addNewSequence()
                       .addNewElement();


           localElement.setName("YourSubElement");
           localElement.setMinOccurs(new BigInteger("1")); // make it a required element
           localElement.setMaxOccurs(new BigInteger("1")); // make it a 1...1 element

           // Write to string and print to screen
           String s = parse.xmlText();
           System.out.println(s);


     }


}

16-bit PWM on Arduino Leonardo Pro Micro

First, dimming a led lamp using 8-bit regular analogWrite().

And here, 16-bit pwm by writing directly to the registers.

Below is the source code (adapted from http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on-your)

#define LED OCR1A // pin 9 (our led pin)

void setup() {
    // pin 9 is one of the 16-bit PWM pins on the Pro Micro
    pinMode(9, OUTPUT);

    // Do something I don't really understand
    ICR1 = 0xFFFF;
    TCCR1A = 0b10101010;
    TCCR1B = 0b00011001;

    // Set the led to 0 brightness
    LED = 0;
}

unsigned int temp = 0;

void loop() {
    LED = temp; //set brightness, equivalent to analogWrite but now with 16-bit
    temp++; //temp should be from 0-65535
    delay(1);
}

Ohara’s Irish Red

Tastes like: coffee.

20130717-204933.jpg

Ladybird ?

20130716-115400.jpg