Skip to content

Instantly share code, notes, and snippets.

Philip Mateescu philipmat

Block or report user

Report or block philipmat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@philipmat
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 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 Dec 9, 2018
say command in Powershell
View say.ps1
[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 Feb 22, 2018
Code Snippets for C#
View ilog.snippet
<?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>
@philipmat
philipmat / ConvertTo-Base64.ps1
Last active Aug 20, 2019
ConvertTo-Base64 - Powershell script
View ConvertTo-Base64.ps1
<#
.SYNOPSIS
Converts a file to BASE64 encoding and displays the encoded content.
.PARAMETER InputFile
The file to be converted to Base64. Displays the encoded string to output (see -ToJson)
.PARAMETER 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
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
philipmat / MyExtensions.cs
Created Jul 26, 2017
LINQPad Extension Methods
View MyExtensions.cs
public static class MyExtensions
{
// Write custom extension methods here. They will be available to all queries.
public static void ShowSqlPrint(this System.Data.Common.DbConnection thisConnection)
{
((System.Data.SqlClient.SqlConnection)thisConnection).InfoMessage += (object obj, SqlInfoMessageEventArgs e) =>
{
if (e.Message.Length < 2000) string.Format("\u2192 {0}", e.Message).Dump(); //\u03FE\u03FF
else e.Message.Length.Dump("Message too long");
};
@philipmat
philipmat / String Concat.cs
Created Jul 26, 2017
Speed of String Concatenation
View String Concat.cs
var s1 = string.Empty;
var s2 = new List<string>();
var s3 = new System.Text.StringBuilder();
var sw = new Stopwatch();
const string Message = "Hello I am string number {0}";
sw.Restart();
for (int i = 0; i < 30; i++) {
s1 += string.Format(Message, i) + "\n";
@philipmat
philipmat / dropfk.sql
Created Jul 26, 2017
MSSQL - Drop FK
View dropfk.sql
SET NOCOUNT ON
GO
DECLARE Fkeys CURSOR FOR
SELECT 'ALTER TABLE ' + TABLE_SCHEMA + '.[' + TABLE_NAME + '] DROP CONSTRAINT [' + CONSTRAINT_NAME + ']'
FROM information_schema.table_constraints
WHERE CONSTRAINT_TYPE = 'FOREIGN KEY'
OPEN Fkeys
@philipmat
philipmat / Routing.linq
Last active Jul 22, 2017
Simple Message Routing: Static vs Dynamic
View Routing.linq
<Query Kind="Program">
<NuGetReference>Autofac</NuGetReference>
<Namespace>Autofac</Namespace>
</Query>
void Main()
{
var facker = Configure();
// example 1
You can’t perform that action at this time.