Skip to content

Instantly share code, notes, and snippets.

View tomfordweb's full-sized avatar
🏠
Working from home

Tom Ford tomfordweb

🏠
Working from home
View GitHub Profile
@tomfordweb
tomfordweb / default.json
Created February 18, 2021 05:31
Pinky4
{"version":1,"notes":"","documentation":"\"This file is a QMK Configurator export. You can import this at <https://config.qmk.fm>. It can also be used directly with QMK's source code.\n\nTo setup your QMK environment check out the tutorial: <https://docs.qmk.fm/#/newbs>\n\nYou can convert this file to a keymap.c using this command: `qmk json2c {keymap}`\n\nYou can compile this keymap using this command: `qmk compile {keymap}`\"\n","keyboard":"pinky/4","keymap":"tom1","layout":"LAYOUT","layers":[["KC_GESC","KC_1","KC_2","KC_3","KC_4","KC_5","KC_6","KC_7","KC_8","KC_9","KC_0","KC_MINS","KC_EQL","KC_GRV","KC_TAB","KC_Q","KC_W","KC_E","KC_R","KC_T","KC_LBRC","KC_RBRC","KC_Y","KC_U","KC_I","KC_O","KC_P","KC_BSLS","KC_LCTL","KC_A","KC_S","KC_D","KC_F","KC_G","KC_HOME","KC_END","KC_H","KC_J","KC_K","KC_L","KC_SCLN","KC_QUOT","KC_LSFT","KC_Z","KC_X","KC_C","KC_V","KC_B","KC_BSPC","KC_SPC","KC_N","KC_M","KC_COMM","KC_DOT","KC_SLSH","KC_RSFT","KC_LALT","MO(1)","KC_LGUI","KC_DEL","KC_ENT","TT(1)","KC_NO","KC_NO"],["KC_N
@tomfordweb
tomfordweb / tri.scss
Last active May 4, 2019 12:57
SASS Triangle
@mixin triangle($direction, $size, $color) {
width: 0;
height: 0;
border: $size solid transparent;
border-#{$direction}: $size solid $color;
}
// div { @include triangle(left, 20px, #BADA55);
@tomfordweb
tomfordweb / index.js
Created April 16, 2019 12:41
JS Helpful Array Functions
// convert object of objects to array of objects
const arr = Object.keys(obj).map(i => obj[i])
@tomfordweb
tomfordweb / Cors.php
Created April 11, 2019 14:30
Laravel CORS Middlware: Allowing external CORS requests on your Laravel site.
<?php
namespace App\Http\Middleware;
use Closure;
class Cors
{
/**
* Handle an incoming request.
@tomfordweb
tomfordweb / eqHeight.js
Last active April 11, 2019 21:33
Equal height elements. I use it on resize and load events normally.
/**
* Set the height to that of the tallest element for all shared selectors
* selector string querySelectorAll
* responsive bool whether or not to reset height before calculating tallest
**/
function eqHeight(selector, responsive = true) {
var findClass = document.querySelectorAll(selector);
// if we don't find any of the elements...back out.
if (!findClass.length) return;
@tomfordweb
tomfordweb / columns.scss
Last active April 11, 2019 00:52
Creates some basic CSS
/**
* Creates the boilerplate CSS for flexbox columns.
* Apply to a container where its immediate descendants have a class name of
* "col-#" where # is the number of columns you would see in a row
* You can provide a map of width overrides where you specify screen width and your desired column count
* @param {string} $base_col_class The base column class: ex: cols-4 will create 4 25% width columns in your "row"
* @param {integer} $min: 1 The number to begin iteration at
* @param {integer} $max: 6 The number to end iteration at
* @param {map} $breakpoints () A map consisting of the width breakpoint for keys and the column count for value
* @param {string} $full_breakout_width The screen dimensions where columns will have their "default" characteristics
@tomfordweb
tomfordweb / fullwidth.scss
Created March 21, 2019 18:58
SASS Mixin: Full Width Pseudo Elements
// adapted from
// https://css-tricks.com/full-browser-width-bars/
@mixin full-width-pseudo($bg, $pos: relative) {
/* negative offset = section padding */
margin: 0 -30px;
/* add back section padding value */
padding: 0.25rem 30px;
position: 'absolute';
background: $bg;
@tomfordweb
tomfordweb / index.jsx
Created February 12, 2019 13:04
Bootstrap Dropdown
// in progress :)
/**
* Renders a boostrap dropdown that enables the user to select a "type" for a phone number
* @param {integer} options.id The ID of the phone number model
* @param {function} options.onClick What happens when you select a value
* @param {integer} options.value The value of an existing record (so we can pre-fill input) - uses the key defined in Phone model
*/
export const BoostrapDropdown = ({ id, onClick, value, items, defaultLabel}) => {
const label = (value)
@tomfordweb
tomfordweb / niceDate.js
Created December 4, 2018 00:18
ES6 Format timestamp to locale string
/**
* Returns a nice date, dude!
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
* @param {string} timestamp A timestamp waiting to be parsed
* @pram {object} options See the link provided above
* @param {String} locale locale string
* @return {string} A formatted timestamp
*/
export const niceDate = (timestamp, options = {}, locale = "en-US") => {
const mergedOptions = {
@tomfordweb
tomfordweb / LoadableImage.jsx
Created November 14, 2018 18:01
Hide Image until it has been loaded. Not a promise.
import React from 'react';
import PropTypes from 'prop-types';
const hiddenImageStyle = {
width: 0,
height: 0
};
class LoadableImage extends React.Component {
constructor(props) {