[#338014] Sqlite3-ruby ON Windows Vista with 1.9.1p129 mingw32 — "J. D." <jdezenzio@...>

I'm using the ming compiled 1.9.1 p 129 successfully on Vista and I even

13 messages 2009/06/01

[#338085] Games for Programmers — Daniel Berger <djberg96@...>

Hi everyone,

18 messages 2009/06/01

[#338135] nfc 1.0.0 Released — Aaron Patterson <aaron@...>

nfc version 1.0.0 has been released!

16 messages 2009/06/02

[#338141] <, >, and ranges in a case statement. — Max Williams <toastkid.williams@...>

I feel like this should be simple but i can't figure it out.

16 messages 2009/06/02

[#338307] Compiling Ruby 1.9.1 zlib issue on Windows — "J. D." <jdezenzio@...>

Hi everyone,

14 messages 2009/06/03

[#338344] Ruby OS — Sparky Mat <max@...>

I was considering porting the Ruby 1.9 VM to bare metal (something

16 messages 2009/06/04

[#338466] ruby_frame in 1.8 is what in 1.9? — Jason Roelofs <jameskilton@...>

So I have some C++ extension code that nicely uses ruby_frame->orig_func and

11 messages 2009/06/05

[#338469] Problem with cronjob and ruby script — Matthew Lagace <mlagace@...>

Hello,

20 messages 2009/06/05
[#338476] Re: Problem with cronjob and ruby script — Bil Kleb <Bil.Kleb@...> 2009/06/05

Matthew Lagace wrote:

[#338478] Re: Problem with cronjob and ruby script — Matthew Lagace <mlagace@...> 2009/06/05

Hmm I've tried running with a blank environment and it fails with the

[#338481] Re: Problem with cronjob and ruby script — Hassan Schroeder <hassan.schroeder@...> 2009/06/05

On Fri, Jun 5, 2009 at 8:00 AM, Matthew Lagace<mlagace@rasib.ca> wrote:

[#338483] Re: Problem with cronjob and ruby script — Matthew Lagace <mlagace@...> 2009/06/05

Oh I see can you give me an example please?

[#338516] Twitter Personalities (#208) — Daniel Moore <yahivin@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

23 messages 2009/06/05

[#338519] SPAM from Usenet — Eric Hodel <drbrain@...7.net>

It seems the gateway is passing a lot more spam these days.

71 messages 2009/06/05
[#338522] Re: SPAM from Usenet — James Gray <james@...> 2009/06/05

On Jun 5, 2009, at 4:30 PM, Eric Hodel wrote:

[#338524] Re: SPAM from Usenet — Eric Hodel <drbrain@...7.net> 2009/06/05

On Jun 5, 2009, at 14:42, James Gray wrote:

[#338686] How to sort array ascending, except zero ? — Paganoni <noway@...>

Hello, I need to sort

24 messages 2009/06/08

[#338769] Ruby 1.9.x Concurrency — "s.ross" <cwdinfo@...>

Poking through the Apple press releases today, I sat up and took

20 messages 2009/06/09
[#338808] Re: Ruby 1.9.x Concurrency — James Gray <james@...> 2009/06/09

On Jun 9, 2009, at 1:23 AM, s.ross wrote:

[#338825] Re: Ruby 1.9.x Concurrency — Charles Oliver Nutter <headius@...> 2009/06/09

On Tue, Jun 9, 2009 at 9:16 AM, James Gray<james@grayproductions.net> wrote:

[#338835] Re: Ruby 1.9.x Concurrency — Tony Arcieri <tony@...> 2009/06/09

On Tue, Jun 9, 2009 at 10:06 AM, Charles Oliver Nutter

[#338776] require_all 1.0.0: A wonderfully simple way to load your code — Tony Arcieri <tony@...>

require_all

12 messages 2009/06/09

[#338875] centos and ruby 1.9.1 - possible? — "Älphä Blüë" <jdezenzio@...>

I hate even typing the question but my vps template has centos

20 messages 2009/06/10
[#338886] Re: centos and ruby 1.9.1 - possible? — James Britt <james.britt@...> 2009/06/10

底phBl鵫 wrote:

[#338918] Re: centos and ruby 1.9.1 - possible? — "Älphä Blüë" <jdezenzio@...> 2009/06/10

James Britt wrote:

[#338890] Ruby 1.8.6-pl369 released — Kirk Haines <wyhaines@...>

We have released Ruby 1.8.6-pl369. This is primarily a security release.

12 messages 2009/06/10
[#338935] Re: [Security] Ruby 1.8.6-pl369 released — Charles Oliver Nutter <headius@...> 2009/06/10

On Wed, Jun 10, 2009 at 12:14 AM, Kirk Haines<wyhaines@gmail.com> wrote:

[#338894] Any plans for a Ruby 1.9.1 One-Click Installer? — Benjamin L. Russell <DekuDekuplex@...>

Are there any plans for a Ruby 1.9.1 One-Click Installer for Windows?

18 messages 2009/06/10

[#339014] publically accessible fastri — Roger Pack <rogerpack2005@...>

I have been thinking recently that I wish I could access ri data for

14 messages 2009/06/11

[#339033] Idiomatic way to detect first/last iteration? — Kendall Gifford <zettabyte@...>

Hi there, is there any recognized ruby idiomatic way for detecting

20 messages 2009/06/11

[#339099] wrapping a C struct[] constant — Martin DeMello <martindemello@...>

I have some C code with a struct definition

15 messages 2009/06/12
[#339106] Re: wrapping a C struct[] constant — Eero Saynatkari <ruby-ml@...> 2009/06/12

Martin DeMello wrote:

[#339119] Re: wrapping a C struct[] constant — Jason Roelofs <jameskilton@...> 2009/06/12

On Fri, Jun 12, 2009 at 7:42 AM, Eero Saynatkari <ruby-ml@kittensoft.org>wrote:

[#339123] Re: wrapping a C struct[] constant — Martin DeMello <martindemello@...> 2009/06/12

On Fri, Jun 12, 2009 at 7:01 PM, Jason Roelofs<jameskilton@gmail.com> wrote:

[#339146] Matrix Rotator (#209) — Daniel Moore <yahivin@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

17 messages 2009/06/12

[#339260] each by arity — Trans <transfire@...>

I've always wondered, why?

20 messages 2009/06/14
[#339262] Re: each by arity — Joel VanderWerf <vjoel@...> 2009/06/14

Trans wrote:

[#339264] Re: each by arity — Tony Arcieri <tony@...> 2009/06/14

On Sun, Jun 14, 2009 at 1:37 PM, Joel VanderWerf <vjoel@path.berkeley.edu>wrote:

[#339265] Re: each by arity — Yossef Mendelssohn <ymendel@...> 2009/06/14

On Jun 14, 3:32m, Tony Arcieri <t...@medioh.com> wrote:

[#339304] formatting a listing — George George <george.githinji@...>

i have a listing which looks like this

21 messages 2009/06/15

[#339395] Ruby feasibility? — Dave Kubasiak <davekub@...>

Good morning,

14 messages 2009/06/16

[#339404] shebang! on Leopard — "Paul M." <paul.maxfield007@...>

Hey everyone,

14 messages 2009/06/16

[#339513] String += vs << — Joshua Ball <chezball@...>

A friend recently sent me this article:

12 messages 2009/06/17

[#339546] enterprise 1.0.0 Released — Aaron Patterson <aaron@...>

enterprise version 1.0.0 has been released!

12 messages 2009/06/18

[#339680] Capturing System Call Return Values? — Tyler Knappe <tyler.knappe@...>

I'm attempting to use Ruby to make system calls (in this case python

18 messages 2009/06/19
[#339683] Re: Capturing System Call Return Values? — Roger Pack <rogerpack2005@...> 2009/06/19

Tyler Knappe wrote:

[#339734] 'move into' a module's namespace in irb — Max Williams <toastkid.williams@...>

I'm in an irb session where i have a lot of modules loaded. All of the

13 messages 2009/06/20

[#339757] regular expression gurus--help! — timr <timrandg@...>

I want all possible three letter sets for a string. Scan does this:

18 messages 2009/06/21

[#339776] if column header contain regexp, delete column — Paul Shapiro <fightoplankton@...>

I need to see if a csv column header matches a pattern (see columns 2/3

10 messages 2009/06/21

[#339809] ruby suggestion: officially sanctioned tutorials/howto's — Roger Pack <rogerpack2005@...>

Current situation:

24 messages 2009/06/22
[#339811] Re: ruby suggestion: officially sanctioned tutorials/howto's — James Gray <james@...> 2009/06/22

On Jun 22, 2009, at 7:10 AM, Roger Pack wrote:

[#339824] Re: ruby suggestion: officially sanctioned tutorials/howto's — Joel VanderWerf <vjoel@...> 2009/06/22

James Gray wrote:

[#339854] Re: ruby suggestion: officially sanctioned tutorials/howto's — Robert Dober <robert.dober@...> 2009/06/22

On Mon, Jun 22, 2009 at 6:50 PM, Joel VanderWerf<vjoel@path.berkeley.edu> wrote:

[#339941] Re: ruby suggestion: officially sanctioned tutorials/howto's — Robert Klemme <shortcutter@...> 2009/06/23

On 23.06.2009 01:20, Robert Dober wrote:

[#339944] Re: ruby suggestion: officially sanctioned tutorials/howto's — Robert Dober <robert.dober@...> 2009/06/23

On Tue, Jun 23, 2009 at 11:30 PM, Robert

[#339946] Re: ruby suggestion: officially sanctioned tutorials/howto's — Roger Pack <rogerpack2005@...> 2009/06/23

>> Having said that it is probably a good idea to include tutorials in the

[#340001] Re: ruby suggestion: officially sanctioned tutorials/howto's — Robert Klemme <shortcutter@...> 2009/06/24

On 24.06.2009 00:00, Roger Pack wrote:

[#339834] map shall not return an Enumerator ( was re guru help ) — Robert Dober <robert.dober@...>

On Mon, Jun 22, 2009 at 2:52 PM, Brian Candler<b.candler@pobox.com> wrote:

10 messages 2009/06/22

[#339871] Execute Ruby script over HTTP protocol as Java Script — Speed Knownas <karthick1983@...>

Hi All,

13 messages 2009/06/23

[#339982] THREE HUNDRED! — Ryan Davis <ryand-ruby@...>

I just finished my release flood and we cracked release #300!

46 messages 2009/06/24
[#339983] Re: THREE HUNDRED! — Xeno Campanoli <xeno.campanoli@...> 2009/06/24

Ryan Davis wrote:

[#339985] Re: THREE HUNDRED! — Ryan Davis <ryand-ruby@...> 2009/06/24

[#339988] Re: THREE HUNDRED! — John Barnette <jbarnette@...> 2009/06/24

On Tue, Jun 23, 2009 at 8:29 PM, Ryan Davis<ryand-ruby@zenspider.com> wrote:

[#339994] Re: THREE HUNDRED! — lith <minilith@...> 2009/06/24

> I fear change. Could you please stop improving your software and just

[#340022] Time for a ruby-announce list? — Trans <transfire@...>

We are seeing a lot or release announcements among the regular posts

45 messages 2009/06/24
[#340088] Re: Time for a ruby-announce list? — Roger Pack <rogerpack2005@...> 2009/06/24

> We are seeing a lot or release announcements among the regular posts

[#340090] How do I get an integer from an array? — Peter Bailey <pbailey@...>

Hi,

14 messages 2009/06/24

[#340171] Attr Methods and object setters — Marc Heiler <shevegen@...>

We can do:

28 messages 2009/06/25
[#340193] Re: Attr Methods and object setters — Gregory Brown <gregory.t.brown@...> 2009/06/25

On Thu, Jun 25, 2009 at 2:05 PM, Marc Heiler<shevegen@linuxmail.org> wrote:

[#340216] Re: Attr Methods and object setters — Fabian Streitel <karottenreibe@...> 2009/06/26

> This is the pattern I use:

[#340264] Re: Attr Methods and object setters — Gregory Brown <gregory.t.brown@...> 2009/06/26

On Fri, Jun 26, 2009 at 4:00 AM, Fabian

[#340299] Re: Attr Methods and object setters — Fabian Streitel <karottenreibe@...> 2009/06/27

See here: http://pastie.org/526403

[#340301] Re: Attr Methods and object setters — Gregory Brown <gregory.t.brown@...> 2009/06/27

On Sat, Jun 27, 2009 at 10:42 AM, Fabian

[#340335] Re: Attr Methods and object setters — Daniel DeLorme <dan-ml@...42.com> 2009/06/28

Gregory Brown wrote:

[#340239] Trying to define a 'class' without using 'class' sentence — Fernando Guillen <fguillen.mail@...>

Hi people.. I was watching the Dave Thomas' talk on the ScotlandOnRails

18 messages 2009/06/26

[#340385] RDoc-style documentation for Ruby keywords — "David A. Black" <dblack@...>

Hi --

20 messages 2009/06/29

[#340409] Best OS packages for Ruby? — "Michael J. I. Jackson" <mjijackson@...>

Hi all,

23 messages 2009/06/29
[#340427] Re: Best OS packages for Ruby? — Fabian Streitel <karottenreibe@...> 2009/06/29

Hi Michael,

[#340484] Re: Best OS packages for Ruby? — David Masover <ninja@...> 2009/06/30

On Monday 29 June 2009 12:11:38 pm Fabian Streitel wrote:

[#340515] Re: Best OS packages for Ruby? — Joel VanderWerf <vjoel@...> 2009/06/30

David Masover wrote:

[#340518] Re: Best OS packages for Ruby? — James Britt <james.britt@...> 2009/06/30

Joel VanderWerf wrote:

[#340588] Re: Best OS packages for Ruby? — Fabian Streitel <karottenreibe@...> 2009/07/01

>

[#340410] Making a random string — Lloyd Linklater <lloyd@2live4.com>

I have been trying to generate a random string. One approach in, say,

21 messages 2009/06/29
[#340492] Re: Making a random string — Brian Candler <b.candler@...> 2009/06/30

Lloyd Linklater wrote:

[#340432] attr_writers within blocks — Wijnand Wiersma <wijnand@...>

Hi all,

14 messages 2009/06/29

[#340460] Question on networking with custom binary interface. — Greg Chambers <gregory.w.chambers@...>

So I am working on this Ruby server application for Windows that needs

13 messages 2009/06/29

Re: [QUIZ][Solution] Twitter Personalities (#208)

From: Justin Collins <justincollins@...>
Date: 2009-06-08 23:07:57 UTC
List: ruby-talk #338756
Justin Collins wrote:
> Daniel Moore wrote:
>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>>
>> The three rules of Ruby Quiz:
>>
>> 1.  Please do not post any solutions or spoiler discussion for this
>> quiz until 48 hours have elapsed from the time this message was
>> sent.
>>
>> 2.  Support Ruby Quiz by submitting ideas and responses
>> as often as you can!
>> Visit: http://rubyquiz.strd6.com/suggestions
>>
>> 3.  Enjoy!
>>
>> Suggestion:  A [QUIZ] in the subject of emails about the problem
>> helps everyone on Ruby Talk follow the discussion.  Please reply to
>> the original quiz message, if you can.
>>
>> RSS Feed: http://rubyquiz.strd6.com/quizzes.rss
>>
>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>>
>> ## Twitter Personalities (#208)
>>
>> Merhaba Rubyists,
>>
>> This week's quiz is to create a program that will generate messages
>> 140 characters in length. There primary use will be to create a
>> Twitter "personality". At the end of the quiz period these
>> "personalities" will be unleashed on the internet and we'll see how
>> they do in the wild.
>>
>> The programs will consist of two parts: a component for interacting
>> with Twitter, and a top secret "personality" module.
>>
>> For the Twitter interface component there will be no no-spoiler
>> period. Please feel encouraged to discuss different libraries or
>> methods on the mailing list. Let's all work together to find the best
>> interface.
>>
>> The "personality" component can take any inputs and will produce a 140
>> character message when called. The "personality" may remember state.
>> The no-spoiler period applies for the "personality" component; please
>> save them until everyone has had a chance to consider their own
>> implementations.
>>
>>
>> Have Fun!
>>   
>
> Posting to Twitter, I found, was pretty straightforward using the 
> Twitter4r gem, although it only worked for me under Ruby 1.9:
>
> require 'twitter'
> client = Twitter::Client.new :login => "myname", :password => 
> "mypassword"
> client.status :post, "Working on Ruby Quiz."
>
>
> I hope that helps anyone who might have been hesitant because of the 
> Twitter interface part.
>
> -Justin
>


So, here is my full solution, which just pulls transcriptions of 
Dijkstra's notes and tries to extract decent quotes. Also attempts to 
find relavent replies. Works most of the time. You can see some results 
at http://twitter.com/ewdbot and get a nicer-looking version from 
http://gist.github.com/125781

#A little Twitter thing to post random quotes from Edsger Dijkstra

require 'yaml'
require 'open-uri'
require 'twitter'  #twitter4r gem
require 'hpricot'

class DijkstraQuote
    class << self

        #Match the website's naming scheme
        def random_ewd
            (rand(1289) + 30).to_s.rjust(4, "0")
        end

        #Get a random quote
        def get_quote
            quote = nil
            while quote.nil? do
                quote = fetch random_ewd
            end

            quote
        end

        #Get a random quote from the specified set of notes
        def fetch ewd

            #Check if we've already retrieved this set of notes
            if File.exists? "ewd#{ewd}"
                quotes = YAML.load_file "ewd#{ewd}"
                quotes[rand quotes.length]
            else
                $stderr.puts "Fetching EWD#{ewd}..." if $DEBUG

                #Fetch a transcript of Dijkstra's notes
                begin
                    file = 
open("http://www.cs.utexas.edu/~EWD/transcriptions/EWD#{ewd[0,2]}xx/EWD#{ewd}.html") 
{ |f| Hpricot(f) }
                rescue OpenURI::HTTPError
                    $stderr.puts "Not found" if $DEBUG
                    return nil
                end

                text = file.to_plain_text

                #Pick some sentences that seem good
                lines = text.split(/\.(?:\s+|\n+)/).map do |l|
                    l.gsub(/\t|\n|\r/, " ").squeeze(" ").strip
                end.select do |l|
                    l.length > 40 and l.length < 140 and l[0,1] == 
l[0,1].upcase and l[-3, 3] != "viz"
                end

                #Cache them for later
                File.open "ewd#{ewd}", "w" do |f|
                    YAML.dump lines, f
                end

                #Return a random sentence
                lines[rand lines.length]
            end
        end

        #(Very crudely) tries to find a quote that is related to the 
message.
        #Note that this only searches the cache.
        def find_related message

            #Get the longer words
            words = message.gsub(/[^a-zA-Z ]/, "").split.select { |w| 
w.length > 4 }

            quote = nil
            if words.length > 0
                word = /#{Regexp.union(words)}/i

                #Check local files for the search word
                Dir.glob("ewd*").find do |f|
                    text = File.read f
                    if text =~ word

                        #Get the list of quotes and grab one
                        quotes = YAML.load_file f
                        matches = quotes.grep word
                        quote = matches[rand(matches.length)]
                    else
                        false
                    end
                end
            else
                quote = get_quote
            end

            quote
        end
    end
end

#Post to Twitter
class DijkstraTwitter

    def initialize
        @twitter = Twitter::Client.new :login => "?", :password => "?"
    end

    #Post a random quote. If _ask_ is true, asks for approval first
    def post_random ask = false
        quote = DijkstraQuote.get_quote

        if ask and ask_permission("Would you like to post this: 
\"#{quote}\"") or not ask
            @twitter.status :post, quote
        end
    end

    #Check unanswered @ewd messages and come up with responses
    def post_replies ask = false
        require 'set'

        #Keep track of what has been replied to already
        if File.exist? "ewdreplies"
            replied = YAML.load_file "ewdreplies"
        else
            replied = Set.new
        end

        replies = @twitter.status(:replies)

        replies.each do |status|
            status_id = status.id.to_s
            next if replied.include? status_id
            message = status.text
            user = status.user.screen_name
            if reply_to message, user, ask
                replied << status_id
            end
        end

        File.open "ewdreplies", "w" do |f|
            YAML.dump replied, f
        end
    end

    #Send a reply if we can find one
    def reply_to message, sender, ask = false
        puts "Responding to \"#{message}\""

        quote = DijkstraQuote.find_related message
        if not quote
            puts "Nothing related. Skipping."
            return false
        elsif ask and ask_permission("Would you like to post this: 
\"#{quote}\"") or not ask
            response = "@#{sender} #{quote}"
            if response.length > 140
                response = response[0,140]
            end

            @twitter.status(:post, "@#{sender} #{quote}")
            true
        else
            if ask and ask_permission "Ignore this reply?"         
                true
            else
                false
            end
        end
    end

    #Ask if the user would like to post the quote which was found
    def ask_permission message
        puts message

        response = nil
        until response =~ /^(y|n)/i
            print "(Y/N): "
            response = gets
        end

        $1.downcase == "y"
    end
end

#Try it out
puts DijkstraQuote.get_quote

#dt = DijkstraTwitter.new
#dt.post_random true
#dt.post_replies true


My favorite so far: "In this sense, Programming = Mathematics + Murphy's 
Law"

-Justin

In This Thread