This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using FluentValidation; | |
public sealed class ValidationFilter<T> : IEndpointFilter | |
where T : class | |
{ | |
public async ValueTask<object?> InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next) | |
{ | |
if (context.Arguments.FirstOrDefault(x => x?.GetType() == typeof(T)) is not { } argument) | |
return Results.Problem($"Missing argument type. Expected to validate {typeof(T).Name}."); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This was just a thought experiment of reimplementing the Rails signed_id's concept | |
* in NodeJS. All values below are examples and do not represent any real world data. | |
* | |
* This script might be useful for folks who need to support signed IDs that were | |
* generated by a Ruby on Rails application that is being ported to NodeJS. | |
*/ | |
const { createHmac, pbkdf2Sync } = require("node:crypto"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def within_circle(lon:, lat:, distance:, unit:, direction: "asc") | |
{ | |
query: { | |
bool: { | |
must: { | |
match_all: {} | |
}, | |
filter: [ | |
{ | |
geo_distance: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "Approved 👍", | |
"description": "Looks Good To Me!", | |
"color": "88e87f" | |
}, | |
{ | |
"name": "Blocked ⛔️", | |
"description": "This Is Blocked By Something!", | |
"color": "fc2929" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SlackWebhook | |
attr_accessor :webhook | |
def initialize(webhook) | |
@webhook = webhook | |
end | |
def send_message(text) | |
uri = URI(webhook) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// URL signature has following format: | |
// http://<uri>?timestamp=<timestamp>&signature=<signature> | |
const Boom = require('boom') | |
const crypto = require('crypto') | |
const algorithm = process.env.SIGNATURE_ALGORITHM || 'sha1' | |
const TIMESTAMP_RANGE = parseInt(process.env.TIMESTAMP_RANGE) || 5 * 60 * 1000 | |
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i |