Skip to content

Instantly share code, notes, and snippets.

View mneedham's full-sized avatar

Mark Needham mneedham

View GitHub Profile

-> http://localhost:5984/sharpcouch/_design/name/

{"_id":"_design/name","_rev":"186784868","views":{"by_username":{"map":"function(doc) { if(doc.doctype != "User") return true; emit(doc.username, doc); }"}}}

-> http://localhost:5984/sharpcouch/_design/name/_view/by_username

{"error":"EXIT","reason":"{function_clause,n [{couch_httpd,handle_db_request,n [{mochiweb_request,#Port<0.2535>,'GET',n "/sharpcouch/_design/name/_view/by_username",n {1,1},n {8,n {"host",n {'Host',"localhost:5984"},n {"accept",n {'Accept',n "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"},n nil,n {"accept-language",n {'Accept-Language',"en-us,en;q=0.5"},n {"accept-encoding",n {'Accept-Encoding',"gzip,deflate"},n {"accept-charset",n

-> http://localhost:5984/sharpcouch/_design/name/

{"_id":"_design/name","_rev":"4219834987","views":{"by_username":{"map":"function(doc) { emit(doc.username, doc); }"}}}

-> http://localhost:5984/sharpcouch/_design/name/_view/by_username

{"error":"EXIT","reason":"{function_clause,n [{couch_httpd,handle_db_request,n [{mochiweb_request,#Port<0.2536>,'GET',n "/sharpcouch/_design/name/_view/by_username",n {1,1},n {9,n {"host",n {'Host',"localhost:5984"},n {"accept",n {'Accept',n "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"},n nil,n {"accept-language",n {'Accept-Language',"en-us,en;q=0.5"},n {"accept-encoding",n {'Accept-Encoding',"gzip,deflate"},n {"accept-charset",n {'Accept-Charset',"ISO-8859-1

let ExtractValues1 (item:string) =
let matchBuildDuration item = Regex.Match(item, "(.*\)),([0-9]+),")
Regex.Split(item, "\n") |>
Array.map (fun item ->
let m = matchBuildDuration item
if(m.Success)
then { Agent = m.Groups.[1].Value; Duration = m.Groups.[2].Value }
else { Agent = ""; Duration = ""} ) |>
Array.filter (fun item -> item.Agent <> "" && item.Duration <> "")
let ApplyRegex pattern response = Regex.Split(response, "\n") |> Array.map (fun x -> Regex.Match(x, pattern))
let GetMatchingGroups = Array.filter (fun (x:Match) -> x.Success) >> Array.map (fun x -> x.Groups) >> Array.to_seq
let GetAgentsAndBuildTimes =
ApplyRegex "(.*\)),([0-9]+)," >>
GetMatchingGroups >>
Seq.map (fun group -> group.[1].Value, group.[2].Value ) >>
Seq.group_by (fun x -> fst x) >>
Seq.map (fun (agent, buildInfo) -> agent, (buildInfo |> Seq.map (fun x -> snd x)) )
let a input1 input2 input3 = // do some stuff
let b input1 input2 input3 =
a input1 input2 input3 |> someOtherFunction
------------
let a input1 input2 input3 = //do some stuff
let b input1 input2 input3 funcA =
funcA input1 input2 input3 |> someOtherFunction
Tests:
[<Test>]
let should_throw_exception_if_feed_xml_is_invalid () =
Assert.Throws<FailureException>(fun () -> FeedBurners.ProcessFeed "some broken xml" |> ignore) |> ignore
[<Test>]
let should_throw_exception_if_no_feed_found () =
let feedXml = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<rsp stat=""fail"">
class MyContainer[T] {
private var obj:T = null
def value = obj
def value_=(v:T) = obj = v
}
val cont = new MyContainer[String]
cont.value = "Daniel"
(contains? '(nil 1 2 nil 3) nil)
=> false
@Component
public class FooStrategyModelFactory {
private final MemberRepository memberRepository;
private final BarRepository barRepository;
private final FooStrategyRepository fooRepository;
private final BarViewFactory barViewFactory;
private final JsonConverter jsonConverter;
@Autowired
(defmacro create-feedback [person sc ie]
(list 'do '(println "Feedback for" person)
'(println "Strengthen Confidence (+ve)")))
user=> (macroexpand-1 '(create-feedback "mark" "something good" "something bad"))
(do (println "Feedback for" person) (println "Strengthen Confidence (+ve)"))
user=> (create-feedback "mark" "something good" "something bad")
java.lang.Exception: Unable to resolve symbol: person in this context (NO_SOURCE_FILE:470)