Skip to content

Instantly share code, notes, and snippets.

@quexy
quexy / SpecRun.Indices.sql
Created September 3, 2013 08:55
Naive SpecRun statistics store database indices
use SpecRun
create nonclustered index idx_events on
[Events] (Id, EventSourceId, Sequence, TimeStamp)
include (Version, Name, Data)
create nonclustered index idx_eventsources on
[EventSources] (Id, Type, Version)
create nonclustered index idx_pipelinestate on
@quexy
quexy / JiraClientTest.Program.cs
Last active August 29, 2015 13:56
TechTalk.JiraRestClient sample
using System;
using System.Linq;
using TechTalk.JiraRestClient;
namespace JiraClientTest
{
class Program
{
static void Main(string[] args)
{
@quexy
quexy / SpecFlow.ObjectConverter.cs
Last active August 29, 2015 13:56
A smarter replacement for SpecFlow.Assist's CreateInstance<T>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
namespace TechTalk.SpecFlow.ObjectConversion
{
public static class ObjectConverterExtensions
{
@quexy
quexy / SpecFlow.ObjectVerifier.cs
Last active August 29, 2015 14:01
Object verifier for SpecFlow
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq.Expressions;
namespace TechTalk.SpecFlow.ObjectVerification
{
public static class ObjectVerifierExtensions
{
/// <summary>
@quexy
quexy / SpecFlow.CollectionVerifier.cs
Last active August 29, 2015 14:01
Collection verifier for SpecFlow
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
namespace TechTalk.SpecFlow.ObjectVerification
{
public static class CollectionVerifierExtensions
{
/// <summary>
@quexy
quexy / Console.ReadPassword.cs
Last active February 7, 2017 15:18
Console masking password reader
[System.Diagnostics.DebuggerStepThrough]
public static string ReadPassword(char maskChar = '*')
{
var password = string.Empty;
var categories = new[] { UnicodeCategory.Control, UnicodeCategory.Format, UnicodeCategory.OtherNotAssigned, UnicodeCategory.PrivateUse, UnicodeCategory.Surrogate };
for (var key = Console.ReadKey(true); key.Key != ConsoleKey.Enter; key = Console.ReadKey(true))
{
if (!categories.Contains(CharUnicodeInfo.GetUnicodeCategory(key.KeyChar)))
{
password = string.Concat(password, key.KeyChar);
@quexy
quexy / qemu-arch-cpu.c
Last active August 29, 2015 14:06
QEMU for architecture-switching chroot (eg: initial RPi setup)
// based on: https://www.gentoo.org/proj/en/base/embedded/handbook/?part=1&chap=5
// build as: gcc -static qemu-arch-cpu.c -O3 -s -o /usr/bin/qemu-arch-cpu
// use like: ln -s /usr/bin/qemu-arch-cpu /usr/bin/qemu-arm-arm1176
#include <malloc.h>
#include <string.h>
#include <unistd.h>
char** parse_tuple(char* tuple) {
int pos = 0;
@quexy
quexy / SqlClientExtensions.cs
Last active November 7, 2017 12:23
Rudimentary OR/M IDbCommand & IDataReader extension methods
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Threading;
namespace System.Data
{
public static class SqlClientExtensions
@quexy
quexy / CancelableActionCall.cs
Last active June 19, 2017 11:20
Cancelable wrapper for Begin--End-style async methods
using System;
using System.Linq.Expressions;
using System.Threading;
namespace Cancelable
{
public struct CancelableActionCall<TS>
{
private readonly TS _svc;
private readonly CancellationToken _token;
@quexy
quexy / CircularBuffer.cs
Last active June 19, 2017 11:19
Fixed size circular FIFO buffer
namespace System.Collections.Generic
{
using System.Linq;
public sealed class CircularBuffer<TItem> : IList<TItem>, ICollection<TItem>, IEnumerable<TItem>
{
private int count = 0;
private int offset = 0;
private readonly TItem[] buffer;