Skip to content

Instantly share code, notes, and snippets.

@wking-io
wking-io / functions.php
Last active September 18, 2019 17:24
Filter out posts from index page to show only one specific category
function customize_query ( $query ) {
// Make sure this is only effecting the public side
if ( ! is_admin() ) :
// Make sure this is a query for the post page and is the main query for the page
if ( is_home() && $query->is_main_query() ) :
// Set query to only pull posts from the specified category
$query->set( 'category_name', 'Newsletter' );
endif;
endif;
@wking-io
wking-io / SketchSystems.spec
Last active May 15, 2019 15:40
Role Menu Editor
Role Menu Editor
Loading Page
success -> Edit Role
permission failure -> Load Error
nonce failure -> Load Error
data failure -> Load Error
network failure -> Load Error
missing role failure -> Load Error
Edit Role
change role -> Loading Page
{-| This is the error I am getting:
-- NAMING ERROR ----------------- /Users/wking/sites/elm-pair/tests/PairSpec.elm
I cannot find a `Pair.from` variable:
17| Pair.from 0 randomMaybe
^^^^^^^^^
The `Pair` module does not expose a `from` variable. These names seem close
though:
@wking-io
wking-io / generateKeyframes.js
Last active December 12, 2018 04:12
Dynamic Keyframes - CSS-in-JS
// Main function w/helpers for readibility
const generateKeyframes = total => frames =>
Array
.from({ length: total })
.reduce((acc, _, i) =>
ifElse(
hasFrame(frames),
makeKeyframe(total, frames, acc),
always(acc)
)(i)
@wking-io
wking-io / elm-handler.js
Last active November 19, 2018 02:27
Elm Handler for React
import React from 'react'
import PropTypes from 'prop-types'
class ElmHandler extends React.Component {
node = React.createRef()
/**
* Setup the Elm app using the ref for this components node
* using the flags passed in as props. Connect the port handler
* function passed in from props to the ports established in the
// Set base multiplier for use with rem units
html { font-size: 4px }
// Set body back to default size
body { font-size: 4rem }
// Add spacing to elements without worrying if vertical rythm matches the scale
h1 { margin: 0 0 10rem 0 }
@wking-io
wking-io / Monads.js
Created December 8, 2017 14:18
Function Programming Categories
const Right = v => ({
chain: f => f(v),
map: f => Right(f(v)),
fold: (f, g) => g(v),
});
const Left = v => ({
chain: f => f(v),
map: f => Left(f(v)),
fold: (f, g) => f(v),
@wking-io
wking-io / remove-class.js
Last active October 11, 2017 19:47
How can I pass arguments to a callback function?
import transformSibs from 'transform-sibs';
// Use a curried function to pass more arguments to callback
const removeClass = className => el => el.classList.remove(className);
// get element from DOM
const $item = document.querySelector('.item');
// Transform all siblings of $item and remove class 'active'
transformSibs($item, removeClass('active'));
@wking-io
wking-io / transform-sibs.js
Created October 11, 2017 19:43
How can I transform siblings of an element?
const transformSibs = (el, callback) => Array
.from(el.parentNode.childNodes)
.filter(child => child.nodeType == 1 && child != el)
.forEach(sibling => {
callback(sibling);
return sibling;
});