Skip to content

Instantly share code, notes, and snippets.

View johnie's full-sized avatar
httpster

Johnie Hjelm johnie

httpster
View GitHub Profile
@jcobb
jcobb / gist:2993853
Created June 26, 2012 06:42
Combine multiple WordPress queries
<?php
// An example of creating two separate WP queries, combining the results,
// sorting by date and formatting the results for us in a loop like a regular query.
// order the posts by date in descending order (should go in functions.php to keep things tidy)
function order_by_date( $a, $b )
{
return strcmp( $b->post_date, $a->post_date );
}
@bennadel
bennadel / index.htm
Created February 28, 2013 14:23
Grouping Nested ngRepeat Lists In AngularJS
<!doctype html>
<html ng-app="Demo" ng-controller="DemoController">
<head>
<meta charset="utf-8" />
<title>
Grouping Nested ngRepeat Lists In AngularJS
</title>
</head>
<body>
@urre
urre / gist:5244404
Last active November 28, 2017 02:44
WordPress ignore
.htaccess
wp-config.php
xmlrpc.php
wp-content/uploads/
wp-content/blogs.dir/
wp-content/upgrade/*
wp-content/backup-db/*
wp-content/advanced-cache.php
wp-content/wp-cache-config.php
wp-content/cache/*
@davidpaulsson
davidpaulsson / rwd-lazy-loading.js
Last active February 3, 2016 03:24
Lazy loading with padding-bottom hack for responsive images
/**
* Place this inline at the bottom of the html document, right before
* closing `</body>`. It's important to have this inline as we want to
* display images asap.
*
* Markup example for the actual images. It also calculates the image
* container using the [padding-top hack](https://gist.github.com/davidpaulsson/10101985),
* please do this calculation on the back end, before drawing the DOM.
* Current example can load three images sizes, customize to fit your needs. It
* also adds the calculated image URL as an data-original tag on the img element it creates,
@scottjehl
scottjehl / noncritcss.md
Last active August 12, 2023 16:57
Comparing two ways to load non-critical CSS

I wanted to figure out the fastest way to load non-critical CSS so that the impact on initial page drawing is minimal.

TL;DR: Here's the solution I ended up with: https://github.com/filamentgroup/loadCSS/


For async JavaScript file requests, we have the async attribute to make this easy, but CSS file requests have no similar standard mechanism (at least, none that will still apply the CSS after loading - here are some async CSS loading conditions that do apply when CSS is inapplicable to media: https://gist.github.com/igrigorik/2935269#file-notes-md ).

Seems there are a couple ways to load and apply a CSS file in a non-blocking manner:

@retlehs
retlehs / an-introduction-to-the-roots-theme-wrapper.md
Created February 26, 2015 15:04
Roots documentation from pre-8.0.0

After reading through this guide, you will:

  • Understand the Roots Wrapper and recognize how it extends and complements the WordPress template hierarchy.
  • Know what is meant by the DRY Principle, why being DRY bests being WET, and see how most WordPress themes are WET.
  • Be able to filter the Roots Wrapper and create a new base template for a Custom Post Type.

Template Hierarchy

WordPress is pretty smart. Every time you load up a request it will search for the most relevant template available in your theme and load it. This is the Template Hierarchy in action and it enables us to easily customize the appearance of our sites.

@paulirish
paulirish / bling.js
Last active July 23, 2024 14:51
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
};
NodeList.prototype.__proto__ = Array.prototype;
@paulirish
paulirish / what-forces-layout.md
Last active July 24, 2024 09:43
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@posener
posener / go-shebang-story.md
Last active July 23, 2024 12:17
Story: Writing Scripts with Go

Story: Writing Scripts with Go

This is a story about how I tried to use Go for scripting. In this story, I’ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion I’ll deep dive to scripts, shells, and shebangs. Finally, we’ll discuss solutions that will make Go scripts work.

Why Go is good for scripting?

While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.