Skip to content

Instantly share code, notes, and snippets.

@llupa
llupa / readme.md
Last active September 13, 2023 13:38
Team agreement on test categorisation

Introduction

I am writting this gist for two reasons:

  • I promised I will write it. Hey Dazz 👋
  • It seems that more than 1 (one) person has found this an interesting approach

A small preface: This was applied in an API project built with Symfony (API Platform). That is, there was no front-end, or HTML responses. This API project supports only json or json-ld. Our tests used the Symfony test-pack (PHPUnit and some Symfony helper classes).

@clemensv
clemensv / messaging-and-eventing-platforms.md
Created January 5, 2022 14:43
Elements of Messaging and Eventing Platforms
title
Elements of Messaging and Eventing Platforms

This document provides a brief overview of the essential elements of a messaging and eventing platform and how they relate to each other.

Message and Event Broker Categories

@m-radzikowski
m-radzikowski / script-template.sh
Last active May 4, 2024 04:13
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@pesterhazy
pesterhazy / memorable-uuids.md
Last active January 11, 2024 08:50
A UUID to remember

In their most used version v4, UUIDs are random, and that's a useful property. But sometimes all you want is a UUID that is easy to remember. To hell with randomness!

A minor complication is that for a string to parse as a valid UUID, the variant and version bits should be set correctly (to 2 and 4, respectively). Here are a few suggestions that pass the test:

facade00-0000-4000-a000-000000000000
decade00-0000-4000-a000-000000000000
@checco
checco / postgres-owner-grants.sql
Last active June 14, 2023 15:19
How to change OWNER for DATABASE, SCHEMA or TABLE on AWS RDS PostgreSQL. An how to REASSIGN owner for all objects on AWS RDS PostgreSQL
--
-- Change database owner
--
ALTER DATABASE "db_name" OWNER TO user;
--
-- List schemas
--

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@christopher-hopper
christopher-hopper / vm-resize-hard-disk.md
Last active April 5, 2022 10:30
Resize a Hard Disk for a Virtual Machine provisioned using Vagrant from a Linux base box to run using VirutalBox.

Resize a Hard Disk for a Virtual Machine

Our Virtual Machines are provisioned using Vagrant from a Linux base box to run using VirutalBox. If the Hard Disk space runs out and you cannot remove files to free-up space, you can resize the Hard Disk using some VirtualBox and Linux commands.

Some assumptions

The following steps assume you've got a set-up like mine, where:

@IvanChepurnyi
IvanChepurnyi / config.xml
Created November 5, 2013 09:41
Disable Mage_Reports module
<config>
<frontend>
<catalog_product_compare_remove_product>
<observers>
<reports>
<type>disabled</type>
</reports>
</observers>
</catalog_product_compare_remove_product>
<customer_login>