Skip to content

Instantly share code, notes, and snippets.

@LSTANCZYK
LSTANCZYK / ps-download-all-nuget-packages
Created March 19, 2024 23:25 — forked from bevand/ps-download-all-nuget-packages
Powershell script to download all packages from a nuget feed
$destinationDirectory = "C:\LocalNuGetTest\"
$webClient = New-Object System.Net.WebClient
$webClient.Credentials = New-Object System.Net.NetworkCredential("USERNAME", "PASSWORD")
$feed =[xml]$webClient.DownloadString("https://hostednugetfeed.com/custom-feed/nuget/v2/Packages")
$records = $feed | select -ExpandProperty feed | select -ExpandProperty entry #| select -ExpandProperty content
for ($i=0; $i -lt $records.Length; $i++) {
$content = $records[$i] | select -ExpandProperty content
$properties = $records[$i] | select -ExpandProperty properties
@LSTANCZYK
LSTANCZYK / IniSerializer.cs
Created January 16, 2024 20:36 — forked from mika76/IniSerializer.cs
INI Serializer for .NET Core in C# - Pretty basic with some validations and Serialize and Deserialize methods. There are lot's of variations for ini files though so it will probably not support every scenario. Feel free to adapt to your use-case.
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace tools
{
/// <summary>
/// Serializer class for ini files.
@LSTANCZYK
LSTANCZYK / FindStringInTables.sql
Created March 30, 2023 17:55
Find string Value in all tables in SQL database
DECLARE @SearchStrTableName nvarchar(255), @SearchStrColumnName nvarchar(255), @SearchStrColumnValue nvarchar(255), @SearchStrInXML bit, @FullRowResult bit, @FullRowResultRows int
SET @SearchStrColumnValue = '%searchthis%' /* use LIKE syntax */
SET @FullRowResult = 1
SET @FullRowResultRows = 3
SET @SearchStrTableName = NULL /* NULL for all tables, uses LIKE syntax */
SET @SearchStrColumnName = NULL /* NULL for all columns, uses LIKE syntax */
SET @SearchStrInXML = 0 /* Searching XML data may be slow */
IF OBJECT_ID('tempdb..#Results') IS NOT NULL DROP TABLE #Results
CREATE TABLE #Results (TableName nvarchar(128), ColumnName nvarchar(128), ColumnValue nvarchar(max),ColumnType nvarchar(20))
@LSTANCZYK
LSTANCZYK / Generate POCOs.groovy
Last active October 2, 2023 21:21 — forked from suhdev/Generate POCOs.groovy
Generate C# Classes from Tables in DataGrip
package extensions.data.extractors
/*
* Available context bindings:
* COLUMNS List<DataColumn>
* ROWS Iterable<DataRow>
* OUT { append() }
* FORMATTER { format(row, col); formatValue(Object, col); getTypeName(Object, col); isStringLiteral(Object, col); }
* TRANSPOSED Boolean
* plus ALL_COLUMNS, TABLE, DIALECT
@LSTANCZYK
LSTANCZYK / HttpClientRequestMessage.cs
Created October 4, 2022 20:00 — forked from rschiefer/HttpClientRequestMessage.cs
Retry OData Client calls with Polly in .NET 4.5
public class HttpClientRequestMessage : DataServiceClientRequestMessage
{
private HttpRequestMessage requestMessage;
private readonly HttpClient client;
private readonly HttpClientHandler handler;
private readonly MemoryStream messageStream;
private readonly Dictionary<string, string> contentHeaderValueCache;
private readonly RetryPolicy<HttpResponseMessage> pollyPolicy;
public HttpClientRequestMessage(string actualMethod, RetryPolicy<HttpResponseMessage> pollyPolicy)
@LSTANCZYK
LSTANCZYK / CustomerHandling.json
Created May 31, 2022 18:12
NSwagStudio generated C# client syntax errors files
This file has been truncated, but you can view the full file.
{
"swagger": "2.0",
"info": {
"description": "This page is to register a new customer",
"version": "2.0-1",
"title": "CustomerHandling"
},
"host": "test.com",
"basePath": "/main/ifsapplications/projection/v1/CustomerHandling.svc",
"tags": [
@LSTANCZYK
LSTANCZYK / oauth2-restsharp.cs
Created January 25, 2022 17:02 — forked from teocomi/oauth2-restsharp.cs
OAuth2 C# RestSharp
string url = "https://myurl.com";
string client_id = "client_id";
string client_secret = "client_secret";
//request token
var restclient = new RestClient(url);
RestRequest request = new RestRequest("request/oauth") {Method = Method.POST};
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("client_id", client_id);
request.AddParameter("client_secret", client_secret);
@LSTANCZYK
LSTANCZYK / PBIRS_ArgumentCompleter.PS1
Created August 20, 2021 19:50 — forked from SQLvariant/PBIRS_ArgumentCompleter.PS1
PowerShell Argument Completer for SSRS & Power BI Report Server
<# SSRS / PBIRS #>
Register-ArgumentCompleter -ParameterName ReportServerUri -ScriptBlock {
"http://localhost:8016/Reports_SQL2016", 'http://localhost:8081/PBIRServer' | ForEach-Object {
$CompletionText = $_
New-Object System.Management.Automation.CompletionResult (
$CompletionText,
$_,
'ParameterValue',
"$_ (SSRSInstance)"
)
@LSTANCZYK
LSTANCZYK / allowlistforpihole.txt
Created April 22, 2021 20:05 — forked from shanselman/allowlistforpihole.txt
A gist with an ALLOW LIST for a PiHole to make sure your XBox and Windows Services keeps working and appropriate anonymized telemetry goes where it needs to go
analytics.twitter.com
api.mixpanel.com
api.segment.io
attestation.xboxlive.com
az416426.vo.msecnd.net
browser.pipe.aria.microsoft.com
c.bing.com
c.msn.com
c1.microsoft.com
cdn-gl.imrworldwide.com
@LSTANCZYK
LSTANCZYK / FileStashy.cs
Created January 6, 2021 20:12 — forked from secretGeek/FileStashy.cs
FileStashy (and IStashy)
// This is an implementation of "IStashy" that saves/loads your objects as Json, in files, in a subfolder named after the type of the Object.
public class FileStashy : IStashy<string>
{
private readonly IHostingEnvironment _hostingEnvironment;
public FileStashy(IHostingEnvironment hostingEnvironment)
{
_hostingEnvironment = hostingEnvironment;
}