392769-397835 subjects 393170-393641

Reading specific columns on a text file
392999 [cassiopgodin] I'm working on script here and I need do read the 1st and the 10th
+ 393000 [matma.rex@gm] line.split(" ")[0 , 11] does, in fact, return 11 items, starting from 0th.
| 393002 [cassiopgodin] Thank you very much, that was perfect.
+ 393001 [rob@ag le on] first
  393103 [shortcutter@] 35959

moveto(x,y) method
393004 [aport99@gm i] How can I declare moveto method if I want to change co-ordinates (x,y)
+ 393005 [code@ap th o] module Domieszka
+ 393006 [peter@va de ] You probably want a class here, so you can make
+ 393007 [aport99@gm i] ok, than you very much. It must be a module because it will be used in

class Circle
393008 [aport99@gm i] With co-ordinates x y that are in Domieszka module I want to do ray r in
+ 393009 [aport99@gm i] ray that has some length:) not co-ordinates
+ 393018 [steve@st ve ] Circle = Struct.new(:x, :y)
  393019 [steve@st ve ] Circle = Struct.new(:x, :y, :r)

Basic Ruby performance
393012 [dniq@dn q- n] First, I should point out that I'm new to Ruby, although it seems pretty
+ 393013 [dniq@dn q- n] s = "This is a test string"
| 393015 [ryand-ruby@z] s = "This is a test string"
| + 393016 [peter@va de ] Euhmmm, I doubt that ...
| | 393020 [ryand-ruby@z] You're replacing a method call (a.match b) with a syntactic construct a =
| | + 393022 [josh.cheek@g] Wow, I never knew that. I don't understand how it accomplishes this, a
| | | + 393024 [ryand-ruby@z] a =3D~
| | | | 393032 [code@ap th o] . . . unless you have a different default for the method's argument.
| | | + 393029 [code@ap th o] That's only because it *does* look cleaner.
| | + 393028 [dniq@dn q- n] The reason I tried to use Regexp.new is because I figured it would
| |   + 393036 [jeremy@bo p.] Everything in Ruby is an object, even regexps, so you can save your
| |   | + 393040 [josh.cheek@g] The o flag tells Ruby to only interpolate the first time, and then cache
| |   | | 393044 [jeremy@bo p.] Thanks for the tip! :-)  Still, sprinkling that option around might
| |   | + 393060 [dniq@dn q- n] Thank you for the advices!
| |   |   393063 [wyhaines@gm ] Do you realize that there are multiple Ruby interpreters with
| |   |   393065 [dniq@dn q- n] Yeah, I saw it in another post - I'll give them a try.
| |   + 393052 [shortcutter@] Not necessary in Ruby: regexp literals are treated specially and are
| + 393017 [jeremy@bo p.] Ryan is being a little facetious about the parenthesis and whitespace in
|   + 393021 [ryand-ruby@z] I tried to drive that point home by showing a ruby solution that was =
|   + 393027 [dniq@dn q- n] Hmmm... Didn't realize this would make difference :) Thanks!
|     393058 [cremes.devli] Hard to believe that this thread has gone this long without a mention of other Ruby runtimes.
+ 393014 [ryand-ruby@z] like
| 393026 [dniq@dn q- n] My code was merely an example of very simple loop. Its purpose was not
| + 393033 [su.comp.lang] One thing you can do is to replace for loops with while loops. For loops
| | 393034 [dniq@dn q- n] Hmmm... Thanks! Definitely useful advice!
| + 393051 [shortcutter@] your processing is CPU bound?  If it is IO bound the difference
|   393061 [dniq@dn q- n] Yep, I'm sure it's CPU bound: the CPU load is at 100%. The data comes in
|   393066 [josh.cheek@g] It creates a Range, which just iterates, not an array. A more idiomatic way
|   393069 [dniq@dn q- n] Phew... :)
+ 393030 [dniq@dn q- n] I have to tell, however, that string.split() works much faster in Ruby
+ 393041 [botpena@gm i] omg, careful w big numbers in ruby..
| 393043 [botpena@gm i] using plain fixnum may help, but the jump is still there
| + 393046 [botpena@gm i] pls ignore. i think it is consistent at 10
| + 393059 [rubytalk2dav] Ummmm... yeah... every time you tell it to do ten times as many loops,
|   393089 [botpena@gm i] i noticed the mult 10 too late. what i was emphasizing is that, given
+ 393045 [reid.thompso] $ cat mult.rb
+ 393062 [dniq@dn q- n] Here's a question: when I say "for a in ( 0..1E8 )" - does Ruby create
| 393064 [echristopher] It might make a counter-based loop internally, but at a higher level
+ 393071 [dniq@dn q- n] Tried rubinius and jruby. Rubinius so far is the fastest one, but still
| + 393073 [cremes.devli] The thing you need to know about Rubinius and JRuby is that they both JIT (just-in-time) compile the code, but they need to collect statistics on the runtime profile first. That usually takes a few seconds. So any test that runs for under 10s or so doesn't give the runtime much opportunity to optimize the code.
| + 393476 [headius@he d] I cannot reproduce. Post your jruby -v...I suspect it's running with
|   393477 [headius@he d] And your other bench. Again, pretty meaningless.
+ 393072 [dniq@dn q- n] - Ruby 1.8.7 does not support \p{} regexps (like \p{Alnum} for example),

