Skip to content

Instantly share code, notes, and snippets.

Roy Jossfolk primedime

Block or report user

Report or block primedime

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View load-page-for-id.php
function my_template( $template ) {
$url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
// check if the page url contains ?id=
if( strpos($url,'?id=') !== false ){
if ( $new_template = locate_template( array( 'page-company-profile.php' ) ) )
return $new_template ;
}
return $template;
}
View quick-display-div-by-ip.js
function loadIP() {
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://freegeoip.net/json/', true);
xhr.onload = function() {
const data = JSON.parse(this.response);
const country = data.country_code;
console.log(country);
const europe = ['GB', 'AL', 'AD', 'AT', 'BY', 'BE', 'BA', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FO', 'FI', 'FR', 'DE', 'GI', 'GR', 'HU', 'IS', 'IE', 'IT', 'LV', 'LI', 'LT', 'LU', 'MK', 'MT', 'MD', 'MC', 'NL', 'NO', 'PL', 'PT', 'RO', 'RU', 'SM', 'RS', 'SK', 'SI', 'ES', 'SE', 'CH', 'UA', 'VA', 'RS', 'IM', 'RS', 'ME', 'DE'];
const inEU = europe.indexOf(country) !== -1;
@primedime
primedime / redux-quick-example.js
Last active Dec 27, 2017
Quick example of how to properly use Redux
View redux-quick-example.js
/* Create Reducer, which is a function
that produces some amount of state
*/
const reducer = (state = [], action) => {
if (action.type === 'split_string') {
return action.payload.split('');
} else if (action.type === 'add_character') {
// Make a new array
// Take all elements in current State array
// Add action.payload to new State
@primedime
primedime / disney-park-wait-time-hours.js
Last active Feb 16, 2018
get wait times and open/close hours for Disney Parks
View disney-park-wait-time-hours.js
const disneyMagicKingdom = new Themeparks.Parks.WaltDisneyWorldMagicKingdom();
const epcot = new Themeparks.Parks.WaltDisneyWorldEpcot();
const disneyHollywoodStudios = new Themeparks.Parks.WaltDisneyWorldHollywoodStudios();
const disneyAnimalKingdom = new Themeparks.Parks.WaltDisneyWorldAnimalKingdom();
const universalStudiosFlorida = new Themeparks.Parks.UniversalStudiosFlorida();
const universalIslandsOfAdventure = new Themeparks.Parks.UniversalIslandsOfAdventure();
const universalVolcanoBay = new Themeparks.Parks.UniversalVolcanoBay();
const seaworldOrlando = new Themeparks.Parks.SeaworldOrlando();
@primedime
primedime / wp-api-http-request-example.js
Last active Feb 23, 2018
Sample code for XMLHttpRequest
View wp-api-http-request-example.js
function getAllCategories() {
const allCategories = [417, 418, 419, 420, 421, 422]
for (let categories of allCategories) {
let ourRequest = new XMLHttpRequest()
ourRequest.open('GET', 'https://www.orlandoattractions.com/wp-json/wp/v2/posts?categories=' + categories)
ourRequest.onload = () => {
if (ourRequest.status >= 200 && ourRequest.status < 400) {
You can’t perform that action at this time.