Skip to content

Instantly share code, notes, and snippets.

View weeksdev's full-sized avatar
🏠
Working from home

Andrew Weeks weeksdev

🏠
Working from home
View GitHub Profile
@weeksdev
weeksdev / ManualInteractionWithSplunkEventCollector.cs
Created May 19, 2020 20:49
Manual http request to splunk event collector
WebRequest request = WebRequest.Create("https://splunkserver/services/collector");
request.Method = "POST";
request.Headers.Add("Authorization", "Splunk YOUR_GUID");
ASCIIEncoding encoding = new ASCIIEncoding();
var requestBody = JsonConvert.SerializeObject(new
{
@event = new
@weeksdev
weeksdev / example.csx
Last active April 29, 2020 18:42
Info on CSX Scripts
using System;
using System.Net;
class Webby
{
public string Request(string url, string processName)
{
try
{
WebClient client = new WebClient();
@weeksdev
weeksdev / NugetCommands.md
Created January 16, 2020 16:19
Nuget Commands

Creating nuspec file

Go to the path with the .csproj file

Run the following command:

nuget spec

Filling out assembly info

@weeksdev
weeksdev / VSCodeSetup.md
Created December 10, 2019 18:05
VS Code Setup Dotnet Core

VS Code Setup

  1. Install VSCode _ Install C# Extensions _ Install Auto-Using
  2. Install dotnet sdk 2.2.402 -> https://dotnet.microsoft.com/download/dotnet-core/thank-you/sdk-2.2.402-windows-x64-installer
  3. Install msbuild 2019 -> Build Tools for Visual Studio 2019 (Down on bottom) -> https://visualstudio.microsoft.com/downloads/
  4. Install dbeaver to be able to view sqlite dbs or use this for simple option: https://sqlitebrowser.org/blog/portableapp-for-3-11-2-release-now-available/
  5. From cli run: dotnet dev-certs https
@weeksdev
weeksdev / create_database.sql
Last active January 13, 2021 14:35
Create Database MS Sql Server
CREATE LOGIN {{username}} WITH PASSWORD = '{{strong_password}}';
CREATE DATABASE {{database_name}};
ALTER DATABASE {{database_name}} SET RECOVERY SIMPLE;
ALTER AUTHORIZATION ON DATABASE::{{database_name}} TO {{username}};
SELECT suser_sname (owner_sid), * FROM sys.databases ORDER BY name WHERE name = '{{database_name}}';
--FOR WINDOWS LOGIN
create login [<<DOMAIN\USERNAME>>] from windows;
-- For older versions of SQL Server:
Mock<IValidator<Suggestion>> validator = new Mock<IValidator<Suggestion>>();
validator.Setup(v => v.Validate(It.IsAny<ValidationContext>())).Returns(new FluentValidation.Results.ValidationResult());
SELECT
cast(r.total_elapsed_time as decimal(18,2)) / 1000 / 60,
r.session_id
,st.TEXT AS batch_text
,SUBSTRING(st.TEXT, statement_start_offset / 2 + 1, (
(
CASE
WHEN r.statement_end_offset = - 1
THEN (LEN(CONVERT(NVARCHAR(max), st.TEXT)) * 2)
ELSE r.statement_end_offset
@weeksdev
weeksdev / appveyor.yml
Last active May 19, 2019 19:46
dotnet-new project templating via bash script
version: 1.0.{build}
image: Visual Studio 2015
build_script:
- cmd: PowerShell -Version 2.0 .\build.ps1
test: off
@weeksdev
weeksdev / bash_profile.md
Created May 2, 2019 16:25
Bash Profile Aliases

alias gofolder='cd "c:/Program Files/Some Folder"'

alias gitlogjira="git log --pretty=oneline | grep -e '[A-Z]\+-[0-9]\+' -o | sort -u"

alias tree='cmd //c tree //a'

alias gitlog="git log --pretty --oneline"

@weeksdev
weeksdev / console-logs.md
Created April 1, 2019 18:34
Finding console.logs

Removing console logs

^.*console\.log\(.*\).*\n