Skip to content

Instantly share code, notes, and snippets.

View lawrencegripper's full-sized avatar

Lawrence Gripper lawrencegripper

View GitHub Profile
@lawrencegripper
lawrencegripper / gist:9303955
Last active August 29, 2015 13:56
Parallel Azure VM Script
$vms = Get-azurevm | ?{ $_.Status -eq "StoppedDeallocated"}
$jobs = @()
foreach ($vm in $vms)
{
$params = @($vm.Name, $vm.ServiceName)
$job = Start-Job -ScriptBlock {
param($ComputerName, $ServiceName)
start-Azurevm -Name $ComputerName -ServiceName $ServiceName
} -ArgumentList $params
$jobs = $jobs + $job
@lawrencegripper
lawrencegripper / binding.xaml
Last active January 12, 2016 23:54
Setup infinite scrolling for windows store with gridview
<GridView Grid.Row="1" ItemsSource="{Binding Popular}" />
@lawrencegripper
lawrencegripper / CacheFactoryWrapper.cs
Last active October 11, 2015 09:58
Azure Cache from Cloud Config
/// <summary>
        /// Wrapper for the cache factory to create a DataCache from Authentication token and discovery url
        /// </summary>
        /// <param name="token"></param>
        /// <param name="discoveryurl"></param>
        /// <returns></returns>
        private DataCache CacheFactoryWrapper(string token, string discoveryurl)
        {
            DataCacheFactoryConfiguration config = new DataCacheFactoryConfiguration();
            config.AutoDiscoverProperty = new DataCacheAutoDiscoverProperty(true, discoveryurl);
@lawrencegripper
lawrencegripper / SimpleIISDSC.ps1
Created September 19, 2014 15:30
Chocolatey, PowerShell DSC and Azure IAAS - Automating dev box creation
configuration IISInstall
{
node ("localhost")
{
WindowsFeature IIS
{
Ensure = "Present"
Name = "Web-Server"
}
}
configuration IISInstall
{
node ("localhost")
{
WindowsFeature IIS
{
Ensure = "Present"
Name = "Web-Server"
}
}
@lawrencegripper
lawrencegripper / WaitForSessions.ps1
Last active May 25, 2021 09:50
IISGraceFullSessionMonitor
#Get the open requests being handled by IIS
$req = Get-WebRequest
while ($req.Count -gt 0)
{
#Wait if there are some
Write-Host "Waiting for request, current inflight: " $req.Count
Start-Sleep -Seconds 2
#Check again for sessions
$req = Get-WebRequest
@lawrencegripper
lawrencegripper / newMachineDsc.ps1
Last active August 29, 2015 14:16
Machine Install DSC
Configuration myChocoConfig
{
$PackagesToInstall = @('foxitreader','spotify', 'git');
Import-DscResource -Module cChoco
Node "localhost"
{
cChocoInstaller installChoco
@lawrencegripper
lawrencegripper / DemoUsage.cs
Last active August 29, 2015 14:21
Microsoft Band Wrapper to Stream sensor data to Reactive Extensions
var bandHelper = new BandReativeExtensionsWrapper();
stream = await bandHelper.GetHeartRateStream();
var hrSubscription = stream
.Buffer(new TimeSpan(0, 0, 10))
.Select(x =>
{
var avg = x.Average(y => y.SensorReading.HeartRate);
return avg;
@lawrencegripper
lawrencegripper / invokeWithCookie.ps1
Last active January 18, 2024 06:34
Invoke-webrequest With Cookie
$downloadToPath = "c:\somewhere\on\disk\file.zip"
$remoteFileLocation = "http://somewhere/on/the/internet"
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$cookie = New-Object System.Net.Cookie
$cookie.Name = "cookieName"
$cookie.Value = "valueOfCookie"
@lawrencegripper
lawrencegripper / BandAccessWrapper.cs
Created May 29, 2015 13:32
Detecting Taps or Shakes on Microsoft Band
using Microsoft.Band;
using Microsoft.Band.Sensors;
using Microsoft.Band.Tiles;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Popups;