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
void Main() | |
{ | |
var instanceName = "LINQPad"; | |
var counterCollectionInterval = TimeSpan.FromSeconds(1); | |
var continueCollectingTimeFrame = TimeSpan.FromSeconds(10); | |
var counters = from performanceCounterDefinition in PerformanceCounterRepository.GetPerfCounters | |
from counterName in performanceCounterDefinition.Counters | |
select new { |
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
<Query Kind="Program"> | |
<NuGetReference>Newtonsoft.Json</NuGetReference> | |
<NuGetReference>Rx-Main</NuGetReference> | |
<NuGetReference>StackExchange.Redis</NuGetReference> | |
<Namespace>System.Reactive.Linq</Namespace> | |
<Namespace>System.Reactive.Disposables</Namespace> | |
<Namespace>StackExchange.Redis</Namespace> | |
</Query> | |
void Main() |
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
public static class Guard | |
{ | |
public static void NotNull<T>(Expression<Func<T>> notNullableExpression) where T : class | |
{ | |
var compliedExpression = notNullableExpression.Compile(); | |
if (compliedExpression() == null) | |
{ | |
var paramName = notNullableExpression.GetObjectNameGraph(); | |
throw new ArgumentNullException(paramName); |
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
using System; | |
using System.Linq; | |
using System.Text; | |
using Newtonsoft.Json.Schema; | |
namespace JsonSchemaToCode | |
{ | |
public class CSharpObjectDefinition : ObjectDefinition | |
{ | |
public override string ToString() |
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
docker build -f ./cron.docker --tag cronsample:local . | |
docker run -d cronsample:local --name cronsample_rhysc | |
# Wait a bit, a minute in fact | |
docker container cp cronsample_rhysc:/var/log/cron.log ./cron.log | |
cat ./cron.log | |
# Should see "Hello world" printed on a new line for every minute the container has been running |
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
SELECT 'SELECT ' || string_agg(column_name, ', ') || ' FROM ' || table_name | |
FROM information_schema.columns | |
WHERE table_schema='my_schema' | |
GROUP BY table_name |
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
public class RequireApiKey : ActionFilterAttribute | |
{ | |
private static readonly ILog Logger = LogManager.GetLogger(typeof(RequireApiKey)); | |
public override void OnActionExecuting(HttpActionContext context) | |
{ | |
var ipAddress = GetIpAddress(context); | |
Logger.InfoFormat("API attempt. Uri {0} - IP {1} - Headers {2} ", context.Request.RequestUri, ipAddress, context.Request.Headers); | |
IEnumerable<string> values; | |
if (context.Request.Headers.TryGetValues("ApiKey", out values) && GetApiKeys().Any (x => x ==values.First()) |
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
public class InlineFileAttribute : ActionFilterAttribute | |
{ | |
private const string ContentDisposition = "Content-Disposition"; | |
public override void OnResultExecuted(ResultExecutedContext filterContext) | |
{ | |
var headers = filterContext.HttpContext.Response.Headers; | |
if (!string.IsNullOrWhiteSpace(headers[ContentDisposition])) | |
headers[ContentDisposition] = headers[ContentDisposition].Replace("attachment", "inline"); | |
base.OnResultExecuted(filterContext); |
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
# opens a GUI to manage users under the given account - fine for adding/upodate one or two accounts | |
runas /user:myDomain\myusername "C:\Windows\System32\rundll32.exe dsquery, OpenQueryWindow" | |
##POWERSHELL – to load the users, done from a server so it has the AD PS modules | |
import-module activedirectory | |
# basic search using ps filters | |
Get-ADUser -filter {GivenName -like "rickie"} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Calendar Demo</title> | |
<!-- BEGIN CALENDAR CSS - ideally these would be in a separate file - eg /calendar-template.css --> | |
<style> |
NewerOlder