Skip to content

Instantly share code, notes, and snippets.

View ismichaelni's full-sized avatar
👓

Michael ismichaelni

👓
View GitHub Profile
@ismichaelni
ismichaelni / Program.cs
Created January 10, 2025 05:03 — forked from davepcallan/Program.cs
.NET Rate limiting simple examples
using Microsoft.AspNetCore.RateLimiting;
using System.Threading.RateLimiting;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRateLimiter(options =>
{
// 1. Fixed Window Limiter (20 requests per 2 minutes)
// -----------------------------------------------
// |----------------- 2 min -----------------|
@ismichaelni
ismichaelni / aws_iam_secret_to_smtp_password.md
Created October 24, 2024 06:12 — forked from damusix/aws_iam_secret_to_smtp_password.md
Convert AWS IAM credentials to AWS SMTP credentials

Convert AWS IAM credentials to AWS SMTP credentials

If you do, or want to, use AWS to deploy your apps, you will end up using AWS SES via SMTP when you're launching an app that sends out emails of any kind (user registrations, email notifications, etc). For example, I have used this configuration on various Ruby on Rails apps, however, it is just basic SMTP configurations and crosses over to any framework that supports SMTP sendmail.

There are two ways to go about this:

Luckily, you found this MD file and the NOT SO EASY WAY is suddenly copy-pasta... sudo yum....

@ismichaelni
ismichaelni / README.md
Created March 25, 2022 07:08 — forked from int128/README.md
Example of Envoy TCP Proxy
@ismichaelni
ismichaelni / gist:a2837b1a88e0e7088a73fa4ccd968181
Created June 3, 2020 09:36 — forked from jrotello/gist:8873462
Powershell helper to ease Elasticsearch interaction without curl
function Invoke-Elasticsearch {
[CmdletBinding()]
Param(
[Uri]$Uri,
[Microsoft.PowerShell.Commands.WebRequestMethod]$Method = 'Get',
$Body = $null,
[PSCredential]$Credential
)
$headers = @{}
@ismichaelni
ismichaelni / alert.sh
Created October 15, 2019 04:18 — forked from cherti/alert.sh
send a dummy alert to prometheus-alertmanager
#!/bin/bash
name=$RANDOM
url='http://localhost:9093/api/v1/alerts'
echo "firing up alert $name"
# change url o
curl -XPOST $url -d "[{
\"status\": \"firing\",
# MIT License
#
# Copyright (c) 2018, Zane Claes
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# MIT License
#
# Copyright (c) 2018, Zane Claes
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# MIT License
#
# Copyright (c) 2018, Zane Claes
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@ismichaelni
ismichaelni / gist:446b42c08a25c46c337b18d5b3ec0009
Created May 29, 2018 02:19 — forked from klovadis/gist:5170485
A Lua script for Redis that allows you to set hash values based on a dictionary table
-- sets all fields for a hash from a dictionary
local hmset = function (key, dict)
if next(dict) == nil then return nil end
local bulk = {}
for k, v in pairs(dict) do
table.insert(bulk, k)
table.insert(bulk, v)
end
return redis.call('HMSET', key, unpack(bulk))
end
@ismichaelni
ismichaelni / gist:619d3e16e7bc8de91107831b81762a93
Created May 28, 2018 04:13 — forked from klovadis/gist:5170446
Two Lua scripts for Redis to turn HGETALL and HMGET into dictionary tables
-- gets all fields from a hash as a dictionary
local hgetall = function (key)
local bulk = redis.call('HGETALL', key)
local result = {}
local nextkey
for i, v in ipairs(bulk) do
if i % 2 == 1 then
nextkey = v
else
result[nextkey] = v