This file contains hidden or 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(); |
This file contains hidden or 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
04425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E2500000004425248450000000000001E25000000 |
This file contains hidden or 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
function countInversions(xs){ | |
var count = 0; | |
function mergeSort(xs){ | |
var size = xs.length | |
if (size < 2) return xs | |
var mid = Math.floor(size / 2), | |
left = xs.slice(0, mid), | |
right = xs.slice(mid) |
This file contains hidden or 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 xs = [-4,-3,-7,+2,+1,-1,-4], //[2,1] = 3 | |
ys = [-2,11,-4,13,-5,-2], //[11,-4,13] = 20 | |
zs = [5,15,-30,10,-5,40,10,-8] // [...] = 55 | |
function sum(j,as){ | |
var max = Math.max; | |
function tabulate(i,runMax,curMax){ | |
if(i > j) return curMax | |
var newMax = max(runMax+as[i],as[i]) | |
return tabulate(i + 1, newMax, max(curMax,newMax)) |
This file contains hidden or 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 qapik = [50,20,10,5,3,1], | |
usCoins = [25,10,5,1]; | |
//denominations (ds) must be in descending order | |
function makeChange(coins,ds){ | |
var result = {} | |
for(var i = 0, d = ds[i]; i < ds.length; d = ds[++i]){ | |
result['n'+d] = Math.floor(coins/d) // a div d | |
coins = coins % d | |
} |
This file contains hidden or 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 url = "http://thenewobjective.com/blog/", | |
email = /\b[A-Z0-9+_.-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\b/gi, | |
delay = 2000, | |
visited = {}, hostname, | |
baseDocument = new ActiveXObject("htmlfile"), | |
a = baseDocument.createElement("a"); | |
a.href = url; | |
hostname = a.hostname; |
This file contains hidden or 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 #False #True | |
def Bool | |
def False <| Bool | |
and False -> False | |
and True -> True | |
or False -> False | |
or True -> True |
This file contains hidden or 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
function selected(){ | |
var sel = window.getSelection(), | |
cnt = sel.rangeCount, | |
ranges=[]; | |
for(var i = 0; i < sel.rangeCount; i++) | |
ranges[i] = sel.getRangeAt(i); | |
return ranges | |
} | |
function highlight(node,sels){ |
This file contains hidden or 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
Function.prototype.valueOf = function(){ | |
id.fs.push(this) | |
} | |
function id(){ | |
var fs = [] | |
function f(x){ | |
for(var i=0,len=fs.length,v=x;i<len;v=fs[i++](v)); | |
return v | |
} |
This file contains hidden or 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
function trampoline(f) { | |
while (typeof f === "function") f = f(); | |
return f; | |
} | |
function fib(n){ | |
function f(n0,n1,step){ | |
return step == n ? n1 : function() { return f(n1, n0 + n1, step +1) } | |
} | |
return trampoline(f(0,1,1)) |