Skip to content

Instantly share code, notes, and snippets.

View westonruter's full-sized avatar

Weston Ruter westonruter

View GitHub Profile
@tomjn
tomjn / gist:6140601
Last active December 20, 2015 13:39
If you're lucky enough to be using any version of PHP 5 with WordPress ( 100% chance! ) You can do this:
<?php
$posts = new posts_loop();
foreach( $posts as $id => $post ) {
the_title();
// etc...
}
// put this below in your functions.php:
@tomjn
tomjn / gist:6140172
Last active December 20, 2015 13:39
If you're lucky enought o be running WordPress on PHP 5.5, you can use generators for your post loops like this
<?php
// with the above we can now do things like this:
foreach ( posts_loop() as $p ) {
get_template_part( 'content', 'page' );
comments_template( '', true );
}
// put this below in your functions.php:
#!/bin/bash
# Run php files in the repo through phpcs, opting for a subset of only checking staged or modified files
# By @westonruter
status_filter='^.M'
status_filter_description="Linting modified files only"
while getopts ":sa" opt; do
case $opt in
s)
@Rarst
Rarst / CommentsFeed.php
Last active July 28, 2021 10:27
Build Gist comments feed for specific user, using GitHub API.
<?php
namespace Rarst\GitHub\Gist;
use GuzzleHttp\Client;
use GuzzleHttp\Command\Guzzle\Description;
use GuzzleHttp\Command\Guzzle\GuzzleClient;
/**
* Build Gist comments feed for specific user, using GitHub API.
@pwenzel
pwenzel / google-maps-oembed-wordpress.php
Created February 1, 2013 22:45
Faux Google Maps oEmbed for Wordpress
<?php
/* Faux Google Maps oEmbed
* Embed google maps in a nicer iframe without using their provided embed code
* @usage Paste a Google Maps link in your post and it will be replaced with an iframe when published
* @link http://bigsaturday.net/oembed-google-maps-wordpress/
*/
wp_embed_register_handler( 'google_map', '#https://maps\.google\.com/maps(.*)#i', 'embed_google_map' );
function embed_google_map( $matches ) {
$query = parse_url($matches[0]);
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 19, 2024 11:00
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@westonruter
westonruter / crontab
Last active November 22, 2018 08:15
Script to ping URLs defined in urls.txt and alert you if they do not return 200 OK. You'll need to `sudo apt-get install bsd-mailx` to get the email, and you'll want to add a filter to make sure that $from is never sent to spam. A log is also kept in log.txt including timestamp, status code, and URL.
*/5 * * * * /home/pi/pinger/pinger.sh > /dev/null 2>&1
@xentek
xentek / wp-unit-tests.md
Created August 26, 2012 19:06
WordPress Unit Tests Quick Start

WordPress Unit Tests Quick Start Guide

This quick start guide is geared towards installing PHPUnit on OSX in order to run the WordPress unit tests. It uses homebrew to install PHP using homebrew-php. You can likely skip this step if you've already got php and pear installed properly.

If you use MAMP, then try these instructions to use MAMP's php and pear to install PHPUnit.

install homebrew

ruby &lt;(curl -fsSkL raw.github.com/mxcl/homebrew/go)
@joshwnj
joshwnj / files-from-month.sh
Created May 21, 2012 22:17
give me a list of files from the month of May 2011
## give me a list of files from the month of May 2011
ls -laht --color=never | egrep 'May[ ]+[0-9]+[ ]+2011(.*)' | sed 's/.*2011 / /'
## move them to a separate directory
mkdir may-2011; ls -laht --color=never | egrep 'May[ ]+[0-9]+[ ]+2011(.*)' | sed 's/.*2011 / /' | xargs -I {} mv {} may-2011/
@luetkemj
luetkemj / wp-query-ref.php
Last active February 6, 2024 14:25
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/