Skip to content

Instantly share code, notes, and snippets.

@deefdragon
deefdragon / HowTo.md
Last active July 15, 2023 07:39
RabbitMQ Time Delay Queue
View HowTo.md

Time Delay Queue

One of the things that I was sure must exist, but had, until this point, never found anywhere was a distributed time delay. That is, a way to add data to a bucket/queue/dataset/what have you, that would then allow for work to be done on that data after a pre-determined delay. A delay that was independent to each item (the ability for different delays on each item automatically allows for the same delay on each item)

When working in a single service, using a sleep command is often good enough, but when you have to wait longer than about a minute, you should be using a separate (ideally distributed) tool.

The reason for this, in my opinion, is that you should not trust your service to not be shut down in the time between the event starts and the event ends.

This gist explains, roughly, how to create a time delay queue in RabbitMQ (And thus AMQP in general) as well as includes code required to do so in terraform.

@deefdragon
deefdragon / migrate.configmap.yaml
Last active December 2, 2023 19:41
Migrating Kubernetes PVC/PVs from one storage class to another
View migrate.configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
# any name can be used; Velero uses the labels (below)
# to identify it rather than the name
name: change-storage-class-config
# must be in the velero namespace
namespace: velero
# the below labels should be used verbatim in your
# ConfigMap.
@deefdragon
deefdragon / main.go
Last active December 1, 2020 18:53
golang x/time/rate example
View main.go
package main
import (
"fmt"
"sync"
"time"
"golang.org/x/time/rate"
)
@deefdragon
deefdragon / gist:96edde1fb21e09dc87a8db3ed473f36b
Last active November 30, 2020 01:12
Cookies not sent to api over websocket, ngx-cookie-service
View gist:96edde1fb21e09dc87a8db3ed473f36b
TLDR: add {withCredentials: true} to the options sent in the request. In angular I had to create an interceptor to do the job.
I have been fighting with my server, attempting to send a UUID with my requests to give my non-logged in clients some kind of persistance. I started with passing it as a header, but because one of my requests uses web-sockets, I cant use headers for everything. This means that I have to use a cookie for the requests. I would have rather used the header, but whatever.
Storing the cookie is important anyway because the UUID should be stored between requests. As such, on every request, the UUID is checked, and if it doesent exist, the cookie is created. The header is then added to the request where needed.
For most of the calls, I had already created an interceptor that would generate a header to add to the calls. Because websockets dont keep headers (WHY was that a decision made when you literally upgrade the protocol I DONT know, but I digress) I had to use a cookie, or come up wit
View test.yaml
openapi: 3.0.0
info:
version: "0.0.1"
title: StreemTech API
description: A Starter StreemTech API that contains different status codes etc. and the basics of the api as is created so far.
contact:
name: API Support
url: http://wiki.streem.tech/api
email: admin@streem.tech
license:
@deefdragon
deefdragon / x509 valid for a not b.md
Last active October 10, 2019 14:48
x509: certificate is valid for a, not b
View x509 valid for a not b.md

writing this for search engine indexing more than anything. TLDR: kubernetes cluster DNS messed up. Had to rebuild by cluster

I recently ran into an issue with my kubernetes cluster not being able to run the container that I was building. This container was a relativly simple golang program. do a get request, parse the json, insert into remote database.

when running in my cluster (Self Rolled High Avalibility if that matters), the program panicked on a x509 error. specifically x509: certificate is valid for pfSense-5d68c9b017846, not api.pathofexile.com

View golang syntax error near unexpected token `newline' build error.md

I am an idiot. Its only through mistakes that you learn tho. I have recently been running into issues with my new golang projects. ONLY the new ones. Whenever I try to make a new project, it would always have issues. The biggest issue is the fact that "go build" would not produce an executable without "-o main.exe" as arguments. When an executable was produced, if I ran it I got

$ ./main.exe
./main.exe: line 1: syntax error near unexpected token \`newline\'
./main.exe: line 1: \`!<arch>\'

I thought that this was something wrong with my install. Possibly my environmental varaibles. The fact that it was only new projects should have directed me more to how the project was set up. Digging through those proved not to help. Eventually I poked arround the go irc, (far and away the best place to go for help), and finally someone (Thank you neebs) was able to catch what I was doing wrong.

It had been so long since I last created a project, and I had only ever created one mod project from scratch, that I w

@deefdragon
deefdragon / 1 - Handle Changing.md
Last active September 2, 2018 20:53
In support of Handle Chaining; On Check
View 1 - Handle Changing.md

Handle Changing

I am in favor of the fact that the handle keyword has the ability to chain, as this allows for the ability to, for example, print variables that were used previously that are the actual root cause of the error instead of just dealing with the symptoms of the problem.