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 / ConvertTo-UNCPath.ps1
Created December 28, 2023 19:07
PowerShell Toolbox
param (
[Parameter(Mandatory=$true)]
[string]$RelativePath
)
$ComputerName = $env:COMPUTERNAME
$AbsolutePath = Convert-Path $RelativePath
$UNCPath = $AbsolutePath -replace "^([A-Za-z]):", '$1$'
$UNCPath = $UNCPath -replace '\\', '\'
$UNCPath = "\\$ComputerName\$UNCPath"
@bruno-brant
bruno-brant / concentration.py
Last active November 18, 2023 13:38
Small experiment I wrote for myself to understand the concentration of molecules in the body considering their half-life and daily intake.
def concentration_after(initial_dosage, age, half_life):
"""
Age is the number of days, dosage is the amount (in mg) that was applyed at
the day 0
:param initial_dosage: Initial dosage
:param age: how many hours since the dosage
:param half_life: how many hours for a half-life of the molecule
"""
return initial_dosage * 0.5 ** (age / half_life)
@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.

@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 / 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;

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 / 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;
using System;
#pragma warning restore CA1000 // Do not declare static members on generic types
namespace QSaude.Commons
{
/// <summary>
/// Indicates a value that may or may not be present. Used to signal
/// that something might be null.
/// </summary>
@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 / 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);
}