Skip to content

Instantly share code, notes, and snippets.

View pferreirafabricio's full-sized avatar
🔥

Fabrício Pinto Ferreira pferreirafabricio

🔥
View GitHub Profile
@pferreirafabricio
pferreirafabricio / reset-pinia.ts
Created August 5, 2023 13:00
🗑 Basic logic to reset all Pinia stores at same time
import { defineStore, getActivePinia } from "pinia";
const activePinia = getActivePinia();
if (!activePinia) return;
Object.entries(activePinia.state.value).forEach(([storeName, state]) => {
console.debug("Resetting store", storeName);
const storeDefinition = defineStore(storeName, state);
const store = storeDefinition(activePinia);
@pferreirafabricio
pferreirafabricio / UfStatesBrazil.php
Last active February 11, 2023 17:40
🐘 Classe de constantes em PHP com todos os UFs de cada estado do Brasil
<?php
namespace App\Constants;
/**
* Classe com todos os UFs de cada estado do Brasil
*/
class UfStatesBrazil
{
public const ACRE = 'AC';
@pferreirafabricio
pferreirafabricio / OfxExample.ofx
Created February 5, 2023 13:13
💸 An OFX file example
OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
@pferreirafabricio
pferreirafabricio / CanvasUtils.cs
Created December 13, 2022 12:33
Method to check if a canvas element was clicked on Unity
public class CanvasUtils
{
private bool HasClickedOnCanvasElement()
{
PointerEventData pointerData = new PointerEventData(EventSystem.current);
List<RaycastResult> results = new List<RaycastResult>();
pointerData.position = Input.mousePosition;
Raycaster.Raycast(pointerData, results);
@pferreirafabricio
pferreirafabricio / GetStringBetweenByIndex.ps1
Last active November 3, 2022 14:55
Basic script to get a string between two indexes with PowerShell
$originalString = "Hello world"
$firstIndex = $originalString.IndexOf('H')
$lastIndex = $originalString.IndexOf('o')
$startIndex = $firstIndex + 1
$length = ($lastIndex - $firstIndex) - 1;
$finalString = $originalString.Substring($startIndex, $length)
@pferreirafabricio
pferreirafabricio / ConvertGitLogToJson.ps1
Created October 26, 2022 20:33
Powershell script to convert git logs in JSON
# Credits: https://stackoverflow.com/a/49515414/12542704
$header = @("commit", "tree", "parent", "refs", "subject", "body", "author", "commiter")
[string] $gitLogs = (git --no-pager log -n 10 --no-merges --pretty=format:'%H|%T|%P|%D|%s|%b|%an|%cn;')
$replacedArray = $gitLogs.Replace("; ", ';') -split ";", 0, "multiline";
$handledLogs = foreach ($commit in $replacedArray) {
$prop = $commit -split "\|"
$hash = [ordered]@{}
@pferreirafabricio
pferreirafabricio / canvasUtilities.js
Last active July 8, 2022 13:33
Class with some utilities to work on a canvas context
/**
* Class with some utilities to work on a canvas context
* @author Fabrício Pinto Ferreira
*/
export class CanvasUtility {
/**
* @param {CanvasRenderingContext2D} newContext
*/
constructor(newCanvasContext) {
/** @type {CanvasRenderingContext2D} */
@pferreirafabricio
pferreirafabricio / global.json
Created June 22, 2022 13:58
Example of global.json file for configuring a dotnet core application to use the the latest dotnet core SDK version 3.1
{
"sdk": {
"version": "3.1.0",
"rollForward": "latestFeature"
}
}
@pferreirafabricio
pferreirafabricio / .gitattributes
Last active June 4, 2022 20:30
Example o a .gitattributes file for correct identification of languages on GitHub
# Auto detect text files and perform LF normalization
* text=auto
*.cs linguist-language=csharp
*.csproj linguist-language=csharp
*.sln linguist-language=csharp
*.md linguist-detectable=true
*.md linguist-documentation=false
# And ignore those repositories considering them as documentation
@pferreirafabricio
pferreirafabricio / backupMongoDatabase.ps1
Last active September 16, 2021 14:33
Create a backup in a .zip file with all collections of a MongoDB Database
#region Variables
<# Set the MongoDB access variables #>
$databaseName = "databaseName"
# $username = ""
# $password = ""
# $authenticationDatabase = ""
$mongoDbHost = "localhost:27017"
# $uri = ""