This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To use: | |
# - Add an environment variable called NV_LLAMA_API_KEY and set it to a valid API key | |
# - Add the following script somewhere to your profile | |
# - At a *blank* PowerShell prompt, press Ctrl+` (backtick) | |
# - Type what you want to do at the prompt in plain english | |
# - The code generated by the LLM will be inserted into the input buffer without executing it | |
# - Make whatever changes are necessary to the generated command(s) and proceed as normal | |
# | |
# > Ask AI: recursively get all files in the current directory with the archive bit set | |
# > Get-ChildItem -Recurse -File | Where-Object { $_.Attributes -match 'Archive' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To use: | |
# - Add an environment variable called OPENAI_API_KEY and set it to a valid API key | |
# - Add the following script somewhere to your profile | |
# - At a *blank* PowerShell prompt, press Ctrl+` (backtick) | |
# - Type what you want to do at the prompt in plain english | |
# - The code generated by GPT4 will be inserted into the input buffer without executing it | |
# - Make whatever changes are necessary to the generated command(s) and proceed as normal | |
# | |
# > Ask GPT: recursively get all files in the current directory with the archive bit set | |
# > Get-ChildItem -Recurse -File | Where-Object { $_.Attributes -match 'Archive' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Adds OrderBy[Descending]/ThenBy[Descending] extension methods to IQueryable types | |
/// that take a string parameter indicating the selector path, enabling parameterized | |
/// ORDER BY clauses in LINQ queries. | |
/// </summary> | |
public static class DynamicSort | |
{ | |
private static readonly Lazy<MethodInfo> OrderByMethod = new(() => GetQueryableMethod(nameof(Queryable.OrderBy), 2)); | |
private static readonly Lazy<MethodInfo> OrderByDescendingMethod = new(() => GetQueryableMethod(nameof(Queryable.OrderByDescending), 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
// Storage Account containing the blobs | |
Source = AzureStorage.Blobs("mystorageaccount"), | |
// Select the container containing azuread user risk events | |
Container = Source{[Name="insights-logs-userriskevents"]}[Data], | |
// Get only blobs for a specific day (parameter ReportDate must be defined) | |
// The tenantId below is a random example -- use your own tenantId, or add a parameter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION [Today]() RETURNS date AS BEGIN RETURN CONVERT(date, GETUTCDATE()) END; | |
GO | |
CREATE FUNCTION [Tomorrow]() RETURNS date AS BEGIN RETURN CONVERT(date, DATEADD(day, 1, GETUTCDATE())) END; | |
GO | |
CREATE FUNCTION [Yesterday]() RETURNS date AS BEGIN RETURN CONVERT(date, DATEADD(day, -1, GETUTCDATE())) END; | |
GO | |
CREATE FUNCTION [ThisMonthStart]() RETURNS date AS BEGIN RETURN CONVERT(date, DATEADD(day, 1-DATEPART(day, GETUTCDATE()), GETUTCDATE())) END; | |
GO | |
CREATE FUNCTION [ThisMonthEnd]() RETURNS date AS BEGIN RETURN CONVERT(date, DATEADD(day, -1, DATEADD(month, 1, DATEADD(day, 1-DATEPART(day, GETUTCDATE()), GETUTCDATE())))) END; | |
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ============================================= | |
-- Author: Josh Einstein | |
-- Create date: 2/19/2005 | |
-- Description: Calculates the distance between two VH coordinates. | |
-- ============================================= | |
ALTER FUNCTION [dbo].[DistanceBetween] | |
( | |
@v1 int, | |
@h1 int, | |
@v2 int, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Imports serveral Office365-related modules into the session and authenticates using | |
saved or supplied credentials. | |
.DESCRIPTION | |
This script requires the following modules, which must be installed before running. | |
They will be imported automatically if they are installed. If they are not installed, | |
the script will return with an error. | |
- MSOnline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "System.Management.Automation" | |
#r "System.Web" | |
using System.Net; | |
using System.Net.Http; | |
public static string Query(this HttpRequestMessage request, string name, string defaultValue = null) { | |
var pairs = request.GetQueryNameValuePairs().Where(q => String.Equals(q.Key, name, StringComparison.OrdinalIgnoreCase)); | |
if (pairs.Any()) { return pairs.First().Value; } | |
return defaultValue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#.SYNOPSIS | |
# Removes all .DS_Store files from the current directory as well | |
# as any subdirectories. | |
#.DESCRIPTION | |
# .DS_Store is an artifact left by Mac OSX. On Mac that is harmless | |
# to remove, but otherwise pretty annoying. They tend to make their | |
# way into remote file shares and zip files and are not hidden by | |
# default in Windows. | |
function Remove-DSStore { |
NewerOlder