Skip to content

Instantly share code, notes, and snippets.

@ryanvgates
ryanvgates / NLog.Config
Created June 16, 2017 03:09
NLogUserIdToDB
<targets>
<target name="dbLogger" xsi:type="Database"
connectionStringName="DefaultConnection" commandText="
insert into dbo.Log (
Date, Level, Message, Username,
ServerName, SessionId
) values (
@Date, @Level, @Message,
@Username, @ServerName, @SessionId
);">
@ryanvgates
ryanvgates / DoesntWork.cs
Last active September 1, 2017 03:25
Web API Put Gotcha
[HttpPut]
public async Task<RestResponseModel<Company>> Put([FromUri] int companyId, Company company)
{
var response = new RestResponseModel<Company>();
try
{
company.LastModifiedOn = DateTime.UtcNow;
company.ModifiedBy = Guid.Parse(this.UserAspId);
response.Data.Add(await this.dataAccess.UpdateCompany(id, company));
}
@ryanvgates
ryanvgates / Jenkins_Update_Plugins.ps1
Last active December 5, 2017 02:40
Updating Jenkins Plugins with Powershell Blog Post
Function Update-Plugins($jenkinsServer, $username, $authToken) {
$authValue = $($username+":"+$authtoken)
$pluginsToBeUpdated = @()
Invoke-RestMethod -Method Get -Uri $($jenkinsServer + "/jnlpJars/jenkins-cli.jar") -OutFile "jenkins-cli.jar" -ContentType "application/octet-stream"
Write-Output "`nHere are the currently installed plugins`n"
cmd /c java -jar jenkins-cli.jar -s $jenkinsServer -auth $authValue list-plugins '2>&1' | Tee-Object -Variable output
foreach ($item in $output) {
@ryanvgates
ryanvgates / scalacheck.scala
Created April 6, 2018 03:59
soflcc-2018: Property Based Testing by Nicolas A Perez - Scala Check
val numbers = Gen.choose(2, 100);
numbers: org.scalacheck.Gen[Int] = org.scalacheck.Gen$$anon
sum.check
@ryanvgates
ryanvgates / web.config
Created April 6, 2018 04:37
No IFrame For You
<configuration>
<appSettings>
<add key="AllowedSites" value="site1.com;site2.com;site3.com"/>
</appSettings>
</configuration>
@ryanvgates
ryanvgates / Jenkinsfile
Last active May 29, 2018 04:30
Jenkins MSTest Publish Results - Run MStest
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\MSTest.exe" /resultsfile:"%WORKSPACE%\Results.trx" /testcontainer:solution\\project\\bin\\Release\\project.dll
@ryanvgates
ryanvgates / Response
Created May 1, 2018 01:33
HEC Response
{
"text": "Data channel is missing",
"code": 10
}
@ryanvgates
ryanvgates / web.config
Created May 6, 2018 18:59
Nuget Server - Web.config changes
<add key="requireApiKey" value="true" />
<add key="apiKey" value="{secret key}" />
<add key="allowOverrideExistingPackageOnPush" value="false" />
<add key="ignoreSymbolsPackages" value="true" />
<add key="enableDelisting" value="false" />
<add key="enableFrameworkFiltering" value="false" />
@ryanvgates
ryanvgates / Request
Created May 7, 2018 03:56
Splunk HEC Gotcha - Request
POST https://splunkhost:8088/services/collector
Authorization: Splunk fe358871-c9be-4f9a-a38b-0a09bf41b64c
{
"event": "test"
}
@ryanvgates
ryanvgates / Response
Created May 7, 2018 03:57
Splunk HEC Gotcha - Successful Response
{
"text": "Success",
"code": 0
}