Skip to content

Instantly share code, notes, and snippets.

View dancrowley303's full-sized avatar

Dan Crowley dancrowley303

View GitHub Profile
@dancrowley303
dancrowley303 / volatile-trap.cs
Created June 14, 2018 02:28
thread safe data structure access strategies
using System;
using System.Threading;
using System.Threading.Tasks;
namespace VolatileTrap
{
class Widget
{
private long count = 0;
@dancrowley303
dancrowley303 / Program.cs
Created June 7, 2018 02:05
TPL Task waiting on CancellationToken or AutoResetEvent
using System;
using System.Threading;
using System.Threading.Tasks;
namespace cancelThis
{
class Program
{
static void WaitingOnCancellationToken()
{
@dancrowley303
dancrowley303 / Program.cs
Created May 24, 2018 08:25
azure-servicebus-various-client-handling-strategies
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.ServiceBus;
namespace bussub
{
@dancrowley303
dancrowley303 / naive pathfinding
Last active August 29, 2015 14:05
Naive pathfinding function in Swift. Throw into a playground to mess around with. (Need to figure out an algorithm for calculating adjacent nodes). See http://gabrielgambetta.com/path1.html for original algorithm.
import UIKit
class Node : Equatable {
let name: String;
var previous: Node? = nil
var adjacents: [Node] = []
init (name: String) {
self.name = name
var Laws = {
drinking_age : function (fn) {
fn.call(this, this.age > 21);
}
}
/* snip */
Laws.drinking_age.call(this, function (able_to_drink) {
@dancrowley303
dancrowley303 / gist:1291751
Created October 17, 2011 01:47
style trigger for zero length textbox
Would like to have a xaml (view) only method to change the textbox text to "Search ..." when the textbox is empty.
My xaml file has this:
<TextBox Name="searchBox" Text="{Binding Path=TextFilter, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox.Style>
<Style TargetType="{x:Type TextBox}">
<Style.Triggers>
<DataTrigger Binding="Text.Length, {Binding RelativeSource={RelativeSource = Self}}" Value="0">
@dancrowley303
dancrowley303 / gist:976114
Created May 17, 2011 07:44
wpf cucumber style syntax
This is an example of the type of domain syntax I'd want in a WPF UI automation testing feature:
Given the default user exists
When I enter "daniel" in the username textbox
And I enter "pass" in the password textbox
And I click the authenticate button
Then I should see the authentication panel
And the border of the username textbox should be red
@dancrowley303
dancrowley303 / win_scancode.txt
Created May 9, 2011 06:56
Windows Scancode Map
System\\CurrentControlSet\\Control\\Keyboard Layout
@dancrowley303
dancrowley303 / activerecordlog2devnull.rb
Created February 22, 2011 06:25
Stop Active Record logging to stdout
#Add this line to development.rb to shut up ActiveRecord
ActiveRecord::Base.logger = Logger.new('/dev/null')
<html>
<style type="text/css">
div { float: right }
* { float: none }
</style>
<body>
<div class="floatright">float right</div>
<p>I'm defined under the right floated right div</p>