Skip to content

Instantly share code, notes, and snippets.

@joefearnley
joefearnley / ucWords.js
Created May 20, 2020 17:52
JS ucWords()
const upperCaseWords = sentence => sentence.split(' ').map(w => w[0] + w.substr(1).toLowerCase()).join(' ');
var sentence = 'EASY TRACK IS YOUR KEY TO AFFORDABLE ORGANIZATION';
var upperCase = upperCaseWords(sentence);
console.log(upperCase);
const puzzle1 = message => {
const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
return message.split('').map(c => {
if (c === ' ' || c === '.') {
return c;
}
const position = alphabet.indexOf(c);
let newPosition = (position - 13 < 0) ? position + 13 : position - 13;
return alphabet[newPosition];
// one liner
let digits = num => parseInt((''+num).split('').map(n => n*n).join(''));
// cleaned up a little bit
let squareDigitsString = num => (''+num).split('').map(n => n*n).join('');
let squareDigits = parseInt(squareDigitsString);
IT'S SHOWTIME
TALK TO THE HAND "Where's the Buffet?"
TALK TO THE HAND "Hot Damn"
TALK TO THE HAND "Pansy Immune System"
TALK TO THE HAND "Upper Football"
TALK TO THE HAND "William Butterfield"
TALK TO THE HAND "Smooth as Silk"
TALK TO THE HAND "Black Metal"
TALK TO THE HAND "Large Can of Beer"
@joefearnley
joefearnley / app.arnoldc
Created July 31, 2015 20:16
Basic program written in ArnoldC
IT'S SHOWTIME
HEY CHRISTMAS TREE counter
YOU SET US UP 0
HEY CHRISTMAS TREE end
YOU SET US UP 1
STICK AROUND end
GET TO THE CHOPPER counter
HERE IS MY INVITATION counter
@joefearnley
joefearnley / gist:daaaa7a4a4b379911486
Created June 23, 2014 15:50
Add jQuery to WordPress Theme
<?php
// include in your header.php file, right before the </head> tag.
<?php wp_head(); ?>
// include in your footer.php file, right before the </body> tag.
<?php wp_footer(); ?>
@joefearnley
joefearnley / gist:4fee82916c13bf3e98dc
Created June 23, 2014 15:49
Add jQuery to WordPress Theme
<?php
function si_jquery_enqueue() {
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '3.1.1', true );
}
@joefearnley
joefearnley / gist:69dc719882fae816f7e4
Created June 23, 2014 15:48
Add jQuery to WordPress Theme
<?php
if ( !is_admin() ) {
add_action( 'wp_enqueue_scripts', 'si_jquery_enqueue', 10 );
}
@joefearnley
joefearnley / filter_search.php
Last active May 29, 2017 12:19
Filter WordPress Search
<?php
function filter_search($query) {
if ( $query->is_search ) {
$query->set('post_type', array( 'post', 'product' ) );
}
return $query;
}
add_filter('pre_get_posts', 'filter_search');
@joefearnley
joefearnley / custom_post_type.php
Last active August 29, 2015 14:02
Create WordPress Custom Post Type
<?php
add_action( 'init', 'create_product_post_type' );
function create_product_post_type() {
register_post_type( 'product',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),