Skip to content

Instantly share code, notes, and snippets.

@joepie91
joepie91 / 1.md
Last active March 19, 2018 19:29

This is a bit of a hack.

@joepie91
joepie91 / wildcard-certificates.md
Last active September 16, 2023 18:11
Why you probably shouldn't use a wildcard certificate

Recently, Let's Encrypt launched free wildcard certificates. While this is good news in and of itself, as it removes one of the last remaining reasons for expensive commercial certificates, I've unfortunately seen a lot of people dangerously misunderstand what wildcard certificates are for.

Therefore, in this brief post I'll explain why you probably shouldn't use a wildcard certificate, as it will put your security at risk.

A brief explainer

It's generally pretty poorly understood (and documented!) how TLS ("SSL") works, so let's go through a brief explanation of the parts that are important here.

The general (simplified) idea behind how real-world TLS deployments work, is that you:

@joepie91
joepie91 / .service
Last active February 4, 2024 22:34
systemd service file example for Node.js
[Unit]
After=network.target
Description=Hello World App
[Service]
Environment="NODE_ENV=production"
ExecStart=/usr/bin/node /home/foo/test/index.js
Restart=on-failure
User=foo
@joepie91
joepie91 / npm-packages-missing.md
Last active January 11, 2018 20:35
I can't install a package!

UPDATE: According to npm Inc., the issue has been resolved. This gist will be updated with a link to the post-mortem once it's published. Please make sure to read the below explanation anyway, since there may still be a security impact for you.

UPDATE 2: An initial statement has been released, in which npm Inc. states that there has been no security impact. A full post-mortem is said to be forthcoming, and will be added here when it's published.

UPDATE 3: The full postmortem has been published, including a list of affected packages.


There's currently a known issue affecting the NPM registry, making certain packages impossible to install. You may see an error message indicating that a package doesn't exist, or that the registry is down. More details can be found [here](https

@joepie91
joepie91 / hydra.md
Created November 26, 2017 09:31
Hydra notes

Just some notes from my attempt at setting up Hydra.

Setting up on NixOS

No need for manual database creation and all that; just ensure that your PostgreSQL service is running (services.postgresql.enable = true;), and then enable the Hydra service (services.hydra.enable). The Hydra service will need a few more options to be set up, below is my configuration for it:

    services.hydra = {
        enable = true;
 port = 3333;
@joepie91
joepie91 / genius-programmer.md
Last active June 25, 2023 08:46
The One Secret Trick To Becoming A Genius Programmer

The One Secret Trick To Becoming A Genius Programmer

Okay, the title of this post is a bit of a lie. There's no one secret trick to becoming a genius programmer - there are two, and they're more habits than tricks. Nevertheless, these kind of 'secret tricks' seem to resonate with people, so I went for this title anyway.

Every once in a while, a somewhat strange thing happens to me. I'll be helping somebody out on IRC - usually a beginner - answering a number of their questions in rapid succession, about a variety of topics. Then after a while, they call me a "genius" for being able to answer everything they're asking; either directly, or while talking about me to somebody else.

Now, I don't really agree with this "genius" characterization, and it can make me feel a bit awkward, but it shows that a lot of developers have a somewhat idealistic and nebulous notion of the "genius programmer" - the programmer that knows everything, who can do everything, who's never stumped by a problem, and of which ther

@joepie91
joepie91 / futures-tokio.md
Created September 19, 2017 19:06
Futures and Tokio

(This Gist is a work-in-progress, and things may be added or changed over time.)

Event loops

If you're not familiar with the concept of an 'event loop' yet, watch this video first. While this video is about the event loop in JavaScript, most of the concepts apply to event loops in general, and watching it will help you understand Tokio and Futures better as well.

Concepts

  • Futures: Think of a Future like an asynchronous Result; it represents some sort of result (a value or an error) that will eventually exist, but doesn't yet. It has many of the same combinators as a Result does, the difference being that they are executed at a later point in time, not immediately. Aside from representing a future result, a Future also contains the logic that is necessary to obtain it. A Future will 'complete' (either successfully or with an error) precisely once.
  • Streams: Think of a [Stream](https
@joepie91
joepie91 / .md
Last active November 30, 2017 14:42
About the Ayo fork of Node.js

This is a brief post to answer some of the common questions about Ayo (a fork of Node.js), to cut down on the noise in #Node.js. Keep in mind that I'm in no way associated with Ayo, this is just an attempt to cover some of the frequent questions.

Important note: Be aware that discussion about the political reasons behind the Ayo fork is considered off-topic in the #Node.js channel, as that channel is primarily intended for technical support, and this is a topic that is very likely to invite trolling and polarization.

If you wish to discuss the politics behind the fork, there are plenty of comment threads around the web on the usual sites; Hacker News, Reddit, and so on. Please direct your discussion there instead.

Discussions in #Node.js about the technical aspects of the Ayo fork (eg. compatibility) are, of course, fine.

Why was Ayo forked?

@joepie91
joepie91 / nixos-sysinfo.sh
Created August 18, 2017 12:19
Bash function for printing system information for nixpkgs issues
function nixos-sysinfo {
echo "* System: $(nixos-version)"
echo "* Nix version: $(nix-env --version)"
echo "* Nixpkgs version: $(nix-instantiate --eval '<nixpkgs>' -A lib.nixpkgsVersion)"
echo "* Sandboxing enabled: $(grep build-use-sandbox /etc/nix/nix.conf | grep -oE 'true|false')"
}
@joepie91
joepie91 / .md
Last active April 12, 2024 16:08
Prefix codes (explained simply)

A "prefix code" is a type of encoding mechanism ("code"). For something to be a prefix code, the entire set of possible encoded values ("codewords") must not contain any values that start with any other value in the set.

For example: [3, 11, 22] is a prefix code, because none of the values start with ("have a prefix of") any of the other values. However, [1, 12, 33] is not a prefix code, because one of the values (12) starts with another of the values (1).

Prefix codes are useful because, if you have a complete and accurate sequence of values, you can pick out each value without needing to know where one value starts and ends.

For example, let's say we have the following codewords: [1, 2, 33, 34, 50, 61]. And let's say that the sequence of numbers we've received looks like this:

1611333425012