Skip to content

Instantly share code, notes, and snippets.

View mckernanin's full-sized avatar

Kevin McKernan mckernanin

View GitHub Profile
@mckernanin
mckernanin / nginx.conf
Last active November 17, 2023 09:27
Example nginx config to get WordPress uploads from remote if they don't exist locally
# save space, and grab uploads from the live site
location /wp-content/uploads/ {
if (!-e $request_filename){
rewrite ^/wp-content/uploads/(.*) http://yourlivesite.com/wp-content/uploads/$1 redirect;
}
}
@mckernanin
mckernanin / setup.sh
Created August 31, 2018 00:25
Scaffold a typescript project quickly
#!/bin/bash
yarn add dotenv express joi lodash morgan
yarn add -D nodemon ts-node types-installer typescript add-npm-scripts
yarn add-npm-scripts start "nodemon"
yarn add-npm-scripts build "tsc"
yarn types-installer
cat > nodemon.json <<EOL
{
"watch": ["src"],
#!/bin/bash
COMMITS=$(git cherry -v main $1 | cut -d " " -f 2)
for COMMIT in $COMMITS
do
git checkout $COMMIT
./script.sh
{
"nodes": [
{
"id": 30004553,
"name": "4-EP12"
},
{
"id": 30004552,
"name": "XF-TQL"
},
@mckernanin
mckernanin / functions.php
Created December 30, 2015 21:33
Add page slug as a body class for WordPress
<?php
//Page Slug Body Class
function add_slug_body_class( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
return $classes;
}
@mckernanin
mckernanin / docker-compose.yml
Last active April 5, 2019 02:42
Example mongodb docker setup
version: "2"
services:
mongo:
image: mckernanin/mongo-auth:4.0.8
environment:
AUTH: "yes"
MONGODB_ADMIN_USER: admin
MONGODB_ADMIN_PASS: '**********' # set your admin password here
MONGODB_APPLICATION_DATABASE: appname # give the db a name
MONGODB_APPLICATION_USER: application
@mckernanin
mckernanin / functions.php
Created August 27, 2017 16:11
Enqueueing parent theme styles
<?php
function my_enquee_scripts() {
$label = 'parent-theme-styles';
$fileurl = get_template_directory_uri() . '/style.css';
wp_enqueue_style( $label, $fileurl );
}
add_action( 'wp_enqueue_scripts', 'my_enquee_scripts' );
<?php
/**
* CMB2 Theme Options
* @version 0.1.0
*/
class RTC_Admin {
/**
* Option key, and option page slug
* @var string
@mckernanin
mckernanin / keybase.md
Created March 31, 2017 23:44
keybase.md

Keybase proof

I hereby claim:

  • I am mckernanin on github.
  • I am mckernanin (https://keybase.io/mckernanin) on keybase.
  • I have a public key ASAjPR8hCkehQd_Pyfw7zl00aQMLUe5lHeuBj7A_8JqC-Ao

To claim this, I am signing this object:

@mckernanin
mckernanin / functions.php
Last active March 8, 2017 19:40
Add new admin via functions.php
<?php
/**
* Function to insert an administrator login into a WordPress site.
* Login and email have to be unique, the function doesn't update existing accounts.
* Function should be placed in functions.php of the active theme.
*/
function insert_admin(){
$login = ''; // username goes here.
$passw = ''; // password goes here, will be hashed on creation.