Skip to content

Instantly share code, notes, and snippets.

@spencermorin
spencermorin / move-wp-multisite.sql
Created June 28, 2013 20:40
Move Project Nami ( or WordPress ) multisite install to a new domain.
update wp_options set option_value='http://example.com' where option_name = 'siteurl' or option_name = 'home'
update wp_blogs set domain='example.com' where blog_id = '1' or blog_id = '2'
update wp_2_options set option_value='http://example.com/second-blog-path' where option_name='siteurl' or option_name='home'
update wp_site set domain='example.com' where id='1'
update wp_sitemeta set meta_value='http://example.com' where meta_key='siteurl'
@vdavez
vdavez / docx2md.md
Last active April 21, 2024 20:05
Convert a Word Document into MD

Converting a Word Document to Markdown in Two Moves

The Problem

A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.

The Solution

As it turns out, there are several open-source tools that allow for conversion between file types. Pandoc is one of them, and it's powerful. In fact, pandoc's website says "If you need to convert files from one markup format into another, pandoc is your swiss-army knife." But, although pandoc can convert from markdown into .docx, it doesn't work in the other direction.

@vgrem
vgrem / SPOUpload-Files.ps1
Last active December 3, 2023 04:09
Upload files into Document Library in SharePoint Online
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Function Ensure-Folder()
{
Param(
[Parameter(Mandatory=$True)]
[Microsoft.SharePoint.Client.Web]$Web,
@jokecamp
jokecamp / gist:2c1a67b8f277797ecdb3
Last active January 31, 2024 01:48
Powershell HMAC SHA 256 Example
# Powershell HMAC SHA 256
$message = 'Message'
$secret = 'secret'
$hmacsha = New-Object System.Security.Cryptography.HMACSHA256
$hmacsha.key = [Text.Encoding]::ASCII.GetBytes($secret)
$signature = $hmacsha.ComputeHash([Text.Encoding]::ASCII.GetBytes($message))
$signature = [Convert]::ToBase64String($signature)
@proxb
proxb / Example1Runspace.ps1
Created August 10, 2015 00:50
Example 1 of returning data back from a runspace
# Create an array of computers to do work against
$Computers = “computer01”,”computer02”,”computer03”,”computer04”,”computer05”
# Create an empty array that we'll use later
$RunspaceCollection = @()
# This is the array we want to ultimately add our information to
[Collections.Arraylist]$qwinstaResults = @()
# Create a Runspace Pool with a minimum and maximum number of run spaces. (http://msdn.microsoft.com/en-us/library/windows/desktop/dd324626(v=vs.85).aspx)
@proxb
proxb / Example2Runspace.ps1
Created August 10, 2015 00:58
Example 2 showing synchronized collections
# Create an array of computers to do work against
$Computers = “computer01”,”computer02”,”computer03”,”computer04”,”computer05”
# Create an empty array that we'll use later
$RunspaceCollection = @()
# This is the array we want to ultimately add our information to
$qwinstaResults = [System.Collections.ArrayList]::Synchronized((New-Object System.Collections.ArrayList))
# Create a Runspace Pool with a minimum and maximum number of run spaces. (http://msdn.microsoft.com/en-us/library/windows/desktop/dd324626(v=vs.85).aspx)
@dieseltravis
dieseltravis / PS-BGInfo.ps1
Last active April 23, 2024 15:16
update wallpaper background image with powershell (like Sysinternals BGInfo)
# PS-BGInfo
# Powershell script that updates the background image with a random image from a folder and writes out system info text to it.
# run as a lower priority task
[System.Threading.Thread]::CurrentThread.Priority = 'BelowNormal'
# Configuration:
# Font Family name
$font="Input"
<#
.SYNOPSIS
Sets the system fields for a specific list/library item.
.DESCRIPTION
This will set the system fields (created, created by, modified, modified by)
for a specific list/library item.
Provide any or all of those system fields as a parameter and they will be set.
If no modified date is provided, the item keeps its current modified date.
@jdhitsolutions
jdhitsolutions / Test-UpOrDown.ps1
Last active November 13, 2020 18:05
A PowerShell function that uses the web site DownForEveryoneOrJustme.com to test is a web site or domain is up or down
#requires -version 4.0
Function Test-UporDown {
<#
.Synopsis
Test if a web site is down or if it is just you.
.Description
The function uses the web site DownForEveryoneOrJustme.com to test is a web site or domain is up or down, or if the problem is just you. The command will write a custom object to the pipeline. See examples.
@daviwil
daviwil / VSCodeDeepDive.md
Created April 13, 2017 13:38
The notes from my session "Authoring in VS Code" at the 2017 PowerShell and DevOps Global Summit in Bellevue, WA.

Visual Studio Code Deep Dive

David Wilson - @daviwil Software Engineer, PowerShell Team

Overview

  1. Visual Studio Code overview
  2. Configuring the editor
  3. Extensions