Skip to content

Instantly share code, notes, and snippets.

Andy Brudtkuhl abrudtkuhl

View GitHub Profile
@abrudtkuhl
abrudtkuhl / kramerbot.js
Created Mar 21, 2016
Slack bot in Node.js grabbing data from a WordPress REST API backend.
View kramerbot.js
'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 / admin_filter_by_custom_fields.php
Created Jul 22, 2014
WordPress Filter Posts By Custom Field Value In Admin
View admin_filter_by_custom_fields.php
<?php
/*
Plugin Name: Admin Filter BY Custom Fields
Plugin URI: http://en.bainternet.info
Description: Filter posts or pages in admin by custom fields (post meta)
Version: 1.0
Author: Bainternet
Author URI: http://en.bainternet.info
*/
@abrudtkuhl
abrudtkuhl / nginx-elasticsearch-proxy.conf
Last active Aug 23, 2019 — forked from karmi/nginx-elasticsearch-proxy.conf
NGINX Reverse Proxy Authentication For Elasticsearch
View nginx-elasticsearch-proxy.conf
# Run me with:
#
# $ nginx -p /path/to/this/file/ -c nginx.conf
#
# All requests are then routed to authenticated user's index, so
#
# GET http://user:password@localhost/_search?q=*
#
# is rewritten to:
#
@abrudtkuhl
abrudtkuhl / wp_posts.reset.sql
Created Jul 22, 2014
Reset Auto_Increment in WordPress Posts table
View wp_posts.reset.sql
DELETE FROM wp_posts;
DELETE FROM wp_post_meta;
TRUNCATE TABLE wp_posts;
TRUNCATE TABLE wp_post_meta;
@abrudtkuhl
abrudtkuhl / web.config
Created Jun 30, 2014
WordPress on IIS Web.config to use permalinks
View web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
@abrudtkuhl
abrudtkuhl / CreatePost.cs
Last active Aug 18, 2018
Using WordPressSharp To Publish A Post
View CreatePost.cs
// 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"
};
@abrudtkuhl
abrudtkuhl / Github OAuth ASP.Net MVC
Created Jun 26, 2012
Github OAuth callback for ASP.Net MVC. Set yourapp.com/github/callback as the OAuth callback URL when you setup your application. If the users chooses to grant you permission, this controller/action get called to complete the transaction. See http://devel
View Github OAuth ASP.Net MVC
public class GithubController : Controller
{
/// <summary>
/// Github OAuth Callback
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public JsonResult callback(string code)
{
var clientId = "[insert yours]";
@abrudtkuhl
abrudtkuhl / wordpress.gitignore
Created Jul 30, 2014
.gitignore file for WordPress
View wordpress.gitignore
# This is a template .gitignore file for git-managed WordPress projects.
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
# content. Or see git's documentation for more info on .gitignore files:
@abrudtkuhl
abrudtkuhl / index.html
Last active Mar 6, 2018
Simple KnockoutJS paging with DataTables
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Simple KnockoutJS Paging With DataTables.net</title>
<!-- Bootstrap -->
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
@abrudtkuhl
abrudtkuhl / single-{category}.php
Created Sep 25, 2015
WordPress Single Page Template For Categories
View single-{category}.php
<?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
You can’t perform that action at this time.