Skip to content

Instantly share code, notes, and snippets.

@SteveGilham
SteveGilham / spotlight.ps1
Created June 24, 2020 09:20
Copying windows spotlight images
# where the images are
$assets = Join-path $env:userprofile "AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets"
# regularly refreshed screen images are recent
$weeks = new-object system.timespan (14,0,0,0)
# copy those files locally and apply '.jpg'
dir $assets | ? { $_.LastWriteTime -gt ([datetime]::now - $weeks) } | % { copy $_.FullName "$($_.Name).jpg" }
(*
.SYNOPSIS
This script estimates cyclomatic complexities over a folder full of assemblies.
.DESCRIPTION
It loads the assemblies, and then introspects over each method, estimating the
complexity as number of branch instructions which do not target the next instruction
and which have a unique target instruction.
.NOTES
(*
.SYNOPSIS
This script estimates cyclomatic complexities over a folder full of assemblies.
.DESCRIPTION
It loads the assemblies, and then introspects over each method, estimating the
complexity as number of branch instructions which do not target the next instruction
and which have a unique target instruction.
.NOTES
@SteveGilham
SteveGilham / fhould.fs
Created June 18, 2019 16:26
Should wrapper for F#
namespace Tinesware.FSharp
open System
open System.Collections.Generic
open Should
module fhould =
let inline (|->) x y =
ObjectAssertExtensions.ShouldBeGreaterThan(x, y)
@SteveGilham
SteveGilham / Obsolete.log
Last active December 8, 2018 20:22
This is what happens to a record with an [<Obsolete>] field
{ Wanted = String.Empty
----^
stdin(8,5): warning FS0044: This construct is deprecated. Use 'Wanted' instead
{ Wanted = String.Empty
----^
@SteveGilham
SteveGilham / obsolete.fsx
Last active December 8, 2018 20:21
What happens to a record with an [<Obsolete>] field?
open System
type R =
{ Wanted : String
[<Obsolete("Use 'Wanted' instead")>]
Unwanted : String }
static member Create () =
{ Wanted = String.Empty
Unwanted = String.Empty }
@SteveGilham
SteveGilham / Messages.resx
Created May 19, 2018 07:06
a more complex cmdlet in C++/CLI -- resources
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
@SteveGilham
SteveGilham / TouchFileCommand.cpp
Created May 19, 2018 07:04
a more complex cmdlet in C++/CLI -- source file
#include "TouchFileCommand.h"
namespace PSBook { namespace Commands
{
SetFileTouchTimeCommand::SetFileTouchTimeCommand(void)
{
Date = DateTime::Now;
rm = gcnew Resources::ResourceManager(L"PowershellCpp.Messages", GetType()->Assembly);
}
@SteveGilham
SteveGilham / TouchFileCommand.h
Created May 19, 2018 07:02
a more complex cmdlet in C++/CLI -- header file
#pragma once
using namespace System;
using namespace System::IO;
using namespace System::Management::Automation;
namespace PSBook { namespace Commands
{
[Cmdlet(VerbsCommon::Set, "FileTouchTime", DefaultParameterSetName = "Path", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact::Medium)]
public ref class SetFileTouchTimeCommand :
public PSCmdlet
@SteveGilham
SteveGilham / SnapInPP.cpp
Created May 19, 2018 07:00
simple cmdlet in C++/CLI
using namespace System;
using namespace System::Management::Automation;
using namespace System::ComponentModel;
namespace PSBook { namespace Commands
{
[RunInstaller(true)]
public ref class PSBookChapter2MySnapIn : PSSnapIn
{
public: