Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin McKernan mckernanin

View GitHub Profile
View fountain.json
{
"nodes": [
{
"id": 30004553,
"name": "4-EP12"
},
{
"id": 30004552,
"name": "XF-TQL"
},
@mckernanin
mckernanin / docker-compose.yml
Last active Apr 5, 2019
Example mongodb docker setup
View docker-compose.yml
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 / setup.sh
Created Aug 31, 2018
Scaffold a typescript project quickly
View setup.sh
#!/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"],
@mckernanin
mckernanin / functions.php
Created Aug 27, 2017
Enqueueing parent theme styles
View functions.php
<?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' );
View CMB group options page
<?php
/**
* CMB2 Theme Options
* @version 0.1.0
*/
class RTC_Admin {
/**
* Option key, and option page slug
* @var string
View 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:

View gist:c29950a9a977ff6dcfc96875f3ca50d4
<?php
define( 'LIVE_URL', 'http://yoursite.com')
// add_action('init', 'my_replace_image_urls' );
function my_replace_image_urls() {
$site_url = get_site_url();
if ( false !== strpos( $site_url, '.dev' ) ){
add_filter( 'wp_get_attachment_url', 'replace_dev_url', 10, 2 );
add_filter( 'wp_calculate_image_srcset', 'replace_dev_url_srcset', 10, 2 );
}
}
@mckernanin
mckernanin / functions.php
Created Aug 16, 2016
Quickly replace the text in Divi's footer
View functions.php
<?php
function mck_replace_footer_text( $text ){
if ( 'Designed by %1$s | Powered by %2$s' === $text ) {
$text = '&copy; ' . date('Y') . ' ' . get_bloginfo( 'name' ) . '. All rights reserved.';
}
return $text;
}
add_filter( 'gettext', 'mck_replace_footer_text' );
@mckernanin
mckernanin / functions.php
Created Aug 6, 2016
REST API Endpoint Example
View functions.php
<?php
add_action( 'rest_api_init', 'spe_register_api_hooks' );
function spe_register_api_hooks() {
$namespace = 'simple-posts/v1';
register_rest_route( $namespace, '/list-posts/', array(
'methods' => 'GET',
'callback' => 'spe_get_posts',
) );
}
function spe_get_posts() {
@mckernanin
mckernanin / functions.php
Last active Aug 6, 2016
WordPress Admin AJAX Example
View functions.php
<?php
add_action('wp_ajax_action_name', 'callback_function');
add_action('wp_ajax_nopriv_action_name', 'callback_function');
function callback_function() {
echo 'stuff to return';
die();
}
You can’t perform that action at this time.