Skip to content

Instantly share code, notes, and snippets.

Embeds One Default Demo

Success Cases

defmodule Post do
  use Ecto.Schema
@bamorim
bamorim / main.bal
Created October 22, 2023 16:57
Token and FeatureFlag in Ballerina
import ballerina/http;
import ballerina/jwt;
import ballerinax/jaeger as _;
listener http:Listener httpListener = new (8080);
type RefreshTokenResponse readonly & record {|
string token;
|};
@bamorim
bamorim / config.exs
Last active March 28, 2023 08:42
Opentelemetry Span <> Logger integration
import Config
config :opentelemetry,
processors: [
{OpentelemetrySpanLogger, []},
:batch
]
@bamorim
bamorim / iots.ts
Created May 28, 2021 20:18
io-ts vs runtypes
‎‎​
@bamorim
bamorim / xor.ts
Created April 9, 2021 20:23
xorts
type XOR<T, U> = (T | U) extends object
? (Without<T, U> & U) | (Without<U, T> & T)
: T | U
type Without<T, U> = {
[P in Exclude<keyof T, keyof U>]
?
: never
}
# Maintainer: Bernardo Amorim
pkgname=crd2pulumi-bin
_pkgname=crd2pulumi
pkgver=1.0.5
pkgrel=1
pkgdesc='Generate typed CustomResources based on Kubernetes CustomResourceDefinitions.'
arch=('x86_64')
url='https://github.com/pulumi/crd2pulumi'
license=('APACHE')
const lang = require("./fm-lang");
const to_net = require("./fm-to-net");
const to_js = require("./fm-to-js");
const json = require("./fm-json");
// Return a term or a reference to it based on a name
function name_to_term(name, defs) {
if (defs[name] && defs[name][0] === "Ref" && !defs[defs[name][1].name]) {
name = defs[name][1].name;
}
declare module "formality-lang" {
import core, { Defs, Term } from "formality-lang/fm-core";
import lang from "formality-lang/fm-lang";
import net from "formality-lang/fm-net";
import to_js from "formality-lang/fm-to-js";
import to_net from "formality-lang/fm-to-net";
function exec(
term_name: string,
defs: Defs,
require "json"
require "uri"
require "set"
inside_services = JSON.parse(File.read("inside-services.json"))["items"]
inside_config_maps = JSON.parse(File.read("inside-config-maps.json"))["items"]
inside_namespaces = JSON.parse(File.read("inside-namespaces.json"))["items"].map { |ns| ns["metadata"]["name"] }
dmz_services = JSON.parse(File.read("dmz-services.json"))["items"]
dmz_config_maps = JSON.parse(File.read("dmz-config-maps.json"))["items"]
@bamorim
bamorim / nrrw_generalization.lua
Created February 24, 2019 23:48
NRRW Generalization
-- Number of steps
k = 2
s = 3
-- Add the first vertex with self loop
local u = addVertex()
connectVertices(u, u)
setAttributes(u, "color", "red")
-- Give a chance to render