Skip to content

Instantly share code, notes, and snippets.

View clausjoergensen's full-sized avatar

Claus Jørgensen clausjoergensen

View GitHub Profile
/// <summary>
/// Watch the values for each joint on the robot.
/// </summary>
/// <remarks>
/// The interval between each callback is defined in USBC.ini in miliseconds.
/// </remarks>
/// <param name="watchJoint"></param>
/// <returns>true if the method has been succesfully executed; otherwise, false.</returns>
[DllImport(NativeMethods.DllName, EntryPoint = "?WatchJoint@@YAHP6AXPAX@Z@Z",
CallingConvention = CallingConvention.Cdecl)]
http://en.wikipedia.org/wiki/Quicksort
let rec QuickSort(input : List<int>) =
match input with
| [] -> []
| head :: tail ->
let smaller = qsort (tail |> List.filter(fun e -> e <= x))
let larger = qsort (tail |> List.filter(fun e -> e >= x))
smaller @ [head] @ larger
@clausjoergensen
clausjoergensen / gist:1089189
Created July 18, 2011 11:03
A generic LongListCollection for use with the Silverlight Toolkit's LongListSelector
public class LongListCollection<T, TKey> : List<LongListItem<T, TKey>>
{
public LongListCollection()
{
}
public LongListCollection(IEnumerable<T> items, Func<T, TKey> keySelector)
{
if (items == null)
throw new ArgumentException("items");
@clausjoergensen
clausjoergensen / gist:1089190
Created July 18, 2011 11:03
A generic LongListCollection for use with the Silverlight Toolkit's LongListSelector
public class LongListCollection<T, TKey> : List<LongListItem<T, TKey>>
{
public LongListCollection()
{
}
public LongListCollection(IEnumerable<T> items, Func<T, TKey> keySelector)
{
if (items == null)
throw new ArgumentException("items");
namespace RestSharp.Deserializers
{
public class XmlDeserializer : IDeserializer
{
...
private void Map(object x, XElement root)
{
...
open System
type Node<'T>(nodeValue : 'T, next : Node<'T> option) =
member this.NodeValue
with get() =
nodeValue
member this.Next
with get() =
@clausjoergensen
clausjoergensen / DependencyObjectExtension.cs
Created August 6, 2011 18:15
Attached Navigation Behaviours for WP7
using System;
using System.Windows;
using System.Windows.Input;
using Microsoft.Phone.Controls;
namespace Rejseplanen.Assets
{
public class DependencyObjectExtension
{
public static readonly DependencyProperty NavigateToProperty =
<Grid assets:DependencyObjectExtension.NavigateTo="/Views/SearchMetroPage.xaml">...</Grid>
using System.IO;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
private Image OpenImage(String filename)
{
byte[] image = File.ReadAllBytes(filename);
Stream stream = new MemoryStream();
stream.Write(image,0,image.Length);