Skip to content

Instantly share code, notes, and snippets.

@Joeao
Joeao / index.ts
Last active September 5, 2024 12:02
Supabase Edge Functions - Resize, Tinify & Upload Image
import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
import { crypto } from "https://deno.land/std@0.201.0/crypto/mod.ts";
import {
ImageMagick,
initialize,
MagickFormat,
} from "https://deno.land/x/imagemagick_deno@0.0.25/mod.ts";
import { Tinify } from "https://deno.land/x/tinify@v1.0.0/mod.ts";
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.33.2";
@brentjanderson
brentjanderson / README.md
Created June 14, 2022 15:53
Elixir runtime-controlled supervision tree using feature flags (circuit breaker)

These snippets provide a foundation for starting and stopping supervision trees at runtime using feature flags (e.g. Launch Darkly).

Some things to note when adapting these snippets:

  1. application.ex needs to be adapted into an existing application. The important part is that each child spec provided is compliant, and that there is a feature flag (ld_key) specified.
  2. As written, if a feature flag fails for some reason, it defaults to starting all children. There is room for adaptation here as needed.
  3. This implementation will still require a FeatureFlags module to be available that implements is_on?/2. Adjust as needed to accomodate your own feature flag setup.
@sorentwo
sorentwo / recording_output_with_pro.livemd
Created February 21, 2022 14:15
Demonstration of using Oban job output with Pro's Relay and Workflow

Recording Output with Oban Pro

Setup

To get started, install Oban, Pro, and our dependencies. Note that the oban_pro install requires a working Pro license.

Mix.install([
@eramdam
eramdam / .skhdrc
Created November 17, 2020 15:38
yabai/skhd config
#!/usr/bin/env sh
:: default : yabai -m config active_window_opacity 1; yabai -m config normal_window_opacity 1;
# Focus
shift + alt - home : yabai -m window --focus north
shift + alt - j : yabai -m window --focus north
shift + alt - end : yabai -m window --focus south
shift + alt - k : yabai -m window --focus south
shift + alt - delete : yabai -m window --focus west
@Kestrer
Kestrer / how-to-write-hygienic-macros.md
Created October 17, 2020 05:35
A guide on how to write hygienic Rust macros

How to Write Hygienic Rust Macros

Macro hygiene is the concept of macros that work in all contexts; they don't affect and aren't affected by anything around them. Ideally all macros would be fully hygienic, but there are lots of pitfalls and traps that make it all too easy to accidentally write unhygienic macros. This guide attempts to provide a comprehensive resource for writing the most hygienic macros.

Understanding the Module System

First, a little aside on the details of Rust's module system, and specifically paths; it is

Socket and channel setup

todo

Server receives a message

  • received first by the OS
  • then by websocket server code we don't control
  • eventually handed over to us
  • we parse the message enough to figure out the topic
@ayushgp
ayushgp / hasura-migrate.sh
Last active March 11, 2021 02:45
Take Hasura migrations from one server and apply them to another
# Take Hasura migrations from staging and apply them to prod
# Usage: ./migrate.sh "<staging-endpoint>" "<staging-secret>" "<prod-endpoint>" "<prod-secret>" "<migration-name>"
STAGING_ENDPOINT="$1"
STAGING_SECRET="$2"
PROD_ENDPOINT="$3"
PROD_SECRET="$4"
MIGRATION_NAME="$5"
@adamhjk
adamhjk / service.rs
Created May 28, 2020 14:34
tonic with tracing, opentelemetry, and context propagation
use opentelemetry::api::propagation::text_propagator::HttpTextFormat;
use tracing::{debug, info};
use tracing_futures::Instrument as _;
use tracing_opentelemetry::OpenTelemetrySpanExt as _;
#[tonic::async_trait]
impl crate::protobuf::kubernetes_server::Kubernetes for Service {
async fn kubernetes_deployment_component_get(
&self,
mut request: tonic::Request<crate::protobuf::KubernetesDeploymentComponentGetRequest>,
@keathley
keathley / .credo.exs
Last active December 30, 2023 16:13
Keathley's credo file
# This file contains the configuration for Credo and you are probably reading
# this after creating it with `mix credo.gen.config`.
#
# If you find anything wrong or unclear in this file, please report an
# issue on GitHub: https://github.com/rrrene/credo/issues
#
%{
#
# You can have as many configs as you like in the `configs:` field.
configs: [