From 8e63b4bde54c5bea75f8dd00fab47e42b660e367 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 1 Dec 2008 22:31:09 -0600 Subject: [PATCH 1/2] irc.gitbot: simple IRC bot which tracks git commits, work in progress --- extra/irc/gitbot/gitbot.factor | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 extra/irc/gitbot/gitbot.factor diff --git a/extra/irc/gitbot/gitbot.factor b/extra/irc/gitbot/gitbot.factor new file mode 100644 index 0000000000..93ccb2b407 --- /dev/null +++ b/extra/irc/gitbot/gitbot.factor @@ -0,0 +1,55 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: fry irc.client irc.client.private kernel namespaces +sequences threads io.encodings.8-bit io.launcher io splitting +make mason.common mason.updates calendar math alarms ; +IN: irc.gitbot + +: bot-profile ( -- obj ) + "irc.freenode.org" 6667 "jackass" f ; + +: bot-channel ( -- seq ) "#concatenative" ; + +GENERIC: handle-message ( msg -- ) + +M: object handle-message drop ; + +: bot-loop ( chat -- ) + dup hear handle-message bot-loop ; + +: start-bot ( -- chat ) + bot-profile + [ connect-irc ] + [ + [ bot-channel dup ] dip + '[ _ [ _ attach-chat ] [ bot-loop ] bi ] + "GitBot" spawn drop + ] bi ; + +: git-log ( from to -- lines ) + [ + "git-log" , + "--no-merges" , + "--pretty=format:%h %an: %s" , + ".." swap 3append , + ] { } make + latin1 [ input-stream get lines ] with-process-reader ; + +: updates ( from to -- lines ) + git-log reverse + dup length 4 > [ 4 head "... and more" suffix ] when ; + +: report-updates ( from to chat -- ) + [ updates ] dip + [ 1 seconds sleep ] swap + '[ _ speak ] interleave ; + +: check-for-updates ( chat -- ) + [ git-id git-pull-cmd short-running-process git-id ] dip + report-updates ; + +: bot ( -- ) + start-bot + '[ _ check-for-updates ] 5 minutes every drop ; + +MAIN: bot From 2777f54e74fd3222f64acfdb96d414fbd3bc4d7a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 1 Dec 2008 22:31:15 -0600 Subject: [PATCH 2/2] XML parsing benchmark --- extra/benchmark/xml/xml.factor | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 extra/benchmark/xml/xml.factor diff --git a/extra/benchmark/xml/xml.factor b/extra/benchmark/xml/xml.factor new file mode 100644 index 0000000000..a61293cd99 --- /dev/null +++ b/extra/benchmark/xml/xml.factor @@ -0,0 +1,11 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: io.encodings.utf8 io.files kernel sequences xml ; +IN: benchmark.xml + +: xml-benchmark ( -- ) + "resource:basis/xmode/modes/" [ + [ utf8 read-xml drop ] each + ] with-directory-files ; + +MAIN: xml-benchmark