Skip to content

Instantly share code, notes, and snippets.

(defn in?
[xs x]
(some #(= x %) xs))
(defn unwrap
[xs]
(if (and (list? xs) (list? (first xs)) (nil? (next xs)))
(first xs)
xs))
namespace GenericMethodsTypeProvider
open System.Reflection
open System.IO
open Microsoft.FSharp.Core.CompilerServices
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open ProviderImplementation
#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
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
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))
class Program
{
class Foo<T> { }
class Bar<T> : Foo<T> { }
class Concrete : Bar<string> { }
class Another<T> : Foo<T> { }
static void Main(string[] args)
{
// 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)
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
{
$.fn.asyncTypeahead = function (options) {
var defaultTypeaheadOptions = {
queryParameter: "query",
minLength: 1,
items: 10
};
options = $.extend(defaultTypeaheadOptions, options);
function serializeItem() {
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)