Skip to content

Instantly share code, notes, and snippets.

Avatar

Doug Vanderweide dougvdotcom

View GitHub Profile
@dougvdotcom
dougvdotcom / AzureBatchSetCacheControl.cs
Last active Sep 10, 2016
Loops through all containers and blobs in an Azure Storage account; sets cache-control header on all public CloudBlockBlob objects found.
View AzureBatchSetCacheControl.cs
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using System;
namespace AzureCDN
{
class Program
{
static void Main()
{
View php_js_calc.php
<?
if(isset($_POST['submit'])) {
//correct the following code for your DB server / Db
//and uncomment the connection code block below
/*
$host = "localhost";
$user = "db_user_name";
$pass = "db_user_password";
$dbname = "database_name";
@dougvdotcom
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
dougvdotcom / iframe-thumbnail.html
Created Dec 6, 2017
Showing A Larger Image OnClick With JavaScript / DOM Example 2: With IFramed Thumbnails
View iframe-thumbnail.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
Showing A Larger Image From A Thumbnail OnClick Via JavaScript / DOM Revisited
Copyright 2008 Doug Vanderweide, dba Rescue-ME
http://www.dougv.com
Distributed under the Creative Commons Attribution / Share-Alike 2.5 License
http://creativecommons.org/licenses/by-sa/3.0/us/
@dougvdotcom
dougvdotcom / thumbnail.html
Created Dec 6, 2017
Showing A Larger Image OnClick With JavaScript / DOM Example 1: With Thumbnails On Same Page
View thumbnail.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
Showing A Larger Image From A Thumbnail OnClick Via JavaScript / DOM Revisited
Copyright 2008 Doug Vanderweide, dba Rescue-ME
http://www.dougv.com
Distributed under the Creative Commons Attribution / Share-Alike 2.5 License
http://creativecommons.org/licenses/by-sa/3.0/us/
@dougvdotcom
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
<?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(
@dougvdotcom
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
<?php
/*
Plugin Name: Azure WordPress Storage Responsive Images Fix
Plugin URI: http://projectnami.org/fix-for-azure-storage-plugin-and-wp-4-4/
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: https://www.dougv.com/2016/01/fixing-wordpress-4-4-responsive-images-in-azure-scalable-wordpress-installs/
License: GNU GPL 2
*/
@dougvdotcom
dougvdotcom / count_letters_in_string.php
Created Nov 25, 2018
Sometimes, we need to know how many of each character is in a string. This PHP code does just that.
View count_letters_in_string.php
<?
function getLetterCount($input) {
$letters = array();
//make lowercase to simplify counting
$temp = strtolower(trim($input));
//get length of string
$templen = strlen($temp);
@dougvdotcom
dougvdotcom / get_time.php
Created Nov 25, 2018
Scrapes a USNO Web page for the current time
View get_time.php
<?
/*
Syncronizing A Web Page's JavaScript Clock Via AJAX / DOM
Copyright 2007 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.
This program is distributed in the hope that it will be useful,
@dougvdotcom
dougvdotcom / redirect.php
Created Nov 25, 2018
Simple form and PHP to redirect user to a new webpage on form postback
View redirect.php
<?
if(isset($_POST['submit'])) {
$loc = "Location: " . $_POST['newPage'];
header($loc);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
Going To A New URL Via A Drop-Down List: JavaScript And DOM, PHP, ASP.NET