Skip to content

Instantly share code, notes, and snippets.

View madd0's full-sized avatar

Mauricio Díaz Orlich madd0

View GitHub Profile
@madd0
madd0 / kusto-null-bins
Created April 21, 2020 13:45
Add "empty" bins to a kusto query
let Start=startofday(ago(2d));
let Stop=startofday(ago(1d));
requests
| where timestamp >= Start and timestamp < Stop
| summarize Count=count() by bin(timestamp, 1h)
| union (
range x from 1 to 1 step 1
| mv-expand timestamp=range(Start, Stop, 1h) to typeof(datetime)
| extend Count = 0
)
@madd0
madd0 / profile.ps1
Created March 24, 2020 08:58
A PowerShell function to easily navigate to a folder within a $BaseDir from anywhere using a dynamic parameter for tab completion. I use it to jump to repos in my `c:\sources` directory.
$BaseDir = "C:\sources"
Function go {
[CmdletBinding()]
param ()
DynamicParam {
# Set the dynamic parameters' name
$ParameterName = 'Repo'
# Create the dictionary

Keybase proof

I hereby claim:

  • I am madd0 on github.
  • I am madd0 (https://keybase.io/madd0) on keybase.
  • I have a public key ASAxL9uKy0Yywt-vSKzucHFvIn7MlzA6UprY6zBEj5fFDgo

To claim this, I am signing this object:

@madd0
madd0 / msbuild-get-date.proj
Created June 7, 2018 10:19 — forked from sayedihashimi/msbuild-get-date.proj
MSBuild how to get a good formatted date
<Project
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="4.0"
DefaultTargets="Demo" >
<Target Name="Demo">
<PropertyGroup>
<CurrentDate>$([System.DateTime]::Now.ToString(yyyyMMdd-mmss))</CurrentDate>
</PropertyGroup>
16-7-19 18:44:01.7|Debug|LanguageSpecification|Checking if report meets language requirements. English
16-7-19 18:44:01.7|Debug|ReleaseRestrictionsSpecification|Checking if release meets restrictions: Bones 11x21 The Jewel in the Crown 720p
16-7-19 18:44:01.8|Debug|ReleaseRestrictionsSpecification|[Bones 11x21 The Jewel in the Crown 720p] No restrictions apply, allowing
16-7-19 18:44:01.8|Debug|QualityAllowedByProfileSpecification|Checking if report meets quality requirements. HDTV-720p v1
16-7-19 18:44:01.8|Debug|MinimumAgeSpecification|Not checking minimum age requirement for non-usenet report
16-7-19 18:44:01.8|Debug|RetentionSpecification|Not checking retention requirement for non-usenet report
16-7-19 18:44:01.9|Debug|UpgradeDiskSpecification|Comparing file quality with report. Existing file is HDTV-720p v1
16-7-19 18:44:01.9|Debug|QualityUpgradableSpecification|existing item has better or equal quality. skipping
16-7-19 18:44:01.9|Debug|DelaySpecification|Profile does not require a waiting period before
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>filehead</Title>
<Author>Mauricio Díaz Orlich</Author>
<Description>

Input Scopes

Default, AlphanumericHalfWidth, AlphanumericFullWidth, Hiragana, KatakanaHalfWidth, KatakanaFullWidth, Hanja, HangulHalfWidth, HangulFullWidth, ChineseHalfWidth, ChineseFullWidth, NativeScript

![Default](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAl8AAACTCAIAAAA/aOusAAA8P0lEQVR4Xux9BXhU19Z2xiczcSIkAQIJobiU4jVKobg7JUiQoC5BI2gSNLi7e5G2aIHS4i6BCBES4j7xTP43c77ON5f+zzXIGj5Y75M7zzmn3GftvfZevkVkYWFhYlQwGPn5+dWrV//222/x8MkygSEWi4uLi0+dOpWRkSGRSP5vNZ7BYDAYDAaDwWAwGAwGg8FgMBgMhuifE3Cp5KZUqrQlWprWoNiQkpyYlBwvvDo5VbIwtyrWFhNRF0syM9Pi3sQIrw72TtY2tsXFVNRF4pxcTXRMhPBqY21r7+BcXFxEVPIRiQoKCyIjw0p0Y21ubuXsVImM8yITkVZbHBkVVlRUiFdTU1Wliq7akhJCMRBFRYfn5+fiWSaTV67sji8lJiVUE0/8+nVktiZLqL1VdqkmlUrpqEsk8fGv09NT/xL5qkqlEsynoi5NTo5PTk4QXp2dXMzNLYq1WjKRz8hIexP/l8g7OFlbE4q8WKzJyY6JeSW82tjY2ds7kYp8QT6ErkQ31hYWVk6OVCJvfIhg+aKiw/Lz8/4JAek/J6BWm6nVFloqlkEpZGdl6V9VKjXGDNOFTFALC/P1r0qlqaWFVVFREZmgYsj0r3K5Qke9kGxBRF6efqLAQsgoOS8SiYqLivErvEolUlDXCiqSqgFisUTPCgtzS3wpobMQEqlUpm+JmZmFXC6Hm0ImdCkpiQYib65Wq8mYj45nZWX8TeSLyUS+oM

@madd0
madd0 / transactionutils.cs
Created November 9, 2012 10:03
Better TransactionScope
// As per http://blogs.msdn.com/b/dbrowne/archive/2010/06/03/using-new-transactionscope-considered-harmful.aspx
public class TransactionUtils {
public static TransactionScope CreateTransactionScope()
{
var transactionOptions = new TransactionOptions();
transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted;
transactionOptions.Timeout = TransactionManager.MaximumTimeout;
return new TransactionScope(TransactionScopeOption.Required, transactionOptions);
}
}
@madd0
madd0 / idisposable.cs
Created June 12, 2012 20:57
Implement IDispoable Correctly
// From http://msdn.microsoft.com/library/ms244737.aspx
public class Resource : IDisposable
{
private IntPtr nativeResource = Marhsal.AllocHGlobal(100);
private AnotherResource managedResource = new AnotherResource();
// Dispose() calls Dispose(true)
public void Dispose()
{
@madd0
madd0 / gist:2412241
Created April 18, 2012 09:14
Create VHD with diskpart
C:\>diskpart
Microsoft DiskPart version 6.1.7601
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: XXXXXX
DISKPART> create vdisk file=C:\VHDs\Win8CP.vhd type=expandable maximum=60000
100 percent completed