Skip to content

Instantly share code, notes, and snippets.

@jomurgel
jomurgel / keybase.md
Created February 5, 2024 17:37
keybase.md

Keybase proof

I hereby claim:

  • I am jomurgel on github.
  • I am jomurgel (https://keybase.io/jomurgel) on keybase.
  • I have a public key ASCK00IE4mmbugFZvLeA4rFivci2nfYPJlAsGB_gKWXCgQo

To claim this, I am signing this object:

@jomurgel
jomurgel / build.bash
Created February 5, 2022 20:26
Log Build Errors
npm run build 2>&1 > npm_error_log.txt
@jomurgel
jomurgel / git.bash
Created February 9, 2021 14:48
Create and apply patch from branch diff
# Compare the changes against main.
git diff main BRANCH_W_CHANGES_NAME > ./temp_patch
# Checkout to a new branch and apply the patch.
git checkout NEW_BRANCH_NAME && git apply ./temp_patch
@jomurgel
jomurgel / index.jsx
Last active January 7, 2021 16:20
useStateWithCallback Custom Hook — Fire callback function after state change.
import { useState, useEffect } from 'react';
/**
* Fire callback function after state change.
*
* @param {any} initialState intial state value.
* @param {function} callback callback after state change.
*/
const useStateWithCallback = (initialState, callback) => {
const [state, setState] = useState(initialState);
@jomurgel
jomurgel / css-units-best-practices.md
Created November 24, 2020 15:27 — forked from basham/css-units-best-practices.md
CSS Units Best Practices

CSS units

Recommendations of unit types per media type:

Media Recommended Occasional use Infrequent use Not recommended
Screen em, rem, % px ch, ex, vw, vh, vmin, vmax cm, mm, in, pt, pc
Print em, rem, % cm, mm, in, pt, pc ch, ex px, vw, vh, vmin, vmax

Relative units

Relative units

@jomurgel
jomurgel / rest.php
Created July 7, 2020 14:31
Add element to rest end point.
<?php
/**
* Adds category names field to faqs post type.
*/
function add_category_names_to_api() {
register_rest_field(
'post', // post type.
'category_names', // element.
[
'get_callback' => __NAMESPACE__ . '\return_category_names'
@jomurgel
jomurgel / helpers.php
Created June 19, 2020 16:48
Recursively search array for value.
<?php
/**
* Recursively check multidimentional array for value
*
* @param string|int $needle The searched value.
* @param array $haystack The array.
* @param boolean $strict If the third parameter strict is set to TRUE then the in_array() function will also check the types of the needle in the haystack.
*
* @return boolean haystack has needle.
*/
@jomurgel
jomurgel / bash.sh
Last active January 7, 2021 16:22
Split a Branch
git diff BRANCH_NAME > ../temp_patch
git checkout NEW_BRANCH_NAME && git apply ../temp_patch
@jomurgel
jomurgel / users.php
Created March 5, 2020 19:12
Add unfiltered_html capability to editors
<?php
/**
* Filter a user's capabilities. This is generally super iffy with security concerns.
*
* @see WP_User::has_cap().
*
* @param array $allcaps Associative array of capability names and whether the user has the cap.
* @param caps $caps The capabilities needed for the requested meta capability.
* @param array $args Parameters passed to has_cap().
* @param WP_User $user User object.
@jomurgel
jomurgel / states-abbv.js
Last active December 8, 2021 00:22
Gutenberg SelectControl U.S. States
import { __ } from '@wordpress/i18n';
/**
* List of US States.
* Raw Data Source: https://gist.github.com/tleen/6299431
*/
export default [
{
value: '',
label: __('Select a State', 'domain'),