Skip to content

Instantly share code, notes, and snippets.

View bruno-brant's full-sized avatar
🏠
Working from home

Bruno Brant bruno-brant

🏠
Working from home
View GitHub Profile
@bruno-brant
bruno-brant / es6-classes-arent-types--class-greeter
Created April 12, 2017 17:09
ES6 Classes Aren't Type Definitions
class Greeter {
sayHello(name) {
return "Hello, " + name;
}
}
> typeof Greeter
'function'
> greeter = new Greeter();
Greeter {}
> typeof greeter
'object'
@bruno-brant
bruno-brant / push_docker_images_to_openshift.md
Last active September 23, 2025 11:56
How to push docker images to openshift internal registry and create application from it

How to push docker images to openshift internal registry and create application from it

Assuming you have the OCP (openshift container platform) cluster ready and the user has image push permissions on a namespace (ex:- dev)

TL;DR

  • Grab the Cluster IP Address of internal docker registry
  • tag the local image to internal docker registry
  • grab the auth token and login to inter docker registry
@bruno-brant
bruno-brant / alpine-tools.md
Last active October 20, 2025 17:37
alpine: add curl, telnet ect

Tooling in alpine builds

Pretty usual to have to diagnose docker containers based on alpine distros. But the image never comes with basic tools. How do we add it?

apk update						      # update the local registry
apk add busybox-extras			# install telnet and some other basic tools
apk add curl
@bruno-brant
bruno-brant / sample-anemic-model.js
Last active August 22, 2019 13:30
[medium] Coding a Non-Anemic Domain (I)
const server = require('restify').createServer();
const cartRepository = require('../repositories');
server.get('/cart/:cart/total', (req, res) => {
const cartId = Number(req.parameters.cart);
const cart = cartRepository.getCartById(cartId);
const total = cart.items.reduce((total, item) => total + item.price, 0);
res.send(200, { total });
@bruno-brant
bruno-brant / json.js
Created October 20, 2019 20:15
Get field from json
// Small tool to obtain a field from a JSON file
// Read the JSON from STDIN
var buff = "";
if (process.argv.length <= 1) {
console.error("Must inform the field to be extracted");
process.exit(-1);
}
@bruno-brant
bruno-brant / generate-diagrams.ps1
Last active March 25, 2020 12:02
PS Script to process all plantuml diagrams in a directory tree
<#
.SYNOPSIS
Use this script to generate all diagrams files in the subdirectory tree
(all files ending with .plantuml)
.DESCRIPTION
This script filters files in the subdirectory three from its location and
call plantuml for each file that was found.
To use the script, plantuml need to be in the path. We suggest you use scoop
@bruno-brant
bruno-brant / SwitchCase.tsx
Created July 21, 2021 16:24
SwitchCase for JSX
import React from "react";
export class Case extends React.Component<{ value: Number | String | Boolean }> {
render() {
return <>{this.props.children}</>;
}
}
export interface SwitchProps {
value: number | boolean | string;
@bruno-brant
bruno-brant / New-DependencyGraph.ps1
Last active September 16, 2022 14:12
Creates a dependency graph for a .NET assembly.
param (
[System.IO.FileInfo] $First,
[string] $OutputFormat = "dot",
[string] $OutputPath
)
$ErrorActionPreference = "stop"
class NodeRelation {
[string]$Start;
@bruno-brant
bruno-brant / README.md
Last active May 9, 2023 20:29
Essential .NET Libraries

Essential .NET Libraries

A few libraries that we can leverage on most projects to make our life easier:

  1. AnyOf - Sort of union types for .NET.

  2. SuccincT - Adds some functional features to .NET, with helpers such as pipe operators and partial function applications.

  3. IntelliEnum - Typed Enums for free.