[#43299] Ruby implementation Q's — justinj@... (Justin Johnson)

Apologies in advance for this meaty posting:

30 messages 2002/07/01

[#43358] (0..3) == (0...4) returning false? — Massimiliano Mirra <list@...>

Is there a reason for two ranges holding the same extension but

41 messages 2002/07/02

[#43416] Segmentation Fault - Ruby Garbage Collection — James Eric Birmingham <avenger@...>

During load testing of our Ruby program, we have been getting

22 messages 2002/07/02

[#43570] self_parent — Tom Sawyer <transami@...>

i was wondering what others thought of the idea of having a built in

47 messages 2002/07/04
[#43571] Re: self_parent — David Alan Black <dblack@...> 2002/07/04

Hello --

[#43584] Re: self_parent — Tom Sawyer <transami@...> 2002/07/04

all my real examples are pretty large, mostly to do with using the REXML

[#43628] Re: self_parent — Massimiliano Mirra <list@...> 2002/07/05

On Fri, Jul 05, 2002 at 07:49:09AM +0900, Tom Sawyer wrote:

[#43662] Re: self_parent — Tom Sawyer <transami@...> 2002/07/05

On Fri, 2002-07-05 at 05:31, Massimiliano Mirra wrote:

[#43705] Re: self_parent — Austin Ziegler <austin@...> 2002/07/05

On Sat, 6 Jul 2002 03:32:11 +0900, Tom Sawyer wrote:

[#43713] Re: self_parent — Michael Campbell <michael_s_campbell@...> 2002/07/05

> In ten years of professional software development, a good chunk of

[#43602] is there a better string.each? — Tyler Spivey <tspivey8@...>

well, i have a bit of a problem:

98 messages 2002/07/05
[#43606] Re: is there a better string.each? — Tom Sawyer <transami@...> 2002/07/05

a = "canada"

[#43644] Re: is there a better string.each? — Sean Russell <ser@...> 2002/07/05

Tom Sawyer wrote:

[#43645] Re: is there a better string.each? — Michael Campbell <michael_s_campbell@...> 2002/07/05

> > thought it was strange myself. personally i'd like it if String

[#43707] Re: is there a better string.each? — Sean Russell <ser@...> 2002/07/05

Hal E. Fulton wrote:

[#43714] Re: is there a better string.each? — Michael Campbell <michael_s_campbell@...> 2002/07/05

[#43774] Re: is there a better string.each? — Sean Russell <ser@...> 2002/07/06

Michael Campbell wrote:

[#43805] Re: is there a better string.each? — Michael Campbell <michael_s_campbell@...> 2002/07/07

[#43848] Re: is there a better string.each? — "Hal E. Fulton" <hal9000@...> 2002/07/07

----- Original Message -----

[#43611] Powered by Ruby (logo) — Davey <davey@...>

Hey,

23 messages 2002/07/05

[#43780] passing to objects at the bottom — Tom Sawyer <transami@...>

i have a chain of objects such that one object contains another which

17 messages 2002/07/06

[#43795] Pre-RCR... nil.empty? — Dave Thomas <Dave@...>

34 messages 2002/07/07
[#43799] Re: Pre-RCR... nil.empty? — David Alan Black <dblack@...> 2002/07/07

Hi --

[#43807] unshifting a directory onto ENV['PATH'] — Bil Kleb <W.L.Kleb@...>

Is there a more elegant (compact?) method than

16 messages 2002/07/07

[#43916] How to determine EOF with sysread? — Jim Freeze <jim@...>

Hi:

13 messages 2002/07/08

[#43943] SV: SV: [ANN] Archive 0.2 — Thomas Søndergaard <tsondergaard@...>

DQo+IFRoYW5rcy4gOi0pIEknbSBub3QgdGVycmlibHkgaW4gaHVycnkgdG8gYWRkIFppcCBzdXBw

13 messages 2002/07/08

[#43944] Re: is there a better string.each? — George Ogata <g_ogata@...>

Hi,

45 messages 2002/07/08
[#43959] Re: is there a better string.each? — Austin Ziegler <austin@...> 2002/07/08

On Mon, 8 Jul 2002 20:43:57 +0900, George Ogata wrote:

[#43949] for ... else ... end — "Kontra, Gergely" <kgergely@...>

Hi!

45 messages 2002/07/08
[#44103] Re: for ... else ... end — Sean Russell <ser@...> 2002/07/09

Yukihiro Matsumoto wrote:

[#44107] Re: for ... else ... end — "Kontra, Gergely" <kgergely@...> 2002/07/09

For the keyword war: (silly, dummy example)

[#43957] Redirecting standard error — Gilles Filippini <gilles.filippini@...>

Hi,

13 messages 2002/07/08

[#44019] String#split converts string args to regexes -- ? — David Alan Black <dblack@...>

Hello --

41 messages 2002/07/08
[#44104] Re: String#split converts string args to regexes -- ? — kasal@... (Stepan Kasal) 2002/07/09

Hallo,

[#44137] Re: String#split converts string args to regexes -- ? — matz@... (Yukihiro Matsumoto) 2002/07/09

Hi,

[#44209] Re: String#split converts string args to regexes -- ? — kasal@... (Stepan Kasal) 2002/07/10

Hallo,

[#44212] Re: String#split converts string args to regexes -- ? — David Alan Black <dblack@...> 2002/07/10

Hi --

[#44265] spliter of for...each: looping — Tom Sawyer <transami@...>

when looping, using each, i find i am often wonton of a few nice

24 messages 2002/07/10
[#44266] Re: spliter of for...each: looping — David Alan Black <dblack@...> 2002/07/10

Hello --

[#44268] Re: spliter of for...each: looping — Tom Sawyer <transami@...> 2002/07/10

hmmm...

[#44270] Re: spliter of for...each: looping — David Alan Black <dblack@...> 2002/07/10

Hi --

[#44272] Re: spliter of for...each: looping — Tom Sawyer <transami@...> 2002/07/10

david,

[#44275] Re: spliter of for...each: looping — David Alan Black <dblack@...> 2002/07/10

Hi --

[#44282] Re: spliter of for...each: looping — Tom Sawyer <transami@...> 2002/07/11

each_with_nindex, rocking! i'll throw that in my library, for sure.

[#44289] Re: spliter of for...each: looping — David Alan Black <dblack@...> 2002/07/11

Hi --

[#44296] RE: Commercial Support for Ruby — "Berger, Daniel" <djberge@...>

> Hi Everyone,

18 messages 2002/07/11

[#44312] opengl — Tom Sawyer <transami@...>

can any one give me some help installing the opengl interface library? i

22 messages 2002/07/11
[#44316] Re: opengl — Dossy <dossy@...> 2002/07/11

On 2002.07.12, Tom Sawyer <transami@transami.net> wrote:

[#44320] Re: opengl — Tom Sawyer <transami@...> 2002/07/11

just did apt-get mesag-dev. still the same thing:

[#44387] Dynamic Methods — "John" <nojgoalbyspam@...>

Hi all,

29 messages 2002/07/12
[#44402] Re: Dynamic Methods — "John" <nojgoalbyspam@...> 2002/07/12

Wow! Thanks Dave!

[#44408] Re: Dynamic Methods — Michael Campbell <michael_s_campbell@...> 2002/07/12

[#44415] Re: Dynamic Methods — "John" <nojgoalbyspam@...> 2002/07/13

> (What do you propose if more than one possibility matches, by the

[#44425] hey! where's #count? — Tom Sawyer <transami@...>

i went to count the number of equal objects in an array and discoverd

24 messages 2002/07/13
[#44515] Re: hey! where's #count? — "Christoph" <chr_news@...> 2002/07/14

"Tom Sawyer" wrote

[#44516] Re: hey! where's #count? — Philipp Meier <meier@...> 2002/07/14

On Sun, Jul 14, 2002 at 11:41:55PM +0900, Christoph wrote:

[#44517] RE: hey! where's #count? — "Christoph" <crippel@...> 2002/07/14

[#44482] instance_eval — "John" <nojgoalbyspam@...>

Hi all,

14 messages 2002/07/13

[#44618] RE: TkText no -textvariable workaround? — "J.Hawkesworth" <J.Hawkesworth@...>

I think what Tom is after is a neat way to have the widget's display

41 messages 2002/07/16
[#44621] RE: TkText no -textvariable workaround? — Tom Sawyer <transami@...> 2002/07/16

On Tue, 2002-07-16 at 09:08, J.Hawkesworth wrote:

[#44622] Re: TkText no -textvariable workaround? — Dossy <dossy@...> 2002/07/16

On 2002.07.17, Tom Sawyer <transami@transami.net> wrote:

[#44626] Re: TkText no -textvariable workaround? — Tom Sawyer <transami@...> 2002/07/16

actually, Dossy, your post was a bit helpful. what i'm after also sort

[#44628] Re: TkText no -textvariable workaround? — Dossy <dossy@...> 2002/07/16

On 2002.07.17, Tom Sawyer <transami@transami.net> wrote:

[#44734] Syntax "surprise" — "David Douthitt" <DDouthitt@...>

I don't know if this qualifies as a real "surprise", but it was to me. I h=

39 messages 2002/07/17

[#44788] Selling ruby to my boss — Francis Hwang <sera@...>

So I've just started working as the sole programmer at a non-profit

22 messages 2002/07/18

[#44829] Q: "print usage_msg, exit 1 if error_flag" does not work — kwatch@... (kwatch)

Hi,

15 messages 2002/07/18
[#44831] Re: Q: "print usage_msg, exit 1 if error_flag" does not work — ts <decoux@...> 2002/07/18

>>>>> "k" == kwatch <kwatch@lycos.jp> writes:

[#44832] Re: Q: "print usage_msg, exit 1 if error_flag" does not work — Hugh Sasse Staff Elec Eng <hgs@...> 2002/07/18

On Thu, 18 Jul 2002, ts wrote:

[#44833] Re: Q: "print usage_msg, exit 1 if error_flag" does not work — ts <decoux@...> 2002/07/18

>>>>> "H" == Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:

[#44855] Ruby in MacOSX 10.2 (Jaguar) — Luc Heinrich <lucsky@...>

It now seems to be "official" that Ruby will come by default with the next iteration of MacOSX.

12 messages 2002/07/18

[#44893] amrita 0.8.1 — Taku Nakajima <tnakajima@...>

Amrita is a a html/xhtml template library for Ruby.

22 messages 2002/07/19

[#44920] Objective C backend for Ruby? — "James F.Hranicky" <jfh@...>

While people are kicking around ideas for new backends for Ruby,

24 messages 2002/07/19

[#44985] GUI's and the Rouge, Part II — Tom Sawyer <transami@...>

in part one of this message i mention the problem of non-POLS and

72 messages 2002/07/20
[#45161] Re: GUI's and the Rouge, Part II — patrick-may@... (Patrick May) 2002/07/23

Ned Konz <ned@bike-nomad.com> wrote in message news:<200207201125.13528@ned.bike-nomad.com>...

[#45241] Re: GUI's and the Rouge, Part III (yes, finally) 1/2 — Tom Sawyer <transami@...> 2002/07/23

a bit of an intro: my original thought on the matter of making a

[#45246] Re: GUI's and the Rouge, Part III (yes, finally) 1/2 — Albert Wagner <alwagner@...> 2002/07/24

Still looks like plain old Model-View-Controller to me. You've split the

[#45282] RE: GUI's and the Rouge, Part III (yes, finally) 1/2 — "Curt Hibbs" <curt@...> 2002/07/24

Tom Sawyer wrote:

[#45287] RE: GUI's and the Rouge, Part III (yes, finally) 1/2 — Steve Tuckner <STUCKNER@...> 2002/07/24

What about WX-Windows. There is no ruby bindings for it, but would that fit

[#45300] RE: GUI's and the Rouge, Part III (yes, finally) 1/2 — Tom Sawyer <transami@...> 2002/07/24

On Wed, 2002-07-24 at 08:39, Steve Tuckner wrote:

[#45314] Re: GUI's and the Rouge, Part III (yes, finally) 1/2 — Wayne Vucenic <wvucenic@...> 2002/07/24

Hi Tom,

[#45364] RE: GUI's and the Rouge, Part III (yes, finally) 1/2 — "Curt Hibbs" <curt@...> 2002/07/25

Wayne Vucenic wrote:

[#45416] wxWindows for ruby — "repeater" <repeater@...> 2002/07/25

> Wayne Vucenic wrote:

[#44994] Learning Japanese — "John" <nojgoalbyspam@...>

Inspired to learn to read Japanese due to a lot of information on Ruby being

12 messages 2002/07/20

[#45044] Install troubles — Jim Freeze <jfreeze@...>

Hi:

13 messages 2002/07/21
[#45051] Re: Install troubles — Chris Gehlker <gehlker@...> 2002/07/21

On 7/21/02 12:13 PM, "Jim Freeze" <jfreeze@freebsdportal.com> wrote:

[#45085] ruby-dev summary 17696-17713 — Minero Aoki <aamine@...>

Hi all,

28 messages 2002/07/22
[#45090] rdtool and rdoc — Dave Thomas <Dave@...> 2002/07/22

Minero Aoki <aamine@mx.edit.ne.jp> writes:

[#45118] Re: rdtool and rdoc — "David Douthitt" <DDouthitt@...>

I took a look at your comparison page. I've not used either, but some thin=

16 messages 2002/07/22

[#45136] Strings and member-operators — the Bare <grrr@...>

Hi:

22 messages 2002/07/22
[#45140] Re: Strings and member-operators — Dossy <dossy@...> 2002/07/23

On 2002.07.23, the Bare <grrr@wild.net> wrote:

[#45148] Re: Strings and member-operators — David Alan Black <dblack@...> 2002/07/23

Hi --

[#45173] Re: Strings and member-operators — Dossy <dossy@...> 2002/07/23

On 2002.07.23, David Alan Black <dblack@candle.superlink.net> wrote:

[#45175] Re: Strings and member-operators — David Alan Black <dblack@...> 2002/07/23

Hi --

[#45198] Re: Strings and member-operators — George Ogata <g_ogata@...> 2002/07/23

Hello,

[#45201] Re: Strings and member-operators — David Alan Black <dblack@...> 2002/07/23

Hi --

[#45206] Re: Strings and member-operators — Tom Sawyer <transami@...> 2002/07/23

let me get this straight? is the original question how to strip a string

[#45257] Re: GUI's and the Rouge, Part III (yes, finally) 1/2 — Benjamin Peterson <bjsp123@...>

>you have this super application you wrote --the

11 messages 2002/07/24

[#45269] Can I get data back from a fork? — Jim Freeze <jfreeze@...>

Hi:

15 messages 2002/07/24

[#45286] Re: GUI's and the Rouge, Part III (yes, finally) 1/2 — Benjamin Peterson <bjsp123@...>

>its really just SOC on aanother level.

10 messages 2002/07/24

[#45368] Re: [OT] Re: GUI's and the Rouge, Part III (yes, finally) 1/2 — Benjamin Peterson <bjsp123@...>

>The functionality of a spreadsheet had been around

39 messages 2002/07/25
[#45476] Re: curses dev kit, was Re: [OT] Re: GUI's and the Rouge — Thomas Dickey <dickey@...> 2002/07/26

clemens fischer <ino-waiting@gmx.net> wrote:

[#45480] Re: curses dev kit, was Re: [OT] Re: GUI's and the Rouge — Massimiliano Mirra <list@...> 2002/07/26

On Fri, Jul 26, 2002 at 07:51:25PM +0900, Thomas Dickey wrote:

[#45422] Singleton Classes & thread safety — David King Landrith <dave@...>

I'm a bit new to Ruby, so please excuse me if this is a simplistic=20

24 messages 2002/07/25
[#45425] Re: Singleton Classes & thread safety — Ned Konz <ned@...> 2002/07/25

On Thursday 25 July 2002 02:06 pm, David King Landrith wrote:

[#45427] Re: Singleton Classes & thread safety — David King Landrith <dave@...> 2002/07/25

On Thursday, July 25, 2002, at 05:26 PM, Ned Konz wrote:

[#45430] Re: Singleton Classes & thread safety — Ned Konz <ned@...> 2002/07/25

On Thursday 25 July 2002 02:44 pm, David King Landrith wrote:

[#45431] How do you think of... — Michael Campbell <michael_s_campbell@...> 2002/07/25

This is going to sound like an odd question, and there's no "right"

[#45429] Opinion on Ruby maturity, the missing things — "Paul E.C. Melis" <paul@...>

Hello all,

18 messages 2002/07/25
[#45440] Re: Opinion on Ruby maturity, the missing things — John Carter <john.carter@...> 2002/07/25

On Fri, 26 Jul 2002, Paul E.C. Melis wrote:

[#45465] Ruby-Talk Index — Tom Sawyer <transami@...>

here's a one nighter coding challange for some one feeling the need to

17 messages 2002/07/26
[#45466] Re: Ruby-Talk Index — matz@... (Yukihiro Matsumoto) 2002/07/26

Hi,

[#45467] Re: Ruby-Talk Index — Tom Sawyer <transami@...> 2002/07/26

On Thu, 2002-07-25 at 23:50, Yukihiro Matsumoto wrote:

[#45621] Seattle.rb meeting tomorrow (7/30) — Pat Eyler <pate@...>

Just a quick reminder that we'll be meeting tomorrow night at 7:00 PM at

11 messages 2002/07/29

[#45644] FormatR 1.06 — Paul Rubel <rubel@...>

A new release of FormatR is out, 1.06. FormatR provides perl-like

37 messages 2002/07/30

[#45688] Ruby Language Q's — "Justin Johnson" <justinj@...>

76 messages 2002/07/30
[#45689] Re: Ruby Language Q's — Dave Thomas <Dave@...> 2002/07/30

"Justin Johnson" <justinj@mobiusent.com> writes:

[#45690] Re: Ruby Language Q's — ts <decoux@...> 2002/07/30

>>>>> "D" == Dave Thomas <Dave@PragmaticProgrammer.com> writes:

[#45723] Syntax proposal — Massimiliano Mirra <list@...>

I often write things like this:

12 messages 2002/07/30

[#45737] ActiveRubyScript and RubyAEOSA — Chris Gehlker <gehlker@...>

I just discovered ActiveRubyScript (sometimes written as two words) by

14 messages 2002/07/30
[#45742] Re: ActiveRubyScript and RubyAEOSA — "Hal E. Fulton" <hal9000@...> 2002/07/30

----- Original Message -----

[#45768] RE: A very basic tail -f implementation — "Berger, Daniel" <djberge@...>

> From: Paul Brannan [mailto:pbrannan@atdesk.com]

12 messages 2002/07/30

[#45799] Question about GetoptLong — Patrick Bennett <patrick.bennett@...>

I'm trying to recreate a Perl script in Ruby and have run into a problem.

22 messages 2002/07/31

[#45829] Unicode in Ruby now? — Tobias Peters <tpeters@...>

I've read the thread "Unicode in Ruby's Future?" [ruby-talk: 40016]. It

52 messages 2002/07/31
[#45840] Re: Unicode in Ruby now? — matz@... (Yukihiro Matsumoto) 2002/07/31

Hi,

[#45954] Re: Unicode in Ruby now? — Tobias Peters <tpeters@...> 2002/08/01

On Wed, 31 Jul 2002, Yukihiro Matsumoto wrote:

[#45960] Re: Unicode in Ruby now? — Curt Sampson <cjs@...> 2002/08/01

On Thu, 1 Aug 2002, Tobias Peters wrote:

[#45969] Re: Unicode in Ruby now? — Alexander Bokovoy <a.bokovoy@...> 2002/08/01

On Thu, Aug 01, 2002 at 07:53:07PM +0900, Curt Sampson wrote:

[#45973] Re: Unicode in Ruby now? — Curt Sampson <cjs@...> 2002/08/01

On Thu, 1 Aug 2002, Alexander Bokovoy wrote:

[#45979] Re: Unicode in Ruby now? — Alexander Bokovoy <a.bokovoy@...> 2002/08/01

On Thu, Aug 01, 2002 at 09:55:48PM +0900, Curt Sampson wrote:

[#45982] Re: Unicode in Ruby now? — Curt Sampson <cjs@...> 2002/08/01

On Thu, 1 Aug 2002, Alexander Bokovoy wrote:

[#45993] Re: Unicode in Ruby now? — Alexander Bokovoy <a.bokovoy@...> 2002/08/01

On Thu, Aug 01, 2002 at 11:23:38PM +0900, Curt Sampson wrote:

[#46042] Re: Unicode in Ruby now? — Curt Sampson <cjs@...> 2002/08/02

On Fri, 2 Aug 2002, Alexander Bokovoy wrote:

[#46260] Re: Unicode in Ruby now? — Clifford Heath <cjh_nospam@...> 2002/08/04

Curt Sampson wrote:

[#46266] Re: Unicode in Ruby now? — Curt Sampson <cjs@...> 2002/08/05

On Mon, 5 Aug 2002, Clifford Heath wrote:

[#46281] Re: Unicode in Ruby now? — Clifford Heath <cjh_nospam@...> 2002/08/05

Curt Sampson wrote:

[#45922] Re: Unicode in Ruby now? — Clifford Heath <cjh_nospam@...> 2002/08/01

Matz,

[#45931] Re: Unicode in Ruby now? — Curt Sampson <cjs@...> 2002/08/01

On Thu, 1 Aug 2002, Clifford Heath wrote:

[#45859] matrix challange — Daniel Bretoi <lists@...>

15 messages 2002/07/31

[#45876] Emacs is dead, long live whatever comes after that as long as it is made with Ruby — Jani Alanko <jani.alanko@...>

Subject is not exactly right but I was too lazy to invent something that

13 messages 2002/07/31

Re: rubycam.rb v 1.7 CGI webcam script for use with cqcam, etc...

From: Phil <pvnews1@..._nekophile.com>
Date: 2002-07-03 19:14:07 UTC
List: ruby-talk #43508
Want to clarify that some redundancy existed in that post - the relevant
portion follows.

On Wed, 19 Jun 2002 16:54:21 -0700, Phil wrote:

> I don't want to mess with Sourceforge, so consider this my form of
> dissemination in case the server disappears some time.  Please forward
> mods to the email address listed under AUTHOR below.  PS: New to ruby
> when I wrote it - now have RSI - probably not going to make it very
> slick.  ;-)
> 
> -------------
> 
> #!/usr/bin/env ruby
> 
> ########################################################################
> ## VERSION: $Id: rubycam.rb,v 1.7 2002/03/22 20:08:52 rubycam Exp $ ##
> ## AUTHOR: Phil Voris <rubycam at nekophile.com> ## ## LICENSE: Ruby
> License - must include this header comment block ##
>      http://www.ruby-lang.org/en/LICENSE.txt ##
> ## DESCRIPTION:
> ## This CGI webcam script attempts to conserve resources by not ##
> creating images more often than the number of seconds indicated by ##
> the refresh setting.  Maximum flexibility is given by allowing the ##
> administrator to set the image-producing command line.  The ## defaults
> are arranged to use cqcam ## (http://www.cs.duke.edu/~reynolds/cqcam/).
> ##
> ## REQUIRES: ruby
> ##           ruby modules: net/smtp (for error reporting), ftools ##
>       rb2html.rb (for viewing source) ##           some image-grabber,
> such as cqcam ##           optionally, some image manipulation software
> ##
> ## USAGE:
> ## * Install under cgi-bin or wherever cgi executables are allowed. ## *
> Configure the global config section below. ## * Configure the default
> config section below. ## * Optionally create one or more config files to
> call in the PATH_INFO. ## * Ensure that img_file_web_directory exists
> and is writable by the ##   web server ## * [See end of script for
> recommendations for config and calling from ##   html.]
> ##
> ## TO DO:
> ## It would be nice to add caching.  That is, deliver a header ##
> indicating that the page (the image) hasn't changed until it ## actually
> does.  I attempted this, but found that ## HTTP_IF_MODIFIED_SINCE didn't
> appear in the environment.  I then ## attempted to use a session to
> track if the use had seen the page ## with the current image - however
> sessions weren't quite working for ## me - perhaps someone else can
> resolve this issue.
> ########################################################################
> 
> 
> #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # GLOBAL
> CONFIGURATION - EDIT HERE
> #
> # These options must be set
> #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 
> ## allow options from URL (true / false) use_config_files = true
> 
> ## img file directory [relative to DOC_ROOT] img_file_web_directory =
> '/img/cam'
> 
> ## configuration files directory
> config_dir = './config'
> 
> ## directory where rb2html and associated files may be found ## (used
> for /view)
> rb2html_directory = './rb2html-1.0'
> 
> ## file base-name
> lock_filename = 'rubycam.lock'
> 
> ## maximum age to keep a lock file (seconds, must exceed refresh time)
> max_lockfile_age = 500
> 
> ## shows a little (R) which links to the source.  Specify the target ##
> frame ('_new', '_self', etc) or nil to not display it.
> source_link_target = '_new'
> 
> #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # END
> GLOBAL CONFIGURATION
> #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 
> #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #
> PER-CAM CONFIGURATION - SET DEFAULTS HERE #                       - MAY
> MODIFY IN CONFIG FILES #
> # Anything listed in this section may be set - as below - in a #
> separate file.
> #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 
> ## default_cqcam_opts
> cmd_line = 'cqcam -r -q 25 -s 1 -j'
> 
> ## filename for the images
> img_filename = 'plain.jpg'
> 
> ## admin email address
> admin_email_address = 'webmaster@localhost'
> 
> ## page title
> title = 'Rubycam'
> 
> ## background (color)
> bgcolor = 'black'
> 
> ## text (color)
> text_color = 'yellow'
> 
> ## browser refresh length (in seconds) refresh = 60
> 
> ## img_background_color (color | nil to disable globally)
> img_background_color = nil
> 
> ## randomize transparency_background_color (true / false)
> use_randomize_img_background_color = false
> 
> ## randomize transparency_background_color (true / false)
> use_randomize_text_color = false
> 
> ## match text and img backgrounds - useful for randomization ## (true /
> false)
> text_color_matches_img_background_color = false
> 
> ## color for the source link, if it appears (color) source_link_color =
> 'darkred'
> 
> #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # END
> PER-CAM CONFIGURATION
> #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 
> 
> 
> 
> 
> 
> ########################################## ### PROCESS URL OPTIONS FROM
> PATH_INFO ### ########################################## ## If the
> script is called from a URL with path info equal to 'view' or ## 'get'
> the contents of the script will be displayed.  'get' results ## in
> text/plain output while view - relying on rb2html - output color- ##
> coded html output with line numbers. path_info =
> ENV['PATH_INFO'].untaint
> 
> if path_info == '/get'
>    ## Print source
>    puts( "Content-type: text/plain\n\n" ) IO::foreach(
>    ENV['SCRIPT_FILENAME'].untaint ) { |l|
>      puts l
>    }
>    exit
> elsif path_info == '/view'
>    ## Print formatted source
>    puts( "Content-type: text/html\n\n" ) rb2html_executable =
>    rb2html_directory + '/rb2html.rb' if File::file?( rb2html_executable
>    )
>      begin
>        htmlpipe = IO::popen( 'ruby ' + rb2html_executable + ' ' +
> 			   ENV['SCRIPT_FILENAME'].untaint )
>        puts( htmlpipe.readlines() )
>      rescue SystemCallError
>        ## Mail admin if any errors - if you don't want mail, change ##
>        the admin address.
>        require 'net/smtp'
>        smtp = Net::SMTP::new( "localhost" )
>        smtp.start
>        body = "Error:\nruby " + rb2html_executable + ' ' +
> 	ENV['SCRIPT_FILENAME'].untaint
>        smtp.sendmail( body, 'rubycam_user@localhost',
>        admin_email_address ) smtp.finish
>      end
>      exit
>    else
>      puts( "Content-type: text/plain\n\n" ) puts( "Error: cannot execute
>      " + rb2html_executable ) exit
>    end
> elsif path_info != nil
>    if not File::file?( config_dir + path_info )
>      ## Print error
>      puts( "Content-type: text/plain\n\n" ) puts( "Error: invalid config
>      file: '" + config_dir + path_info +
> "'\n" +
> 	 "Set the PATH_INFO (in the url) to a valid config file name." )
>      exit
>    elsif path_info.index( '../' ) != nil
>      ## Print error
>      puts( "Content-type: text/plain\n\n" ) puts( "Error: invalid config
>      file: '" + config_dir + path_info +
> "'\n" +
> 	 "'../' not permitted in config file pathname." )
>      exit
>    elsif not File::readable?( config_dir + path_info )
>      ## Print error
>      puts( "Content-type: text/plain\n\n" ) puts( "Error: unreadable
>      config file: '" + config_dir + path_info +
> "'" )
>      exit
>    else
>      ## Process config file
>      config_file_string = ''
>      File::open( config_dir + path_info ).readlines.each do |line|
>        config_file_string.concat( line )
>      end
>      eval config_file_string
>    end
> end
> 
> 
> ###########################
> ### DETERMINE FILE INFO ###
> ###########################
> 
> ## First, we determine the colors to be used for text (the image time)
> ## and for the background of the image (not the page bgcolor).
> color_hash = {
>    0 => 'white',
>    1 => 'red',
>    2 => 'orange',
>    3 => 'yellow',
>    4 => 'green',
>    5 => 'blue',
>    6 => 'purple',
>    7 => 'lightgreen',
>    8 => 'pink',
>    9 => 'lightyellow',
>    10 => 'lightblue',
>    11 => 'lightgray',
>    12 => 'gray'
> }
> }
> ## If img_background_color is set to nil, then no image background ##
> color options will apply.
> if img_background_color != nil and
>      use_randomize_img_background_color
>    img_background_color = color_hash[rand(13)]
> end
> 
> ## If randomization is used for text and image, then the image ##
> background color is used for both. if  use_randomize_text_color and
>      not text_color_matches_img_background_color
>    text_color = color_hash[rand(13)]
> elsif ( img_background_color != nil ) and
>        text_color_matches_img_background_color
>    text_color = img_background_color
> end
> 
> img_file_webpath = img_file_web_directory + '/' + img_filename
> img_file_pathname = ENV['DOCUMENT_ROOT'] + img_file_webpath
> img_file_pathname.untaint
> img_file_tmp_pathname = img_file_pathname + '.tmp'
> 
> ## Time
> time_now = Time::now
> 
> ## Mtime
> if File::exist?( img_file_pathname )
>    img_file_mtime = File::mtime( img_file_pathname ) img_file_mtime_int
>    = img_file_mtime.to_i img_file_mtime_string = img_file_mtime.to_s
>    img_file_age = time_now.to_i - img_file_mtime_int
> end
> 
> ###########################
> ###    LOCKFILE CODE    ###
> ###########################
> 
> ## Lock file name is global - there is only one camera and it can take
> ## only one picture at a time.  The lockfile is set during this process.
> lock_file_pathname = ENV['DOCUMENT_ROOT'] + img_file_web_directory + '/'
> +
>    lock_filename
> lock_file_pathname.untaint
> 
> ## If the lockfile somehow gets stale, it will be removed. locked =
> false
> if File::exist?( lock_file_pathname )
>    if ( File::mtime( lock_file_pathname ) < ( time_now - (
> max_lockfile_age ) ) )
>      File::unlink( lock_file_pathname )
>    else
>      locked = true
>    end
> end
> 
> ###########################
> ###       EXECUTE       ###
> ###########################
> 
> ## If there's no image, or it's an old one, and the camera is free, ##
> then we take a new picture.
> if  ( ( not File::exist?( img_file_pathname ) ) or
>        ( img_file_age >= refresh ) ) and
>      ( not locked )
> 
>    lockfile = File::new( lock_file_pathname, mode='w' )
> 
>    begin
>      ## Execute
>      img_file = File::open( img_file_tmp_pathname, mode='w').write(
> IO::popen( cmd_line ).read() )
>      require 'ftools'
>      File::mv( img_file_tmp_pathname, img_file_pathname ) File::unlink(
>      lock_file_pathname )
>      img_file_mtime = Time::now
>      img_file_mtime_string = img_file_mtime.to_s
>    rescue SystemCallError
>      ## Mail admin if any errors - if you don't want mail, change ## the
>      admin address.
>      require 'net/smtp'
>      smtp = Net::SMTP::new( "localhost" )
>      smtp.start
>      body = "Subject: Error with rubycam\n" +
>        "Failed to execute:\n" + cmd_line + "\n\nSee logs for details."
>      smtp.sendmail( body, 'rubycam_user@localhost', admin_email_address
>      ) smtp.finish
>      File::unlink( lock_file_pathname )
>    end
> 
> end
> 
> ###########################
> ###        HTML         ###
> ###########################
> 
> puts( "Content-type: text/html\n" +
>       'Last-Modified: ' + img_file_mtime_string + "\n" + 'Expires: ' + (
>       img_file_mtime + refresh ).to_s + "\n\n" )
> 
> puts( '<head><title>' + title + '</title>' +
>       '<META HTTP-EQUIV="Refresh" CONTENT="' + refresh.to_s +
>       '"></head>' )
> 
> puts( '<body bgcolor="' + bgcolor + '" text="' + text_color + '">' )
> 
> puts( '<center><table><tr><td' )
> 
> if img_background_color != nil
>    puts( ' bgcolor="' + img_background_color + '"' )
> end
> 
> puts( '><img src="' + img_file_webpath + '"></td></tr></table><p>' )
> 
> puts( '<p><b>' + img_file_mtime_string + '</b>' )
> 
> if source_link_target != nil
>    puts( ' <small><a href="' + ENV['SCRIPT_NAME'].untaint + '/get"
> target="' + source_link_target + '"><font color="' + source_link_color +
> '">&reg;</font></a></small>' )
> end
> 
> puts( '</center></body></html>' )
> 
> 
> 
> ###########################
> ###  CALLING FROM HTML  ###
> ###########################
> ##
> ## Include the following in your page head: ## ##     <script
> language=javascript>
> ##     function openwin(url){
> ##         var hWnd =
> ##
> window.open(url,"","width=350,height=300,resizable=yes,scrollbars=yes");
> 
> ##         if (!hWnd.opener) hWnd.opener = self; ##     } ##    
> function openminiwin(url){
> ##         var hWnd =
> ##
> window.open(url,"","width=180,height=140,resizable=yes,scrollbars=yes");
> 
> ##         if (!hWnd.opener) hWnd.opener = self; ##     } ##    
> </script>
> ##
> ## Call within body of page as:
> ##
> ## <ul>
> ##         <li><a
> href="Javascript:openwin('/cgi-bin/webcam/rubycam.rb');">Webcam</a> ##
>       <li><a
> href="Javascript:openwin('/cgi-bin/webcam/rubycam.rb/transgif.conf');">Psychedelicam</a>
> ##         <li><a
> href="Javascript:openwin('/cgi-bin/webcam/rubycam.rb/greyjpeg.conf');">Greycam</a>
> ##
> ##
> ##         <li><a href="/cgi-bin/webcam/rubycam.rb/view">Formatted
> Source</a>
> ##         <li><a href="/cgi-bin/webcam/rubycam.rb/get">Source</a> ##
> </ul>
> ##
> 
> ###########################
> ###   CONFIG FILE # 1   ###
> ###########################
> ## greyjpeg.conf - produces a grey jpeg #  cmd_line = 'cqcam -s 1 |
> ppmtojpeg --progressive --greyscale --optimize --quality=33
> --comment="Made with Rubycam"' #  img_filename = 'grey.jpg' #  title =
> 'Greycam'
> #  refresh = 60
> 
> ###########################
> ###   CONFIG FILE # 2   ###
> ###########################
> ## transgif.conf - produces a transparent gif with weird effects #
> cmd_line = 'cqcam -s 1 | ppmquant 2 | ppmtogif -transparent grey
> -interlace -sort -comment="Made with Rubycam"' #  img_filename =
> 'transparent.gif'
> #  title = 'Psychedelicam'
> #  refresh = 60
> #  img_background_color = 'red'
> #  use_randomize_img_background_color = true #  use_randomize_text_color
> = true
> #  text_color_matches_img_background_color = true
> 
> 
> ## EOF

In This Thread

Prev Next