Skip to content

Instantly share code, notes, and snippets.

@chancesmith
chancesmith / json-object-array-foreach-loop.php
Last active December 11, 2022 15:54
Foreach loop through JSON object array
<?php
$json = '[
{
"categories": "10,11",
"title": "Promos",
"columns": "col-md-3"
},
{
"categories": "10,12",
@chancesmith
chancesmith / readme.md
Last active November 24, 2021 11:47
Wordpress Setup shell script

Setup Instructions

  • add wp-setup.sh to your home directory
  • in terminal $ chmod +x wp-setup.sh so we can execute this without admin permissions needed
  • add an alias in your terminal profile and source the profile...(see command in next step)
  • $ echo '\n\n alias wpsetup="~/wp-setup.sh"' >> ~/.zshrc && . ~/.zshrc

Usage

Now, when you are ready run $ wpsetup in the folder you want to setup Wordpress locally in.

@chancesmith
chancesmith / charts.ts
Created July 23, 2021 02:29
chart types
type StatType = {}
type BarType = {
label: string;
value: number;
};
type DetailType = {
key: string;
value: number;
@chancesmith
chancesmith / notification-bar-set-cookie.html
Created November 7, 2016 20:11
Bootstrap alert top notification bar + cookie set after closed
@chancesmith
chancesmith / SelectField.tsx
Created February 28, 2020 11:48 — forked from hubgit/SelectField.tsx
Use react-select with Formik
import {FieldProps} from 'formik';
import React from 'react';
import Select, {OptionsType, ValueType} from 'react-select';
interface Option {
label: string;
value: string;
}
interface CustomSelectProps extends FieldProps {
@chancesmith
chancesmith / index.html
Created August 20, 2018 15:42
simple css spinner
<div class="spinner"></div>
@chancesmith
chancesmith / readme.md
Last active March 21, 2018 19:07
Setup Mac Computer Guide for Website Developement
@chancesmith
chancesmith / .zshrc
Last active February 13, 2018 20:56
ZSH profile
plugins=(git sublime cloudapp node npm osx extract z)
# User configuration
# Remap alt-left and alt-right to forward/backward word skips.
# via @waltz, https://gist.github.com/waltz/8658549
bindkey "^[^[[D" backward-word
bindkey "^[^[[C" forward-word
# export MANPATH="/usr/local/man:$MANPATH"
@chancesmith
chancesmith / wp_functions.php
Created March 31, 2016 15:50
Wordpress Functions (background image, Appearance/Menus, dashboard link for tutorial videos, ifMobile function)
<?php
// functions.php file
// anchor all forms on site on submission (Gravity Forms)
add_filter( 'gform_confirmation_anchor', '__return_true' );
//if mobile function
function isMobile() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
@chancesmith
chancesmith / lazy-load-images.js
Created November 8, 2017 16:55
Lazy load images
// #1 using the spread operator get all our images with the class 'lazyload'
const imgElements = [...document.querySelectorAll('.adg-lazy-image')]
// IE browser support :(
var isIE;
(function() {
var ua = window.navigator.userAgent,
msie = ua.indexOf('MSIE '),
trident = ua.indexOf('Trident/')