Skip to content

Instantly share code, notes, and snippets.

View StreamReaderExtension.cs
using System.IO;
using System.Text;
public static class StreamExtensions
{
public static string ToEncodedString(this Stream stream, Encoding enc = null)
{
enc = enc ?? Encoding.UTF8;
byte[] bytes = new byte[stream.Length];
View Get-LockScreenImages.ps1
$imagePath = "$home\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets\*"
$destinationPath = "$home\OneDrive\Pictures\Lock screen"
Add-Type -AssemblyName System.Drawing
# get images from lock screen folder
$items = Get-ChildItem -Path $imagePath
foreach($item in $items) {
$fileName = $item.Name
View Sapper TypeScript Sass template.md

Get up and running with Sapper/Svelte, TypeScript and Sass

Clone the template into the current (empty) directory with 'degit'

npx degit zplume/sapper-rollup-sass-typescript

Install npm dependencies

View ObjectToQueryString.js
function objectToQueryString(paramsObject) {
return Object.keys(paramsObject).reduce((accumulator, currentKey) => {
const prefix = accumulator === "" ? "?" : "&";
return `${accumulator}${prefix}${currentKey}=${encodeURIComponent(paramsObject[currentKey])}`;
}, "");
}
View Get-NpmAudit.ps1
param(
[Parameter(Mandatory=$true)]
[string]$Path
)
$ErrorActionPreference = "Stop"
$CurrentLocation = (Get-Location).Path
try {
View DurableOrchestrationContextExtensions.cs
using Microsoft.Azure.WebJobs;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace LS.DurableFunctions.Examples
{
public static class DurableOrchestrationContextExtensions
{
/// <summary>
@zplume
zplume / CsvHelperExample.cs
Last active May 29, 2019 14:09
Example of using CsvHelper to write a CSV file (up to 10MB in size) to SharePoint Online
View CsvHelperExample.cs
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using OfficeDevPnP.Core;
using Microsoft.SharePoint.Client;
using System.IO;
using CsvHelper;
using File = Microsoft.SharePoint.Client.File;
using CsvHelper.Configuration.Attributes;
View GetQueryStrings.js
const queryStrings = window.location.search.substring(1).split("&").reduce((output, item, index) => {
if(item === "")
return output;
const keyValue = item.split("=");
output[decodeURIComponent(keyValue[0])] = keyValue[1] !== undefined ?
decodeURIComponent(keyValue[1]) :
true; // return true for query strings with no value
View Create-MailEnabledSecurityGroups.ps1
param(
# Credentials paramter should be a variable containing the result of Get-Credential
[Parameter(Mandatory = $true)]
[pscredential]$Credentials,
[Parameter(Mandatory = $true)]
[string]$ConfigFile
)
$ErrorActionPreference = "Stop"
@zplume
zplume / FunctionAppMap.ps1
Last active December 16, 2018 22:11
Get-AzureFunctionKeys.ps1 retrieves Azure Function auth. codes for the Functions specified in FunctionAppMap.ps1, using the Azure REST API and user credentials. This script uses Get-AADToken.ps1 (https://gist.github.com/zplume/574e133b43ecf3037473286580ed524e) to retrieve an Azure access token.
View FunctionAppMap.ps1
# Map Function App friendly name to URL
return @{
DEV = @{
"CreateTenderSite" = "https://dev-createtendersite.azurewebsites.net";
"CopyDocuments" = "https://dev-copydocuments.azurewebsites.net";
"Notifications" = "https://dev-notifications.azurewebsites.net";
"PermissionAssignment" = "https://dev-permissions.azurewebsites.net"
};
TEST = @{