This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
// Adapted from: http://stackoverflow.com/questions/128618/c-file-size-format-provider | |
// Credit: http://flimflan.com/blog/FileSizeFormatProvider.aspx | |
public sealed class ByteSizeFormatProvider : IFormatProvider, ICustomFormatter | |
{ | |
public object GetFormat(Type formatType) | |
{ | |
return formatType == typeof(ICustomFormatter) ? this : null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Net | |
open System.Net.Mime | |
open System.Text | |
let opt x = if x = null then None else Some(x) | |
type WebClient() = | |
inherit System.Net.WebClient() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2014 Atif Aziz. All rights reserved. | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function AddOrUpdateWebQuery(ByVal URL As String, Optional DontRefresh As Boolean = False) As QueryTable | |
Dim Connection As String: Connection = "URL;" & URL | |
Dim PostText As String: Dim Parts() As String | |
If Len(URL) > 1024 Then | |
' URL exceeds 1K so use HTTP POST to get around the limit | |
Parts = Split(URL, "?", 2) | |
URL = Parts(LBound(Parts)) | |
If UBound(Parts) > LBound(Parts) Then PostText = Parts(UBound(Parts)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Linq; | |
using System.Reflection; | |
using Jayrock; | |
using Jayrock.JsonRpc; | |
using Jayrock.Services; | |
static class Program | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if WINFORMS | |
using System.Windows.Forms; | |
static partial class XlTableFormat | |
{ | |
static int? _clipboardId; | |
public static int ClipboardId { get { return (_clipboardId ?? (_clipboardId = DataFormats.GetFormat("XlTable").Id)).Value; }} | |
} | |
#else | |
using System; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | |
using System; | |
using System.Linq; | |
using System.Runtime.ExceptionServices; | |
using System.Security; | |
#if HAS_AWAIT | |
namespace System.Linq | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.Collections.Generic | |
let groupAdjacent projection (source : _ seq) = seq { | |
let rec loop (e : IEnumerator<_>) g (members : List<_>) = seq { | |
members.Add(e.Current) | |
if e.MoveNext() then | |
let key = projection e.Current | |
if key = g then | |
yield! loop e key members | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
// http://stackoverflow.com/a/3453272/6682 | |
static class ConsoleRedirection | |
{ | |
// http://msdn.microsoft.com/en-us/library/system.console.isinputredirected.aspx | |
public static bool IsInputRedirected() { return IsRedirected(StdHandle.Stdin); } | |
// http://msdn.microsoft.com/en-us/library/system.console.isoutputredirected.aspx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reactive.Disposables; | |
static partial class Swapper | |
{ | |
public static Func<T, T> Create<T>(Func<T> getter, Action<T> setter) | |
{ | |
if (getter == null) throw new ArgumentNullException("getter"); | |
if (setter == null) throw new ArgumentNullException("setter"); |
OlderNewer