Skip to content

Instantly share code, notes, and snippets.

@atifaziz
atifaziz / Export-ExcelProject.ps1
Last active Jun 9, 2021
PowerShell script to export VBA project components (classes, modules, etc.) from an Excel workbook
View Export-ExcelProject.ps1
# 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 / WebQueryModule.bas
Created Jun 30, 2016
Excel VBA macro to disable background refresh on all web queries
View WebQueryModule.bas
Sub DisableBackgroundRefreshOnAllWebQueries()
Dim Worksheet As Worksheet
For Each Worksheet In ActiveWorkbook.Worksheets
Dim QueryTable As QueryTable
For Each QueryTable In Worksheet.QueryTables
If 0 = StrComp(Left(QueryTable.Connection, 4), "URL;", vbTextCompare) _
And QueryTable.BackgroundQuery Then
Debug.Print QueryTable.Connection
QueryTable.BackgroundQuery = False
@atifaziz
atifaziz / TaskWhenAll.cs
Last active May 29, 2021
Implementation of Task.WhenAll in C# and F#
View TaskWhenAll.cs
// http://msdn.microsoft.com/en-us/library/system.threading.tasks.task.whenall.aspx
using System;
using System.Threading;
using System.Threading.Tasks;
static class TaskExtensions
{
public static Task<T[]> WhenAll<T>(this Task<T>[] tasks)
{
@atifaziz
atifaziz / Unprotect-ProtectedData.ps1
Created Mar 31, 2017
Decrypting DPAPI-protected Base64 data from PowerShell
View Unprotect-ProtectedData.ps1
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 / json.vbs
Last active May 15, 2021
JSON Encoder for VBScript
View json.vbs
'==========================================================================
' JSON Encoder for VBScript
' Copyright (c) 2013 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
'
@atifaziz
atifaziz / BuildNeuralNetworkDemo.cs
Last active Apr 27, 2021
Neural Network Demo with C# by James McCaffrey, MSR and Build 2013 versions
View BuildNeuralNetworkDemo.cs
// 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 / XMLModule.bas
Created Feb 13, 2014
XML pretty printing in VBA
View XMLModule.bas
Function PrettyXML(ByVal Source, Optional ByVal EmitXMLDeclaration As Boolean) As String
Dim Writer As MXXMLWriter, Reader As SAXXMLReader
Set Writer = New MXXMLWriter
Writer.indent = True
Writer.omitXMLDeclaration = Not EmitXMLDeclaration
Set Reader = New SAXXMLReader
Set Reader.contentHandler = Writer
Reader.Parse Source
PrettyXML = Writer.Output
@atifaziz
atifaziz / VisualCron.ps1
Last active Apr 22, 2021
PowerShell scripts for VisualCron
View VisualCron.ps1
# 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 / Get-ProcessTree.ps1
Last active Apr 12, 2021
PowerShell 2.0 script to get processes tree
View Get-ProcessTree.ps1
# 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 / .gitconfig
Last active Mar 25, 2021
My Git aliases
View .gitconfig
[alias]
aliases = config --get-regexp ^alias\\.
last = log -1 HEAD
ls = log --decorate --pretty=format:%Cgreen%h%Cred%d%Creset\\ %s\\ [%an]
ll = log --pretty=fuller
st = status
diffc = diff --cached
ci = commit
cia = commit --amend
mff = merge --ff-only