[ANN] isolate 3.2.2 Released
393025 [ryand-ruby@z] isolate version 3.2.2 has been released!

problem with method
393035 [aport99@gm i] Why method pole= doesn't work??
+ 393037 [code@ap th o] I'm not entirely sure what you're trying to do.  Does this accomplish
+ 393038 [aport99@gm i] I mean that Pole= is the same as Pole_is. I want to declare accessors to
+ 393039 [aport99@gm i] pole= is the name of the method
+ 393042 [josh.cheek@g] There's a bunch of things here to pay attention to.

[ANN] md2man 1.1.0
393047 [sunaku@gm il] md2man - markdown to manpage - https://github.com/sunaku/md2man#readme

[ANN] binman 3.0.1
393048 [sunaku@gm il] binman - UNIX man pages for Ruby bin/ scripts

Choosing target network for UDP broadcast
393050 [wever@ax ni ] socket = UDPSocket.new
+ 393055 [shortcutter@] Hm, no UDP specialist here but can't you bind to the proper address
+ 393056 [sean.ohalpin] Use #bind - http://ruby-doc.org/stdlib-1.9.3/libdoc/socket/rdoc/Socket.html=
  393057 [sean.ohalpin] ml#method-i-bind

Problem migrating to Ruby 1.9.2
393076 [pbayford@ta ] Some assistance please - I have a Ruby project, which I started in Ruby
+ 393077 [ryand-ruby@z] Ruby
+ 393078 [shortcutter@] Did you consider using Marshal?
| 393094 [pbayford@ta ] I did try using Marshal, however, while the examples show how to use
| 393102 [shortcutter@] The docs at http://www.ruby-doc.org/core-1.9.3/Marshal.html#method-c-dump
| 393293 [pbayford@ta ] Thanks for the assist Robert - marshal does indeed work - the key for me
| 393308 [shortcutter@] ve
+ 393080 [pbayford@ta ] Just went back to it to get a copy of the errors, which were extensive,
  393081 [rubytalk2dav] Yes, we fixed it by remote control.  ;-)
  393092 [pbayford@ta ] I guessed as much!!! Seriously, wondering if something in the site code

