Skip to content

Instantly share code, notes, and snippets.

View icavalheiro's full-sized avatar
😅

Ivan Schuaste Cavalheiro icavalheiro

😅
View GitHub Profile
@icavalheiro
icavalheiro / donut.cs
Created June 4, 2024 21:27
the donut.c formatted and converted to C# for learning
using System.Text;
float sin(float x)
{
return MathF.Sin(x);
}
float cos(float x)
{
return MathF.Cos(x);
@icavalheiro
icavalheiro / Program.cs
Created May 22, 2024 15:38
convert images in a folder to png (support most img formats)
using SixLabors.ImageSharp;
using System.Threading.Tasks;
var imagesPath = @"/path/to/images/";
var images = Directory.GetFiles(imagesPath);
Parallel.ForEach(images, imagePath => {
using var image = Image.Load(File.OpenRead(imagePath));
image.SaveAsPng(imagePath + ".png");
@icavalheiro
icavalheiro / convert.js
Created May 22, 2024 15:23
Convert iphone's HEIC files in a folder into JPEGs (its slow)
const fs = require('fs').promises
const path = require('path')
const convert = require('heic-convert')
async function getFiles(folder){
const filesFound = await fs.readdir(folder)
const files = []
filesFound.forEach(file => {
files.push(path.join(folder, file))
curl --user-agent "Googlebot/2.1 (+http://www.google.com/bot.html)" -v $@
@icavalheiro
icavalheiro / Program.cs
Created December 22, 2021 16:00 — forked from DanielSWolf/Program.cs
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Threading;
static class Program {
static void Main() {
Console.Write("Performing some task... ");
using (var progress = new ProgressBar()) {
for (int i = 0; i <= 100; i++) {
progress.Report((double) i / 100);
@icavalheiro
icavalheiro / update_all.alias.bashrc
Created October 28, 2021 16:39
Updates all apps repos in ubuntu based distros
alias update_all="sudo apt update && sudo apt upgrade -y && sudo snap refresh && sudo flatpak update"
@icavalheiro
icavalheiro / install_mtga.sh
Created September 14, 2021 03:54
example command on how to install MTGA (or run any windows app actually) using proton that was installed by steam
#!bash
STEAM_COMPAT_CLIENT_INSTALL_PATH=$HOME/.proton STEAM_COMPAT_DATA_PATH=$HOME/.proton "/home/ivan/.steam/steam/steamapps/common/Proton 6.3/proton" run '/home/ivan/Downloads/MTGAInstaller.exe'
@icavalheiro
icavalheiro / event-hub.ts
Last active August 27, 2021 23:05
React Event Hub (useEvent)
import { useEffect } from 'react';
class EventHub
{
private listeners: {};
constructor ()
{
this.listeners = {};
}
@icavalheiro
icavalheiro / MSSQL-docker-compose.yml
Created December 5, 2020 03:40
docker-compose for a mssql database using express pid
version: '3'
services:
mssql:
image: mcr.microsoft.com/mssql/server:2019-CU8-ubuntu-16.04
container_name: "MS_SQL"
ports:
- "1433:1433"
volumes:
- ./db:/var/opt/mssql
environment:
@icavalheiro
icavalheiro / web.config
Created September 17, 2020 17:28
Web.config for static file serving with IIS
<?xml version="1.0"?>
<!-- This is a web.config for static file serving in a windows ISS web server
Created by Ivan S Cavalheiro [[email protected]] -->
<configuration>
<system.webServer>
<!-- custom error pages -->
<httpErrors errorMode="Custom">
<remove statusCode="500" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.html" responseMode="ExecuteURL" />