Skip to content

Instantly share code, notes, and snippets.

View chrisdavidmiles's full-sized avatar
💙

Chris David Miles chrisdavidmiles

💙
View GitHub Profile
@chrisguitarguy
chrisguitarguy / mask-links.php
Created December 14, 2011 14:38
Mask external WordPress links behind a redirect.
@mxriverlynn
mxriverlynn / 720p.sh
Created September 8, 2012 16:31
Size an OSX window to 720p (1280x720)
#!/usr/bin/env bash
echo "Setting $1 bounds to 720p"
# 720p is 1280x720.
# Bounds is startX, startY, endX, endY. Adjust size from starting position to account for this
osascript -e "tell application \"$1\" to set the bounds of the first window to {250, 220, 1530, 940}"
# activate the app, to bring it to the front
osascript -e "tell application \"$1\" to activate"
@thomasfr
thomasfr / warmly.sh
Last active October 12, 2023 06:17
A wget based easy poor man`s cache warmer script
#!/bin/bash
# warmly.sh
# A wget based, easy, poor man`s cache warmer script
# https://gist.github.com/thomasfr/7926314
# The MIT License (MIT)
#
# Copyright (c) 2013,2014 Thomas Fritz <fritztho@gmail.com> (http://fritzthomas.com)
#
@lmartins
lmartins / functions.php
Created November 14, 2014 12:44
Sanitize file names during upload to Wordpress
/**
* Sanitize File name during upload
* http://stackoverflow.com/questions/3259696/rename-files-during-upload-within-wordpress-backend
*/
function make_filename_hash($filename) {
$info = pathinfo($filename);
$ext = empty($info['extension']) ? '' : '.' . $info['extension'];
$name = basename($filename, $ext);
return md5($name) . $ext;
}
@blainerobison
blainerobison / gist:e802658da007e6e806b1
Last active August 24, 2022 00:42
wp: Custom Upload Directory By File Type [WordPress]
/**
* Set custom upload directory
*
* Images => /img
* PDF => /pdf
* Misc => /misc
*
* Note: Doesn't work with 'browser uploader'
* Note: Use with 'wp_update_attachment_metadata' hook if we want to define our own attachment metadata
* Allowed file types: http://codex.wordpress.org/Uploading_Files#About_Uploading_Files_on_Dashboard
@joshuadavidnelson
joshuadavidnelson / remove-post-type-from-search-results.php
Last active March 8, 2022 13:56
Remove a post type from search results, but keep all others
<?php
/**
* Modify query to remove a post type from search results, but keep all others
*
* @author Joshua David Nelson, josh@joshuadnelson.com
* @license http://www.gnu.org/licenses/gpl-2.0.html GPLv2+
*/
add_action( 'pre_get_posts', 'jdn_modify_query' );
function jdn_modify_query( $query ) {
@zgordon
zgordon / gist-oembed-wordpress
Created June 15, 2015 04:45
oEmbed Gist into WordPress
wp_embed_register_handler(
'github-gist',
'/https:\/\/gist\.github\.com\/([^\/]+)\/([^\/]+)/',
function($matches, $attr, $url, $rawattr) {
$embed = "&lt;script src=\"{$url}.js\"&gt;&lt;/script&gt;";
return apply_filters(
'embed_github_gist',
$embed,
$matches,
@kasperhartwich
kasperhartwich / delete-from-slack.php
Last active January 26, 2021 08:10
Script to delete old files from Slack
#!/usr/bin/env php
<?php
date_default_timezone_set('GMT');
if (count($argv)<2) {
echo $argv[0] . ' <token> <until>' . PHP_EOL;
echo 'Example: ' . $argv[0] . ' abcd-12345678-123456789-12345 \'-3 months\'' . PHP_EOL;
exit;
}
@andreibosco
andreibosco / creative-cloud-disable.md
Last active June 26, 2024 09:36
disable creative cloud startup on mac
@unculturedswine
unculturedswine / functions.php
Created May 24, 2017 15:06
WooCommerce Subscriptions Custom Thank You Page Redirect
add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' );
function wc_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( '#' );
exit;
}
}