Skip to content

Instantly share code, notes, and snippets.

View gabtoschi's full-sized avatar
💻
Learning

Gabriel Toschi gabtoschi

💻
Learning
View GitHub Profile
@gabtoschi
gabtoschi / FixPCGamePass.bat
Created April 9, 2023 01:22
A batch file to fix "No applicable app..." error on PC Game Pass
@echo off
title Fixing your PC Game Pass
powershell.exe -executionpolicy remotesigned -command "Get-AppXPackage | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register \"$($_.InstallLocation)\AppXManifest.xml\"}"
@gabtoschi
gabtoschi / dust.reference.md
Last active April 8, 2022 11:53
Dust.js reference sheet

Dust.js Reference Sheet

Dust.js is a JavaScript templating engine, barely maintained in the past years. Even the interactive tutorial in the official website is broken on Chromium browsers and has really strange behavior on Firefox. This reference sheet is a quick-to-look reference if you need to work in a project that still uses Dust.

Object / variable references

To reference a variable, use curly brackets.

<div>This is the value of a variable: {myVariable}.</div>
<div>You can use dot-notation to access object's attributes: {myObject.attribute}</div>
@gabtoschi
gabtoschi / reducedNumber.ts
Created May 10, 2021 12:20
Forma reduzida de números (3 mil, 42,3 mi, 321,9 bi) em português, feito em TypeScript
const reducedFormStringsByDivisionAmount = [
'', 'mil', 'mi', 'bi', 'tri', 'quatr', 'quint', 'sext', 'sept',
];
export function getNumberReducedForm(value: number): string {
const numberStr = value.toString();
// encontre a quantidade de classes numéricas que se tornarão não significativas
// 1350 = 1.350 => divisionAmount = 1
// 18352140 = 18.352140 => divisionAmount = 2
@gabtoschi
gabtoschi / functionPointer.c
Created November 28, 2020 00:51
Some function pointer examples in C
#include <stdlib.h>
#include <stdio.h>
void fullMessage(char *name, void (*greeting)(char *)) {
greeting(name);
printf("Good luck in your life!\n");
}
void hello(char *name) {
printf("Hello, %s! ", name);
@gabtoschi
gabtoschi / modRobot.c
Created November 28, 2020 00:50
Using modular arithmetic to move a robot in 4 directions
#include <stdlib.h>
#include <stdio.h>
#define TOTAL_POS 4
#define addMod(x, n) (x + 1) % n
#define subMod(x, n) (x - 1 + n) % n
int main(int argc, char const *argv[]){
@gabtoschi
gabtoschi / merge3.c
Created October 7, 2020 17:48
A snippet of a merge function to a 3-way merge sort in C. The idea was to optimize the code size and the amount of whiles and ifs.
typedef struct {
int *data;
int size;
int current;
} mergeArray;
#define COPY_MERGE_ARRAY(dest, source) dest.data[dest.current++] = source.data[source.current++]
int copyItemToFinalArray(mergeArray array, mergeArray final) {
COPY_MERGE_ARRAY(final, array);
@gabtoschi
gabtoschi / readString.c
Created September 20, 2020 22:40
C function to read a string to a heap array (I know that isn't the most optimized way to do this, but someone can make do with)
// stream: if you want to read from the standard input, use stdin
// delim: a delimiter to the function stop reading, you can use '\n' to a standard linebreak
char *readString(FILE *stream, char delim){
char *str = NULL;
int counter = 0;
char c;
do {
c = fgetc(stream);