Skip to content

Instantly share code, notes, and snippets.

@caleb-vear
caleb-vear / ExtensionExample.cs
Last active August 29, 2015 14:25
An example of an extension method for an interface I control.
// We are keeping the interface super simple to implement.
// It turns out that there are a number of situations where I want to
// send a message after a delay of a given period. Rather than force
// every implementation to provide that I add via the PublishAfterDelay
// extension method.
public interface ISimulatorBus
{
void Publish(object message);
<!-- Scripts Start -->
<b:if cond='data:post.isFirstPost'>
<!-- Facebook -->
<div id='fb-root'/>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "http://connect.facebook.net/en_US/all.js#xfbml=1";

I can't get curl to validate the SSL cert for https://testintegrations.pentanasolutions.com/iTestDriveService. It works fine in my web browser. The certificate is signed by DigiCert which I thought perhaps was not included in the bundle on my linux box.

To try and work around that I extracted the CA certificates from my windows machine in the the AllCA.pem file and told curl to use that. The ssl validation still failed. I then tried just extracting the DigiCert root certificate by viewing the certificate chain from the browser and using just this cert with curl. It still doesn't validate the certificate.

I then tried getting https://www.google.com.au which did work. I find it very odd as this works even when I specify the CA certificate to be just the DigiCert certificate even though google's key is not signed by DigiCert. This makes me wonder if curl is even using my ca file at all.

@caleb-vear
caleb-vear / AsyncProcess.cs
Last active December 22, 2015 06:48
Poor mans await
public static class AsyncHelper<TResult>
{
public static Task<TResult> RunAsync(Func<TaskCompletionSource<TResult>, IEnumerable<Task>> createProcessSequence)
{
return RunAsync(createProcessSequence, TaskScheduler.Current);
}
public static Task<TResult> RunAsync(Func<TaskCompletionSource<TResult>, IEnumerable<Task>> createProcessSequence, TaskScheduler continuationScheduler)
{
var cancellationTokenSource = new CancellationTokenSource();
@caleb-vear
caleb-vear / FailDemo.xaml
Created November 15, 2012 01:55
Grid auto column width text wrapping fail.
<Window x:Class="TestGridTextWrapping.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid Width="525">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
@caleb-vear
caleb-vear / ContinueAfter.cs
Created October 9, 2012 01:19
Continue After implementation
public static IObservable<TRet> ContinueAfter<T, TRet>(this IObservable<T> observable, Func<IObservable<TRet>> selector)
{
return observable
.Materialize()
.Where(n => n.Kind == NotificationKind.OnCompleted)
.SelectMany(_ => selector());
}
@caleb-vear
caleb-vear / OAuthAuthenticationHandler.cs
Created September 28, 2012 05:07
An example of adding an OAuth message handler to authenticate web api requests.
using System.ServiceModel.Channels;
using System.ServiceModel.Web;
using Microsoft.IdentityModel.Tokens;
namespace System.Net.Http
{
using Threading;
using Web;
using Web.Http;
using Microsoft.IdentityModel.Claims;
@caleb-vear
caleb-vear / not-test.html
Created December 7, 2011 01:03
:not test
<html>
<head>
<style>
p:not(.classy) { color: red; }
:not(p) { color: green; }
div { color: black; }
</style>
</head>
<body>
<div>
<Window.Resources>
<Style x:Key="ComboBoxFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="4,4,21,4" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
@caleb-vear
caleb-vear / Lets me write.cs
Created October 13, 2011 02:48
Experiment with returning a normal value except under unusual conditions
var endDate = localTime.AddDays(7 * 4);
endDate = endDate.Or(endDate.Previous(DayOfWeek.Sunday)).When(endDate.IsNotA(DayOfWeek.Sunday));