This file contains 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; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
Func<string,double,string> shade = (hex, pct) => { | |
Func<int,int,int,int> clamp = | |
(value,min,max) => value < min ? min : value > max ? max : value; | |
var num = Convert.ToUInt32(hex.Replace("#",""),16); |
This file contains 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
abstract class Term<T> { | |
abstract eval() : T | |
} | |
class Lit extends Term<number> { | |
constructor(public value: number) { super() } | |
eval() : number { return this.value } | |
} | |
class Inc extends Term<number> { |
This file contains 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
// <https://twitter.com/sroucheray/status/658913220292452352> | |
Object.walk = (o, path)=>path.split('.').reduce((o,k)=>o && o[k], o); |
This file contains 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
var sqrt = x => { | |
let improve = y => (y + x/y)/2 | |
let satisfied = y => Math.abs(y*y - x) < 1e-14 //Number.EPSILON | |
let until = (pred,f,x) => pred(x) ? x : until(pred,f,f(x)) | |
return until(satisfied,improve,x) | |
}; |
This file contains 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
adjacent(ems,phy). | |
adjacent(ems,soccer). | |
adjacent(soccer,cunn). | |
adjacent(ems,chem). | |
adjacent(chem,lap). | |
adjacent(lap,bridge). | |
adjacent(lap,arch). | |
adjacent(arch,engel). | |
adjacent(cunn,engel). | |
adjacent(bridge,union1). |
This file contains 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
insert(X, Xs, [X|Xs]). | |
insert(E, [X|Xs], [X|Ys]) :- insert(E,Xs,Ys). | |
permute([],[]). | |
permute(L,[H|T]) :- insert(H,R,L), permute(R,T). | |
sudoku([[X11,X12,X13,X14,X15,X16,X17,X18,X19], | |
[X21,X22,X23,X24,X25,X26,X27,X28,X29], | |
[X31,X32,X33,X34,X35,X36,X37,X38,X39], | |
[X41,X42,X43,X44,X45,X46,X47,X48,X49], |
This file contains 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
module | |
exports Bool | |
protocol Bool | |
False | |
True | |
and Bool => Bool | |
or Bool => Bool | |
not => Bool |
This file contains 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
<!DOCTYPE html> | |
<html lang="en" dir="ltr"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Click-Through Circle</title> | |
<style type="text/css"> | |
html, body{ | |
margin:0; | |
padding:0; | |
} |
This file contains 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
var searchRoot = new System.DirectoryServices.DirectoryEntry( | |
@"LDAP://server:389/DC=foo,DC=com", | |
@"DOMAIN\USERNAME", | |
"PASSWORD" | |
){ AuthenticationType = AuthenticationTypes.ReadonlyServer }; | |
using(var searcher = new System.DirectoryServices.DirectorySearcher(searchRoot)) { | |
searcher.Filter = "(&(objectCategory=group))"; | |
var results = searcher.FindAll(); | |
results.Dump(); |