Skip to content

Instantly share code, notes, and snippets.

View andersonbosa's full-sized avatar
🥑

Anderson Bosa andersonbosa

🥑
View GitHub Profile
@andersonbosa
andersonbosa / deprecated_changelogmd_generator.sh
Created May 12, 2024 16:26
deprecated changelog generator from Moshell.sh
#!/usr/bin/env bash
#
# Author: @andersonbosa
# Description: This script generates a changelog based on Git commit history.
# It identifies the last release commit, parses the commit messages, and
# categorizes them into different sections based on semantic keys. The resulting
# changelog is formatted and saved to a specified file location.
#
ABSOLUTE_SCRIPT_FILE_PATH="${BASH_SOURCE:-$0}"
interface AuthenticationService {
authenticate<I, O> (body: I): Promise<O>
}
class BasicAuthenticationService implements AuthenticationService {
async authenticate<I, O> (body: I): Promise<O> {
const r = { content: "authenticated" }
return r as O
}
@andersonbosa
andersonbosa / enum_typescript.ts
Last active May 6, 2024 20:23
enum_typescript.ts
/*
In this article, we reviewed a few ways to iterate over the keys and values of enum types
in TypeScript. First, we used the inbuilt methods of any TypeScript object, noting that
they are fairly “low-level”.
Second, we moved to a higher-level approach, with for loops. We verified that we can teach
TypeScript to preserve the typing given by enums, without relying on the string or numeric
representation.
*/
enum TrafficLight {
@andersonbosa
andersonbosa / Dockerfile
Created April 23, 2024 17:30
node_exporter service
FROM alpine:edge
WORKDIR /bin/app
RUN wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz \
&& tar -xzvf node_exporter-1.7.0.linux-amd64.tar.gz --directory . \
&& mv -v ./node_exporter-1.7.0.linux-amd64/node_exporter /bin/node_exporter \
&& chmod 777 /bin/node_exporter
@andersonbosa
andersonbosa / GithubRepositoriesTable.tsx
Created April 22, 2024 17:29
GithubRepositoriesTable.tsx
'use client'
import { HTMLAttributes, useEffect, useState } from 'react'
import { Table } from '../atoms/Table'
import { fetchGithubRepositoriesByUsername } from '@/app/lib/fetch'
import { GithubRepo } from '@/lib/types/global'
export type GithubRepo = {
name: any
@andersonbosa
andersonbosa / throttle.ts
Created April 20, 2024 16:12
typescript throttle and debounce
/**
* Allow only one call within the time limit
* @param { Function } func function to limited
* @param { Number } limit time limite in miliseconds
*/
export function throttle (func: Function, limit: number) {
let inThrottle: boolean
return function (this: any) {
const args = arguments
const context = this
@andersonbosa
andersonbosa / Makefile.docker.md
Last active April 12, 2024 14:42
Generic Makefile to help you boost your productivity with Docker

Variables

DOCKER_IMAGE_NAME := my-docker-image DOCKER_CONTAINER_NAME := my-container DOCKER_BUILD_DIR := . DOCKERFILE := Dockerfile DOCKER_RUN_COMMAND := /bin/bash

Commands

build:

@andersonbosa
andersonbosa / npm_automated_dependencies_update.sh
Last active April 11, 2024 21:31
NPM: How to Keep Dependencies Up-To-Date
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
# This command will check every installed dependency and compare the current
# version with the latest version in the npm registry. It is printed out into
# a table outlining available versions.
npm outdated
@andersonbosa
andersonbosa / 1.sh
Last active May 17, 2024 01:58
Scaffold a typescript project quickly
#!/bin/bash
# CREATE INITIAL FILES
cat > package.json <<EOF
{
"name": "@typescript/scaffold",
"version": "1.0.0",
"author": "Anderson Bosa",
"license": "CC0-1.0",
"keywords": ["typescript"],
@andersonbosa
andersonbosa / add_new_document.sh
Last active April 11, 2024 18:09
Add new item from a defined template. Useful for initing new documents like RFC's from a template.
#!/bin/bash
# Author: https://github.com/andersonbosa
# Source: https://gist.githubusercontent.com/andersonbosa/2596ce7856f08299e0e065ccfe878bb4/raw/fd823a48c736288ab9d0b7da3cab05e2f60ff2a4/add_new_document.sh
set -e
#######################################
# Function to convert a string to title case
# Arguments:
# $1: String to be converted to title case