This file contains hidden or 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
(defn in? | |
[xs x] | |
(some #(= x %) xs)) | |
(defn unwrap | |
[xs] | |
(if (and (list? xs) (list? (first xs)) (nil? (next xs))) | |
(first xs) | |
xs)) |
This file contains hidden or 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
namespace GenericMethodsTypeProvider | |
open System.Reflection | |
open System.IO | |
open Microsoft.FSharp.Core.CompilerServices | |
open Microsoft.FSharp.Quotations | |
open Microsoft.FSharp.Quotations.Patterns | |
open ProviderImplementation |
This file contains hidden or 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
#r "../packages/Nuget.Core.2.8.2/lib/net40-Client/Nuget.Core.dll" | |
#r "System.Xml.Linq" | |
open NuGet | |
let repository = PackageRepositoryFactory.Default.CreateRepository "https://nuget.org/api/v2" | |
let aspnet = query { | |
for p in repository.GetPackages() do | |
where (p.Title.Contains "ASP.NET") | |
count |
This file contains hidden or 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.Generic; | |
using System.Reactive.Disposables; | |
using System.Reactive.Linq; | |
using System.Reactive.Subjects; | |
using System.Threading; | |
namespace RxSample | |
{ | |
static class Program |
This file contains hidden or 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
public static class ExpressionsEx | |
{ | |
public static string PropertyName<TSource, TResult>(Expression<Func<TSource, TResult>> expression) | |
{ | |
if (expression == null) | |
{ | |
throw new ArgumentNullException("expression"); | |
} | |
if (!(expression.Body is MemberExpression)) |
This file contains hidden or 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
class Program | |
{ | |
class Foo<T> { } | |
class Bar<T> : Foo<T> { } | |
class Concrete : Bar<string> { } | |
class Another<T> : Foo<T> { } | |
static void Main(string[] args) | |
{ |
This file contains hidden or 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
// Inversions count. Based on merge sort | |
let rec merge (left: list<int>) (right: list<int>) = | |
match left, right with | |
| [], [] -> ([], bigint 0) | |
| _, [] -> (left, bigint 0) | |
| [], _ -> (right, bigint 0) | |
| headLeft::tailLeft, headRight::tailRight when headLeft > headRight -> | |
let (merged, inv) = merge left tailRight | |
(headRight::merged, inv + bigint left.Length) |
This file contains hidden or 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.Generic; | |
using System.Collections.Specialized; | |
using System.Linq; | |
using System.Text; | |
using System.Web; | |
using System.Web.Mvc; | |
namespace MvcPager.Html | |
{ |
This file contains hidden or 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
$.fn.asyncTypeahead = function (options) { | |
var defaultTypeaheadOptions = { | |
queryParameter: "query", | |
minLength: 1, | |
items: 10 | |
}; | |
options = $.extend(defaultTypeaheadOptions, options); | |
function serializeItem() { |
This file contains hidden or 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
public class Repository<T> : IQueryable<T> where T : class | |
{ | |
private readonly DbSet<T> _set; | |
public Repository(DbSet<T> set) | |
{ | |
_set = set; | |
} | |
public void Add(T entity) |