Skip to content

Instantly share code, notes, and snippets.


Doug Vanderweide dougvdotcom

View GitHub Profile
dougvdotcom / await-async.cs
Last active Nov 13, 2015
Demonstration of await and async keywords in c#
View await-async.cs
using System;
using System.Threading.Tasks;
using LinqToTwitter;
using System.Data.SqlClient;
namespace linq2twitter_demo {
public class BaseballGame {
public int Id { get; set; }
public DateTime GameDate { get; set; }
public string HomeTeamName { get; set; }
dougvdotcom / twitter-character-count.cs
Last active Nov 9, 2017
Demonstrates how to count characters in .NET for Twitter status updates
View twitter-character-count.cs
using System;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
namespace TwitterWordCount
class Program
static void Main()
dougvdotcom / FileRecursion.vb
Created Dec 18, 2015
Code for recursively adding file names to a text file via VB.NET. for details.
View FileRecursion.vb
Imports System.IO
Sub GetAllFiles(strPath As String)
Dim objRoot As New DirectoryInfo(strPath)
Dim objSubDir As DirectoryInfo()
Dim objFile As FileInfo()
If objRoot.Exists Then
'if you don't want this to be recursive, remove this for loop
For Each objSubDir In objRoot.GetDirectories
dougvdotcom / NLog-sqlserver-storedprocedure.config.xml
Last active Dec 28, 2015
Configuration file for NLog when using SQL Server stored procedures as a target. See for more info.
View NLog-sqlserver-storedprocedure.config.xml
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns=""
xsi:schemaLocation=" NLog.xsd"
dougvdotcom / NLogErrorLog.sql
Last active Dec 24, 2015
Table and insert stored procedure for NLog when using SQL Server as a target. See for more info.
View NLogErrorLog.sql
USE [mydatabase]
CREATE TABLE [dbo].[NLogErrorLog] (
dougvdotcom / azure-wp-fix-bad-srcset-urls.php
Last active Jan 4, 2016
PHP to correct bad srcset attribute URLs in Scalable WordPress installs using WordPress 4.4. See for details.
View azure-wp-fix-bad-srcset-urls.php
function azure_fix_invalid_srcset_path( $sources ) {
$storageHost = ""; // change me to be your storage domain
$webHost = ""; // change this to be your website domain
$container = "wp-media"; // change this to be the name of your storage container
$newpath = str_replace( $webHost, $storageHost, $sources['url'] );
return str_replace( "wp-content/uploads/D:homesitewwwroot/wp-content/uploads", $container, $newpath );
dougvdotcom / windows-azure-storage.php
Last active Oct 15, 2018
WordPress plugin to fix responsive images, credit Project Nami. Adapted to conform to WordPress coding standards.
View windows-azure-storage.php
Plugin Name: Azure WordPress Storage Responsive Images Fix
Plugin URI:
Description: Corrects srcset URLs for responsive images in a Scalable WordPress install running on Microsoft Azure.
Author: Project Nami / Doug Vanderweide
Version: 0.1
Author URI:
License: GNU GPL 2
dougvdotcom / php_form_validate.php
Last active Apr 29, 2016
Simple server-side validation routine for most PHP forms
View php_form_validate.php
Handling PHP Form Postbacks: Same-Page Validation
Copyright (C) 2016 Doug Vanderweide
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
dougvdotcom / transients-complex-queries.php
Created May 14, 2016
WordPress Transients API: Cache complex queries, especially those that are used in several locations
View transients-complex-queries.php
function create_pulldown_transient() {
//movies picker
$output = '';
$output = '<!-- transient created ' . date( 'r' ) . ' -->';
$output .= '<select id="mt-movies-select" class="mt-movies-jump">';
$output .= '<option value="">Pick a movie ...</option>';
$movies = get_posts(
dougvdotcom / transients-api-selective-cache.php
Created May 14, 2016
WordPress Transients API, code to expire parts of a web page cache at different times
View transients-api-selective-cache.php
//get all asides that are in the category music-gigs
if( false === ( $output = get_transient( 'my-gig-asides-list' ) ) ) {
//rebuild transient
$gigs = new WP_Query( array(
'post_status' => 'publish',
'posts_per_page' => 10,
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(