Skip to content

Instantly share code, notes, and snippets.

@bennotti
bennotti / IDataResponseApi.dto.ts
Created February 8, 2022 14:12
Implementação padronização de resposta com generic T em typescript
// interface resposta padrão + retorno de dados
interface IDataResponseApiDto<T>{
data: T | undefined;
}
class DataResponseApiDto<T> extends ResponseApiDto implements IDataResponseApiDto<T>{
data: T | undefined;
constructor(data: T | undefined, result: boolean = true, message: String = "Executado com sucesso!"){
super (result, message);
@bennotti
bennotti / web-servers.md
Created January 3, 2022 00:16 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@bennotti
bennotti / README.md
Created December 5, 2021 13:53 — forked from henrebotha/README.md
How to set up a TypeORM playground

How to set up a TypeORM playground

This guide is intended for people who'd like to experiment with TypeORM in a hands-on fashion. I find this especially helpful when attempting to construct complex queries.

Prerequisites

You need Yarn and Docker installed.

Process

/* PAGINATION WITH SORTING AND PAGING */
const page = 1; // input page, min value 1
const limit = 2; // input limit min value 1
/* INPUT ARRAY */
const array = [
{ Editable: true, Name: "Daniel Test", Site: "SE100"},
{ Editable: true, Name: "Test new", Site: "SE100"},
{ Editable: false, Name: "Test", Site: "SE100"},
];
@bennotti
bennotti / gist:2735ac7ebcf73a375e845a03b27a0f06
Created September 25, 2021 00:02 — forked from pironim/gist:2f578c60afb67f156136
git pre-commit hook to check branch name
#!/bin/bash
#
# Pre-commit hooks
# Check branch name
BRANCH_NAME_LENGTH=`git rev-parse --abbrev-ref HEAD | grep -E '^t[0-9]{2,16}\_.*_[A-Za-z]{2,2}$' | wc -c`
if [ ${BRANCH_NAME_LENGTH} -eq 0 ] ; then
echo -e '\E[37;44m'"\033[1mERROR\033[0m in pre-commit hook: vim /export/web/.git/hooks/pre-commit"
echo "Branch name should be like t00000_blah_blah_CA - brand is two letters"
@bennotti
bennotti / post-merge
Created September 24, 2021 21:14 — forked from jeffsrepoaccount/post-merge
Git post merge hook for auto-tagging release/hotfix branches based off of branch name
#!/usr/bin/env bash
###############################################################################
#
# Automatically detects a merge on to master from a gitflow-style release
# branch, e.g. release-1.1.1-alpha. If the merged branch matches, the major,
# minor and patch versions are determined and a new release tag is created
# locally. If remote origin exists, this tag will automatically be pushed.
#
# In addition to creating a tag, the release branch will automatically be
# merged into the develop branch. If the branch has already been merged this
@bennotti
bennotti / semantic-commit-messages.md
Created September 1, 2021 20:54 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@bennotti
bennotti / pipeline.cs
Created August 9, 2021 10:19 — forked from benfoster/pipeline.cs
c# Pipeline
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace PipelineDemo
{
// http://www.rantdriven.com/post/2009/09/16/Simple-Pipe-and-Filters-Implementation-in-C-with-Fluent-Interface-Behavior.aspx
public interface IFilter<TContext>
{
@bennotti
bennotti / delete_git_submodule.md
Created June 27, 2021 01:34 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@bennotti
bennotti / erc20-token-sample.sol
Created May 17, 2021 14:12 — forked from jcmartinezdev/erc20-token-sample.sol
Necessary code to generate an ERC20 Token
pragma solidity ^0.4.24;
// ----------------------------------------------------------------------------
// Sample token contract
//
// Symbol : LCST
// Name : LCS Token
// Total supply : 100000
// Decimals : 2
// Owner Account : 0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe