Skip to content

Instantly share code, notes, and snippets.

View joelstransky's full-sized avatar

Joel Stransky joelstransky

View GitHub Profile
@joelstransky
joelstransky / _container.scss
Last active February 14, 2024 21:31
SASS mixin for nested children in contained elements
@use "sass:string";
@use "sass:list";
/**
* Use @container just like media-query
* A mixin to ensure contained grand-children are properly selected within their container
* without having to select all the way down from the contained element.
* $child:string - The valid selector you want inserted
* $index:number - The number of shifts to make in the parent selector
* $asSibling:bool - Use sibling combinator after the shift?
@joelstransky
joelstransky / custom-file-size-units.js
Last active March 28, 2024 16:19
Custom Intl.NumberFormat units
sizeFormatter = new Intl.NumberFormat([], {
style: "unit",
unit: "byte",
notation: "compact",
unitDisplay: "narrow",
});
(_bytes) => {
const units = { B: " bytes", KB: " kb", MB: " mb", GB: " gb", TB: " tb" };
const parts = sizeFormatter.formatToParts(_bytes);
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 5.
Campaign Promise,Kept,Good for America
Build a Wall,No. There are 7 out of 2000 miles complete. All other construction is repair work budgeted before he took office.,No. The border backlog is unimproved and will never be improved with 4th century technology.
Get Mexico to pay for it.,No. He diverted 2.5 billion in military construction projects. A lot of those were housing and schools for military families.,No. The military extends far beyond guns and ammo and he doesn’t understand troop morale at all.
Temporarily ban muslims,No. 3 versions have all been held up in court citing the same lack of planning.,No. All Muslims are no more Bin Laden than all Christians are Jim Jones. Extreme idiocy is scary no matter what rock you crawl from under.
Bring Manufacturing Back,Sorta. He’s attempting brute force through tariffs and easing restrictions which causes foreign countries to open factories here but with no real trade agreements our GDP stands to suffer. At least he’s doing something.,"Should be. Making it diffic
using System;
using System.Text.RegularExpressions;
namespace BreakEvenCalculator
{
// Parses strings into American Odds and converts to other formats.
public class AmericanOdds
{
private const string rx_string = @"^([\+-])(\d\d\d+)$";
{
"compilerOptions": {
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es2016" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "ESNext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"lib": [
"dom",
"es2016"
] /* Specify library files to be included in the compilation. */,
@joelstransky
joelstransky / wordpress-affix-title-admin.css
Created April 17, 2018 21:42
affix the title input in the wordpress admin
// affix the title input in the wordpress admin
#titlediv {
position: fixed;
width: calc( 100% - 180px);
z-index: 1010;
top: 32px;
background: white;
padding: 10px;
margin-left: -20px;
border: 1px solid black;
@joelstransky
joelstransky / .bash_profile
Created December 6, 2017 17:59
Add git branch to front of cli prompt.
PS1='`__git_ps1 "[%s] "`\u:\[$(tput sgr0)\]\[\033[38;5;45m\]\W\[$(tput sgr0)\]\[\033[38;5;15m\]\\$\[$(tput sgr0)\] '
if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
. `brew --prefix`/etc/bash_completion.d/git-completion.bash
fi
if [ -f `brew --prefix`/etc/bash_completion.d/git-prompt.sh ]; then
. `brew --prefix`/etc/bash_completion.d/git-prompt.sh
fi
@joelstransky
joelstransky / functions::custom_field_render.php
Created December 1, 2017 17:19
Alter Advanced Custom Field rendering in admin
<?php
/*
* This snippet is from a project where I used an ACF Options gallery field to collect a set of icons.
* This fields data was then used to replace a radio field's options with the actual icons.
*/
class Special_Excerpt_Icon {
function __construct() {
// filter load_field on all 'radio' fields
add_filter('acf/load_field/type=radio', array($this, 'on_acf_load_radio_field' ) );
}
@joelstransky
joelstransky / functions::taxonomies.php
Created August 22, 2017 21:18
A working sort for taxonomy terms + numeric meta data
<?php
register_taxonomy( 'uh_service_type_taxonomy', array( 'contact_cpt' ), $args );
// add and 'Order' column to Service Type taxonomy terms
add_filter("manage_edit-uh_service_type_taxonomy_columns", "on_manage_edit_uh_service_type_taxonomy_columns");
function on_manage_edit_uh_service_type_taxonomy_columns( $columns ) {
$columns['term_order'] = __('Order');
return $columns;
}
@joelstransky
joelstransky / functions::get_connected_terms.php
Created June 9, 2017 19:53
Wordpress: Create relationship between two taxonomy's using ACF
<?php
$all_tax_a_terms = get_terms( array( 'taxonomy' => 'taxonomy_a', 'hide_empty' => false) );
foreach ($all_tax_a_terms as $a_term) {
$b_terms_set_to_a_term = get_terms( array(
'taxonomy' => 'taxonomy_b',
'meta_key' => 'acf-key-for-taxonomy-b',
'meta_value' => $a_term->slug,
'hide_empty' => false )
);
}