Skip to content

Instantly share code, notes, and snippets.

View AlanGreyjoy's full-sized avatar
🐢
I like turtles

Alan Spurlock AlanGreyjoy

🐢
I like turtles
View GitHub Profile
@AlanGreyjoy
AlanGreyjoy / gist:384fe1af7341825e91b1b74a03f330f2
Created December 22, 2024 16:51
Paper trading price simulator
import { usePrices } from "../hooks/usePrices"; //Implement your own service for fetching realtime stock prices or mock data.
interface SimulatedPrice {
price: number;
timestamp: Date;
}
class PriceSimulator {
private simulatedPrices: Map<string, SimulatedPrice> = new Map();
private volatility = 0.002; // 0.2% base volatility
import React from 'react'
import { Alert, Box, Typography } from '@mui/joy'
import Icon from 'src/_core/components/icon'
/**
* FormAlerts component
* @param {Object} props
* @param {Object} props.errors - Error object
* @param {string} [props.variant='soft'] - Alert variant
* @param {string} [props.color='danger'] - Alert color
@AlanGreyjoy
AlanGreyjoy / gist:5de6ab4ac533a6841bce0ff141707053
Created October 11, 2024 04:51
Node.js Link Preview Generator
/**
* @fileoverview Custom Link Preview Service using Puppeteer
* @description Generates link previews by rendering webpages with Puppeteer
* @reviewed Alan Spurlock - 2024-03-20
*/
const puppeteer = require('puppeteer')
const logger = require('../../utils/logger') //Where ever you might have your logger!
/**
@AlanGreyjoy
AlanGreyjoy / gist:2d937569aca4457957927cf888329df9
Created August 17, 2024 05:37
Dead Simple React Native Collapsible Card (RNUILIB & Iconify)
import { useState } from 'react'
import { Iconify } from 'react-native-iconify'
import { Card, Text, TouchableOpacity, View } from 'react-native-ui-lib'
export default function CollapsibleCard(props) {
const defaultExpanded = props.defaultExpanded || false
const title = props.title || 'Title'
const [expanded, setExpanded] = useState(defaultExpanded)
@AlanGreyjoy
AlanGreyjoy / gist:3a870eef6a65a4c2b9a2cd959289376a
Created August 17, 2024 02:24
Dead simple React Native Expandable View (RNUILIB & ICONIFY)
import { useState } from 'react'
import { Iconify } from 'react-native-iconify'
import { Colors, Text, TouchableOpacity, View } from 'react-native-ui-lib'
export default function ExpandableView(props) {
const title = props.title || 'Expandable View'
const defaultExpanded = props.defaultExpanded || false
const divider = props.divider || false
const [expanded, setExpanded] = useState(defaultExpanded || false)