Skip to content

Instantly share code, notes, and snippets.

View HugoVG's full-sized avatar
🐦
Borb

Hogo HugoVG

🐦
Borb
  • 22:58 (UTC +02:00)
View GitHub Profile
@HugoVG
HugoVG / ripple.shader
Created September 13, 2023 10:26 — forked from gkaizer1/ripple.shader
Unity example of ripple effect
Shader "Unlit/ripple_shader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_amount ("_amount", Range(0.01, 1.0)) = 0.5
_spread ("_spread", Range(0.01, 1.0)) = 0.5
_width ("_width", Range(0.01, 1.0)) = 0.5
_alpha ("_alpha", Range(0.01, 1.0)) = 0.5
@HugoVG
HugoVG / IJWTStore.cs
Created July 23, 2022 14:59
Json web tokens, JWT, for C# API,
public interface IJWTStore
{
Tokens Authenticate(LoginUser users); //This is a small Model of just Username Password you can make your own
string GetNameFromToken(string token);
}
@HugoVG
HugoVG / PictureHelperFunctions.cs
Created July 23, 2022 14:38
Saving a Picture as png to an server regardless of OS, png for better xamarin support, no system.drawing works on linux/windows,
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
public static class GenericHelperFunctions
{
public static bool RegChecks(string checkedto)
{
string pattern = @"^[a-zA-Z0-9_.-]*$"; // Letter and words only
Regex regex = new Regex(pattern);
DebugWrite(regex.IsMatch(checkedto));
// Compare a string against the regular expression
@HugoVG
HugoVG / Login.cshtml
Created July 23, 2022 14:23
Identity framework, logging in and registering with Username instead of email
//Replace Email
<div class="form-floating">
<input asp-for="Input.Email" class="form-control" autocomplete="username" aria-required="true" />
<label asp-for="Input.Email" class="form-label"></label>
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
//with everything under here
<div class="form-floating">
<input asp-for="Input.UserName" class="form-control" autocomplete="username" aria-required="true" />
<label asp-for="Input.UserName" class="form-label"></label>
@HugoVG
HugoVG / Program.cs
Created July 23, 2022 14:13
Seeding an identity database with a super user
CreateDatabase();
using (var scope = app.Services.CreateScope()) //Creates a new scope
{
//Resolve ASP .NET Core Identity with DI help
var roleManager = (RoleManager<IdentityRole>)scope.ServiceProvider.GetService<RoleManager<IdentityRole>>(); //gets services
var userManager = (UserManager<IdentityUser>)scope.ServiceProvider.GetService<UserManager<IdentityUser>>();
CreateRolesAsync(roleManager).Wait();
CreateSuperUser(userManager).Wait();
}
//important that this is called after these
@HugoVG
HugoVG / CommandFile.cs
Created May 15, 2022 14:43
Dsharpplus SlashCommands
//if you want to make a group command with like a /example function you have to make a slash group
[SlashCommandGroup("example", "for example purposes")]
public class exampleCommands : ApplicationCommandModule
{
//ONLY FOR BAKABOT DEV
public Configuration configuration { get; set; } //reference this for using configuration singleton
//
//Adding SlashCommands
[SlashCommand("function", "function you want to add")] //will activate on /example function
@HugoVG
HugoVG / CommandFile.cs
Created May 15, 2022 14:29
Popup Modal
// In here(the command file for the !help or /Dosomething ) you make the modal pop up
[SlashCommand("newModalPopup", "popsup a sample Modal")]
public async Task newModalPopup(InteractionContext ctx)
{
var response = new DiscordInteractionResponseBuilder();
response
.WithTitle("the title of the modal ")
.WithCustomId(ModalEvent.modalNames.{name you created in ModalEvent.cs line 5 }) //name you created in ModalEvent.cs line 5