Skip to content

Instantly share code, notes, and snippets.

View Destitute-Streetdwelling-Guttersnipe's full-sized avatar
🎯
Focusing

DSG (Destitute Streetdwelling Guttersnipe) Destitute-Streetdwelling-Guttersnipe

🎯
Focusing
View GitHub Profile
@eddiewebb
eddiewebb / readme.md
Last active April 9, 2025 04:31
Hugo JS Searching with Fuse.js
@joepie91
joepie91 / genius-programmer.md
Last active January 26, 2025 18:39
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 March 7, 2025 22:07
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

@joepie91
joepie91 / .md
Last active June 25, 2023 08:51
Useful tools for working with NixOS
@joepie91
joepie91 / .md
Last active February 25, 2025 21:32
A *complete* listing of operators in Nix, and their predence.

Lower precedence means a stronger binding; ie. this list is sorted from strongest to weakest binding, and in the case of equal precedence between two operators, the associativity decides the binding.

Prec Abbreviation Example Assoc Description
1 SELECT e . attrpath [or def] none Select attribute denoted by the attribute path attrpath from set e. (An attribute path is a dot-separated list of attribute names.) If the attribute doesn’t exist, return default if provided, otherwise abort evaluation.
2 APP e1 e2 left Call function e1 with argument e2.
3 NEG -e none Numeric negation.
4 HAS_ATTR e ? attrpath none Test whether set e contains the attribute denoted by attrpath; return true or false.
5 CONCAT e1 ++ e2 right List concatenation.
6 MUL e1 * e2 le
@joepie91
joepie91 / .md
Last active June 25, 2023 08:52

A few notes on the "Gathering weak npm credentials" article

Yesterday, an article was released that describes how one person could obtain access to enough packages on npm to affect 52% of the package installations in the Node.js ecosystem. Unfortunately, this has brought about some comments from readers that completely miss the mark, and that draw away attention from the real issue behind all this.

To be very clear: This (security) issue was caused by 1) poor password management on the side of developers, 2) handing out unnecessary publish access to packages, and most of all 3) poor security on the side of the npm registry.

With that being said, let's address some of the common claims. This is going to be slightly ranty, because to be honest I'm rather disappointed that otherwise competent infosec people distract from the underlying causes like this. All that's going to do is prevent this from getting fixed in other l

@jaredcatkinson
jaredcatkinson / Get-InjectedThread.ps1
Last active April 24, 2025 15:06
Code from "Taking Hunting to the Next Level: Hunting in Memory" presentation at SANS Threat Hunting Summit 2017 by Jared Atkinson and Joe Desimone
function Get-InjectedThread
{
<#
.SYNOPSIS
Looks for threads that were created as a result of code injection.
.DESCRIPTION
@joepie91
joepie91 / .md
Created March 27, 2017 21:03
Asking questions respectfully

Every once in a while, somebody comes into an IRC channel with a code question, and their code turns out to be a mess - very hard to understand, even harder to fix, and sometimes flat-out unfixable. This is usually followed by a recommendation towards the person asking the question, suggesting that they clean up the code first, and giving them concrete suggestions on how to do so.

Most of the time, this works fine - the asker cleans up the code and returns with a more readable version. Unfortunately, sometimes it does not.

The problem

Asking people on IRC a question means asking volunteers to give up their time and energy to solve your problem. This is fine, since that's what people are there to do in the first place - however, it means that you are expected to put in your part of the effort as well.

When you respond with something along the lines of:

@joepie91
joepie91 / .md
Created March 25, 2017 22:51
Database characteristics

NOTE: This is simplified. However, it's a useful high-level model for determining what kind of database you need for your project.

Data models

  • Documents: Single type of thing, no relations
  • Relational: Multiple types of things, relations between different types of things
  • Graph: Single or multiple types of things, relations between different things of the same type

Consistency models