Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Nate Lewis NateJLewis

🎯
Focusing
View GitHub Profile
View component-controller-generator.js
let root = 'src';
let resolveToComponents = ( glob = '' ) => {
return $.path.join( root, 'components', glob ); // app/components/{glob}
};
gulp.task( 'component', () => {
const cap = ( val ) => {
return val.charAt( 0 ).toUpperCase() + val.slice( 1 );
};
const name = $.yargs.argv.name;
const parentPath = $.yargs.argv.parent || '';
@NateJLewis
NateJLewis / mdChipDraggable.js
Created Feb 24, 2017 — forked from h0merjam/mdChipDraggable.js
Angular Material draggable chips directive
View mdChipDraggable.js
angular.module('mdChipDraggable', [])
.directive('mdChipDraggable', function () {
return {
restrict: 'A',
scope: {},
bindToController: true,
controllerAs: 'vm',
controller: ['$document', '$scope', '$element', '$timeout',
function ($document, $scope, $element, $timeout) {
var vm = this;
View material-icon-sizes.scss
.material-icons {
&.md-18 {
height: 18px;
width: 18px;
font-size: 18px;
min-height: 18px;
min-width: 18px;
}
&.md-24 {
@NateJLewis
NateJLewis / higherOrder.js
Last active Aug 22, 2016
Playing with higher-order functions.
View higherOrder.js
function makeConcatenater ( left ) {
return function ( right ) {
return left + ' ' + right;
}
}
var addString = makeConcatenater ( 'Hello' );
addString( 'World' );
///////////////////////////////
function makeAdder ( left ) {
@NateJLewis
NateJLewis / states_hash.json
Created Aug 16, 2016 — forked from mshafrir/states_hash.json
US states in JSON form
View states_hash.json
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@NateJLewis
NateJLewis / post_email_notifications.php
Last active Jul 25, 2016
Send email notifications via wp_mail when a post is submitted (pending review) then notify the post author that the post has been published.
View post_email_notifications.php
<?php
function _pit_pending_post_status( $new_status, $old_status, $post ) {
$post_author_id = $post->post_author;
$post_author = get_the_author_meta( 'display_name', $post_author_id );
$post_date = $post->post_date;
$post_title = $post->post_title;
if ( $new_status === 'pending' && $old_status !== 'pending' ) {
$headers[] = 'Content-Type: text/html; charset=UTF-8';
View repeater_with_nested_flexible_content.php
<?php
// CHECK IF REPEATER EXISTS
if( have_rows('repeater_field_name') ):
// REPEATER LOOP
while ( have_rows('repeater_field_name') ) : the_row();
// ANY SUBFIELDS NOT IN THE FLEXIBLE CONTENT (IE THE HEADING)
View example_acf.php
<section id="home-sub-hero" class="container-fluid">
<article class="row center-xs around-xs">
<div class="col-xs-12 col-md-8"><?php
if( get_field( 'subhero_heading', $post_id ) ) :
?><h3 class="subhero_heading"><?php
_e( the_field( 'subhero_heading', $post_id ), '_tvk' );
?></h3><?php
endif;
if( get_field( 'subhero_content', $post_id ) ) :
?><div class="subhero_content"><?php
@NateJLewis
NateJLewis / extras.php
Created Jul 14, 2016
Months of the year, Next year, Countries, US States functions for WordPress includes
View extras.php
<?php
function _pit_month_names() {
for ( $m=1; $m<=12; $m++ ) {
$months[] = array(
'month_display_name' => date( 'F', mktime( 0,0,0, $m, 1, date('Y') ) ),
'month_attr_name' => date( 'M', mktime( 0,0,0, $m, 1, date('Y') ) ),
);
}
return $months;
View vs-style.css
/*
Welcome to Custom CSS!
CSS (Cascading Style Sheets) is a kind of code that tells the browser how
to render a web page. You may delete these comments and get started with
your customizations.
By default, your stylesheet will be loaded after the theme stylesheets,
which means that your rules can take precedence and override the theme CSS
rules. Just write here what you want to change, you don't need to copy all