Skip to content

Instantly share code, notes, and snippets.

View Dissolutio's full-sized avatar

John Dissolutio

  • Austin, TX
View GitHub Profile
@Dissolutio
Dissolutio / readVirtualscapeMapFile.js
Last active April 25, 2025 22:39
JavaScript function reads a specific binary file format used by VirtualScape (a map editor for Heroscape). This is a Virtualscape file (.hsc) decoder.
/*
This function reads a specific binary file format used by VirtualScape.
VirtualScape map editor: https://github.com/didiers/virtualscape
*/
export default function readVirtualscapeMapFile(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader()
reader.onloadend = () => {
const arrayBuffer = reader.result
const virtualscapeMap = processVirtualscapeArrayBuffer(arrayBuffer)
@Dissolutio
Dissolutio / WebWorkerExampleReactVite.tsx
Last active November 17, 2024 18:36
Example of a React component in a Vite app that uses a WebWorker in a useEffect (example worker file included) (SUPER SIMPLE, NO LIBRARIES!)
import React from 'react'
type WorkerArgs = {
some: string
}
/* myCoolWorker.js
// because we specify {type: 'module} in worker options, we can import from our project!
import { coolFn } from './someDir/coolFn'
self.onmessage = (event) => {
@Dissolutio
Dissolutio / gist:f1de21e4fe480df4c85e8635db38aee4
Created November 5, 2024 17:20
PubSub with event context in React: Fire functions in one element tree from another element tree (handy with React3Fiber)
# Pub/Sub in React Context
While React Context is a great way to share data between components, it doesn't inherently implement the Pub/Sub pattern. However, you can combine the two to create a Pub/Sub system within your React application.
Here's a simple implementation:
```js
import React, { createContext, useContext, useState, useEffect } from 'react';
const EventContext = createContext();
@Dissolutio
Dissolutio / AnimatedRadialGradient.js
Created February 21, 2024 04:54
The expo react-native Glow Card (laser color going around outside)
import React from "react";
import { Animated, Easing } from "react-native";
import Svg, { Defs, RadialGradient, Stop, Ellipse } from "react-native-svg";
const HUE_SPEED = 1;
const ANIMATION_DURATION = 4000;
// This wrapper component holds and animates the values for hue and position
export const AnimatedRadialGradient = () => {
const hueValue = React.useRef(new Animated.Value(0)).current;