Skip to content

Instantly share code, notes, and snippets.

View NateJLewis's full-sized avatar
🎯
Focusing

Nate Lewis NateJLewis

🎯
Focusing
View GitHub Profile
@neilgee
neilgee / mod-primary-nav.php
Last active December 4, 2015 07:28
Reposition Genesis Primary Navigation to Header Right Widget and Remove Structural Wrap
<?php
//do not copy the opening php tag above
/**
* Swap Primary Nav to Header Right and Remove Wrap
*
* @package Swap Primary Nav
* @author Neil Gee
* @link http://coolestguidesontheplanet.com/switching-primary-menu-genesis-theme-header-right/
* @copyright (c) 2014, Neil Gee
@vladikoff
vladikoff / resource.js
Created April 17, 2014 17:52
Angular $resource and transformResponse
angular.module('itemServices', ['ngResource'])
.factory('Item', ['$resource',
function ($resource) {
return $resource('items/:id',
{id: '@id'},
{
query: {
isArray: true,
method: 'GET',
params: {},
@sonnyt
sonnyt / gist:8585696
Last active June 15, 2018 12:45
JavaScript Check If Element Has Class
function hasClass(element, className) {
return element.className && new RegExp("(^|\\s)" + className + "(\\s|$)").test(element.className);
}
var myDiv = document.getElementById('MyDiv');
hasClass(myDiv, 'active');
// OR
@Shelob9
Shelob9 / ships.php
Last active April 4, 2020 21:25
Example code for my Pods Screencast: Using Pods Pages With Advanced Content Types -- http://youtu.be/iUDPYid0bUU
<?php
/**
* Template Name: Ships
*/
get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
@webgurus
webgurus / acf_slider_bootstrap
Last active September 7, 2020 10:39
Root's bootstrap slider example with Advanced Custom Fields Gallery plugin.
<?php
/* SLIDER CUSTOM FIELD FOR HOMEPAGE */
$images = get_field('slider_photos');
$count=0;
$count1=0;
if($images) : ?>
<div id="slider">
<div id="carousel" class="carousel slide">
<!-- Indicators -->
@jakemmarsh
jakemmarsh / directives.js
Created June 26, 2013 14:18
AngularJS directive to create a functional "back" button
app.directive('backButton', function(){
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', goBack);
function goBack() {
history.back();
scope.$apply();
@steve-taylor
steve-taylor / doSynchronousLoop.js
Last active December 4, 2022 00:51
Synchronous for loop in JavaScript to ensure that the n+1th item isn't processed until the callback of the nth item's processor has been called.
/**
* Process an array of data synchronously.
*
* @param data An array of data.
* @param processData A function that processes an item of data.
* Signature: function(item, i, callback), where {@code item} is the i'th item,
* {@code i} is the loop index value and {@code calback} is the
* parameterless function to call on completion of processing an item.
*/
function doSynchronousLoop(data, processData, done) {
@briancray
briancray / linkify.js
Created November 6, 2012 13:56
Linkify Twitter API entities
/*
Compliant with Twitter's Developer Display Requirements:
https://dev.twitter.com/terms/display-requirements
*/
var linkify_result = function (tweet /* tweet object from the results array */) {
var subs = [],
last_offset = 0,
new_tweet = '',
entity,
replace = {
@Adirael
Adirael / fix-wordpress-permissions.sh
Created August 17, 2012 23:16
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@maxrice
maxrice / us-state-names-abbrevs.php
Created May 23, 2012 18:32
US State Names & Abbreviations as PHP Arrays
<?php
/* From https://www.usps.com/send/official-abbreviations.htm */
$us_state_abbrevs_names = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AS'=>'AMERICAN SAMOA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',