This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from langchain_core.output_parsers.transform import BaseTransformOutputParser | |
from langchain_core.exceptions import OutputParserException | |
from langchain_core.messages import BaseMessage | |
from langchain_core.runnables.utils import AddableDict | |
import xml.etree.ElementTree as ET | |
from typing import Union, Optional, Any, Iterator, AsyncIterator, Literal | |
from bs4 import BeautifulSoup | |
import logging | |
import re | |
import contextlib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from langchain_core.output_parsers.transform import BaseTransformOutputParser | |
from langchain_core.exceptions import OutputParserException | |
import xml.etree.ElementTree as ET | |
from typing import Union, Optional, Any | |
import re | |
from bs4 import BeautifulSoup | |
import logging | |
class RobustXMLOutputParser(BaseTransformOutputParser): | |
"""A more robust XML parser that handles malformed XML gracefully.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
N = 100000 # Set this to the number of simulated rolls to aggregate | |
def d20(): | |
return random.randint(1, 21) | |
def count_20s(lst): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
namespace Streamweaver.Util | |
{ | |
public static class StaticUtils | |
{ | |
public static Vector3 GetRandomDir2D() | |
{ | |
return new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), 0).normalized; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Got this from Jason Weimann's videos. I like the pattern much better. | |
// from https://unity3d.college/2017/05/26/unity3d-design-patterns-state-basic-state-machine/ | |
public class Entity: Monobehavior | |
{ | |
private ActionState _currentState; | |
private void Update() { | |
_currentState.Tick(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
// Got this online and want to reuse for simple singletons. | |
namespace Streamweaver.Util | |
{ | |
// Class taken from The Secret Labs Unity Cookbook repo | |
public class Singleton<T> : MonoBehaviour where T : MonoBehaviour | |
{ | |
public static T instance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Boundary : MonoBehaviour | |
{ | |
Camera cam; | |
public float width, height; | |
// Start is called before the first frame update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
// Simple camera shake. To call just attach to camera and from whever you want to | |
// call it, do something like 'StartCoroutine(_cameraShake.Shake(0.15f, 0.075f));' | |
public class CameraShake : MonoBehaviour | |
{ | |
public IEnumerator Shake(float duration, float magnitude) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
// Example of implementing a Spawn Manager with ObjectPool.cs from | |
// https://gist.github.com/Streamweaver/b9164c538e277b9ecf85e71d84e59162 | |
public class SpawnManager : MonoBehaviour | |
{ | |
[System.Serializable] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections.Generic; | |
// Original adopted from Quill18's SimplePool Example. Storing here as an example. | |
// Example of using with a spawn manager in Gist | |
// https://gist.github.com/Streamweaver/1567f1c5c450d3ec2deb0efedce31ddf | |
// See below for a pooled particle system extension of this. | |
public static class ObjectPool | |
{ |
NewerOlder