Example JWT with Private JWK

When writing code or testing, it’s useful to have valid examples of whatever you’re working with for sanity checks. I need some example JWTs with accompanying private JWK and couldn’t find any, so I minted a few. I’m posting them here in the hopes they’re useful to others, too.

These keys were created using a fresh RS256 key. No other keys have been created using this key. Because the private part of this key pair is public — it’s literally right below, in plain text — remember that these keys should only ever be used for sanity checking and testing. In particular, never use these keys for production use cases!

Continue reading “Example JWT with Private JWK”

Apache HTTPComponents HTTP Header Names are Case Insensitive

The source code never lies.

    /**
     * Gets all of the headers with the given name.  The returned array
     * maintains the relative order in which the headers were added.
     *
     * <p>Header name comparison is case insensitive.
     *
     * @param name the name of the header(s) to get
     *
     * @return an array of length &ge; 0
     */
    @Override
    public Header[] getHeaders(final String name) {
        List<Header> headersFound = null;
        for (int i = 0; i < this.headers.size(); i++) {
            final Header header = this.headers.get(i);
            if (header.getName().equalsIgnoreCase(name)) {
                if (headersFound == null) {
                    headersFound = new ArrayList<>();
                }
                headersFound.add(header);
            }
        }
        return headersFound != null ? headersFound.toArray(EMPTY) : EMPTY;
    }

emoji4j v15.0.1 Released

A new version v15.0.1 of my emoji processing library, emoji4j, for Java 8+ just dropped. Here are the updates:

  • Update to Unicode 15
  • New method GraphemeMatcher#results()
  • Imroved documentation
  • Even more tests

There is also now a Cookbook in the emoji4j wiki to help users solve hard or common problems with emoji4j.

Enjoy!

Parsing Rich Social Media Text

If you ever need to convert “plain” social media text like:

Hey @importantguy, check out my project https://www.mycoolproject.com/ #PrettyPlease

into “rich” social media text like:

Hey @importantguy, check out my project https://www.mycoolproject.com/ #PrettyPlease

Then you need a social text parsing library. The industry standard is twitter/twitter-text, but it doesn’t work for everything. (For example, it only parses valid Twitter mentions, but will not parse all valid TikTok mentions, since those screen names can contain a “.”.) So while you may need to customize for your specific use case(s), this post should at least give you a good starting point.

Continue reading “Parsing Rich Social Media Text”

Community-Managed OpenAPI Spec for Pinecone API

The excellent vector database Pinecone has a very useful API, but client support is sparse. While the API and its clients are in theory based off of an OpenAPI specno one seems to be able to find it.

But I needed an OpenAPI spec for the API, so I reverse engineered one (read: copy and pasted from the documentation).

It is very new and so should be considered very experimental. If you use it and find a bug, please open an issue, or even better submit a pull request!

Litecene: Full-Text Search for Google BigQuery

I just released the first beta version of litecene, a Java library that implements a common boolean search syntax for full-text search, with its first transpiler for BigQuery.

Litecene makes Searching Text in BigQuery Easy!

Litecene Syntax

Litecene uses a simple, user-friendly syntax that is derived from Lucene query syntax that should be familiar to most users. It includes clauses for term with wildcard, phrase with proximity, AND, OR, NOT, and grouping.

As an example, this might be a good Litecene query to identify social media posts talking about common ways people user their smartphones:

(smartphone OR "smart phone" OR iphone OR "apple phone" OR android OR "google phone" OR "windows phone" OR "phone app"~8) AND (call* OR dial* OR app OR surf* OR brows* OR camera* OR pic* OR selfie)

The syntax is documented in more detail here.

Continue reading “Litecene: Full-Text Search for Google BigQuery”