Skip to content

Instantly share code, notes, and snippets.

View rynbyjn's full-sized avatar
🤘
metal

Ryan Boyajian rynbyjn

🤘
metal
  • Denver, CO
View GitHub Profile
@rynbyjn
rynbyjn / Atom.tsx
Created December 1, 2023 23:50
Atom CSS animation React component
import { keyframes } from '@emotion/react'
import styled from '../../constants/theme'
interface AtomProps {
size: number
}
const Atom: React.FC<Partial<AtomProps>> = ({ size = 50 }) => {
return (
@rynbyjn
rynbyjn / blobs.css
Last active October 20, 2021 22:53
Blobs
* {
box-sizing: border-box;
}
body {
background: #fff;
}
.container {
align-items: center;
@rynbyjn
rynbyjn / veracode_playground.json
Last active July 28, 2021 22:49
playground for stuff
{
"MRData": {
"xmlns": "http:\/\/ergast.com\/mrd\/1.4",
"series": "f1",
"url": "http://ergast.com/api/f1/2018/circuits.json",
"limit": "30",
"offset": "0",
"total": "21",
"CircuitTable": {
"season": "2018",
@rynbyjn
rynbyjn / bump_version.js
Created November 20, 2020 23:37
Node script for bumping the major version for a React Native iOS app
require('dotenv').config({ path: './.env' })
const { execSync } = require('child_process')
const fs = require('fs')
const readline = require('readline')
// this should always be relative to this file
const packageFile = require('../package.json')
// get args passed to node
const args = process.argv
// passing the `--cleanup` arg will bail from creating the pull request and
@rynbyjn
rynbyjn / stats.ts
Last active December 19, 2019 22:40
A FPS monitor that tracks averages over last one and five minutes based on [stats.js](https://github.com/mrdoob/stats.js)
// Based on [stats.js](https://github.com/mrdoob/stats.js)
// frames per second (higher is better)
export let fps = 0
// ms to render one frame (lower is better)
export let mspf = 0
// average fps over last minute
export let fpsAvg1Min: number | undefined
// average fps over last 5 minutes
@rynbyjn
rynbyjn / nonJPActors.ts
Last active October 24, 2019 20:15
Code exercise with jurassic park actor filtering
// Data Sets:
// There are two data sets below: An object of humans with names as keys,
// and an array of Jurassic Park films.
// Goal: Create an array of objects that contain ONLY the humans who are
// NOT cast in any jurassic park films. The array of objects should have
// this structure:
// [
// {
@rynbyjn
rynbyjn / favicon-notification.ts
Last active December 19, 2019 22:38
This snippet composites a notification red dot on top of an existing favicon with a transparent border
import debounce from 'lodash.debounce'
export const handleFavNotification = debounce((showDot: boolean) => {
const canvas = document.createElement('canvas')
canvas.width = 32
canvas.height = 32
const ctx = canvas.getContext('2d')
const favicon: HTMLLinkElement | null = document.querySelector(
'link[rel="icon"]',
)
@rynbyjn
rynbyjn / px2rem.ts
Created June 14, 2019 16:03
A stylis.js plugin to convert pixel values to rem values
// Based on the [postcss-pxtorem plugin](https://github.com/cuth/postcss-pxtorem)
const minPixelValue = 4
export const ROOT_VALUE = 16
const unitPrecision = 5
// See https://github.com/cuth/postcss-pxtorem/blob/master/lib/pixel-unit-regex.js
const pxRegExp = /"[^"]+"|'[^']+'|url\([^)]+\)|(\d*\.?\d+)px/gi
// Not an exhaustive list but should cover most use cases:
@rynbyjn
rynbyjn / color.ts
Created March 29, 2019 15:59
Some helper functions for color manipulation and compliance in javascript
export const fullHex = (hex: string): string => {
let h: string = hex.replace(/[^a-f\d]/gi, '')
if (h.length < 6) {
h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2]
}
return h
}
export const updateHexLuminance = (hex: string, lum: number = 0): string => {
const h: string = fullHex(hex)
@rynbyjn
rynbyjn / hooks.md
Last active November 28, 2018 20:10
L&L on React 16.7.0 hooks

React 16.7.0 hooks

  • Currently in alpha.2, but scheduled for release ~Q1 2019 React roadmap
  • Opt in (100% backwards compatible)

3 things that suck in React

  1. Reusing logic (wrapper hell) think HOCs & render prop functions
  2. Reduce “giant” components (too much boiler plate logic split across lifecycle methods)