Skip to content

Instantly share code, notes, and snippets.

View chrisguitarguy's full-sized avatar

Christopher Davis chrisguitarguy

View GitHub Profile
FROM openjdk:9-jre AS build
## Deps to install DynamoDB
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
coreutils \
ca-certificates \
&& mkdir -p /dynamodb/data
WORKDIR /dynamodb
@chrisguitarguy
chrisguitarguy / get-links.py
Created September 14, 2011 17:04
Get specific links from a page using python and BeautifulSoup
@chrisguitarguy
chrisguitarguy / cpt-permalinks.php
Created October 10, 2011 17:28
How to add fields to the WordPress permalinks page
@chrisguitarguy
chrisguitarguy / default-author.php
Created July 2, 2012 20:07
Set a default author for posts on your WordPress site.
<?php
/*
Plugin Name: Default Author
Plugin URI: http://pmg.co
Description: Set a default author for all posts and pages
Version: 1.0
Text Domain: default-author
Author: Christopher Davis
Author URI: http://christopherdavis.me
License: GPL2
@chrisguitarguy
chrisguitarguy / nginx.conf
Created February 22, 2018 16:22
How to proxy requests from nginx to an upstream backend. Could be use for Python or JavaScript (express) apps.
http {
# other stuff here
# The upstream backend server this can be named whatever you desire
# See http://nginx.org/en/docs/http/ngx_http_upstream_module.html
upstream backend {
# this is the actual hostname + port of the backend server
server backend:8080;
# how many keep alive connections to allow, only set this if you're going
# to specify the `Connection` header in the proxy below, nginx sets the
@chrisguitarguy
chrisguitarguy / logs.py
Created December 19, 2011 16:44
A simple python script to email myself server logs. Meant to run as a cron job.
import argparse
import os
import smtplib
from email import Encoders
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.Utils import formatdate
@chrisguitarguy
chrisguitarguy / big-xml.php
Created February 27, 2013 04:15
How to use a combination of XMLReader and SimpleXMLElement to parse large XML files in PHP.
<?php
/**
* an example of how to read huge XML files relatively quickly and efficiently
* using a few core PHP libraries.
*
*/
// Assume your file is very large, 140MB or somethig like that
$fn = __DIR__ . '/some_file.xml';
@chrisguitarguy
chrisguitarguy / remove-feeds.php
Created March 28, 2012 04:37
Remove all feeds from WordPress
<?php
/*
Plugin Name: Remove All Feeds [for WPSE33072]
Description: Remove all feeds from WordPress
Author: Christopher Davis
Author URI: http://christopherdavis.me
License: GPL2
*/
@chrisguitarguy
chrisguitarguy / mask-links.php
Created December 14, 2011 14:38
Mask external WordPress links behind a redirect.
@chrisguitarguy
chrisguitarguy / KeepValueListener.php
Created February 26, 2016 14:29
A way to keep original values around when a Symfony form is submitted with an empty value. Useful for password fields especially
<?php
/**
* Copyright (c) 2016 PMG <https://www.pmg.com>
*
* License: MIT
*/
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\Form\FormEvents;