Skip to content

Instantly share code, notes, and snippets.

View pferreirafabricio's full-sized avatar
🔥

Fabrício Pinto Ferreira pferreirafabricio

🔥
View GitHub Profile
TypeScript 11 hrs 45 mins █████████▋░░░░░░░░░░░ 46.2%
C# 5 hrs 5 mins ████▏░░░░░░░░░░░░░░░░ 20.0%
Markdown 2 hrs 46 mins ██▎░░░░░░░░░░░░░░░░░░ 10.9%
Vue.js 2 hrs 37 mins ██▏░░░░░░░░░░░░░░░░░░ 10.3%
PHP 1 hr 9 mins ▉░░░░░░░░░░░░░░░░░░░░ 4.5%
@pferreirafabricio
pferreirafabricio / convertImagesToBase64.ps1
Last active March 30, 2024 16:03
Script to loop through a folder with images and convert all of them to a Base64 string
<#
Usage on Linux:
pwsh ./convertImagesToBase64.ps1 /home/user/folder/images
Usage on Windows:
./convertImagesToBase64.ps1 C:/Path/To/Imagens
#>
$folderPath = $args[0]
@pferreirafabricio
pferreirafabricio / useScrollByDrag.ts
Created September 4, 2023 13:13
🤚 A React Hook to make an HTML element (e.g. a table, list, div with large text) scrollable with the mouse
import { useEffect, useState } from 'react';
export function useScrollByDrag({
elementToScroll,
scrollVelocity = 1,
}: {
elementToScroll: HTMLElement | null;
scrollVelocity?: number;
}) {
useEffect(() => {
@pferreirafabricio
pferreirafabricio / png-to-base64.ps1
Last active March 30, 2024 15:44
🖼 Convert an image to a Base64 string with PowerShell
<#
OBS:
The AsByteStream parameter was introduced in Windows PowerShell 6.0
If your PowerShell version (run `(Get-Host).Version` to find out) is lower than 6 then use the version for Powershell 5.1:
#>
$pathToImage = "/home/user/development/image.png"
# For Powershell 5.1
[String]$base64 = [convert]::ToBase64String((Get-Content $pathToImage -Raw -Encoding Byte))
@pferreirafabricio
pferreirafabricio / Request.cs
Last active March 18, 2024 08:46
A simple C# script for making HTTP Request on Unity
using System;
using System.Collections;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Networking;
namespace Project.Base
{
public static class Request
@pferreirafabricio
pferreirafabricio / row-count-size-tables.sql
Last active January 24, 2024 12:11
📊 Get row count and size for all tables in SQL Server
SELECT s.Name AS SchemaName,
t.NAME AS TableName,
p.rows AS RowCounts,
CAST(SUM(a.total_pages) * 8 / 1024.0 AS DECIMAL(10, 2)) AS TotalSpaceMB
FROM sys.tables t
INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN sys.allocation_units a ON p.partition_id = a.container_id
LEFT OUTER JOIN sys.schemas s ON t.schema_id = s.schema_id
WHERE t.TYPE = 'U'
@pferreirafabricio
pferreirafabricio / laravel-simplier-script.php
Created December 27, 2023 00:36
🐘 A simple start script to build a standalone app using Laravel features
<?php
require __DIR__ . './vendor/autoload.php';
$app = require_once __DIR__ . './bootstrap/app.php';
$kernel = $app->make(\Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = \Illuminate\Http\Request::capture()
);
@pferreirafabricio
pferreirafabricio / dotnet-watch-not-interactive.ps1
Created November 30, 2023 16:24
🔥 How to make .NET stop asking if you want to reload when you made a change
$env:DOTNET_WATCH_RESTART_ON_RUDE_EDIT = 1
# Or
dotnet watch run --non-interactive
@pferreirafabricio
pferreirafabricio / binding-slots.vue
Created November 20, 2023 18:28
Example of how to bind slots in Vue 2
<template>
<template v-for="(_, slotName) in $slots" v-slot:[slotName]="scope">
<slot :name="slotName" v-bind="scope" />
</template>
</template>
@pferreirafabricio
pferreirafabricio / UnitTestHangFireNSubstitute.cs
Created September 21, 2023 19:25
🧪 How to unit test if a Hangfire Job was enqueued with NSubstitute
var _backgroundJobClient = Substitute.For<IBackgroundJobClient>();
await _someService.MethodThatEnqueueSomething("idXXX");
_backgroundJobClient.Received()
.Create(
Arg.Is<Job>(
job => job.Type == typeof(MyJobClass)
&& job.Args[0].ToString() == "idXXX"
),