Skip to content

Instantly share code, notes, and snippets.

View MauRiEEZZZ's full-sized avatar
💭
Come on, Jump!

Maurice MJ de Jong MauRiEEZZZ

💭
Come on, Jump!
View GitHub Profile
@MauRiEEZZZ
MauRiEEZZZ / gist:01ccbf0b3ae312252702
Last active August 29, 2015 14:27
CustomersRepository typo CS-ASP_064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LocalDbExample.Persistence
{
public class CustomersRepository
{
@MauRiEEZZZ
MauRiEEZZZ / CustomerManager.cs
Created August 15, 2015 19:58
CustomersManager typo CS-ASP_064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LocalDbExample;
namespace LocalDbExample.Domain
{
public class CustomerManager
@MauRiEEZZZ
MauRiEEZZZ / Compress-ByteArray.ps1
Created October 12, 2019 20:05
Compress Byte Array
function Compress-ByteArray {
[CmdletBinding()]
Param (
[Parameter(Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName)]
[byte[]] $byteArray
)
Process {
[System.IO.MemoryStream] $inMemDataStream = New-Object System.IO.MemoryStream
$gzipInstance = New-Object System.IO.Compression.GzipStream $inMemDataStream, ([IO.Compression.CompressionMode]::Compress)
@MauRiEEZZZ
MauRiEEZZZ / ReadAllBytes.ps1
Last active October 12, 2019 20:07
Read the file into memory
$fileAsByteArray = [System.IO.File]::ReadAllBytes($FilePath);
$Base64String = [System.Convert]::ToBase64String($fileAsByteArray);
$Base64String | Out-File '.\a file'
$sysmonAsString="H4sIAAAAAAAAC+y9f2BUxdU/vLvZJEtY..."
$ByteArray = [System.Convert]::FromBase64String($sysmonAsString)
[System.IO.File]::WriteAllBytes('.\Sysmon.exe', $ByteArray);
Start-Process -FilePath '.\Sysmon.exe'
function DownloadSysmon {
[cmdletbinding()]
Param()
$Result = $(Test-Path (Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath sysmon.exe));
if(-not $Result) {
try {
# https://msdn.microsoft.com/en-us/library/system.io.path.gettempfilename%28v=vs.110%29.aspx
$tmpfile = [System.IO.Path]::GetTempFileName()
$null = Invoke-WebRequest -Uri 'https://live.sysinternals.com/Sysmon.exe' `
-OutFile $tmpfile -ErrorAction Stop
@MauRiEEZZZ
MauRiEEZZZ / Load-EasyKQLMagic.py
Created October 18, 2019 13:58
KQLMagic reload
#%%
%reload_ext Kqlmagic
@MauRiEEZZZ
MauRiEEZZZ / Setup-EasyKQLMagic.py
Last active October 18, 2019 14:33
Example how to use KQLMagic
#%%
!pip install Kqlmagic --no-cache-dir --upgrade
#%%
tenantID='a87101d0-71e5-40d5-829e-cf14f5cbe9de'
workspaceID='88e4dd19-caa6-4a38-a2e2-506488c113df'
#%%
%env KQLMAGIC_CONNECTION_STR=loganalytics://code;tenant="$tenantID";workspace="$workspaceID"
#%%
%kql AzureActivity | where Caller contains "maurice" | where TimeGenerated > ago(12h) | project TimeGenerated, OperationName, ActivityStatus, CallerIpAddress
!pip install msrestazure --no-cache-dir --upgrade
!pip install azure-keyvault --no-cache-dir --upgrade