Skip to content

Instantly share code, notes, and snippets.

View jakewtaylor's full-sized avatar

Jake Taylor jakewtaylor

View GitHub Profile
{
"name": "African Elephant",
"latinName": "Loxodonta Africana",
"facts": [
{
"key": "Class",
"value": "Mammal"
},
{
"key": "Countries Found",
<?php
$sql = "SELECT id, forename, surname
FROM character_information
WHERE project_name='$project_name'
AND username='$usernamevariable'";
$characters = $conn->query($sql);
while ($character = $characters->fetch_assoc()) {
@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.

@jakewtaylor
jakewtaylor / Extensions.md
Last active October 9, 2018 14:19
VS Code Settings
@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 / 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 / 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 / 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'
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;
const ordinal = n => {
const options = ['th', 'st', 'nd', 'rd'];
const v = n % 100;
return options[(v - 20) % 10]
|| options[v]
|| options[0];
};