Skip to content

Instantly share code, notes, and snippets.

View dancrowley303's full-sized avatar

Dan Crowley dancrowley303

View GitHub Profile
@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">
var Laws = {
drinking_age : function (fn) {
fn.call(this, this.age > 21);
}
}
/* snip */
Laws.drinking_age.call(this, function (able_to_drink) {
@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
@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 / 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 / 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;