Difficulty writing a sorting method (Chris Pine's Learn to Program)
393079 [offbeatheart] Chris Pine's book. The assignment I'm working on is to write a sorting
+ 393082 [rcoulman@gm ] I'm fairly new to Ruby myself, but not to programming in general.
+ 393144 [jgabrielygal] Welcome to Ruby, I hope you enjoy it !

Inheritance in other notation
393083 [aport99@gm i] notation like 'class Square', we can write class Rectangle like 'class
393088 [jeremy@bo p.] class Rectangle < Square
393104 [shortcutter@] reated classes, so you don't have to do anything special to make Rectangle =
393105 [josh.cheek@g] Probably neither should inherit from the other since they break Liskov
393109 [shortcutter@] gle

Psych YAML problems
393084 [jlambert@oh ] Caught Psych::SyntaxError: (xxxxxx.yaml): couldn't parse YAML at line 168
393097 [ryand-ruby@z] 168 column 8

4 random numbers take highest 3 and add them together.
393085 [serpentinexc] I want to get 4 random numbers. The numbers will be between 1-6. I want
+ 393087 [jeremy@bo p.] It would be easier for others to help you if you included the actual error message you get in addition to the code that purportedly produced the error. Not everyone seeing your post has the ability (that's me at the moment) or desire to copy and paste your code, but they may be able to help anyway with the error message in hand. :-)
+ 393090 [list.push@gm] This is a different approach but if it doesn't work, I think it is
+ 393091 [list.push@gm] If you don't like inject, this is even shorter and easier to understand.
+ 393093 [kachick1@gm ] I think that error from some causes.
| 393095 [kachick1@gm ] sorry, my ex2 is not safety(if [1, 1, 3, 6])
+ 393098 [josh.cheek@g] even begin identifying them. I recommend you start with something simple
+ 393111 [serpentinexc] Thank you Harry. Thank you everyone. This works.

libv8 problem
393086 [phildobbin@g] I'm trying to run an intial rake to create my databases on a Rails
393106 [hassan.schro] Why `sudo` for this?
393107 [phildobbin@g] I ran `sudo` because rake complained `no password_auth`.
393108 [phildobbin@g] I found the cause: an errant line in my bashrc was leading Ruby up the

Encoding error
393096 [guillaume.do] # encoding: UTF-8
393101 [matma.rex@gm] Marshal.dump generates binary data, not containing any real strings

[ANN] Code Zauker
393099 [jj@gi or i. ] I am happy to announce my new Ruby project after years of python coding

Please help me find the error in my logical OR
393110 [serpentinexc] Please help me find the error in my logical OR.
+ 393113 [ryand-ruby@z] Why aren't you using Array#sort? I'm sure it was suggested.
+ 393134 [gilbertly@gm] as an exercise, you may play your code with the following values for stats1=
+ 393157 [rubytalk2dav] I think it would be a lot easier to fix if it weren't depending on

[ANN] event_hook 1.1.1 Released
393112 [ryand-ruby@z] event_hook version 1.1.1 has been released!

Re: Freightrain 0.8.0 released
393114 [beagle4321_2] I was super impressed with freightrain, when I looked at it last year.
393116 [shevegen@li ] rb testapp.rb
393118 [andrea@an re] I'm in Argentina at the moment and I can't investigate
393119 [andrea@an re] I'm in Argentina at the moment and I can't investigate
393120 [andrea@an re] I'm really sorry I didn't kept much contact with you

Hooking a function to run in IRB context (but only in IRB context)?
393115 [shevegen@li ] I start IRB.
+ 393117 [josh.cheek@g] Don't know how to do it with irb, but if you use pry (which is way better
+ 393126 [shevegen@li ] Hmm thanks but ... I am really not sure how to do that ...
| 393151 [jrmair@gm il] Put this in your `.pryrc`
+ 393127 [b.candler@po] => nil

[ANN] bulker 0.1.0 Released
393121 [daixque@gm i] bulker version 0.1.0 has been released!

Re: Armagh v Cork Gaa Allianz Football 2012 game live watch free,
393122 [newgame071@y] Watch here

str.encode! sets valid_encoding even if resulting string is invalid (1.9.3)
393123 [tgarnett@pa ] I get some untrusted input from some of our partners that should be in
393365 [ppaysant@go ] I'm observing the same problem. String#encode does not replace invalid

Simple even and odd number loop in Ruby
393124 [faithfromslo] type in a number. When this number is an "even" number, it will divide
+ 393125 [matma.rex@gm] def f n # this function calculates next number in your sequence
| + 393129 [echristopher] There's also Integer#even? and #odd?.
| + 393160 [faithfromslo] Thank you Bartosz, this is exactly what I was looking for. My loop was not good at all. I am still learning. If you are interested in doing online mentoring, please let me know. I would love to have such a good mentor like you.
+ 393158 [shortcutter@] Please show the code so we can give you concrete advice (vs. writing
+ 393165 [faithfromslo] How would you make this loop stop when it reaches number one?
| 393210 [jgabrielygal] Instead of looping forever (while true), you should only loop until num is 1.
+ 393252 [mmanny14@ya ] please is there any ideas on how to do this for a range of number say 2
+ 413653 [lists@ru y- ] If you wanted to print out only even integers from 0 - 20
| 413666 [mike@st k. a] divide
| 413670 [shortcutter@] 1. even numbers are printed; they are divided by two all the time
| 413675 [tamouse.list] The original problem (if I understand it) seems like an ideal
| 413729 [lists@ru y- ] I could be wrong, but aren't there 4 superfluous "self." in that code?
| 413730 [tamouse.list] Yes.
+ 413654 [lists@ru y- ] If you wanted to print out only even integers from 0 - 20

inheritance one more time
393128 [aport99@gm i] Square = Struct.new(:x,:y,:a) do
+ 393130 [echristopher] I'm not sure what's in your Domieszka module, but in the code you
+ 393132 [aport99@gm i] That's full of code. I think there is no problem with Domieszka.
  393138 [echristopher] Oh, right -- I forgot Square is a struct with a and a= defined on it.

Error with splat params in method definition
393131 [joneslee85@g] ```
393135 [jeremy@bo p.] Have you tried calling your method with the workaround with exactly 0 or
393147 [shortcutter@] This cannot reliably be evaluated because there is an ambiguity.  Will

393133 [daniel.manch] Daniel Manchego

How to keep list of reglar expressions into array
393136 [lakshmi27.u@] I have morethan one regular expressions
+ 393137 [josh.cheek@g] I have absolutely no idea what this means.
+ 393139 [botpena@gm i] try,
+ 393143 [shortcutter@] /r(?:uby|ails):\s*$/i

how to exit from outerblock
393140 [lakshmi27.u@] I have 2 blocks .i want exit innerblock and outer block if condition
+ 393141 [josh.cheek@g] a=[1,2,3,4,5,6]
+ 393142 [shortcutter@] "e.it" is a Groovyism.  We're in the realms of Ruby here. :-)

[ANN] md2man 1.2.0
393145 [sunaku@gm il] md2man - markdown to manpage - https://github.com/sunaku/md2man#readme

[ANN] binman 3.1.0
393146 [sunaku@gm il] binman - man pages for bin scripts

View/lookup referenced source file
393148 [piggy181@gm ] I wonder what would an experience ruby developer does when working a
393152 [richard.conr] I think it is more accurate to say that Rubists both professional and

393149 [fatihdurmus1] ...

393150 [fatihdurmus1] ...
393153 [msporysz06@g] oh that went well.

ruby encoding 1.8.7
393155 [srinivasarao] i am using rails 2.2.2 and ruby 1.8.7 and sql server 2008. when i am

formal argument cannot be a constant
393161 [tohasmukh@ya] def display_method(NM)
+ 393162 [rcoulman@gm ] In Ruby, variable names start with lower-case letters and constants
| 393172 [tohasmukh@ya] Thanks Randy. It works
+ 393163 [jgabrielygal] In Ruby, constants start with upper case letter, the error message
+ 393173 [tohasmukh@ya] Thanks Randy. It works

Using _ like in Scala?
393164 [shevegen@li ] fruits = %w( apple banana orange )
+ 393167 [rubytalk2dav] Lots of things... some of which we want to do, some not.  Let's not go
+ 393197 [josh.cheek@g] It could, but I doubt anyone would go for it. As an example, there are
+ 393201 [tony.arcieri] IMHO, Ruby's block argument semantics are already crazy enough.
| 393204 [echristopher] How so?
| 393206 [tony.arcieri] - Yielding arguments to a block without arguments discards the arguments
| 393208 [darkintent@g] It would make more sense to just eliminate the need to type even a
| + 393216 [shortcutter@] Like
| | 393219 [josh.cheek@g] I do this sometimes, but I do it like this
| | 393220 [shortcutter@] +1
| | 393240 [josh.cheek@g] The name would have no impact on the language, it is still just a block
| | + 393241 [darkintent@g] Good to know that Ruby already supports what I thought of doing.
| | + 393254 [shortcutter@] Hmm...  Maybe I wasn't clear enough.  I was trying to ask how any
| |   393259 [josh.cheek@g] Not sure about other editors, but TextMate knows what context it is in if
| |   393263 [shortcutter@] by
| |   + 393271 [steve@st ve ] $ echo "foo" |  ruby -pe 'next unless $_ =~ /(foo|bar|baz)/'
| |   | 393282 [darkintent@g] Wouldn't the general use case at issue here be addressed by adding
| |   | 393299 [shortcutter@] I do not think it is a good idea as a general rule because that
| |   + 393292 [josh.cheek@g] Yes, what I want is an editor feature (it's also a cognitive aid, even
| |     393300 [shortcutter@] Somehow I didn't understand what you meant by "syntax for naming
| |     393304 [josh.cheek@g] Yeah, I gave that example in my first response, just before "But never
| |     393328 [echristopher] Does TextMate have its own mechanism to name a folded block of code,
| |     393334 [josh.cheek@g] I am pretty sure I'd have to hack the syntax file. I probably would if I
| + 393224 [code@ap th o] What -- like this?
|   393237 [darkintent@g] Yes.  Does this only work in the REPL?  I've never tried that kind of
|   393242 [code@ap th o] As mentioned elsewhere, this works in Ruby, period.
+ 393222 [markus@fi ch] You've already got a lot of responses, on top of my head these are the

Easy loop question
393166 [faithfromslo] and odd numbers multiplied by three plus one.
+ 393169 [ryand-ruby@z] Please do your own homework
+ 393180 [rubytalk2dav] Ask yourself, why is it going forever?  Change the code that makes it
+ 393188 [faithfromslo] Yes, I have done it now. Now I just need to make it count all the
+ 393209 [cidza@ti .i ] print "Give me an integer number: "
+ 393218 [faith@ce tr ] def f n # this function calculates next number in your sequence

How to make a command-line string code block argument become a real block of code inside a script
393168 [gabrielgtz00] If a exec
393171 [sduncan@we a] This should work.