Skip to content

Instantly share code, notes, and snippets.

View richjenks's full-sized avatar
🏍️

Rich Jenkins richjenks

🏍️
View GitHub Profile
@richjenks
richjenks / mongo.js
Created January 21, 2018 13:40
MongoDB Snippets
// Start
mongod --dbpath C:\Programs\MongoDB\Data
// Dump & Restore
mongodump --host HOST_NAME --db DATABASE_NAME --username USERNAME --password "PASSWORD" --out BACKUP_PATH
mongorestore --host HOST_NAME --db DATABASE_NAME RESTORE_PATH
@richjenks
richjenks / .htaccess
Created December 22, 2017 09:22
Apache Killswitch
# Redirect 503 /
# Quick Convert
ffmpeg -i input.mkv -c copy output.mp4
# To "Standard" MP4
ffmpeg -i input.mkv -c:v h264 -c:a aac output.mp4
@richjenks
richjenks / rachet-modal-switch.js
Created April 16, 2017 17:04
Ratchet Vue.js modal switch
// v-on:click handlers can only take one expression, so you can't close
// a modal and update vars in one. This function updates vars on the
// current Vue object, closes a modal (based on CSS selector) and,
// optionally, opens another modal after a delay to all appear smooth
modalNav: function(vars, close, open) {
for (var attr in vars) { this[attr] = vars[attr]; }
document.querySelectorAll(close)[0].classList.remove('active')
if (typeof open !== 'undefined') {
window.setTimeout(function () {
document.querySelectorAll(open)[0].classList.add('active')
<?php
function delete($path) {
$files = scandir($path);
foreach ($files as $file) {
if (!in_array($file, ['.', '..'])) {
$full = $path . DIRECTORY_SEPARATOR . $file;
if (is_file($full)) unlink($full);
if (is_dir($full)) delete($full);
}
@richjenks
richjenks / README.md
Last active February 12, 2017 13:12
Finds a value in a CSV file based on its column and row header

Intersect CSV

Finds a value in a CSV file based on its column and row header

Usage

mixed intersect ( string $filename , mixed $column , mixed $row )
# Basic
rsync -avz --delete ./source/ ./destination
# Windows deployment script with SSH fix
rsync -avz --delete --progress --exclude '.git' --chmod=755 -e 'C:\Programs\rsync\ssh.exe' ./path/to/source user@host:/path/to/destination
@richjenks
richjenks / wp_set_single_template.php
Created December 15, 2016 17:02
Specify a template for a post type while storing the template file outside of a theme
<?php
/**
* Allows you to specify a template for a post type while storing the
* template file outside of a theme.
*
* @param string $file Full path to template file
* @param string $post_type Post Type to use template
*/
function set_single_template( $file, $post_type ) {
@richjenks
richjenks / wp_taxonomy_radios.php
Created December 15, 2016 17:00
Changes the taxonomy checkboxes into radios so only one can be selected
<?php
/**
* Changes the taxonomy checkboxes into radios so only one can be selected
*
* @param string|array $taxonomies Taxonomy(s) to be affected
* @param string|array $post_types Post Type(s) to be affected
*/
function taxonomy_radios( $taxonomies, $post_types ) {
// Ensure params are arrays
@richjenks
richjenks / wp_add_taxonomy_filter.php
Created December 15, 2016 16:59
Adds filter for taxonomies to posts table
<?php
/**
* Adds filter for taxonomies to posts table
*
* Adapted from:
* @see http://wordpress.org/support/topic/custom-taxonomy-filter-not-working-in-admin-editphp-31b2?replies=8#post-2400615
* @see https://wordpress.stackexchange.com/questions/578/adding-a-taxonomy-filter-to-admin-list-for-a-custom-post-type/3215#3215
*
* @param array $taxonomy Filter to be added