Skip to content

Instantly share code, notes, and snippets.

View ggrumbley's full-sized avatar

Gary Grumbley ggrumbley

View GitHub Profile
@ggrumbley
ggrumbley / frame.tsx
Created May 4, 2023 15:47 — forked from gunn/frame.tsx
Render react content in an iframe
import * as React from 'react'
import { createPortal } from 'react-dom'
type FrameProps = React.IframeHTMLAttributes<HTMLIFrameElement> & {
head?: React.ComponentType<any>
children?: React.ReactNode
}
const Frame = React.memo(({head, children, ...iframeProps}: FrameProps)=> {
const node = React.useRef<HTMLIFrameElement>()
const [doc, setDoc] = React.useState<Document>()
@ggrumbley
ggrumbley / regex_html_tag.md
Created March 29, 2023 22:34 — forked from gavin-asay/regex_html_tag.md
Regex and You: Matching an HTML Tag

Regex and You: Matching an HTML Tag

Regular expressions, ever versatile, will help up locate HTML tags in a string today.

Summary

Pattern matching HTML strings serves at least one crucial function in web dev: sanitizing user input. Allowing user-submitted strings opens one's application to significant vulnerability. Supposing, for example, some ne'er-do-well on the internet submitted a comment that includes <script src="[path]/stealYourData.js"></script>. Regular expressions allow us to match HTML tags in a string, because HTML tags conform to a certain pattern:

  • begin and end with brackets (<>)
  • contain a string name consisting of one or more lowercase letters, like p, a, div, strong, script
@ggrumbley
ggrumbley / steamos_setup.sh
Created March 14, 2023 22:57
SteamOS Env Setup Script
#!/usr/bin/env bash
# Exist if any command returns with non-zero exit status fail.
set -e
# Get current dir (so run this script from anywhere)
export DOTFILES_DIR
DOTFILES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Update dotfiles..."
@ggrumbley
ggrumbley / 55-bytes-of-css.md
Created September 26, 2022 15:57 — forked from JoeyBurzynski/55-bytes-of-css.md
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@ggrumbley
ggrumbley / Classy.md
Last active October 4, 2022 19:58
Classy_Scratch

Classy Scratch Notes

Log MobX Store in Brick

console.log(block, '🧱') // eslint-disable-line no-console
console.log(campaignTemplate, '💅') // eslint-disable-line no-console

console.log(JSON.parse(JSON.stringify(block)), '🧱') // eslint-disable-line no-console
console.log(JSON.parse(JSON.stringify(campaignTemplate)), '💅') // eslint-disable-line no-console
@ggrumbley
ggrumbley / pi.js
Last active March 18, 2021 00:05
// Define a method that rounds pi to a specified decimal place
// Return Pi and how many iterations of the following formula that it took to accomplish
// pi = 4 * (1 – 1/3 + 1/5 – 1/7 + ...)
const calcPi = (scale = 2) => {
const piTarget = Number(Math.PI).toFixed(scale);
let piAnswer;
let accum;
Specification Keyword RGB hex value
CSS Level 1 black #000000
CSS Level 1 silver #c0c0c0
CSS Level 1 gray #808080
CSS Level 1 white #ffffff
CSS Level 1 maroon #800000
CSS Level 1 red #ff0000
CSS Level 1 purple #800080
CSS Level 1 fuchsia #ff00ff
CSS Level 1 green #008000
@ggrumbley
ggrumbley / learn.lua
Created April 18, 2020 05:00 — forked from tylerneylon/learn.lua
Learn Lua quickly with this short yet comprehensive and friendly script. It's written as both an introduction and a quick reference. It's also a valid Lua script so you can verify that the code does what it says, and learn more by modifying and running this script in your Lua interpreter.
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
@ggrumbley
ggrumbley / G_fish_prompt.fish
Last active January 2, 2019 21:47
My Tweaked Sorin Prompt
# Options
set __fish_git_prompt_show_informative_status
set __fish_git_prompt_showcolorhints
set __fish_git_prompt_showupstream 'informative'
# Colors
set green (set_color green)
set magenta (set_color magenta)
set normal (set_color normal)
set red (set_color red)