Skip to content

Instantly share code, notes, and snippets.

@ryanzec
ryanzec / authentication-store.ts
Last active August 11, 2023 07:04
Basic SolidJS implementation of Auth0 as a store
import type { Navigator } from '@solidjs/router';
import { Auth0Client, createAuth0Client } from '@auth0/auth0-spa-js';
import jwtDecode, { InvalidTokenError, JwtPayload } from 'jwt-decode';
import { createRoot, createSignal } from 'solid-js';
import { applicationUtils, GlobalVariable } from '$/utils/application';
const domain = applicationUtils.getGlobalVariable(GlobalVariable.AUTH0_DOMAIN);
const clientId = applicationUtils.getGlobalVariable(GlobalVariable.AUTH0_CLIENT_ID);
@ryanzec
ryanzec / AIController.cs
Last active July 19, 2022 05:07
Unity Utility Based AI Setup
using System.Collections.Generic;
using UnityEngine;
namespace UGPXFramework {
public class AIController {
private DynamicBlackboard _blackboard = new DynamicBlackboard();
private List<IAIScan> _scans = new List<IAIScan>();
private List<IAIAction> _actions = new List<IAIAction>();
public AIController(GameObject gameObject) {
@ryanzec
ryanzec / patterns.js
Created March 6, 2019 23:54
random frontend patterns
// PATTERN
// avoid popup blocker when you need async code when opening new tab\
// NOTE: the downside to this approach it the the user will see a blank page until the async method finished but instead of opening
// NOTE: to a blank page, you could probably have a redirect page that has animation or something
//first have a method that does the async functionality and get passed in the new tab window
const doRedirect = async (newWindow) => {
try {
const redirectUrl = await api.getRedirectUrl();
@ryanzec
ryanzec / examples.cpp
Created May 29, 2018 01:00
c++ / sdl / etc examples
// @example scrolling example
case SDL_MOUSEMOTION:
{
bool mouseInUiNow = isInRect(sideUiBackground, event.motion.x, event.motion.y);
if (mouseInUiNow && !mouseInUi) {
mouseInUi = true;
} else if (!mouseInUiNow && mouseInUi) {
mouseInUi = false;
}
@ryanzec
ryanzec / .gitignore
Created September 11, 2017 21:37
Unity .gitignore file (Using Rider IDE)
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
# Exclude 3rd party libraries installed from the assets store
[Aa]ssets/Asset Store Resources/
# Some asset tools can't be moved so need to explicitly
@ryanzec
ryanzec / .editorconfig
Created August 23, 2014 21:50
My standard editor config file
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true