Skip to content

Instantly share code, notes, and snippets.

View linkdd's full-sized avatar
🙂

David Delassus linkdd

🙂
View GitHub Profile
@linkdd
linkdd / example-libcluster.ex
Last active September 16, 2021 10:30
Example of libcluster configuration (Elixir)
defmodule MyApp.Application do
use Application
def start(_type, _args) do
topologies = [
default: [
strategy: Cluster.Strategy.Kubernetes.DNS,
config: [
service: "my-elixir-app-svc-headless",
application_name: "my_app"
@linkdd
linkdd / mix.exs
Created September 14, 2021 22:30
Sample Mix project configuration with datapio_cluster
defmodule MyApp.MixProject do
use Mix.Project
def project do
[
app: :my_app,
version: "0.1.0",
elixir: "~> 1.12",
start_permanent: Mix.env() == :prod,
deps: deps()
@linkdd
linkdd / config.exs
Created September 14, 2021 22:39
Example of datapio_cluster_config
import Config
config :datapio_cluster,
service_name: [env: "MYAPP_SERVICE_NAME", default: nil],
app_name: [env: "MYAPP_APP_NAME", default: "my_app"],
cache_tables: [
some_set: [:id, :attr1, :attr2],
some_other_set: [:id, :attr]
]
@linkdd
linkdd / hackernews-new-comms.js
Last active August 25, 2024 11:15
Add a bell emoji to unread comments on HackerNews
// Can be used with https://github.com/xcv58/Custom-JavaScript-for-Websites-2
// This snippet is released under the terms of the CC0 license: https://creativecommons.org/publicdomain/zero/1.0/deed.en
const cache_key = 'hn_comments_views'
const cache = JSON.parse(localStorage.getItem(cache_key) || '{}')
document.querySelectorAll('.athing.comtr').forEach(comm => {
if (!cache[comm.id]) {
const span = document.createElement('span')
span.innerHTML = '🔔' // :bell: emoji
@linkdd
linkdd / Dockerfile
Created October 19, 2021 10:51
Example Dockerfile for Elixir/Phoenix project
## Layers containing files for the next stages
# Project configuration
FROM scratch AS context
ADD mix.exs mix.lock /workspace/
ADD config /workspace/config
# Asset files
FROM scratch AS assets
@linkdd
linkdd / get-docker-host.sh
Created January 23, 2022 03:05
Get Docker Host IP Address
#!/bin/sh
cat <<EOF | docker run --rm -i alpine:latest sh
apk add --no-cache iproute2 >/dev/null
ip -4 route show default | cut -d' ' -f3
EOF
@linkdd
linkdd / github-workflow-step-kubeconfig.yml
Created January 23, 2022 03:08
Github Workflow Step to edit the KinD generated kubeconfig for use inside a Docker container
# uses script from https://gist.github.com/linkdd/4bbd9fc4966e00e067305f1fb8c2588c
- name: setup@kubeconfig
run: |
hostip=$(sh .github/scripts/get-docker-host.sh)
sed "s/127.0.0.1/$hostip/g" $HOME/.kube/config > ${{ github.workspace }}/kubeconfig.yml
@linkdd
linkdd / kind-cluster-config.yml
Created January 23, 2022 03:14
Example of KinD cluster configuration
---
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
apiServerAddress: "127.0.0.1"
@linkdd
linkdd / github-workflow-step-kind.yml
Created January 23, 2022 03:16
Example of KinD cluster creation in a Github Workflow
- name: setup@kindconfig
run: |
kind_in="${{ github.workspace }}/.github/config/kind.yml.in"
kind_out="${{ github.workspace }}/.github/config/kind.yml"
hostip=$(sh .github/scripts/get-docker-host.sh)
sed "s/127.0.0.1/$hostip/g" $kind_in > $kind_out
- name: setup@kubernetes
uses: engineerd/[email protected]
with:
@linkdd
linkdd / defer-frame.hpp
Created February 7, 2022 14:30
Golang's defer feature for your C++ functions.
#pragma once
#include <functional>
#include <vector>
#include <algorithm>
class defer_frame {
public:
using function = std::function<void(void)>;