Skip to content

Instantly share code, notes, and snippets.

View philcleveland's full-sized avatar

Phil Cleveland philcleveland

View GitHub Profile
@philcleveland
philcleveland / DandD.cs
Created December 12, 2013 21:30
Drag and drop with Rx
var mouseDown = Observable.FromEventPattern<MouseButtonEventArgs>(this, "MouseDown")
.Select(x => x.EventArgs.GetPosition(this));
var mouseUp = Observable.FromEventPattern<MouseButtonEventArgs>(this, "MouseUp")
.Select(x => x.EventArgs.GetPosition(this));
var mouseMove = Observable.FromEventPattern<MouseEventArgs>(this, "MouseMove")
.Select(x => x.EventArgs.GetPosition(this));
mouseMove.SkipUntil(mouseDown)
@philcleveland
philcleveland / App.xaml
Created April 24, 2014 16:04
Answer for SO question
<Application
x:Class="Approve.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:local="clr-namespace:Approve">
<!--Application Resources-->
public class AreaFallowed
{
public AreaFallowed(string gardenID, NodaTime.LocalDate date, int x, int y, int width, int length)
{
GardenId = gardenID;
Date = date;
X = x;
Y = y;
Width = width;
Length = length;
@philcleveland
philcleveland / HackBinding.txt
Created May 16, 2014 16:18
RxUI combobox hack binding
XAML
---------------------------------------------------------------
<ComboBox Grid.Row="0" x:Name="gardens" Margin="10" FontSize="24">
<ComboBoxItem>New...</ComboBoxItem>
<ComboBoxItem>G1</ComboBoxItem>
<ComboBoxItem>G2</ComboBoxItem>
<ComboBoxItem>G3</ComboBoxItem>
</ComboBox>
@philcleveland
philcleveland / mouseWheel.js
Last active August 29, 2015 14:07
Rx-js = mouseWheel handling
var canvasMouseOver = Rx.Observable.fromEvent(myCanvas, "mousedown");
var canvasMouseWheel = Rx.Observable.fromEvent(myCanvas, "mousewheel");
canvasMouseWheel.skipUntil(cavasMouseOver)
.subscribe(function (val) {
if (val.originalEvent.wheelDelta < 0) {
mainViewVM.incrementFrame();
}
else {
@philcleveland
philcleveland / GameOfLife.fs
Created November 10, 2014 18:35
Game of life in F#
open System
open System.Threading
let printBoard (grid:int[,]) =
let maxX = (Array2D.length1 grid) - 1
let maxY = (Array2D.length2 grid) - 1
for row in 0 .. maxX do
for col in 0 .. maxY do
if(grid.[row,col] = 1) then printf "*|" else printf " |"
printfn ""
@philcleveland
philcleveland / UnitOfMeasure.fs
Created November 15, 2014 17:25
Problem get UOM to work in the srm_color method
//ounce
//gallon
[<Measure>] type gal
//lovibond
[<Measure>] type L
//pounds
[<Measure>] type lbs
//gc = grain color
//weight = grain weight in lbs
<script>
function getStudyMetadata() {
var promise = $.ajax({
type: "GET",
url: "/study/metadata/{id}",
dataType: "json"
}).promise();
return Rx.Observable.fromPromise(promise);
};
@philcleveland
philcleveland / .gitattributes
Created December 3, 2014 16:47
Git Attributes to fix LF probs
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
@philcleveland
philcleveland / DeleteIISExpressSites.ps1
Created December 5, 2014 20:24
Removes all IIS Express Sites
$appCmd = "C:\Program Files (x86)\IIS Express\appcmd.exe"
$result = Invoke-Command -Command {& $appCmd 'list' 'sites' '/text:SITE.NAME' }
for ($i=0; $i -lt $result.length; $i++)
{
Invoke-Command -Command {& $appCmd 'delete' 'site' $result[$i] }
}