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 February 14, 2024 11:04
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 August 11, 2019 22: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 / privacy.css
Last active July 11, 2022 12:47
Whatsapp CSS Injection
/* SIDEBAR */
div[data-testid="cell-frame-container"]:not(:hover) {
/*#pane-side:not(:hover) img { */
filter: blur(6px);
}
div[data-testid="cell-frame-container"]:not(:hover) span {
font-size: 125%;
color: transparent;
text-shadow: 0 0 8px #FFF;

Tips for Heroku CLI

Copy all variables

Copies all variables from "$source" app to "$target" app.

$source = "";
$target = "";
heroku config -a $source | where { -not $_.StartsWith("===") } | %{ $kv = -split $_; $key = $kv[0].Replace(":", ""); $value = $kv[1]; heroku config:set -a $target "$key=$value" }
@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;