Skip to content

Instantly share code, notes, and snippets.

View vvucetic's full-sized avatar

Vedran Vučetić vvucetic

View GitHub Profile
@vvucetic
vvucetic / README.md
Last active November 15, 2022 10:18
s3 policy for emptying bucket

S3 Lifecycle policy for emptying bucket

aws s3api put-bucket-lifecycle-configuration --bucket $BUCKET --region $REGION --lifecycle-configuration file://lifecycle.json
@vvucetic
vvucetic / rate-limit.lua
Created May 31, 2020 19:58 — forked from jbaiter/rate-limit.lua
Simple Nginx Rate Limiting with Lua, redis and redis-cell
-- Requires the `redis-cell` module to be installed in Redis: https://github.com/brandur/redis-cell
local redis = require "nginx.redis"
local red = redis:new()
red:set_timeout(1000)
local ok, err = red:connect("127.0.0.1", 6379)
if not ok then
ngx.log(ngx.ERR, "failed to connect to redis: ", err)
ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
Resources:
RateLimitACL:
Type: AWS::WAFv2::WebACL
Properties:
Name: rate-limit-acl
Scope: REGIONAL
Description: Auto-generated rate-limiting ACL.
DefaultAction:
Allow: {}
VisibilityConfig:
Resources:
RateLimitACL:
Type: AWS::WAFv2::WebACL
Properties:
Name: rate-limit-acl
Scope: REGIONAL
Description: Auto-generated rate-limiting ACL.
DefaultAction:
Allow: {}
VisibilityConfig:
Resources:
RateLimitACL:
Type: AWS::WAFv2::WebACL
Properties:
Name: rate-limit-acl
Scope: REGIONAL
Description: Auto-generated rate-limiting ACL.
DefaultAction:
Allow: {}
VisibilityConfig:
@vvucetic
vvucetic / alert.sh
Created October 24, 2019 12:04 — 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\",
@vvucetic
vvucetic / Jenkinsfile
Last active March 14, 2019 14:13
Stop previously running Jenkins pipeline jobs
@NonCPS
def cancelPreviousBuilds() {
def jobName = env.JOB_NAME
def buildNumber = env.BUILD_NUMBER.toInteger()
/* Get job name */
def currentJob = Jenkins.instance.getItemByFullName(jobName)
/* Iterating over the builds for specific job */
for (def build : currentJob.builds) {
def exec = build.getExecutor()
import time
class Bucket(object):
def __init__(self, max_amount, refill_time, refill_amount):
self.max_amount = max_amount
self.refill_time = refill_time
self.refill_amount = refill_amount
self.reset()
def _refill_count(self):