I hereby claim:
- I am jbrestan on github.
- I am jbrestan (https://keybase.io/jbrestan) on keybase.
- I have a public key whose fingerprint is 806C 03DD D1B2 E3F3 53E4 5C3F 6912 176F 7B2A 8734
To claim this, I am signing this object:
public static Func<A, R> Y<A, R>(Func<Func<A, R>, Func<A, R>> f) | |
{ | |
Func<A, R> g = null; | |
g = f(a => g(a)); | |
return g; | |
} |
public abstract class TypeSafetyWrapper<T> | |
{ | |
private readonly T value; | |
public TypeSafetyWrapper(T value) | |
{ | |
this.value = value; | |
} | |
public T Value { get { return value; } } |
public static IGetOperationResult<T> ExecuteGetOrCreateWithLock<T>(this ICouchbaseClient client, | |
string key, Func<T> defaultNewValue, TimeSpan keyExpiration, TimeSpan lockExpiration) | |
{ | |
var initialGetResult = client.ExecuteGetWithLock<T>(key, lockExpiration); | |
if (initialGetResult.StatusCode == (int) StatusCodeEnums.NotFound || | |
(initialGetResult.InnerResult != null && | |
initialGetResult.InnerResult.StatusCode == (int) StatusCodeEnums.NotFound)) | |
{ | |
// Key not found. We'll have to create it with the default value and make sure we get the lock. |
void Main() | |
{ | |
var u = new Union | |
{ | |
Foo = null, | |
Bar = new Bar() | |
}; | |
u.Foo.S = "ohai!"; | |
let inline tryParse input = | |
let mutable result = Unchecked.defaultof< ^a> | |
if (^a: (static member TryParse : string -> ^a byref -> bool) (input, &result)) | |
then Some(result) else None |
// Pagination as a function | |
static IQueryable<T> Paginate<T>(this IQueryable<T> query, int pageNumber, int pageSize) => | |
query.Skip(pageSize*pageNumber).Take(pageSize); | |
// Usage | |
var paginatedQuery = originalQuery.Paginate(pageNumber, pageSize); | |
// Composition (fluent with extension methods) | |
var paginatedFilteredQuery = originalQuery.Where(predicate).Paginate(pageNumber, pageSize); |
[TestClass] | |
public class OperatorAbuseTest | |
{ | |
[TestMethod] | |
public void TestTheAbuse() | |
{ | |
var repeat = Operators.Repeat<string>(); | |
var join = Operators.Join<string>(); | |
var result = "Hello" <repeat> 3 <join> ","; | |
var expected = "Hello,Hello,Hello"; |
public static class Ensure | |
{ | |
public static TValue NotNull<TValue>(Expression<Func<TValue>> parameterExpression) | |
{ | |
var possibleNull = parameterExpression.Compile().Invoke(); | |
if (possibleNull == null) | |
{ | |
var paramName = GetVariableName(parameterExpression); | |
throw new ArgumentNullException(paramName); |
let zip xs ys = | |
let step acc x = | |
match acc with | |
| (rs, y::ys) -> ((x,y)::rs, ys) | |
| _ -> acc | |
Seq.fold step ([], ys) xs | |
|> fst | |
|> List.rev |
I hereby claim:
To claim this, I am signing this object: