Skip to content

Instantly share code, notes, and snippets.

View ericlobdell's full-sized avatar

Eric Lobdell ericlobdell

View GitHub Profile
void Main()
{
var validEmailList = new List<EmailAddress>()
{
new EmailAddress("[email protected]"),
new EmailAddress("[email protected]", true)
};
IsValidPrimaryCollection(validEmailList)
.Dump("One email marked as primary");
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions
Enable-RemoteDesktop
#Browsers
cinst firefox
#CLI Tools
cinst openssh
cinst poshgit
cinst cmder
@ericlobdell
ericlobdell / validdecimalattribute.cs
Last active May 3, 2017 15:16
Validate string property is a valid decimal value
public class ValidDecimalAttribute : ValidationAttribute
{
public decimal MinValue { get; set; } = decimal.MinValue;
public decimal MaxValue { get; set; } = decimal.MaxValue;
public override bool IsValid(object value)
{
if (value != null && !(value is string))
return false;
-- Notes:
concat :: [[a]] -> [a]
concat xss = [x | xs <- xss, x <- xs]
len :: [a] -> Int
len xs = sum [1 | _ <- xs]
factors :: Int -> [Int]
HttpContext.Current = new HttpContext(
new HttpRequest("", "http://tempuri.org", ""), new HttpResponse(new StringWriter()));
NameValueCollection headers = HttpContext.Current.Request.Headers;
Type t = headers.GetType();
const BindingFlags nonPublicInstanceMethod = BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance;
t.InvokeMember("MakeReadWrite", nonPublicInstanceMethod, null, headers, null);
t.InvokeMember("InvalidateCachedArrays", nonPublicInstanceMethod, null, headers, null);
using System;
using System.Diagnostics;
namespace BuildRunner.Services
{
public class ProcessBuilder
{
public ProcessStartInfo ProcessStartInfo { get; private set; }
private Process _instance;
:- dynamic event/1.
:- dynamic rule/3.
:- dynamic situation/6.
%%%%%%%%%%%%% Event Database (our working memory, or what we know)
event([(freq_visited_terrorist_url(abcal), tq([]))]).
event([(visited_url(jackson,abcal,10), tq(5,15))]).
event([(passport_record(jackson,country-xyz),tq(5,35))]).
event([(near(jackson,gg_bridge), tq(20,25))]).
@ericlobdell
ericlobdell / simplethens.js
Created October 13, 2015 02:43
demonstrating chainibility of .then after promise.
let get5 = new Promise((resolve, reject) => resolve( 5 ));
let add1 = n => n + 1;
get5
.then(add1)
.then(add1)
.then(add1)
.then(add1)
.then(console.log); // 9
@ericlobdell
ericlobdell / tolls.pl
Created September 30, 2015 01:40
AI class tolls.pl program file
%% This is our Prolog program—the beginnings of a full-fledged AI system.
%% The symbol to the left indicates a comment. First one declares the objects
%% in our rules. The number indicates the number of arguments for the object. For
%% example, “has_toll/2” indicates that “has_toll” takes two arguments.
:- dynamic has_toll/2.
:- dynamic is_type/2.
:- dynamic has_purpose/2.
%% Here are three rules with variables.
@ericlobdell
ericlobdell / AjaxController.js
Last active August 29, 2015 14:14
Ajax wrapper for API controller
( function ( window, $ ) {
"use strict";
window.AjaxController = api
function api( controller ) {
this.controllerUrl = "/api/" + controller + "/";
}
api.prototype.Post = function ( endpoint, data ) {