Skip to content

Instantly share code, notes, and snippets.

/*
* Inspired by:
* http://designedbythomas.co.uk/blog/how-detect-width-web-browser-using-jquery
*
* This script is ideal for getting specific class depending on device width
* for enhanced theming. Media queries are fine in most cases but sometimes
* you want to target a specific JQuery call based on width. This will work
* for that. Be sure to put it first in your script file. Note that you could
* also target the body class instead of 'html' as well.
* Modify as needed
@jquimera
jquimera / php-html-css-js-minifier.php
Created October 17, 2017 20:03 — forked from taufik-nurrohman/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
// Based on <https://github.com/mecha-cms/extend.minify>
define('MINIFY_STRING', '"(?:[^"\\\]|\\\.)*"|\'(?:[^\'\\\]|\\\.)*\'');
define('MINIFY_COMMENT_CSS', '/\*[\s\S]*?\*/');
define('MINIFY_COMMENT_HTML', '<!\-{2}[\s\S]*?\-{2}>');
define('MINIFY_COMMENT_JS', '//[^\n]*');
define('MINIFY_PATTERN_JS', '/[^\n]+?/[gimuy]*');
define('MINIFY_HTML', '<[!/]?[a-zA-Z\d:.-]+[\s\S]*?>');
@jquimera
jquimera / WordPress get_the_ID() replacement.md
Created December 7, 2017 13:32 — forked from morganestes/ WordPress get_the_ID() replacement.md
Get the WordPress post ID no matter where you are.

This extends the built-in WordPress function get_the_ID() to return the post ID both inside and outside the loop.

Used outside the loop (in header.php):

<?php if ( function_exists( 'gt_hide_nav' ) && ! gt_hide_nav() ) : ?>
  <nav role="navigation">
    <?php if ( function_exists( 'bones_main_nav' ) ) bones_main_nav(); ?>
  </nav>
// Hide Header on on scroll down
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbar = document.querySelector(".site-header");
var navbarHeight = navbar.offsetHeight;
window.addEventListener("scroll", function(){
didScroll = true;
@jquimera
jquimera / node-cms.md
Created January 17, 2018 15:08 — forked from eyecatchup/node-cms.md
[WIP] List of Node-based content management systems (CMS)
@jquimera
jquimera / eventThrottler.js
Created January 19, 2018 14:41 — forked from cferdinandi/eventThrottler.js
A technique for throttling listener events (like resize or scroll) for better performance. https://developer.mozilla.org/en-US/docs/Web/Reference/Events/resize
var eventTimeout; // Set timeout variable
/**
* The function that runs the event actions
*/
var actualEventHandler = function () {
// handle the event...
};
/**
@jquimera
jquimera / jquery.equalHeights.js
Created January 19, 2018 16:21 — forked from davetayls/jquery.equalHeights.js
Equal heights reloaded with window resize
/**
 * Equal Heights Plugin
 * Equalize the heights of elements. Great for columns or any elements
 * that need to be the same size (floats, etc).
 *
 * Version 1.0
 * Updated 12/10/2008
 *
 * Copyright (c) 2008 Rob Glazebrook (cssnewbie.com)
 *
@jquimera
jquimera / wordpress-dropdown-naviation.js
Created January 19, 2018 19:27 — forked from Narga/wordpress-dropdown-naviation.js
Wordpress - Dropdown Navigation jQuery Code
if(!jQuery.browser.msie){jQuery("ul.topnav").css({opacity:"0.95"});} // IE - 2nd level Fix
jQuery(".topnav > li > ul").css({display: "none"}); // Opera Fix
jQuery("ul.sub-menu").parent().append("<div>&nbsp;</div>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
jQuery("ul.sub-menu li.menu-item").append("<span>&#187;</span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
jQuery("ul.menu li a").hover(function() { //When trigger is clicked...
//Following events are applied to the subnav itself (moving subnav up and down)
jQuery(this).parent().find("ul.sub-menu").slideDown('fast').show(400); //Drop down the subnav on hover
jQuery(this).parent().hover(function() {
}, function(){
jQuery(this).parent().find("ul.sub-menu").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
@jquimera
jquimera / anchor-scroll-with-offset.js
Created January 20, 2018 21:24 — forked from HoundstoothSTL/anchor-scroll-with-offset.js
Anchor scroll with fixed header offset
(function($) {
$('a[href*=#]:not([href=#])').click(function()
{
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname)
{
var target = $(this.hash),
headerHeight = $(".primary-header").height() + 5; // Get fixed header height
@jquimera
jquimera / README.md
Created January 25, 2018 23:12 — forked from barrysteyn/README.md
C/C++ Examples For Understanding

Introduction

These toy examples are for helping with understanding C/C++. There is an excellent C++ samples site which demonstrates many useful things.