Skip to content

Instantly share code, notes, and snippets.

View philipmat's full-sized avatar

Philip Mateescu philipmat

View GitHub Profile
@philipmat
philipmat / Program.cs
Last active October 10, 2023 18:22
DotNet LongTimePattern
Console.WriteLine($".NET Version={Environment.Version}");
Console.WriteLine($"OS={System.Runtime.InteropServices.RuntimeInformation.OSDescription}");
Console.WriteLine($"Long Time Pattern={new System.Globalization.CultureInfo("en-US").DateTimeFormat.LongTimePattern}");
// This file was initially generated by Windows Terminal 1.1.2233.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@philipmat
philipmat / FindFileLockingProcess.ps1
Created July 2, 2021 13:04
Finds process that locks a given file
[cmdletbinding()]
param(
[Parameter(Position=1, Mandatory = $true)] # Position = 1 allow passing without specifying -FileOrFolderPath
[String] $FileOrFolderPath
)
If((Test-Path -Path $FileOrFolderPath) -eq $false) {
Write-Warning "File or directory does not exist."
}
Else {
@philipmat
philipmat / DetermineNetframeworkVersion.ps1
Created July 2, 2021 13:03
Lists all available .NET Framework versions
<#
The sample scripts are not supported under any Microsoft standard support
program or service. The sample scripts are provided AS IS without warranty
of any kind. Microsoft further disclaims all implied warranties including,
without limitation, any implied warranties of merchantability or of fitness for
a particular purpose. The entire risk arising out of the use or performance of
the sample scripts and documentation remains with you. In no event shall
Microsoft, its authors, or anyone else involved in the creation, production, or
delivery of the scripts be liable for any damages whatsoever (including,
without limitation, damages for loss of business profits, business interruption,
@philipmat
philipmat / IAmUpResponder.cs
Created September 11, 2020 14:43
Socket responder - Listens on a socket for incoming connections and responds with "I Am Up" html.
void Main()
{
IamupResponder.StartListening();
return;
}
/// <summary>
/// Listens on a socket for incoming connections and responds with "I Am Up" html.
/// </summary>
/// <remarks>
/// Inspired by:
@philipmat
philipmat / HttpListener.cs
Created September 11, 2020 14:41
HTTP Listener - creates a netcat-like listener on a local port. Returns 201 to all requests
void Main() {
var cts = new CancellationTokenSource();
var task = StartListener(cts.Token);
do {
Thread.Sleep(1);
} while (true);
cts.Cancel();
@philipmat
philipmat / Create LocalDB Databases.linq
Created September 11, 2020 14:32
Create or Attach SQL Database (for LocalDB) - LINQPad script
<Query Kind="Statements">
<Connection>
<ID>3a5c9133-61a0-4989-b34a-b0b4b3967c7f</ID>
<Persist>true</Persist>
<Server>(localdb)\localdev</Server>
<Database>master</Database>
</Connection>
</Query>
// Example:
@philipmat
philipmat / console.log
Created February 15, 2019 22:41
Visual Studio Code macOS freeze
[main 2019-02-15T22:37:18.094Z] Starting VS Code
[main 2019-02-15T22:37:18.095Z] from: /Users/af59986/Applications/Visual Studio Code.app/Contents/Resources/app
[main 2019-02-15T22:37:18.095Z] args: { _: [],
diff: false,
add: false,
goto: false,
'new-window': false,
'reuse-window': false,
wait: false,
version: false,
@philipmat
philipmat / say.ps1
Last active December 9, 2018 00:51
say command in Powershell
[cmdletbinding()]
param(
[Parameter(Position = 1, Mandatory = $true)]
[String]
$message
)
Add-Type -AssemblyName System.Speech
$synth = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$synth.Speak($message)
@philipmat
philipmat / ilog.snippet
Created February 22, 2018 13:56
Code Snippets for C#
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>ilog</Title>
<Shortcut>ilog</Shortcut>
<Description>Generates a private field to hold a Common.Logging.ILog</Description>
<Author>Philip Mateescu</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>