Skip to content

Instantly share code, notes, and snippets.

View maxneuvians's full-sized avatar
🐝

Max Neuvians maxneuvians

🐝
  • Canadian Digital Service
  • Ottawa, Ontario
  • 10:19 (UTC -04:00)
View GitHub Profile
@maxneuvians
maxneuvians / mx-validate.py
Last active May 6, 2022 23:33
Check if domain has MX record
import json
import random
import string
import urllib.request
import urllib.parse
url = "https://dns.google/resolve"
def get_mx_record(domain):
if validate_domain(domain):
@maxneuvians
maxneuvians / yaml
Created April 8, 2019 21:26
traefik-ssl-config
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
k8s-app: traefik-ingress-lb
name: traefik-ingress-controller
annotations:
flux.weave.works/automated: "true"
namespace: kube-system
spec:
@maxneuvians
maxneuvians / bucket.ex
Last active June 11, 2023 04:07
Leaky Bucket GenServer in Elixir
defmodule LeakyBucket.Bucket do
@moduledoc """
Simulates a leaky bucket implementation
"""
use GenServer
@initial_amount 0
@increment_rate 1
@leak_rate 2
@leak_interval 500
@maxneuvians
maxneuvians / ets_log.ex
Created June 1, 2017 16:36
Elixir ETS Log
defmodule EtsLog do
@moduledoc """
GenServer to manage an in-memory log table. Start with EtsLog.start_link/0
"""
use GenServer
@size 3
# Public API
@doc """
@maxneuvians
maxneuvians / start_docker_registry.bash
Created March 15, 2017 19:40 — forked from PieterScheffers/start_docker_registry.bash
Start docker registry with letsencrypt certificates (Linux Ubuntu)
#!/usr/bin/env bash
# install docker
# https://docs.docker.com/engine/installation/linux/ubuntulinux/
# install docker-compose
# https://docs.docker.com/compose/install/
# install letsencrypt
# https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04
@maxneuvians
maxneuvians / pdf_plug.ex
Last active February 3, 2016 15:56
Elixir Plug for PDF generation with WKHTMLTOPDF
defmodule Sample.PdfPlug do
import Plug.Conn
import Plug.Upload
@wkhtmltopdf_path System.find_executable("wkhtmltopdf")
def init(opts) do
opts
end
#Stories are embedded docs in a Feed
class Feed
include MongoMapper::Document
many :stories
end
class Story
include MongoMapper::EmbeddedDocument
key :title, String