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(fold_test). | |
-export([do_fold/0]). | |
do_fold() -> lists:foldl(fun(T,Acc) -> foo(T,Acc) end, [], [1,2,3]). | |
foo(T, Acc) -> [T | Acc]. |
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
[this fails with a parse error] | |
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> | |
<soap:Body> | |
<SearchRequest xmlns="http://www.example.com/account"> | |
<UserId>User1</UserId> | |
</SearchRequest> | |
</soap:Body> | |
</soap:Envelope> | |
[this works] |
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
from: www.hookedonlinq.com/LINQtoXML5MinuteOverview.ashx | |
XDocument doc = new XDocument( | |
new XDeclaration("1.0", "utf-8", "yes"), | |
new XComment("Sample RSS Feed"), | |
new XElement("rss", | |
new XAttribute("version", "2.0"), | |
new XElement ("channel", | |
new XElement("title", "RSS Channel Title"), | |
new XElement("description", "RSS Channel Description."), |
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
foreach (SearchResult dnResult in rootSearcher.FindAll()) | |
{ | |
EmailAddresses.Add(dnResult.Properties["mail"].ToString()); | |
} | |
foreach (SearchResult dnResult in rootSearcher.FindAll()) | |
{ | |
foreach (string dnName in dnResult.Properties.PropertyNames) | |
{ |
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; | |
namespace extensions | |
{ | |
class Foo | |
{ | |
private int myInt = 3; | |
virtual public int MyInt | |
{ | |
get { return myInt; } |
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
@Grab(group='com.unboundid', module='unboundid-ldapsdk', version='2.3.1') | |
import com.unboundid.ldap.sdk.* | |
def mr = new ModifyRequest('cn=jrandom,ou=accounts,dc=somewhere,dc=com', | |
[new Modification(ModificationType.REPLACE, 'msDS-UserAccountDisabled', 'TRUE'.bytes)]) | |
LDAPConnection.metaClass.modify = {ModifyRequest req -> println req; null} | |
LDAPConnection c = new LDAPConnection() |
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
@Grab(group='com.unboundid', module='unboundid-ldapsdk', version='2.3.1') | |
import com.unboundid.ldap.sdk.* | |
LDAPConnection.metaClass.bind = {SimpleBindRequest req -> println req; null} | |
LDAPConnection c = new LDAPConnection() | |
c.bind(new SimpleBindRequest()) |
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
(ns my.Class | |
(import (a.b.c Thing)) | |
(:gen-class | |
:methods [^{:static true} [foo [Thing] String]])) | |
(defn -foo [t] "foo") |
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
(let [a-map {:l1 {:x \y :l2 {:l3 {:a 1 :b 2}}}} | |
{{val-x :x {{:keys [a b]} :l3} :l2} :l1} a-map] | |
(prn b val-x)) | |
;; 2 \y |
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
import java.util.*; | |
public class Main { | |
static OptionalDouble toDouble(String s) { | |
OptionalDouble val = OptionalDouble.empty(); | |
try { | |
val = OptionalDouble.of(Double.parseDouble(s)); | |
} | |
catch (NumberFormatException e) { | |
//leave empty |
OlderNewer