Skip to content

Instantly share code, notes, and snippets.

@kjbrum
kjbrum / base.js
Created May 19, 2022 03:41
Basic styled-system/styled-components setup.
import React, { forwardRef } from 'react'
import styled from 'styled-components'
import css, { get } from '@styled-system/css'
import {
system,
compose,
space,
color,
typography,
layout,
@kjbrum
kjbrum / groupBy.js
Created April 13, 2021 21:48
Group an array of object by a specified key
/**
* Group an array of object by a specified key
* @param {array} items Array of objects
* @param {string} key Key to use for grouping
* @returns {object}
*/
const groupBy = (items, key) => {
return items.reduce(
(result, item) => ({
...result,
@kjbrum
kjbrum / README.md
Last active April 27, 2020 16:30
Scripts for removing popups
// Credit: https://gist.github.com/yangshun/9892961
const video = {
parse: function(url) {
// - Supported YouTube URL formats:
// - http://www.youtube.com/watch?v=My2FRPA3Gf8
// - http://youtu.be/My2FRPA3Gf8
// - https://youtube.googleapis.com/v/My2FRPA3Gf8
// - Supported Vimeo URL formats:
// - http://vimeo.com/25451551
// - http://player.vimeo.com/video/25451551
@kjbrum
kjbrum / Sass Helpers
Last active October 23, 2021 11:38
Helper files for writing Sass.
# Sass Helpers
- Variables
- Functions
- Mixins
@kjbrum
kjbrum / Base.js
Last active April 19, 2023 22:51
React primitive components using styled-system (with styled-components).
import React, { forwardRef } from 'react'
import styled from 'styled-components'
import css, { get } from '@styled-system/css'
import {
system,
compose,
space,
color,
typography,
layout,
@kjbrum
kjbrum / dev-environment-setup.md
Last active July 9, 2019 21:56
Quick steps for getting your local dev environment up and running.

Dev Environment Setup

Be sure to follow these steps in order, or you might run into unexpected issues.

Xcode

# When asked about the command line tools, hit install.
xcode-select --install
@kjbrum
kjbrum / browserdetect.js
Last active November 17, 2020 23:10
Detect the current browser and version using the user agent.
/**
* browserdetect.js
* Detect the current browser and version using the user agent.
* Credit: https://stackoverflow.com/a/13480430/6272119
*/
var BrowserDetect = {
dataBrowser: [
{ string: navigator.userAgent, subString: "Edge", identity: "MS Edge" },
{ string: navigator.userAgent, subString: "MSIE", identity: "Explorer" },
{ string: navigator.userAgent, subString: "Trident", identity: "Explorer" },
@kjbrum
kjbrum / reinstall-mysql.md
Last active December 5, 2020 19:34
Completely remove MySQL and reinstall.
@kjbrum
kjbrum / r_strip_tags_array.php
Last active May 8, 2018 18:48
Strip tags from an array
<?php
/**
* Strip tags from an array.
*
* @param array $arr The array to remove tags from
* @return array The new array without tags
*/
function r_strip_tags_array( $arr ) {
if( ! is_array( $arr ) ) return $arr;