Skip to content

Instantly share code, notes, and snippets.

View bestknighter's full-sized avatar

Gabriel Barbosa bestknighter

View GitHub Profile
@bestknighter
bestknighter / Nicify.cs
Created July 31, 2022 20:41
C# String Extensions
public static class StringExtensions {
/// <summary>
/// Transforms strings like variable and class names to nice UI-friendly strings, removing
/// underlines, hiphens, prefixes and the like
/// </summary>
/// <param name="str">The string to be nicified</param>
/// <param name="preserveAccronyms">If accronym letters should be kept together</param>
/// <returns>A nicified Title Cased version ready for UIs</returns>
public static string Nicify(this string str, bool preserveAccronyms = true) {
string trimmed = str;
@bestknighter
bestknighter / .editorconfig
Last active December 1, 2023 12:54
My default starting .editorconfig for Unity projects
root=true
[*]
guidelines = 80 2px solid 18FFFFFF, 100 2px dotted 2C1EFF00, 120 1px solid 1FFFFB00, 150 2px solid 30FF0000
[*.cs]
indent_size = 4
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
@bestknighter
bestknighter / code3diff
Created July 16, 2022 18:21
Hack/Workaround to get a 3 way diff in vscode
#!/usr/bin/env sh
if [ $# -ne 4 ]; then
echo "Usage: code3diff BASE REMOTE LOCAL MERGED"
exit -1
fi
BASE=$1
REMOTE=$2
LOCAL=$3
@bestknighter
bestknighter / Demo.cs
Last active June 11, 2022 04:44
Structure (with example) for a Model <-> Viewer inspired code architecture
using System;
public class Program
{
public static void Main()
{
var fc = new MyIntViewer_FancyConsole();
var sc = new MyIntViewer_SimpleConsole();
Console.WriteLine("Hello World");
@bestknighter
bestknighter / DebugNode.hlsl
Last active February 23, 2024 09:56 — forked from aras-p/DebugNode.hlsl
"Print a value" custom function node code for Unity ShaderGraph, aware of +Inf/-Inf and nan
// This gist can be found at https://gist.github.com/bestknighter/660e6a53cf6a6643618d8531f962be2c
// I modified Aras Pranckevičius's awesome shader code to be able to handle Infinite and Not A Number numbers
// Tested on Unity 2023.1.0a15 with ShaderGraph 15.0.1.
// Quick try at doing a "print value" node for Unity ShaderGraph.
//
// Use with CustomFunction node, with two inputs:
// - Vector1 Value, the value to display,
// - Vector2 UV, the UVs of area to display at.
@bestknighter
bestknighter / Joins.gs
Last active November 5, 2021 20:46
GSaaDB (Google Sheets as a Database)
/*************
*
* The following code snippet was written by https://github.com/bestknighter
* It's freely available at https://gist.github.com/bestknighter/ec075ee402176b886a3c51913ab8c08c.
* You can copy, change and even make money with it
* as long as credit is properly given.
*
* You can use these functions as inside the sheet itself,
* just like other functions such as with ADD() or COUNT().
*
@bestknighter
bestknighter / EstudoDirigidoX.c
Last active November 5, 2018 14:30
Código multiplataforma base para os Estudos Dirigidos de Programação Concorrente (UnB)
/****************************************************************************
* *
* Arquivo EstudoDirigidoX.c criado por Gabriel Barbosa (12/0050935) *
* DESCRICAO DO PROBLEMA *
* Codigo multiplataforma *
* Usar flags -std=c11 -lpthread para compilar para Windows *
* Usar flags -std=c11 -pthread para compilar para Linux *
* *
****************************************************************************/
@bestknighter
bestknighter / int_to_float.asm
Last active September 28, 2016 17:41
(MIPS) Macros for loading immediate integers into Coprocessor 1's floating point registers in MARS
.macro li.s (%f_reg, %value)
addi $sp, $sp, -4 # sp++
li $at, %value # at = %value
sw $at, ($sp) # push(at)
lwc1 %f_reg, ($sp) # %f_reg = pop()
addi $sp, $sp, 4 # sp--
cvt.s.w %f_reg,%f_reg # %f_reg = (float)%f_reg
.end_macro
.macro li.d (%f_reg, %value)