Skip to content

Instantly share code, notes, and snippets.

View nessthehero's full-sized avatar
💭
🍕

Ian Moffitt nessthehero

💭
🍕
View GitHub Profile
@nessthehero
nessthehero / jquerify.js
Created August 25, 2020 14:54
Devtools Snippets
// jquerify.js
// https://github.com/bgrins/devtools-snippets
// Add jQuery to any page that does not have it already.
(function () {
if ( !window.jQuery ) {
var s = document.createElement('script');
s.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js');
document.body.appendChild(s);
@nessthehero
nessthehero / query.sql
Created May 18, 2018 11:07
WordPress - Find posts without meta key
SELECT * FROM wp_posts as posts
WHERE posts.post_type = 'post'
AND NOT EXISTS (
SELECT * FROM `wp_postmeta`
WHERE `wp_postmeta`.`meta_key` = "your_meta_key"
AND `wp_postmeta`.`post_id`=posts.ID
)
@nessthehero
nessthehero / gh-pages-deploy.md
Created March 18, 2018 15:43 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@nessthehero
nessthehero / pager.php
Last active November 15, 2016 18:35
A Drupal Pager with Ellipses
<?php
/**
* Generate paging for indexes of content
* @param object $node Node object
* @param array $q Array of query string values
* @param integer $current Current Page (0 based)
* @param integer $page_count Page Count
* @param boolean $ellipsis Show ellipsis between page numbers (to reduce width) (only for more than 9 pages)
* @return void Outputs markup to page
@nessthehero
nessthehero / cheat.md
Created May 27, 2015 13:27
Handlebars Cheat Sheet

Syntax

In this cheatsheet, to simplify, models are represented as JSON.

Code comments

\{{! code comments }}
@nessthehero
nessthehero / gotobyscroll.js
Created February 20, 2015 12:09
goToByScroll.js
function goToByScroll(id) {
'use strict';
// Assign the HTML, Body as a variable...
var $viewport = $('html, body');
$viewport.animate({
scrollTop: $("#" + id).offset().top // set scrollTarget to your desired position
}, 1000);
@nessthehero
nessthehero / README.md
Created October 28, 2014 17:46
Modular Example (Gist Form)

Modular JavaScript

This is a basic example of writing modular JavaScript.

In the example file, we are only loading one script, and loading modules based on feature detection.

The "a" span was detected by jquery, so that module is loaded.

There was no tag with "b", so that module was not loaded.

@nessthehero
nessthehero / Readme.md
Last active August 29, 2015 14:07
Paging explained

Paging explained

An example of logic to print paging numbers. You could take this further by adding ellipsis on either side or showing pages 1-5 and n-last at all times. But that's a bit too advanced for what this is demonstrating.

@nessthehero
nessthehero / README.md
Created August 18, 2014 14:56
How to get HQ thumb from YouTube
@nessthehero
nessthehero / _mixin.scss
Created August 14, 2014 12:51
Breakpoint Mixin
@mixin bp($point, $mode: "min") {
@if $point == small {
@media only screen and (#{$mode}-width: 420px) { @content; }
}
@if $point == medium {
@media only screen and (#{$mode}-width: 768px) { @content; }
}