Skip to content

Instantly share code, notes, and snippets.

View nbeers22's full-sized avatar

Nathan Beers nbeers22

  • Jacksonville Beach, FL
View GitHub Profile
@nbeers22
nbeers22 / Pig-latin_solution.rb
Last active August 29, 2015 14:06
Solution for Pig-latin
# Solution for Challenge: Pig-latin. Started 2014-09-16T15:13:49+00:00
# Script: CONVERT TO PIG LATIN
# Iteration One: CONVERT SINGLE WORD
# GET a word from user input.
# IF the word starts with a vowel, don't change it.
# ELSE replace the word with its pig latin equivalent.
# GET all of the consonants before the first vowel in the word.
@nbeers22
nbeers22 / carousel-loop.php
Last active February 10, 2020 22:08
Bootstrap carousel with WordPress loop
@nbeers22
nbeers22 / 0_reuse_code.js
Last active August 29, 2015 14:28
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@nbeers22
nbeers22 / remove-meta-wordpress.php
Last active July 3, 2023 23:10
Remove all the extra bloat of meta tags that WordPress adds to the <head> and disables the JSON API
<?php
// remove some meta tags from WordPress
remove_action('wp_head', 'wp_generator');
function remove_dns_prefetch( $hints, $relation_type ) {
if ( 'dns-prefetch' === $relation_type ) {
return array_diff( wp_dependencies_unique_hosts(), $hints );
}
return $hints;
}
@nbeers22
nbeers22 / remove-post-type-from-url.php
Last active October 19, 2016 18:46
WordPress - Remove the custom post type name from the URL
<?php
// Remove custom post type name from URL for special posts
function remove_cpt_slug( $post_link, $post, $leavename ) {
if ( 'special' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
@nbeers22
nbeers22 / thinkful.js
Last active March 31, 2019 11:05
Thinkful Functions
// Create a function called wisePerson that takes 2 arguments: wiseType and whatToSay.
// This function takes a block of text and presents it as a quote from the wise person.
// wiseType is the person the quote will be attributed to, and whatToSay is what the wise person will be quoted as saying.
// When called like this: wisePerson('goat', 'Hello world') should return the string 'A wise goat once said: "Hello world".'
const wisePerson = (wiseType, whatToSay) => `A wise ${wiseType} once said: "${whatToSay}"`
// Create a function that takes a single argument: whatToShout.
@nbeers22
nbeers22 / scripts.js
Created March 31, 2019 11:44
Thinful JavaScript number functions
// Create a function called computeArea that takes two arguments: width and height.
// It returns the area of a rectangle whose width is width and height is height.
// So computeArea(2, 2) would return 4, and computeArea(3, 5) would return 15.
const computeArea = (width, height) => width * height;
// Create 2 functions, one called celsToFahr that converts Celsius to Fahrenheit and
// another called fahrToCels that converts Fahrenheit to Celsius. celsToFahr takes one
// argument, celsTemp, and fahrToCels takes one argument, fahrTemp.
// [°F] = [°C] × ​9⁄5 + 32
// [°C] = ([°F] − 32) × ​5⁄9
@nbeers22
nbeers22 / scope.md
Created April 1, 2019 08:36
JavaScript Variable Scope

Questions: What is scope? Your explanation should include the idea of global vs. block scope. Why are global variables avoided? Explain JavaScript's strict mode What are side effects, and what is a pure function?

  1. Scope determines the visibility/accessibility of variables, objects, and funcitons within the code. JavaScript has global scope, function scope, and with the addition of ES6, block scope using let and const. Global variables are available everywhere but are typically viewed as bad practice because they can produce unintended results down the line. They also can be a performance hit, because when JavaScript is compiled it checks for variable