Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View abrudtkuhl's full-sized avatar
🥓

Andy Brudtkuhl abrudtkuhl

🥓
View GitHub Profile
@abrudtkuhl
abrudtkuhl / LogspotDriver.php
Created January 11, 2023 23:36
Logspot Log Driver For Laravel
<?php
namespace App\Logging;
use Illuminate\Log\Events\MessageLogged;
use Monolog\Logger;
use Logspot\Client;
class LogspotDriver
{
@abrudtkuhl
abrudtkuhl / deploy.sh
Created March 4, 2021 13:54 — forked from BenSampo/deploy.sh
Laravel deploy script
# Change to the project directory
cd /home/forge/domain.com
# Turn on maintenance mode
php artisan down || true
# Pull the latest changes from the git repository
# git reset --hard
# git clean -df
git pull origin master
@abrudtkuhl
abrudtkuhl / tracking.js
Created October 31, 2017 17:06
Basic gtag.js Event Tracking Example
document.getElementById('search-submit').onclick = function() {
gtag('event', 'homepage_search', {
'event_category': 'Search',
'event_action': 'submit',
'event_label': 'Homepage Search'
});
};
@abrudtkuhl
abrudtkuhl / kramerbot.js
Last active March 24, 2016 19:32
Node.js class for a Slack bot using the WordPress REST API
/* code inspired by Luciano Mammino via http://bit.ly/1KoCOjM */
'use strict';
var util = require('util');
var path = require('path');
var Bot = require('slackbots');
var WP = require( 'wordpress-rest-api' );
/**
@abrudtkuhl
abrudtkuhl / kramerbot.js
Created March 21, 2016 20:53
Slack bot in Node.js grabbing data from a WordPress REST API backend.
'use strict';
var WP = require( 'wordpress-rest-api' );
var wp = new WP({ endpoint: 'http://local.dev/wp-json/' });
var Bot = require('slackbots');
var settings = {
token: XXXX,
name: 'kramerbot'
};
@abrudtkuhl
abrudtkuhl / plugin.php
Created March 21, 2016 20:38
WordPress REST API - Get Random Post endpoint
<?php
/**
* Plugin Name: WP Slack REST API Backend
* Description: An example of using the WordPress REST API as a backend for a Slack Bot
* Author: Andy Brudtkuhl
* Author URI: http://youmetandy.com
* Version: 0.1
* Plugin URI: https://github.com/abrudtkuhl/heykramer
* License: GPL2+
@abrudtkuhl
abrudtkuhl / kramerbot.js
Created March 19, 2016 19:27
Basic Slack Bot Node.js
'use strict';
var messages = [
'Giddyup',
'Isosceles. You know, I love the name Isosceles. If I had a kid, I would name him Isosceles. Isosceles Kramer.',
'You know what you are? You’re an anti-dentite! It starts with a few jokes and slurs… ‘HEY DENTY!’ Then you will say that dentists should have their own schools!',
'Have you ever met a proctologist? They usually have a very good sense of humor. You meet a proctologist at a party, don’t walk away. Plant yourself there because you will hear the funniest stories you’ve ever heard.',
'What do you think Junior? You think these hands – they’ve been soaking in Ivory Liquid?',
'http://i.giphy.com/aMh59aKR8vjdC.gif'
];
@abrudtkuhl
abrudtkuhl / plugin.php
Last active March 11, 2016 22:09
Extending the WordPress REST API to return message to Slack
<?php
/**
* Plugin Name: WP Slack Slash Command Example
* Description: An example of using the WordPress REST API as a backend for a Slack Slash Command
* Author: Andy Brudtkuhl
* Author URI: http://youmetandy.com
* Version: 0.1
* Plugin URI: https://github.com/abrudtkuhl/wp-slack-slash-command
* License: GPL2+
@abrudtkuhl
abrudtkuhl / single-{category}.php
Created September 25, 2015 15:50
WordPress Single Page Template For Categories
<?php
// CATEGORY SINGLE TEMPLATES :: single-{category_slug}.php
add_filter( 'single_template',
create_function( '$t', 'foreach( (array) get_the_category() as $cat ) {
if ( file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php") ) return TEMPLATEPATH . "/single-{$cat->slug}.php";
} return $t;' ) );
// Example
@abrudtkuhl
abrudtkuhl / CreatePost.cs
Last active August 18, 2018 08:58
Using WordPressSharp To Publish A Post
// create a new Post in WordPress
var post = new Post
{
PostType = "post", // "post" or "page"
Title = "Using WordPressSharp",
Content = "WordPressSharp is a C# utility for interfacing with the WordPress XML-RPC API",
PublishDateTime = DateTime.Now,
Status = "publish" // "draft" or "publish"
};