Skip to content

Instantly share code, notes, and snippets.

View surgicalcoder's full-sized avatar

surgicalcoder

  • United Kingdom
View GitHub Profile
@surgicalcoder
surgicalcoder / Program.cs
Created December 25, 2015 21:03 — forked from DanielSWolf/Program.cs
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Threading;
static class Program {
static void Main() {
Console.Write("Performing some task... ");
using (var progress = new ProgressBar()) {
for (int i = 0; i <= 100; i++) {
progress.Report((double) i / 100);
@surgicalcoder
surgicalcoder / gist:644403f4a1b7eb1c09dd
Created October 15, 2015 10:06
Azure Data Movement API
Import Microsoft.Azure.Storage.DataMovement and all dependencies from Nuget, then have this:
private static void Download()
{
ServicePointManager.DefaultConnectionLimit = Environment.ProcessorCount * 8;
ServicePointManager.Expect100Continue = false;
string storageConnectionString = "DefaultEndpointsProtocol=https;AccountName=elatuse2mtrsprodsql;AccountKey=5LJ7KqzdaQlatfXcMMdJe0xw9jadzYR7VLo37GgMclaFZn5mwV58qszm9Azta5dfwJ5SJXPHKfuKsiIRAm/UyA==;";
@surgicalcoder
surgicalcoder / gist:975d6221bf7d7414a844
Created September 4, 2015 13:34
Automagically run windows updates.
I'm using nlog for my logger, and you need to add a reference to WUApiLib. You need a way to handle multiple reboots to do updates (which is what our custom StepResult bits do)
private static Logger logger = LogManager.GetCurrentClassLogger();
public StepResult PerformAction()
{
UpdateSession session = new UpdateSession();
ISearchResult uResult;