Skip to content

Instantly share code, notes, and snippets.

View mkropat's full-sized avatar
📚
Learning

Michael Kropat mkropat

📚
Learning
View GitHub Profile
<Query Kind="Program">
<Reference>&lt;RuntimeDirectory&gt;\System.Messaging.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.DirectoryServices.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Configuration.Install.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Windows.Forms.dll</Reference>
<Namespace>System.Messaging</Namespace>
</Query>
void Main()
{
function Get-StartProgram {
param([IO.FileInfo] $CsprojFile)
[xml]$projectXml = Get-Content $CsprojFile.FullName
$ns = @{ defaultNamespace = "http://schemas.microsoft.com/developer/msbuild/2003" }
$configuration = $projectXml |
Select-Xml '//defaultNamespace:PropertyGroup/defaultNamespace:Configuration' -Namespace $ns |
select -ExpandProperty Node |
where { $_.Condition -and $_.Condition.Trim() -eq "'`$(Configuration)' == ''" } |
# SplitFile.ps1 - Split large files for use with Kiwix
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$Path,
[int] $ChunkSizeMb = 1024
)
public class ArtificialStackTraceException : Exception
{
public ArtificialStackTraceException(
bool shouldIncludeFileInfo = true,
string message = "Artificial exception used to generate a stack trace."
) : base(message)
{
var stackTrace = new System.Diagnostics.StackTrace(shouldIncludeFileInfo);
StackTrace = stackTrace.ToString();
}
cinst -y 7zip
cinst -7 googlechrome
@mkropat
mkropat / require.js
Last active September 9, 2017 01:53
// Simple wrapper for the https://wzrd.in/ service so you can experiment with
// npm modules in the browser dev console
function require(moduleName, version) {
version = version || 'latest';
let oldExports = window.exports;
window.exports = {};
let oldModule = window.module;
window.module = {
exports: exports,
public class ProjectionEqualityComparer
{
public static IEqualityComparer<T> Create<T, TProperty>(Func<T, TProperty> projection, IEqualityComparer<TProperty> propertyComparer = null)
where T: class
{
return new ProjectionEqualityComparer<T, TProperty>(projection, propertyComparer);
}
}
public class ProjectionEqualityComparer<T,TProperty> : IEqualityComparer<T> where T: class
^!r::Reload
RunOrRaise(caption) {
r := ComObjGet("winmgmts:")
.ExecQuery("SELECT Handle FROM Win32_Process WHERE Caption='" . caption . "'")
If r._NewEnum()[proc]
{
;WinGet, windows, list
;Loop, %windows%
function Get-DateRange {
param(
[Parameter(Mandatory = $true)]
[ValidateNotNull()]
[datetime] $StartDate,
$EndDate,
[timespan] $Duration,
[ValidateNotNull()]