cobra: unable to redefine ‘h’ shorthand

Cobra is both a library for creating powerful modern CLI applications as well as a program to generate applications and command files”

I’m currently using Cobra in the MediaWiki CLI project and recently came across an error while trying to auto-generate docs.

panic: unable to redefine 'h' shorthand in "login" flagset: it's already used for "hostname" flag

goroutine 1 [running]:
github.com/spf13/pflag.(*FlagSet).AddFlag(0xc0000b5d00, 0xc00053d680)
        /go/pkg/mod/github.com/spf13/pflag@v1.0.5/flag.go:874 +0x6f0Code language: PHP (php)

I’m not actually trying to redefine this flag, but it looks like by default cobra always uses the -h flag for a help command, if you don’t define a help flag that doesn’t have the shorthand.

Read more

Wikidata ontological tree of Trains

While looking working on my recent WikiCrowd project I ended up looking at the ontological tree of both Wikidata entities and Wikimedia Commons categories.

In this post, I’ll look at some of the ontology mappings that happen between projects, some of the SPARQL that can help you use this ontology in tools, and also some tools to help you explore this complex tree.

I’m using trains as I think they are fairly easy for most folks to relate to, and also don’t have a massively complex tree.

Commons & Wikidata mapping

Depicts questions in WikiCrowd are entirely generated from these Wikimedia Commons categories, such as Category:Trains & Category:Steam locomotives. These are then mapped to items on Wikidata such as Q870 (train) & Q171043 (steam locomotive).

Wikimedia Commons categories quite often contain infoboxes on the right-hand side that link to a variety of resources for the thing the category is covering. And quite often there is a Wikidata item ID present, this is the case for the categories above.

Likewise on Wikidata statements for P373 (Commons category) will often exist for entities that are depicted on Commons.

Read more

Pre-launch Announcement of Wikibase.Cloud [WikidataCon Writeup]

This entry is part 10 of 12 in the series WBStack

WikidataCon 2021 was in October 2021, and one of the sessions that I spoke in was a “Pre-launch Announcement and Preview of Wikibase.Cloud”.

The recording is now up on YouTube, and below you’ll find a write-up summary of what was said.

You can also find:

So what is wikibase.cloud?

It’s a new platform that has yet to be launched, that is based on WBStack code, but that will be managed and maintained by Wikimedia Deutschland (or Wikimedia Germany).

This is a Wikibase as a service platform, that exists to offer open knowledge projects a new way to create their own Wikibase very quickly and very easily.

Read more

A first look at WikiCrowd

I have quite enjoyed the odd contribution to an app by Google called Crowdsource. You can find it either on the web, or also as an app.

Crowdsource allows people to throw data at Google in controlled ways to add to the massive pile of data that Google uses to improve its services and at the end of the day beat its competition.

It does this by providing a collection of micro contribution tasks in a marginally gamified way, similar to how Google Maps contributions get you Local Guide points etc. In Crowdsource you get a contribution count, a level, and a metric for agreements.

While I enjoy making the odd contribution when bored out of my mind and enjoy looking at the new challenges (currently at 2625 contributions), I always think that data like this should just be going out into the world under a free licence to benefit everyone.

So finally, introducing WikiCrowd, an interface, and soon to be app, that I developed over the new year period.

WikiCrowd Overview

WikiCrowd is hosted on toolforge and can be found at https://wikicrowd.toolforge.org/ (Source code on Github)

In order to contribute, you need some knowledge of the world, a Wikimedia account and that’s it!

Screenshot showing the wikicrowd application, listing various groups of questions users can contribute to

Read more

Pushing patches to sr.ht git repos

I recently wrote a blog post using the taavi/laravel-socialite-mediawiki PHP library which is hosted on sr.ht.

sr.ht, or sourcehut is “is a collection of tools useful for software development”, including git repository hosting.

I had to make a change to the library, and this was my first time contributing to a sr.ht repository. The workflow was quite different from what I am used to and required quite some Googling before I came up with something that I was happy with. So here goes my workflow.

Workflow

Firstly, if you haven’t used sr.ht before you’ll need to create an account and set up some way of pushing code (SSH keys etc). There are some fairly good docs for this already for Setting up your account and first git repository, but you can stop at Creating a git repository.

Once you have an account set up you need to find the sr.ht repository that you want to work with. In my case that is at the URL https://git.sr.ht/~taavi/laravel-socialite-mediawiki

You can find a clone URL over on the right-hand side of the repo page, and you want to go ahead and clone the repo.

git clone https://git.sr.ht/~taavi/laravel-socialite-mediawikiCode language: PHP (php)

You then also want to fork the repo into your own sr.ht account. The button is also on the right.

(You can also use your local clone to send a git email, but I didn’t want to install this tooling)

Screenshot of a sr.ht repository with the clone information highlighted

Read more

Laravel 8 with Wikimedia OAuth login

I recently wrote a little app called wikicrowd (blog post to follow) using Laravel and MediaWiki / Wikimedia authentication. It certainly wasn’t entirely out of the box, and the existing docs still need some tweaking.

This post reflects the steps I went through to set this app up, and it should only take a few minutes.

You can find a tag of the code at the end of this walkthrough on Github for PHP 8. (There is also a tag for PHP 7.4)

Shout out to the developers that worked on the Wikidata Mismatch Finder which is also a Laravel app with MediaWiki OAuth and was used as inspiration when writing this post, along with the documentation for the package used by Taavi.

Setup Laravel

First off I need a Laravel installation. Currently 8.x is the stream of the latest versions, and the installation docs say to run the below command.

curl -s https://laravel.build/demo-laravel-mediawiki-auth | bashCode language: JavaScript (javascript)

I’m not a fan of running random code on the internet on my machine, but this is what the docs say. It creates a directory at the location you specify at the end of the URL, in my case demo-laravel-mediawiki-auth , creates a laravel/laravel project, and does a composer install.

Read more

Installing Android Studio on WSL2 for Flutter

I’m trying to do some “modern” Android development and want to experiment with Flutter while running Windows, and WSL2 with Ubuntu.

Flutter isn’t as easy to install as some programs, no simple apt-get etc, but instead a collection of binaries distributed by different organizations that all need to be tied together.

To start with, you’ll want to read Installing Flutter 2.0 on WSL2 by Josh Kautz. This can guide you through getting Flutter and also the Android SDK with some copy & paste commands.

This post is inspired by these simple steps there to make this easy for folks to copy for Android Studio.

Read more