(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
import base64 | |
import time | |
import urllib2 | |
import cv2 | |
import numpy as np | |
""" | |
Examples of objects for image frame aquisition from both IP and |
/* | |
While generally using HttpContext, and all of the related properties such as | |
Cookies and Session, in WebAPI is not the right way sometimes it needs to be | |
done, especially when migrating existing code before doing a full rewrite but | |
could happen in any legacy MVC project you want to bring WebAPI into. | |
When using Autofac there is the AutofacWebTypesModule which allows you to resolve | |
these dependencies, all of which come from resolving HttpContextBase. | |
WebAPI doesn't provide HttpContext directly but if hosted in IIS rather than |
public class Car { | |
public int Id { get; set; } | |
[Required] | |
[StringLength(20)] | |
public string Make { get; set; } | |
[Required] | |
[StringLength(20)] |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace System { | |
public static partial class ExceptionExtensions { | |
/// <summary> | |
/// Returns a list of all the exception messages from the top-level |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
$/
artifacts/
build/
docs/
lib/
packages/
samples/
src/
tests/
public interface IAsyncRunner | |
{ | |
void Run<T>(Action<T> action); | |
} | |
public class AsyncRunner : IAsyncRunner | |
{ | |
public ILifetimeScope LifetimeScope { get; set; } | |
public AsyncRunner(ILifetimeScope lifetimeScope) |
//Git Mergetool and difftool with Beyond Compare 4 | |
//For Windows | |
//IF running this command in git bash then escape $ with \ | |
git config --global diff.tool bc4 | |
git config --global difftool.bc4.cmd "\"C:/Program Files (x86)/Beyond Compare 4/BCompare.exe\" \"\$LOCAL\" \"\$REMOTE\"" | |
git config --global difftool.prompt false | |
git config --global merge.tool bc4 | |
git config --global mergetool.bc4.cmd "\"C:/Program Files (x86)/Beyond Compare 4/BCompare.exe\" \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\"" | |
git config --global mergetool.bc4.trustExitCode true |
import Foundation | |
import CryptoSwift | |
extension String { | |
func aesEncrypt(key: String, iv: String) throws -> String{ | |
let data = self.dataUsingEncoding(NSUTF8StringEncoding) | |
let enc = try AES(key: key, iv: iv, blockMode:.CBC).encrypt(data!.arrayOfBytes(), padding: PKCS7()) | |
let encData = NSData(bytes: enc, length: Int(enc.count)) | |
let base64String: String = encData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0)); |
A monad is a fancy word for a generic type of the form MyMonad<T>
(a generic type of arity 1).
A monad is special because it adds 'special powers' to the T
that it wraps.
These 'special powers' won't sound very special to an imperative programmer, so you have to squint to see them but bear with me.
IEnumerable<T>
is a monad that gives values of type T
the special power of nondeterminism, or the ability to 'be' multiple values at once.Nullable<T>
is a monad that gives values of type T
the special power of nullability, or the ability to be absent.Task<T>
is a monad that gives values of type T
the special power of asynchronicity, or the ability to be used before they are computed.The trick with monads comes when you want to play with the T
values, because they are inside another type. C# introduced language changes to make dealing with values inside these monads easier: