Skip to content

Instantly share code, notes, and snippets.

View jakewtaylor's full-sized avatar

Jake Taylor jakewtaylor

View GitHub Profile
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use App\Models\Patient;
use App\Models\Practice;
use App\Models\Lab;
class CreateLabOrderRequest extends FormRequest
const ordinal = n => {
const options = ['th', 'st', 'nd', 'rd'];
const v = n % 100;
return options[(v - 20) % 10]
|| options[v]
|| options[0];
};
@jakewtaylor
jakewtaylor / usage.jsx
Last active August 31, 2022 18:21
useStyles() React Hook
import React from 'react';
import { useStyles } from '../hooks/useStyles';
export const Sidebar = ({ colourful = false }) => {
const styles = useStyles(stylesheet);
return (
<div className={styles.sidebar}>
<p
className={styles.compose(
export const arrayEqual = (arr1, arr2) => {
// If either item is falsey we can short circuit and warn
if (!arr1 || !arr2) {
console.warn('arrayEqual(): One of the supplied arrays is falsey.');
return false;
}
// If they're equal we can short circuit
if (arr1 === arr2) return true;
@jakewtaylor
jakewtaylor / maybe.js
Last active January 10, 2019 09:15
Maybe function
const maybe = (item, fallback = null) => item ? item : new Proxy({}, {
get () {
return fallback;
}
});
// Usage:
const items = [{ id: 1, value: 'a' }, { id: 2, value: 'b' }];
maybe(items.find(itm => itm.id === 1)).value; // 'a'
@jakewtaylor
jakewtaylor / GoogleFontLoader.js
Last active November 28, 2018 23:19
GoogleFontLoader React Component.
import React from 'react';
class GoogleFontLoader extends React.PureComponent {
link = null;
createLink = () => {
const { fonts } = this.props;
const families = fonts.reduce((acc, font) => {
const family = font.font.replace(/ +/g, '+');
@jakewtaylor
jakewtaylor / problem.md
Last active November 19, 2018 16:47
help me pls

Folders

There is a table that contains data about a set of folders. Each folder can be a child of another. If folder_id is null, then it's a root level folder. If folder_id is a number, it is a child of the folder with that number.

id name folder_id
1 images null
2 css null
3 home 1
@jakewtaylor
jakewtaylor / Tooltip.js
Created November 13, 2018 14:10
useMouseCoordinates()
const Tooltip = (props) => {
const [x, y] = useMouseCoordinates();
return (
<p>Mouse is at x: {x}, y: {y}.</p>
);
}
@jakewtaylor
jakewtaylor / Extensions.md
Last active October 9, 2018 14:19
VS Code Settings
@jakewtaylor
jakewtaylor / 0_composer_readme.md
Last active November 6, 2017 12:08
Autoload example for Salem

Composer.json

You'll need to add the following to composer.json (some of it is already in there, you need to add the files key and contents.

The app/Support/helpers.php is just an example, and where I would typically put helper functions, but you can put them wherever you like. If you do change it, just change all occurences of app/Support/helpers.php to the path you chose.