Skip to content

Instantly share code, notes, and snippets.


Philip Mateescu philipmat

View GitHub Profile
philipmat / IAmUpResponder.cs
Created Sep 11, 2020
Socket responder - Listens on a socket for incoming connections and responds with "I Am Up" html.
View IAmUpResponder.cs
void Main()
/// <summary>
/// Listens on a socket for incoming connections and responds with "I Am Up" html.
/// </summary>
/// <remarks>
/// Inspired by:
philipmat / HttpListener.cs
Created Sep 11, 2020
HTTP Listener - creates a netcat-like listener on a local port. Returns 201 to all requests
View HttpListener.cs
void Main() {
var cts = new CancellationTokenSource();
var task = StartListener(cts.Token);
do {
} while (true);
philipmat / Create LocalDB Databases.linq
Created Sep 11, 2020
Create or Attach SQL Database (for LocalDB) - LINQPad script
View Create LocalDB Databases.linq
<Query Kind="Statements">
// Example:
philipmat / console.log
Created Feb 15, 2019
Visual Studio Code macOS freeze
View console.log
[main 2019-02-15T22:37:18.094Z] Starting VS Code
[main 2019-02-15T22:37:18.095Z] from: /Users/af59986/Applications/Visual Studio
[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 / say.ps1
Last active Dec 9, 2018
say command in Powershell
View say.ps1
[Parameter(Position = 1, Mandatory = $true)]
Add-Type -AssemblyName System.Speech
$synth = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
philipmat / ilog.snippet
Created Feb 22, 2018
Code Snippets for C#
View ilog.snippet
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="">
<CodeSnippet Format="1.0.0">
<Description>Generates a private field to hold a Common.Logging.ILog</Description>
<Author>Philip Mateescu</Author>
philipmat / ConvertTo-Base64.ps1
Last active Nov 17, 2020
ConvertTo-Base64 - Powershell script
View ConvertTo-Base64.ps1
Converts a file to BASE64 encoding and displays the encoded content.
The file to be converted to Base64. Displays the encoded string to output (see -ToJson)
Instead of displaying the raw Base64, it outputs a JSON-formatted object.
View Exported-2017-12-27.vssettings
<UserSettings><ApplicationIdentity version="15.0"/><ToolsOptions><ToolsOptionsCategory name="Environment" RegisteredName="Environment"><ToolsOptionsSubCategory name="Documents" RegisteredName="Documents" PackageName="Visual Studio Environment Package"><PropertyValue name="ShowMiscFilesProject">false</PropertyValue><PropertyValue name="AutoloadExternalChanges">true</PropertyValue><PropertyValue name="CheckForConsistentLineEndings">true</PropertyValue><PropertyValue name="SaveDocsAsUnicodeWhenDataLoss">false</PropertyValue><PropertyValue name="InitializeOpenFileFromCurrentDocument">true</PropertyValue><PropertyValue name="ReuseSavedActiveDocWindow">false</PropertyValue><PropertyValue name="DetectFileChangesOutsideIDE">true</PropertyValue><PropertyValue name="DontShowGlobalUndoChangeLossDialog">true</PropertyValue><PropertyValue name="AllowEditingReadOnlyFiles">true</PropertyValue><PropertyValue name="DocumentDockPreference">0</PropertyValue><PropertyValue name="MiscFilesProjectSavesLastNItems">0</PropertyValue>
philipmat / Update-File.ps1
Last active Aug 21, 2017
Unix `touch` in Powershell
View Update-File.ps1
Function Update-File
$Usage = "Usage: Update-File [file1 ... fileN]";
# if no arguments, display an error
if ($args.Count -eq 0) {
throw $Usage;
# see if any arguments match -h[elp] or --h[elp]
foreach($file in $args) {
if ($file -ilike "-h*" -or $file -ilike "--h*") {
philipmat / MyExtensions.cs
Last active Sep 11, 2020
LINQPad Extension Methods
View MyExtensions.cs
// requires:
// Newtonsoft.Json
// System.Data.SqlClient
void Main() {
// Write code to test your extensions here. Press F5 to compile and run.
public static class MyExtensions {
public static void ShowSqlPrint(this System.Data.Common.DbConnection thisConnection) {
((System.Data.SqlClient.SqlConnection)thisConnection).InfoMessage += (object obj, SqlInfoMessageEventArgs e) => {
You can’t perform that action at this time.