Skip to content

Instantly share code, notes, and snippets.

@atifaziz
atifaziz / InteractiveT.cs
Last active June 13, 2024 12:23
Interact Monad, derived from https://fssnip.net/8ay (Interactive computation that asks the user questions)
// Interact Monad, derived from https://fssnip.net/8ay (by Tomas Petricek)
// Interactive computation that asks the user questions
using System;
using System.Diagnostics;
using System.Linq;
static Interactive<Color> GetColor() => new WhatColor<Color>(Interactive.Return);
static Interactive<int> GetNumber() => new WhatNumber<int>(Interactive.Return);
@atifaziz
atifaziz / Export-ExcelProject.ps1
Last active June 7, 2024 22:52
PowerShell script to export VBA project components (classes, modules, etc.) from an Excel workbook
# Copyright (c) 2014 Atif Aziz. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@atifaziz
atifaziz / Unprotect-ProtectedData.ps1
Created March 31, 2017 06:25
Decrypting DPAPI-protected Base64 data from PowerShell
Add-Type -AssemblyName System.Security;
[Text.Encoding]::ASCII.GetString([Security.Cryptography.ProtectedData]::Unprotect([Convert]::FromBase64String((type -raw (Join-Path $env:USERPROFILE foobar))), $null, 'CurrentUser'))
@atifaziz
atifaziz / md5.cs
Created December 24, 2012 10:37
C# program to compute MD5 hash of files specified as command-line arguments
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
static class Program
{
static void Run(IEnumerable<string> args)
@atifaziz
atifaziz / GrepWinVisualStudioIntegration.md
Last active April 6, 2024 02:50
Integrating grepWin into Visual Studio

Integrating grepWin into Visual Studio

The simplest way to integrate [grepWin][grepwin] into Visual Studio is to [add it as an external tool][vsextern]. If you [assign it a keyboard shortcut][kbshortcut] then, well, you've got grepWin at your fingertips and getting to it becomes super fast without needing to resort to the silly old mouse! 🐭

However, simply launching grepWin from within Visual Studio means you still need to provide the starting search path. Ideally you can get grepWin to use the project or solution path automatically. Looking into the extended

@atifaziz
atifaziz / StaTask.cs
Created March 24, 2024 09:51
STA thread as an awaitable task
// Author: Atif Aziz
// License: This code is released by "Author" into the public domain.
using System;
using System.Threading;
using System.Threading.Tasks;
static partial class StaTask
{
public static Task RunAsync(Action action) =>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
@atifaziz
atifaziz / BuildNeuralNetworkDemo.cs
Last active November 9, 2023 19:59
Neural Network Demo with C# by James McCaffrey, MSR and Build 2013 versions
// http://channel9.msdn.com/Events/Build/2013/2-401
// http://www.quaetrix.com/Build2013.html
using System;
// For 2013 Microsoft Build Conference attendees
// June 25-28, 2013
// San Francisco, CA
//
// This is source for a C# console application.
@atifaziz
atifaziz / help.md
Last active November 5, 2023 12:20
Windows 10 Command Prompt HELP
Command Description
ASSOC Displays or modifies file extension associations.
ATTRIB Displays or changes file attributes.
BREAK Sets or clears extended CTRL+C checking.
BCDEDIT Sets properties in boot database to control boot loading.
CACLS Displays or modifies access control lists (ACLs) of files.
CALL Calls one batch program from another.
CD Displays the name of or changes the current directory.
CHCP Displays or sets the active code page number.