Topic for #ruby is now Ruby programming language || ruby-lang.org || RUBY SUMMER OF CODE! rubysoc.org/ || Paste >3 lines of text in http://pastie.org || Para a nossa audiencia em portugues http://ruby-br.org/
BrokenCog joined #ruby
ryanf joined #ruby
marcuspat joined #ruby
robwilliamsuk joined #ruby
mxweas_ joined #ruby
<blueadept>
what's the opposite of the intersection & command?
<blueadept>
i dont want to get the matches, i want to get the array items that have no duplicates
<blueadept>
do i have to write one myself?
<blueadept>
i'm using the - array command but it's not working
mxweas_ joined #ruby
<Squarepy>
blueadept: you mean remove duplicates from one array?
<Veejay>
Hi simple question: is there an easy to do a,b = 16 SOME_OPERATOR 5 and have a = 3 and b = 1 after that?
<Veejay>
As in a modulus type of deal
<banister`sleep>
Veejay: divmod
<Veejay>
Nice
roaminghorse joined #ruby
<Veejay>
Works perfectly
<Veejay>
Thanks man
<banister`sleep>
:)
brian- joined #ruby
vitoravelino joined #ruby
pen_isident joined #ruby
skrewler joined #ruby
samvelst joined #ruby
banister_ joined #ruby
samvelst left #ruby
dasfugufish joined #ruby
aef_ joined #ruby
aef_ joined #ruby
aef joined #ruby
wesdreem joined #ruby
Jimchaos_ joined #ruby
funktronic joined #ruby
funktronic left #ruby
mikeycgto joined #ruby
karstensrage joined #ruby
mikeycgto joined #ruby
<karstensrage>
whats the ruby authentication framework for web stuff?
<karstensrage>
devise?
marcuspat joined #ruby
skrewler joined #ruby
<any-key>
I've used auth_logic
<any-key>
rails 3.1 has built-in auth iirc
wyhaines joined #ruby
<karstensrage>
i have to write my own provider so what should i target?
dbgster joined #ruby
radmacd joined #ruby
<Syzygy_>
what does @ do with variables?
<Syzygy_>
and %w
<ryanf>
any-key: are you talking about has_secure_password?
<ryanf>
or is there more auth stuff now?
<any-key>
ryanf: dunno, I've heard it mentioned in brief, I haven't played with it myself
<any-key>
that might be it though
<ryanf>
Syzygy_: @var is an instance variable, %w(a b c) is ['a', 'b', 'c']
<Syzygy_>
oh, so %w defines that the following will be an array?
badabim joined #ruby
<ryanf>
or %w{a b c} or %w|a b c| or %w`a b c` or %w*a b c*
<ryanf>
an array of strings yes
phantasm66 joined #ruby
fatguylaughing joined #ruby
<ryanf>
it's just sugar for making an array of strings with less typing
<robyurkowski>
my personal favorite is using %q() for quotes
<robyurkowski>
makes writing interpreted html really nice
<phantasm66>
i am a total n00b w/ regards to ruby (and OOP in general)... my question is more style related....
<Syzygy_>
ok, and @ ... could you explain that for me an accordance with stuff like java or C#?
<headius>
so weird, why does that trigger my IRC highlight beep?
<headius>
someone type %q
<Syzygy_>
%p
<Syzygy_>
%q
<headius>
bizarre
<Syzygy_>
I'm stupid
<headius>
I wonder why Colloquy beeps on that
<Syzygy_>
you can set custom highlights in most IRC clients
<Syzygy_>
maybe you did at one point
<headius>
oh, what the hell
<headius>
type q
<Syzygy_>
q
<phantasm66>
is it considered bad form (or style) to use a simple case statement in a class (ie: a method is defined... but the case statement would be used to determine (based on the method's argument) a return type of my choosing
<headius>
how the hell did 'q' get in my highlight list
minijupe joined #ruby
<headius>
I really wanted to have it beep every time someone said the letter 'q' apparently
<ryanf>
haha
<phantasm66>
i work with a guy who's telling me that true ruby programmers avoid the use of case statements
<ryanf>
there are a ton of rails helpers that simulate polymorphism based on argument types
<phantasm66>
yes... the term polymorphism was also tossed in my direction by my coworker
<Syzygy_>
so @variable is rubys private?
<phantasm66>
robyurkowski: i guess that answers my question.. basically, stay away from static
<deryl>
@var are instance variables.
<deryl>
think of it as a variable private to a particular instance of a class instantiation
<Syzygy_>
I'll try
<ryanf>
Syzygy_: ruby doesn't actually have the concept of a public field or property
<Syzygy_>
i just read exactly that on this website ^
<ryanf>
attr_accessor and company basically generate getters and setters that simulate public-ness
iamjarvo joined #ruby
<ryanf>
but the underlying value is always stored as an instance variable
<ryanf>
which isn't accessible from outside the object
<Syzygy_>
I think i only need 1 class for this anyway
shevy joined #ruby
<Syzygy_>
I'm trying to make a crawler that looks for a single word on 4 websites
_hrrld joined #ruby
blaenk joined #ruby
beakerman joined #ruby
<any-key>
open-uri + a regex and you're set
<blaenk>
given strings in the form of "e > t + f", how can I add a '*' after the ' > ' part so that it appears before the 't'?
<any-key>
no classes needed
<blaenk>
maybe regex or something
kevinbond joined #ruby
rickmasta joined #ruby
skrewler joined #ruby
<blaenk>
yeah sub with a regex should work
<any-key>
without a doubt
<any-key>
"e > t + f".sub(/> /, '> *')
<any-key>
wow my ssh connection is slow
<blaenk>
yup
<deryl>
acting like mine? you type and you see your letters come out like you were on an old teletype?
<any-key>
worse than that, sometimes a whole minute
* any-key
is a poor college student who cannot afford good internet :(
<deryl>
i get that because i'm on a double nat'd wifi link for internet
<any-key>
my ISP blocks all websites that contain "bittorrent" in the title
<deryl>
and its shared between two properties the landlord owns :/
crankycoder joined #ruby
<any-key>
hooray double nat!
skrewler joined #ruby
<deryl>
hehe
<deryl>
and its really a triple nat, because the link on the dsl router itself is a 10.10 network. nat from my router to the upstream router, that link also being NAT'd, and the link from that router to the dsl is a NAT as well.
<deryl>
which really bugs the hell out of me
<any-key>
just thinking about it bugs the hell outta me
<deryl>
hehe
marcuspat joined #ruby
vitoravelino joined #ruby
sbanwart joined #ruby
sdavis joined #ruby
tomzx joined #ruby
fayimora joined #ruby
zomgbie joined #ruby
badabim joined #ruby
<blaenk>
anyone know of a ruby structure that maps well to a graph? I need to store both node and edge information
<aef>
blaenk: there are graph gems, i don't know how good they are though
hurikhan|Work joined #ruby
<aef>
blaenk: one i've seen was written with a Java styleguide, which is ugly, but it may still be helpful
<any-key>
I've used hashes before, not the most efficient thing ever
<any-key>
it kind of helps to have pointers to nodes
<blaenk>
aef: thanks. I actually don't need anything over the top, just need to store node and edge info, don't need speed or anything fancy
<blaenk>
I was actually looking to see if there were sets but I didn't find a Set class in the ruby docs, guess I didn't look hard enough. thanks aef I'll check that out
<Syzygy_>
shevy � is a logical not, and # is often interpreted as number
<shevy>
aha
<aef>
blaenk: you can also check for supersets or subsets with the Set class
<Syzygy_>
thus �# is my "logo"
<blaenk>
beautiful thanks aef
<blaenk>
aef: however, would I be able to do what I said if I do set1 == set2? to repeat, set1 is bigger, and I want to see if set2's elements are in set1 (all of them)
<blaenk>
oh yeah subsets :D
<shevy>
hmm does that with .to_set really work
banister`sleep joined #ruby
<Syzygy_>
I would still just do it with two for loops :/
<aef>
blaenk: i think what you want is set1.subset?(set2)
<blaenk>
yup found it, thanks again aef
<aef>
shevy: yes it does
<aef>
blaenk: i think its menat the other way arround. set1.superset?(set2) is true if set2 is the subset
<blaenk>
oh okay, thanks :)
<blaenk>
yeah it is
kuadrosx joined #ruby
<blaenk>
the docs are kind of ambiguous but you're right :)
<shevy>
ah
<shevy>
that was it indeed, not it works for me as well :)
<shevy>
%w(b c).to_set.subset?(%w(a b c).to_set) # => true
<aef>
would be cool if sets would support <, >, <= and >=
<aef>
but they don't
<shevy>
eww
wadedog joined #ruby
<shevy>
ah, nevermind. thought for one moment it didn't work what I just wrote... but it works.
<banister`sleep>
aef: what would be the semantics of <=> for sets
<shevy>
%w( b c hwa ).to_set.subset?(%w( a b c ).to_set) # => false
<banister`sleep>
subset/superset?
<aef>
banister`sleep: yes
<banister`sleep>
ah ok
<aef>
would be far more obvious to me as are the superset? and subset? methods
h4mz1d joined #ruby
<aef>
and it would be far cooler if Set would be a core type, as often as i need to require it manually
<shevy>
yeah
<banister`sleep>
aef: then youd need more literal syntax wouldn't u? what would be the syntax?
<aef>
banister`sleep: not neccessarily, but that would also be nice
radic joined #ruby
<aef>
maybe just <:a, :b, :c>, don't know if that would be parser-compliant
lobo_d_b joined #ruby
lobo_d_b joined #ruby
ronniemlr joined #ruby
radmacd joined #ruby
skrewler joined #ruby
<ryanf>
that might be tough since < and > are operators
<Syzygy_>
shevy, in my example, is it really necessary to do line.include? string for every line?
<Syzygy_>
or could i just say f.include? string for the whole thing?
<ryanf>
another % syntax would be more plausible imo
<ryanf>
although I guess the others are all for quoting stuff so maybe it's not a good fit
<aef>
ryanf: %s{:a, :b, :c}
<aef>
or is that reserved already
<aef>
?
<ryanf>
that is the same as :":a, :b, :c" I think
<shevy>
Syzygy_ hmm
<shevy>
Syzygy_ not sure what you mean
durre joined #ruby
<shevy>
Syzygy_ it's not asking .include? for every line right now, right?
<Syzygy_>
open(url) {|f|
<shevy>
yeah but it stores it just in @string
<Syzygy_>
oh
<Syzygy_>
i guess
<shevy>
there are probably more elegant ways, I just wanted to get it done quickly :P
<shevy>
but it is asking .include? only once, through the method
<Syzygy_>
that is true
<Syzygy_>
but couldn't you just write the whole file in the string? why do you need to do it for each line?
<shevy>
Syzygy_ there is probably some method that lets you do that
<banister`sleep>
aef: because you forgot to require 'set'
<aef>
well, that's not what i want to get either: #<Set: {":a :b :c"}>
stunna joined #ruby
<aef>
banister`sleep: but i'm impressed that you can redefine `
<banister`sleep>
aef: i was just suggesting it as a potential literal syntax
<banister`sleep>
ryanf: pry 'parser' works better than irb's for def self.`(*args) it seems
<banister`sleep>
seems that all the multi-line approaches have their pros and cons
<aef>
banister`sleep: i dislike the idea of redefining something already in use for this
<ryanf>
wow, can you really do that?
<banister`sleep>
ryanf: Yeah
<ryanf>
haha yeah irb doesn't like that one bit
<banister`sleep>
aef: well you'd only do it inside the scope of your DSL or some such, you wouldn't do it globaly, that's why i defined it as a class method on Hello
philcrissman joined #ruby
<ryanf>
that's actually really good to know
<shevy>
wait redefine what
<banister`sleep>
shevy: the `` "method"
<shevy>
oh
<ryanf>
sometimes I've like defined _ to execute commands in some special way
<ryanf>
but overriding ` would be way nicer
<shevy>
That is Kernel#` ?
<ryanf>
yeah
<Syzygy_>
so stuff like "def set_search_word(i = 'hello')" sets i hello, no matter what arguments are sent to that method?
<ryanf>
no
<shevy>
Syzygy_ only if you omit arguments to that method
<ryanf>
it's just a default
<shevy>
yeah
<shevy>
def foo(i = 'default value here')
<shevy>
foo() # <-- gives i the default value above
<shevy>
foo('Syzygy_ is learning ruby') # <-- i will be this now
<Syzygy_>
ok
<Syzygy_>
i get it
<Syzygy_>
thanks
<shevy>
Syzygy_ do you have irb? it is very easy to test simple ruby code in it
<shevy>
or even better, pry :D
<ryanf>
that woke him up
<Syzygy_>
I have, but I want to stick to working in files :/
<banisterfiend>
:D
<shevy>
Syzygy_ I work in files all the time too actually but irb is really really super easy to test simple things quickly
<Syzygy_>
I'm uncomfortable working in a console while coding
<shevy>
if you understand the code above, though, it's ok
<imbric>
hey guys, I've got a kind of an odd question about here-documents. Is it possible to have your identifier appear in the string text on a line by itself?
<ryanf>
haha
<ryanf>
imbric: can it be indented?
<imbric>
no
<Syzygy_>
shouldn't be necessary for me to rely on german tutorials ;)
<shevy>
hehe
<Syzygy_>
but thanks
<imbric>
but, do you have a solution that involves indenting, cause that would be interesting as well
<shevy>
Syzygy_ well just read it anyway "__FILE__ ist die magische Variable, die den Namen der gerade benutzen Datei als Wert hat, w�hrend $0 der Name der Datei ist, mit dem das Programm gestartet wurde." ... also keep in mind $0 is just the short name for $PROGRAM_NAME (and most people indeed use $0 ... but I kinda like $PROGRAM_NAME more)
<ryanf>
well if you don't use - in front of the identifier, it won't close the heredoc unless it is at the beginning of the line
<Syzygy_>
ok
<imbric>
ah ha.... nice
<imbric>
interpolation rocks
incluye joined #ruby
<imbric>
thank you ryanf
<ryanf>
np
<ryanf>
alternately, you could, you know, pick a different identifier
Syzygy__ joined #ruby
<Syzygy__>
what does the method name with a ? at the end do?
<Syzygy__>
does it expect a return value?
<banisterfiend>
Syzygy__: boolean return value
<shevy>
Syzygy__ one kind of convent... yeah
pen_isident joined #ruby
<Syzygy__>
and if i want to return another type?
<shevy>
def banisterfiend.lives_in_germany?
<shevy>
return false
<banisterfiend>
Syzygy__: you can but it's not idiomatic
<Syzygy__>
string array for example
h4mz1d joined #ruby
<Syzygy__>
ok
<shevy>
Syzygy_ ruby lets you!
<aef>
Syzygy__: but please, don't do it
<shevy>
haha :D
<banisterfiend>
Syzygy__: you can do that if you want but other rubyists will hunt you down and insult you in front of your friends
<shevy>
join me! join the dark side!
<shevy>
DOWN WITH CONVENTIONS!!!
<shevy>
Syzygy_ I protect you, let's smite them down together!
<Syzygy__>
I don't mind, it's not necessary for people to see my code once it works :>
<aef>
shevy: you might want to write your variables in camelcase to impress a sith lord
<Syzygy__>
camelCase :>
wedtm joined #ruby
<shevy>
aef I hate camelcase :( except for class FooBar ... though there my convention often (or always) is to also have the filename foo_bar.rb
<imbric>
ryanf: sapced out a sec. well its not really for a practical purpose, I was playing around with her-doc and i wondered if you could do it
<aef>
shevy: that's like rails does it. i like that
<shevy>
yeah it's an ok one
<shevy>
the less my poor brain has to think the better
<ryanf>
oh I see
<ryanf>
it is kind of interesting that there's a strong convention in ruby against using camelcase file names
<Syzygy__>
same here :(
<ryanf>
even though classes are always camelcase
<Syzygy__>
I guess each of you could write this in minutes
<ryanf>
it would make rails code a bit simpler for one thing
<shevy>
ryanf I actually use it for one project
<shevy>
oddly enough, not for my other projects... so I confuse myself a little
<shevy>
class FooBla and file FooBla.rb
<ryanf>
yeah
<ryanf>
that does seem logical
<shevy>
hmmm yeah but many people hate that
<ryanf>
and then all you need to translate between scopes and paths is to change :: to /
<ryanf>
shevy: yeah, I'm just wondering why that is. it's not like it's inherently any uglier than lowercase
<ryanf>
or if it is, the actual class names already suffer from that ugliness
<shevy>
no real idea myself. :) I don't really mind either way ... but most of the time for myself, I stick to lowercased .rb file names
<new2net>
I'm doing the "tryruby" demo (the 15 minute one).. I'm having trouble with this line of code:
<new2net>
hello = 3
<Syzygy__>
btw, is there any specific reason you named the Webpage object _ ?
<Syzygy__>
what is your problem with that line new2net?
<new2net>
well Is it valid?
<Syzygy__>
should be
<aef>
banisterfiend, ryanf: it seems you can do Set[:a, :b, :c] . cool enough literal in my opinion.
<Syzygy__>
you could always try "hello *2" and see what the result is
<Syzygy__>
Why do you think it's not valid new2net ?
<shevy>
Syzygy__ oh I just like _ ... it is easy to type and has no name
<new2net>
Syzygy__, well this interpreter tryruby.org is giving me trouble with it
<shevy>
and _._._._ is the coolest thing ever, noone has an idea what will happen :>
<banisterfiend>
aef: well you could also probably do Set(:a, :b, :c) too
<shevy>
Syzygy__ you should stick to names that are self-explanatory though
<Syzygy__>
that's great when showing someone code who has no idea of ruby :/
stephenjudkins joined #ruby
<aef>
banisterfiend: yeah, but i hate that for poisoning the global namespace
<shevy>
Syzygy__ it's just a name for a variable, you can replace _ with webpage if that makes you feel better, it is still the same thing though ;)
<aef>
banisterfiend: if everybody would do that, everything would be full of crap
<Syzygy__>
new2net, that interpreter tends to throw a bit of a tantrum when you don't do what it expects right now
<new2net>
Syzygy__, basically I wanted to know about ruby, and saw "oh hey try it right now" and was like OK perfect. Unfortunately I didn't get much figured out. Maybe you can answer a few questions for me: is ruby statically typed, does it support OOP, and if it does support OOP can I nest classes?
<shevy>
like typically ... webpage = Webpage.new ... or something_fancy = SomethingFancy.new
<aef>
banisterfiend: i know, because Pathname supports it too
<Syzygy__>
it supports OOP
<Syzygy__>
unsure about nesting
<Syzygy__>
and i have no idea what statically typed means
<new2net>
then it's probably not... String foo = new String("hey"); println(foo * 3); can't multiply a string by integer.
<new2net>
but in some languages you can, although it probably should raise an error.
<Syzygy__>
you can multiply a string by intager in ruby
notimik joined #ruby
<Syzygy__>
"hello"*3 will output hellohellohello
<aef>
new2net: it's statically typed because everything has a type, but variables aren't typed, they can reference every object
BiHi joined #ruby
<Syzygy__>
(that's actually in that 15 minute tutorial thing btw)
<aef>
new2net: you can nest classes, but they are always available for everyone, not private
<new2net>
ok.. so I can do this: foo = "hello" foo = (foo * 3).length //15
<aef>
new2net: yes you can do that
<aef>
new2net: that's because in Ruby you can overload operators
<aef>
new2net: every Class can define different logic for almost each operator
<aef>
new2net: an operator is defined just like any other method
<new2net>
aef, awesome :) thats what I've been looking for. Out of curiosity python is the only other interpreted language that supports nesting classes and it also doesn't allow for private, is there any reason Ruby follows the same pattern?
<aef>
new2net: well in Ruby if you type the name of a class, you're actually accessing a constant
<aef>
new2net: a constant which refers to a Class object
<aef>
new2net: if you just type String
<aef>
new2net: you get the Class object that's referred to by the constant String
<aef>
new2net: now if there is a class inside String you access it by using String::OtherClass
<aef>
new2net: and that means the Class object String has a constant OtherClass which then again refers to another Class object
mxweas_ joined #ruby
<aef>
new2net: Class like objects in Ruby just have a namespacing ability thereby
<new2net>
does ruby crash if I try to print a variable that doesn't exist?
<aef>
new2net: it raises an exception
<aef>
new2net: which you can handle if you want, otherwise it will end execution and report it as error
<new2net>
aef, right, I don't normally support print with try catch
<new2net>
s/support/surround
<aef>
new2net: its not try catch, its begin; rescue; end
goodiebo_ joined #ruby
<aef>
new2net: try and catch serve a completely different purpose in Ruby
<new2net>
aef, never heard of this before, please go on
<Syzygy__>
ok shevy, looks like i need to reduce modularity of your code
<Syzygy__>
actually i think i'll completely rewrite it :>
<Syzygy__>
maybe not even make it OOP
<aef>
new2net: well i've seen noone so far using this for something useful
<Syzygy__>
since it really only needs to serve that one purpose
<shevy>
Syzygy__ that's good, always find your style
<aef>
new2net: it seems to be there only to confuse people
<new2net>
aef, oh. like a triple variable?
<aef>
new2net: i don't know taht
<new2net>
variable variable variable, so foo = "bar" ... bar ="baz" ... baz = "confusing" print $$$foo
<Syzygy__>
oh I dread the moment I have to deal with regular expressions for this :
<aef>
new2net: in Ruby you can throw symbols with throw and catch them with catch
<aef>
new2net: it's like a strange goto system
<shevy>
Syzygy__ regexes are not beautiful but useful ... @string =~ /#{your_search_term}/
<Syzygy__>
I know :/
<aef>
new2net: the thing is, as a beginner, you should only care about raise and rescue
<Syzygy__>
it's not so much about my search term, but the line in which my search type is found
<new2net>
aef, spaghetti code
<aef>
new2net: that's for raising exceptions, and handling them
<new2net>
aef, ok. and "Ruby on Rails" is a web application framework, correct?
<aef>
new2net: you got that right
thecreators joined #ruby
<Syzygy__>
stringA = hell stringB = o
<Syzygy__>
stringA + stringB => hello?
<Syzygy__>
actually i can just try it
<Syzygy__>
so nevermind
<shevy>
Syzygy__ ah well as we are using .each_line already, you could build an array like [line_number, line]
<shevy>
and the if you earch for the string where it is found, you also have the line_number
<shevy>
Syzygy__ that works but you forgot to quote it
<Syzygy__>
i did :/
<shevy>
stringA = 'hell'; stringB = 'o'
skrewler joined #ruby
yxhuvud joined #ruby
lobo_d_b joined #ruby
wyhaines joined #ruby
<blaenk>
is there a quick way to get the character that follows another in a string? 'afg42' get '2' given input '4'?
<blaenk>
or should I use a combination of string index + 1
<ryanf>
that is probably the best solution, there are others using regex though
<ryanf>
'afg42'[/4(.)/, 1]
<blaenk>
thanks ryanf
<new2net>
What does it look like when I invoke a method with more than 1 argument?
<aef>
blaenk: or in 1.9 and above: "abc".match(/b(?<next>.)/)[:next]
<blaenk>
in which case I ask, is there a way to write dynamic regex? in other words, the 4 in that regex would be dynamic, an input
<ryanf>
or 'afg42' =~ /4(.)/; $1
<ryanf>
or 'afg42' =~ /(?<=4)./; $&
<ryanf>
blaenk: you can interpolate into a regex
<blaenk>
ah okay thanks :)_
<ryanf>
using #{}
a_a_g joined #ruby
<blaenk>
thanks ryanf and aef
<ryanf>
it is probably better to just use index though instead of building a regex every time
<blaenk>
'afg42'['afg42'.index('4') + 1]?
<ryanf>
haha that isn't very attractive is it
<ryanf>
I assume afg42 will be a variable though?
<blaenk>
well if it works :) that's what I was using but I wanted to see if there was a better way
milkpost_ joined #ruby
<blaenk>
nah basically I have a line like 'E -> *T+F' and I need to know if the * is before a T or an F
<blaenk>
so I was getting the next character and checking if it was inside an array of test characters, ['T', 'F']
<blaenk>
with .include?
ixx joined #ruby
<blaenk>
I should be good with this though thanks again
JohnBat26 joined #ruby
banisterfiend joined #ruby
ziggles joined #ruby
nat2610 joined #ruby
<nat2610>
there isn't in the mysql ruby lib something to return a matrix or the results ? some kind of row_array method ?
<Syzygy__>
so will this add the first occurance of res/117116756 in the current line?
<ryanf>
no
<ryanf>
do you know perl by any chance?
<Syzygy__>
it has been so long ago that I might just as well answer no
<ryanf>
ahh
<ryanf>
I was wondering since that seems like the kind of thing perl would let you do
<ryanf>
ruby doesn't have the same concept that perl does of like an implicit current line
<ryanf>
so if you want to do something with a string, you need to explicitly do it
<Syzygy__>
that means?
<ryanf>
in this case you could do like str.match(/res\/[0-9]+/)[0]
<Syzygy__>
line =~ /regexp/ ?
<ryanf>
that's one way yeah
<ryanf>
the point is, /res\/[0-9]+/ by itself is just a regexp and ruby won't do anything fancy with it automatically like perl does
<Syzygy__>
what does the zero at the end do?
sqbell joined #ruby
<ryanf>
that's the same as an index in an array. it just means it gets the whole match.
<ryanf>
actually a nicer way would be
<ryanf>
str[/res\/[0-9]+/]
<ryanf>
or str[/res\/\d+/]
<blaenk>
how can I do a 'do until' loop, begin ... end until condition?
<ryanf>
that should work I think
<ryanf>
that works with while
<blaenk>
yeah
<blaenk>
thanks
xpot joined #ruby
visof joined #ruby
<Syzygy__>
thanks ryanf I'll try it
<Syzygy__>
blaenk, while condition should work
<Syzygy__>
while condition do end
<Syzygy__>
or while condition { }
<new2net>
aef, you said a class can define logic for an operator. Can you show me an example of the IFF logical operator? in other words A IFF B, A is true if and only if B is true
<aef>
new2net: you can only redefine existing operators. IFF is not a Ruby operator
<aef>
new2net: but you could for example use * as your IFF operator
<Syzygy__>
shevy what does that pp library do?
<new2net>
So A*B B = false, now A should be false too
<blaenk>
Syzygy__: prolly prettyprint
<aef>
new2net: well
<aef>
new2net: your example is a bit strange
<aef>
new2net: because in Ruby everything that is not false or nil, is true
<shevy>
Syzygy__ pp for "pretty print", if you have an array, and you do pp array, it will be nicely indented and structured for you (output)
<aef>
new2net: therefore 0 is true
<aef>
new2net: let me show you another example
<Syzygy__>
oh
<Syzygy__>
I think all that's wrong with my code is the if now
<shevy>
Syzygy__ you can also use p array though that uses normal .inspect I think
<new2net>
implementing IFF would be tricky :) at least in the languages that I know. Assigning a primitive variable a value does not typically manipulate another primitive variable.
<new2net>
shevy, yeah I was just thinking about that. It's disappointing, but I would never get around to actually programming if I got hung up on little details like that.
djdb joined #ruby
<Syzygy__>
do i need to install open uri or does it come with ruby by default?
<new2net>
shevy, but not nearly as disappointing as being type checked full throttle like in Java. Clearly its possible for the programmer to know something that the type checker doesn't
zommi joined #ruby
<Syzygy__>
fixed it
<Syzygy__>
i think it just needs http://
will302 joined #ruby
djr__ joined #ruby
ixx joined #ruby
<Syzygy__>
TypeError: can't convert nil into String
<Syzygy__>
what?
<blaenk>
¿
<shevy>
Syzygy__ you must have some nil object
<new2net>
Syzygy__, You can't call a method off of null. to_s would be the method I guess
<shevy>
x = nil
<shevy>
"abc"+x
<shevy>
TypeError: can't convert nil into String
<Syzygy__>
i guess the regex thingy doesn't exactly work
<shevy>
"abc"+x.to_s => "abc"
<Syzygy__>
but the detection does
<shevy>
see? a programmer is just a modern version of Sherlock Holmes
<banisterfiend>
new2net: what's up
<banisterfiend>
new2net: and are you really new to the net or are you being a silly one
hukl joined #ruby
<shevy>
he seems to know Java so he should have no problem with ruby
<workmad3>
new2net: you can call plenty of methods on nil in ruby... it's just another object :)
<shevy>
and then! we set him to jruby and redcar!
<Syzygy__>
string.include? "hello" || "goodbye"
<Syzygy__>
is this valid syntax?
<blaenk>
no dont think so
<blaenk>
oh
<blaenk>
yeah I don't know what the operator precedence would evaluate to right there
<workmad3>
Syzygy__: it's perfectly valid syntax, but it won't do what you think
<workmad3>
Syzygy__: namely, it won't check that the string includes either "hello" or "goodbye"
<shevy>
but clever idea still!
<blaenk>
oh that's what you're trying to do, no lol
<new2net>
banisterfiend, I'm really new here. I found this binary file on my computer called XOIrc and ran it, surprise I'm not the only one with a computer
<Syzygy__>
how could i do that? :/
<shevy>
well you could turn it around and use an array
<blaenk>
['hello', 'goodbye'].include? 'goodbye'
<blaenk>
that's what you want I think
<shevy>
yeah
<shevy>
my good man blaenk :)
<blaenk>
:)
<Syzygy__>
no blaenk
<Syzygy__>
that's not what i want
<blaenk>
:<
<shevy>
don't believe him blaenk :D
<blaenk>
hang on a minute Syzygy__ while I read your mind then
<shevy>
wow
<shevy>
that one takes me years usually :(
<Syzygy__>
line.include? string1 || string 2
<workmad3>
Syzygy__: you could turn it into a regex, /hello|goodbye/ and then do a match against it... if your_string =~ regex ...
<Syzygy__>
I still haven't fixed my other regex problem :/
<shevy>
ok so you want to find out whether a line includes either string1 or string2
<blaenk>
Syzygy__: can you say what you wanna do maybe I can help
mafolz joined #ruby
<Syzygy__>
yeah shevy
<will302>
Hi everyone, newbie here with a problem with rubygems. When I type gem -v to see if rubygems is installed it says I am 'missing psych' and need to install 'libyaml'. How can I install this?
<shevy>
hmmm... actually it would be cool if .include? would accept an array ...
<workmad3>
Syzygy__: if line =~ /#{string1}|#{string2}/ <-- there you go
<shevy>
or that yeah
<workmad3>
shevy: but then what if you want to check if an array contains an array? :)
<blaenk>
messy but I guess line.match(/#{teststrings.join('|')}/) maybe?
<shevy>
oh? must this be consistent? I am really asking, no idea right now
<shevy>
was just thinking about String
<Syzygy__>
i think it's pretty obvious what i want to do... admitedly that's from the point of view from myself :/
<shevy>
if line =~ /#{string1}|#{string2}/ # <-- use this here Syzygy__
<workmad3>
Syzygy__: and you have an answer (unless I'm on /ignore from Syzygy__ :( )
<Syzygy__>
i already did, that's why i took so long to reply
<Syzygy__>
thanks workmad3
<shevy>
:)
<workmad3>
yay :)
John_P joined #ruby
<Syzygy__>
nooow
<Syzygy__>
i need a complete link
<Syzygy__>
out of a default part
<shevy>
what
<Syzygy__>
and a part that's inside the line
vitoravelino joined #ruby
<shevy>
not sure what you want :)
<shevy>
you want to capture the regex result?
kaspernj joined #ruby
<Syzygy__>
i guess so
<shevy>
something like ...
<shevy>
if line =~ /(#{string1}|#{string2})/
<shevy>
and then $1
<shevy>
or something... I hate regex syntax
<Syzygy__>
yeah, but a different regexp
<shevy>
hehe
<Syzygy__>
/res\/[0-9]+/
<workmad3>
Syzygy__: is this pulling out the 'res/some_number' part of a line that I see in your pastie?
<Syzygy__>
who can blame you, and that's not even the same regex syntax I'm used to
<Syzygy__>
exactly
[1]maarten joined #ruby
<workmad3>
right... for starters, %r{res/\d+} for the regex ;)
<Syzygy__>
you sure? i read the in ruby regex starts with / and ends with /
<Syzygy__>
so /regex/
<workmad3>
it can also use %r{}
<workmad3>
or %R{}
<workmad3>
and when you do, you don't need to escape /
<workmad3>
makes it pretty nice for matching parts of URLs :)
<Syzygy__>
the way i learned regex it would be ^res/[0-9]* or something like that anyway :/
<Syzygy__>
ah i get it
<workmad3>
that wouldn't do what you want... that would match res at the start of the line, and then 0 or more numbers 0-9
<Syzygy__>
the \d does what though? all decimal numbers?
<workmad3>
yeah
zomgbie joined #ruby
<shevy>
:)
<Syzygy__>
and the +? 1 or more?
<shevy>
you can see that workmad3 knows his things
<workmad3>
Syzygy__: yup ;)
<Syzygy__>
more than me in any case
<shevy>
yeah
<shevy>
I couldn't have said to use %r{} myself without looking it up
<Syzygy__>
now all i need is a way to add that matched regex to the string
<workmad3>
oh yeah, capturing... use %r{(res/\d+)} to make sure it's captured
<aef>
new2net: still there?
<new2net>
aef, yes. I waited
<workmad3>
then you can do 'string.match(regex); thread_list << default_url + $1
<aef>
new2net: about type hinting
<aef>
new2net: Ruby does not support this natively
geekfactor joined #ruby
<aef>
new2net: and that's because an ideology named Duck Typing
ixx joined #ruby
<Syzygy__>
i was hoping for something that would work like threadList << defaultURL + %r{{res/\d+}}
<Syzygy__>
D:
<aef>
new2net: an often repeated sentence about this is "if it walks like a duck, it is a duck"
<workmad3>
Syzygy__: I suspect there is a one-liner... but my regex-fu isn't working well enough. I only woke up 30 mins ago :P
<workmad3>
Syzygy__: so I was concentrating on getting you something that worked, rather than worked and was 1 line ;)
<aef>
new2net: which means, that most of the time, you don't want to decide what an object in Ruby is by checking its class
<aef>
new2net: but instead you want only to check if it responds to the methods you need to call on it
<new2net>
aef, I see... so instead of raising the exception, it raises the exception when it turns out that the method invoked doesn't exist?
<aef>
new2net: there is a method #respond_to?(method) which almost every object in Ruby supports
<Syzygy__>
i also added the .to_s
<workmad3>
aef: I'm not sure about a formal construct of an Interface... but it would be very nice to be able to formally declare what methods you need implemented for a mixin to work
<Syzygy__>
and i think i'll leave it at that
<aef>
new2net: through which you can check before calling the actual method, if it exists
<aef>
workmad3: yeah, that's what I would like too
<workmad3>
Syzygy__: you have an 'if if'
<Syzygy__>
oh, thanks
Mchl joined #ruby
<workmad3>
Syzygy__: which by itself isn't a syntax error, but the first one isn't closed, so when it reaches the end of the {} block, it knows you've forgotten to close it :)
<Syzygy__>
so i think my crawler is mostly ready :D
<workmad3>
aef: but then I think about how nightmarish such a thing would be to implement if you wanted it checked... what happens if the mixin interface is supported via method_missing overloads, for example?
<Syzygy__>
now i need to implement it at my site somehow
<new2net>
aef, interesting. How old is ruby? I notice people 2 or 3 times my_age (for lack of better words) use it. But have never met anyone my age who uses it, or mention it really.
<aef>
workmad3: I consider it good style to implement custom respond_to? if you use method_missing
<workmad3>
new2net: mid-90s I think
<workmad3>
aef: agreed, but not everyone does that
<aef>
workmad3: so they had to do that to make it work
<aef>
new2net: i think for quite a long time Ruby wasn't very present in the western world
<workmad3>
right, I need to get to work
<aef>
new2net: only for about the last 5 or so years it agained a lot of attention
<workmad3>
somehow time just vanished :)
vitoravelino joined #ruby
<aef>
actually i think the publicity of Rails made Ruby known, at least that's why everyone I know came to Ruby
<aef>
only to find out that most of the cool things in Rails are provided by Ruby
Morkel joined #ruby
<new2net>
The first time I heard about ruby was when I found a server w/ a cname rails when scanning a network. Obviously, to this channel anyways, it had a web server running. It was some wiki about ruby on rails.
<Syzygy__>
so workmad3, shevy, you've seen my code... is it slow or is that just my internet connection right now?
<shevy>
Syzygy__ open-uri isn't usually the fastest thing for me
tatsuya_o joined #ruby
<shevy>
but perhaps define "slow" first
<shevy>
10 seconds 100 seconds 5555 minutes
<Syzygy__>
takes about a minute to run
codespectator joined #ruby
<Syzygy__>
also it doesn't add the regex
tacrim left #ruby
heftig joined #ruby
jbpros joined #ruby
<Syzygy__>
what exactly does $1 do btw?
<aef>
Syzygy__: gives you the first submatcher result from the last RegExp matching
mengu joined #ruby
<Syzygy__>
ah ok
<shevy>
hmm a minute to run sounds insane, no idea why it takes so long for you. ah .. but perhaps you check with your regex on every line ...
<shevy>
can you upload your current code on pastie?
<new2net>
aef, My parents said they will disown me if I use PHP again.
<aef>
new2net: your parents are wise people
cyri_ joined #ruby
<new2net>
aef, I think they're just haters
<aef>
new2net: I myself did a lot of PHP for a while. Today I'm a better person
<shevy>
haha :D
<shevy>
I actually started with perl ... then switched to PHP ...
<shevy>
I wrote much more PHP code than perl
<shevy>
ruby code is like 1/4-th of PHP so I switched ... :P
RomD joined #ruby
<aef>
shevy: don't you forget the aesthetics
<Syzygy__>
I only know C++, C# and Java
<Syzygy__>
although my C++ has become very rusty
<shevy>
aef well that is it for me basically, terseness is great
<shevy>
hmm within reason though
<shevy>
I can't stand $! $" $� $$ $% $& $/ $( $) $= $? $`
ph^ joined #ruby
robotmay joined #ruby
<aef>
shevy: yeah, I hate them too
pen joined #ruby
<banisterfiend>
$1 and $2 etc are nice
<aef>
shevy: but there is require 'English'
<aef>
banisterfiend: if MatchData wouldn't be as blocky to use, I would clearly prefer it, but it is quite blocky
<banisterfiend>
aef what does blocky mean
<shevy>
aef well problem is ... require 'English' is one extra line in a typical .rb file
<aef>
banisterfiend: just doens't feel right
<shevy>
if one wouldn't have to require it it would be better :\
<banisterfiend>
aef: you're talking about $1 and $2 ?
<aef>
banisterfiend: for example i really dislike it that [0] is the original string
danielpunt joined #ruby
<aef>
banisterfiend: i'm talking about MatchData being not as cool as it could be
<banisterfiend>
ok
<aef>
banisterfiend: so i often tend to use $1 and such instead
nark-1 joined #ruby
sandstrom joined #ruby
sandstrom joined #ruby
<ryanf>
yeah I actually like the perlish regex interface a lot better than the ruby ones
<ryanf>
also $` and $' are really handy
<aef>
ryanf, banisterfiend: since 1.9 you can name the submatchers with (?<somename>) and select them on the MatchData object like result[:somename] which I think is great. the only downpoint is that the regexes tend to become even more horrible to read by doing this
<ryanf>
yeah I don't think I would ever do that unless I were matching multiple groups with the same regex
<ryanf>
and even then it would probably have to be a pretty complicated one
<banisterfiend>
ryanf: hey do u know much about macosx / google chrome? when i start google chrome it complains it wasn't closed properly the last time and offers to restore tabs, however after it displays that dialog it then crashes
<banisterfiend>
and it always crashes, even after i reset/reboot my system
<banisterfiend>
anyway to 'clear' google chrome out or something so it can work again and doesnt try to restore old tabs?
flippingbits joined #ruby
<banisterfiend>
or anyone?
<KL-7>
Regarding named groups in 1.9 if you match a string with (?<somename>) ruby will set matched string to a variable with same name that is 'somename' in that case. Not sure whether it's good or bad as it seems to overwrite existing variables in the current scope.
hemanth joined #ruby
<aef>
KL-7: sounds quite horrible to me
<Syzygy__>
shevy, so my regexp thingys aren't working yet :/
nark-1 left #ruby
<shevy>
I thought it was working before
<shevy>
and it was just slow
<shevy>
!!!
<aef>
banisterfiend: isn't there some kind of application data folder in MacOS? just guessing
<Syzygy__>
that's what i thought, but the string stays empty
<KL-7>
aef, I agree, it can lead to some awful situations
<Syzygy__>
and i think it's really just that my connection is so slow because I'm downloading stuff
<KL-7>
btw, can someone point me to the full list of this dollar sign variables? It's always so difficult to google them
<Syzygy__>
is there a way to double break?
<banisterfiend>
Syzygy__: use throw/catch
<banisterfiend>
or better still design your program in such a way that you dont have to
Topic for #ruby is now Ruby programming language || ruby-lang.org || RUBY SUMMER OF CODE! rubysoc.org/ || Paste >3 lines of text in http://pastie.org || Para a nossa audiencia em portugues http://ruby-br.org/
michael_imac_ joined #ruby
soulnafein joined #ruby
dgaffney joined #ruby
<dgaffney>
hey all, i'm in encoding hell. Anyone want to try to help me figure out the path out of it?
<jensn>
Sure, what is the problem?
<soulnafein>
there's no way out of encoding hell
<dgaffney>
*stays in encoding hell*
<soulnafein>
:-)
<dgaffney>
so, i have a mysql database formatted in latin1, and the chinese in there looks fabulous. Arabic script screws up the printing, but its fine. everything looks great, and the database character set is latin1.
<dgaffney>
somewhere between that beautiful printout and data mapper's printout of the same row, horrible, awful things happen.
Clooth joined #ruby
<dgaffney>
i'm using 1.9.2 and have tried all the iconv stuff, setting external default/internal default etc…. not sure what the "way" is here. I'm using default settings on my mysql instance - i'm sure someone has gotten caught on this the same way.
<zomgbie>
what could be the reason that the render method (via Mail) renders my html template but just without the instance variable @salutation - i'm using sinatra/padrino but think this might be a more general ruby question http://pastie.org/2877512
<dgaffney>
yerp.
<whitequark>
dgaffney: I never had any success with utf8 data in latin1-encoded mysql db
<whitequark>
can you change it to use proper encoding?
closedbracket joined #ruby
_debo joined #ruby
zomgbie joined #ruby
<dgaffney>
i guess - its a big ole db though, so thats time down the hole?
mcpierce|afk joined #ruby
soulnafein left #ruby
<whitequark>
dgaffney: then, you can try .force_encoding('utf-8')
Adman65 joined #ruby
pen_isident joined #ruby
iocor joined #ruby
Jckf joined #ruby
Morkel joined #ruby
sepp2k joined #ruby
S1kx joined #ruby
testingRuby777 joined #ruby
S2kx joined #ruby
raincole_ joined #ruby
raincole joined #ruby
jesteracer joined #ruby
linduxed joined #ruby
<linduxed>
hey guys, i was thinking of installing ruby on my debian server, but i realized that there are like three versions avaliable, along with like three different packages for each one (-dev, -full, and so on)
sepp2k joined #ruby
<linduxed>
i've also read about this "RVM" thing, but it seems to handle all versions, not sure if i want that
<mog->
linduxed, you probably want rvm if you're deploying your own applications
josephwilk joined #ruby
<Tasser>
linduxed, ruby-dev is development headers (learn some debian :-P), that's needed if you want to compile something against ruby, like most *sql gems. ruby-full installs everything and ruby is just the interpreter (without gems or irb)
iocor joined #ruby
<kaspernj>
linduxed, you want to use RVM if you wish to develop gems, test against various interpreters (like JRuby, Rubinius, Ruby 1.8, Ruby 1.9 etc.). Also "bundler" and "jeweler" doesnt work with old Gem-installations (like the ones packaged in older versions of Ubuntu).
<kaspernj>
linduxed, RVM is a really nice thing. It can take a bit of time to understand and set up, but it is very much worth it in the long run :-)
Blackflys joined #ruby
<linduxed>
kaspernj: ok
NuclearLucifer joined #ruby
sepp2k joined #ruby
jtdowney joined #ruby
<NuclearLucifer>
I'm trying to use Logger class from core inside my module. I'm calling it like: `g = Git.open("/var/opt/#{instance}/webapps/ROOT/", :log => Logger.new('/tmp/zylad.log'))' and Ruby is looking it in my module namespace. How can I call it?
zomgbie joined #ruby
zomgbie joined #ruby
negative joined #ruby
BiHi joined #ruby
cjs226 joined #ruby
adambeynon joined #ruby
nerded joined #ruby
tatsuya_o joined #ruby
yalue joined #ruby
shevy joined #ruby
jtrudeau joined #ruby
fayimora joined #ruby
luminare joined #ruby
yfeldblum joined #ruby
Morkel joined #ruby
__Genji_Richmond joined #ruby
flippingbits_ joined #ruby
<whitequark>
NuclearLucifer: technically ::Logger, but I bet you've not require'd "logger"
<NuclearLucifer>
whitequark, you loose. :(
<NuclearLucifer>
I had require stanza.
<NuclearLucifer>
Just didn't know how to call core namespce but I also found the answer with ::Logger.
mklappstuhl joined #ruby
geekfactor joined #ruby
xec joined #ruby
tommyvyo joined #ruby
Spockz joined #ruby
mcpierce joined #ruby
nanderoo joined #ruby
RLa joined #ruby
Kiten joined #ruby
<Kiten>
hello :P
linduxed left #ruby
nerded joined #ruby
kaspernj joined #ruby
milkpost_ joined #ruby
Phrogz joined #ruby
pen joined #ruby
dv310p3r joined #ruby
tatsuya_o joined #ruby
ecolitan joined #ruby
straind joined #ruby
linoj_ joined #ruby
bwlang joined #ruby
possibilities joined #ruby
cjs226 joined #ruby
Phrogz joined #ruby
strife25 joined #ruby
Phrogz joined #ruby
themadcanudist joined #ruby
hurikhan|Work joined #ruby
iamjarvo joined #ruby
wyhaines joined #ruby
BitPuffin joined #ruby
BitPuffin joined #ruby
possibilities joined #ruby
bwlang joined #ruby
dcarper joined #ruby
BitPuffin joined #ruby
wyhaines_ joined #ruby
tatsuya_o joined #ruby
crankycoder joined #ruby
tatsuya_o joined #ruby
Superman joined #ruby
<Guest9743>
Anyone here?
miloshadzic joined #ruby
miloshadzic left #ruby
<Kiten>
'yeah'
<Kiten>
wow that was amazing i just meant to type yeah and accidently quoted it with one strok
<Kiten>
s/strok/stroke
jfredett joined #ruby
theRoUS joined #ruby
theRoUS joined #ruby
kevinbond joined #ruby
Johnnus_ joined #ruby
strife25 joined #ruby
Indian joined #ruby
lobo_d_b joined #ruby
adamjleonard joined #ruby
<Johnnus_>
I'm having some problems with running ruby-debug with ruby 1.9 and rspec. It never hits my breakpoint but instead stops in some rpsec example files (rspec/core/example.rb). I've seen other people having the same problem, but I just can't find any solution for it. Someone got any ideas?
dfamorato_ joined #ruby
yekta joined #ruby
a_a_g left #ruby
beakerman joined #ruby
<banisterfiend>
Johnnus_: are you using ruby-debug for 'next/step' functionality or just to examine state at the point you want to break?
<Johnnus_>
banisterfiend: I'll take a look, thanks!
bbttxu joined #ruby
<banisterfiend>
Johnnus_: to give u a quick start: juts go: gem install pry, and require 'pry' in your next, and put a binding.pry at the point u want to inspect the state
<banisterfiend>
run the tests, and you're good to go
<banisterfiend>
require 'pry' in your test* i mean
<Johnnus_>
banisterfiend: Very neat! Looks like a perfect match, I'll try it out! Thanks!
<banisterfiend>
Johnnus_: cool let me know how u get on
flip_digits joined #ruby
phantasm66 joined #ruby
joast joined #ruby
devdazed joined #ruby
axl_ joined #ruby
iboB joined #ruby
<iboB>
hey if i'm making a c extension, what's a good way to debug it?
<banisterfiend>
iboB: gdb
rsampaio joined #ruby
flip_digits joined #ruby
yalue joined #ruby
bbttxu joined #ruby
jwill joined #ruby
Jackneill joined #ruby
Jackneill joined #ruby
dch4pm4n joined #ruby
Dreamer3 joined #ruby
wilmoore joined #ruby
fayimora joined #ruby
ben_alman joined #ruby
albemuth joined #ruby
dcarper joined #ruby
p0y joined #ruby
wesdreem left #ruby
<Johnnus_>
banister`sleep: worked really well, thanks!
<banister`sleep>
Johnnus_: np, find time to watch the screencast on that website at some point too
wilmoore_ joined #ruby
<banister`sleep>
you'll see it can do some pretty badass things
<Johnnus_>
banister`sleep: yep, will do
redgetan joined #ruby
savage- joined #ruby
monkey13 joined #ruby
ik_5 joined #ruby
<ik_5>
hello
<ik_5>
is there a way for making ruby do a core dump like but for the ahn stack when it stop executing stuff ?
<whitequark>
ik_5: do you mean it's locking up in Ruby code or in C? i.e. is that a bug in Ruby code or the interpreter itself?
<JonnieCache>
you can do a core dump from outside the process using gdb
<JonnieCache>
gdb is awesome
<ik_5>
whitequark, I'm using a framework (called adhearsion), and it stop running at some point (no exception or anything), and I wish to better understand why
<JonnieCache>
hmm maybe its not gdb you use… wish i could remember
<ik_5>
I found that strace always stop at the same place, but I do not know how to translate it to line of code ...
<whitequark>
ik_5: what does happen if you ^C it?
<whitequark>
also, what Ruby version do you use?
<ik_5>
1.8
jwmann joined #ruby
<ik_5>
and it's a daemon ..
travisjeffery joined #ruby
jwmann joined #ruby
whitelogger joined #ruby
Topic for #ruby is now Ruby programming language || ruby-lang.org || RUBY SUMMER OF CODE! rubysoc.org/ || Paste >3 lines of text in http://pastie.org || Para a nossa audiencia em portugues http://ruby-br.org/
jwmann joined #ruby
<whitequark>
ik_5: kill -INT $pid
jwmann joined #ruby
Syzygy__ joined #ruby
<whitequark>
ah, no tty.
<ik_5>
whitequark, i'ved executed it using nohup, but no special output to save the day :(
<whitequark>
can you attach gdb (gdb -p $pid) then make several backtraces at some points (bt;c;^C;bt;c;^C and post to pastie)
<JonnieCache>
ah thats it
flippingbits joined #ruby
<JonnieCache>
gcore is the name
<JonnieCache>
gcore -p <PID> dumps the memory of a process
<ik_5>
whitequark, but gdb will work with mri, not with the ruby code itself as far as i understand
ph^ joined #ruby
<ik_5>
JonnieCache, on what platform ? I can't find it in Linux
<JonnieCache>
its a linux thing. its not here on OS X but i've definitely used it on linux several times
<JonnieCache>
maybe you need to install it
<ik_5>
JonnieCache, I can't find it on the package manager
closedbracket joined #ruby
fatguylaughing joined #ruby
<JonnieCache>
hmm apparently its part of gdb, which makes sense
ramusara joined #ruby
<JonnieCache>
do you have gdb installed?
<whitequark>
ik_5: sure, but some info could be deduced even from C level backtrace
Dangr_ joined #ruby
rippa joined #ruby
<ik_5>
whitequark, I'll try. thanks
jbpros_ joined #ruby
steph021_ joined #ruby
steph021_ joined #ruby
theRoUS joined #ruby
theRoUS joined #ruby
redgetan joined #ruby
vipaca joined #ruby
vipaca joined #ruby
crankycoder joined #ruby
whitelogger joined #ruby
Topic for #ruby is now Ruby programming language || ruby-lang.org || RUBY SUMMER OF CODE! rubysoc.org/ || Paste >3 lines of text in http://pastie.org || Para a nossa audiencia em portugues http://ruby-br.org/
crankycoder joined #ruby
<whitequark>
ik_5: iirc there was some patch for 1.8 ree
<whitequark>
which allowed to print backtraces of other threads
<whitequark>
you could start a thread and invoke that code from it periodically
KL-7 joined #ruby
<ik_5>
whitequark, thanks, i'll look into it
h4mz1d joined #ruby
Draco_ joined #ruby
bluOxigen joined #ruby
closedbracket joined #ruby
iocor joined #ruby
travisjeffery joined #ruby
sean_m joined #ruby
durre_ joined #ruby
wyhaines joined #ruby
nerded joined #ruby
aibo joined #ruby
littlebill902 joined #ruby
alex__c2022 joined #ruby
Draco_ joined #ruby
wilmoore joined #ruby
brianherman joined #ruby
kaspernj joined #ruby
akem joined #ruby
pootpoot joined #ruby
tjj joined #ruby
fayimora joined #ruby
rook_flood joined #ruby
brianherman joined #ruby
io_syl joined #ruby
io_syl joined #ruby
philcrissman joined #ruby
phantasm66 joined #ruby
heftig joined #ruby
phantasm66 joined #ruby
skammer joined #ruby
adambeynon joined #ruby
cbuxton joined #ruby
quest88 joined #ruby
hydrozen joined #ruby
marcuspat joined #ruby
cjz joined #ruby
eywu joined #ruby
Hellojere joined #ruby
rushed joined #ruby
philcrissman joined #ruby
smgt joined #ruby
LiquidInsect joined #ruby
king313 joined #ruby
king313 joined #ruby
statarb3 joined #ruby
statarb3 joined #ruby
Indian joined #ruby
ank joined #ruby
ia9371 joined #ruby
<ia9371>
hello im having trouble with ruby RVM
<ia9371>
why is it not changing version
<ia9371>
i do rvm use 1.9.2 and it wont switch over
<whitequark>
$ rvm info
<ia9371>
ruby -v stays at 1.8.7
Spockz_ joined #ruby
Cervajz joined #ruby
<ia9371>
it sasys 1.9.2
<ia9371>
says ruby 1.9.2
<ia9371>
im using Ubuntu
<ia9371>
no one had this problem>
<Tasser>
ia9371, #rvm
<ia9371>
both my ubuntu computers do this.. mac works fine
<samuelkadolph>
What a dick move, just linking a SO question
artOfWar joined #ruby
<apeiros_>
samuelkadolph: I feel similarly and am still undecided whether I should act upon it :-/
<Tasser>
samuelkadolph, redirect ;-)
<samuelkadolph>
Redirect what?
<apeiros_>
him. to #ror.
theRoUS joined #ruby
theRoUS joined #ruby
maletor joined #ruby
<samuelkadolph>
Why? He's just linking to site, didn't even ask a question
nowthatsamatt joined #ruby
juiceman5000 joined #ruby
<juiceman5000>
is there an equivalent in Ruby to PHP's get_defined_vars() ? I need to find out all variables accessible to me for any given scope; I don't need to know what's in them, just their name and their type
<paulian>
hello. we are debugging a ruby application. Unfortunately we are completely new to ruby, there is an error message printed and the application exits, we would like to get a stack trace. Thanks
g0bl1n joined #ruby
g0bl1n joined #ruby
<apeiros_>
paulian: ruby on rails is #rubyonrails. the backtrace should be in your log.
ik_5 left #ruby
<paulian>
thanks, but we are not using rails, is a command line script ...
<paulian>
We tried using rdebug but we get a segfault after running "cont"
<deryl>
try ruby -d -W2
<deryl>
-d will turn on the debugging
<deryl>
-W2 will crank out the max amount of warning information
<kaspernj>
paulian, try searching the source-code for e.message or e.inspect with a tool like Reggexer... That is useually used to write out error messages. Or "catch" which is used for error handling. It sounds like your app have caught the error and only printed the error message.
<deryl>
wish ruby supported --trace directly
Araxia_ joined #ruby
<paulian>
deryl, kaspernj : thanks very much, we will try that
<apeiros_>
paulian: d'oh, sorry, I somehow read "we're debugging a rails application". no idea why :-S
<kaspernj>
paulian, maybe you should only search for ".message" or ".inspect" since the e-variable could be called something different.
<apeiros_>
I'd search for the message printed
<apeiros_>
it's a known
eywu left #ruby
pen_isident joined #ruby
<kaspernj>
That would also be a good idea :-) Hopefully it isnt translated with gettext or something like that.
<apeiros_>
hm, though, it could be composed, so it might be not in one piece in the source code…
phantasm66 joined #ruby
<kaspernj>
apeiros_, he should probably try your suggestion first :-)
stkowski joined #ruby
KostaS joined #ruby
asdf- joined #ruby
<asdf->
is this chan strictly for ruby or is Ror discussed as well?
enikar joined #ruby
<apeiros_>
ror is preferably discussed in #rubyonrails
<asdf->
thank you
<paulian>
we are trying the grep in our sources, but it could be multiple repositories, is a better way that using strace command to find all the files loaded ? thanks
Evixion` joined #ruby
cjs226 joined #ruby
RORgasm joined #ruby
benj_ joined #ruby
minijupe joined #ruby
<kaspernj>
paulian, I assume you know which file started the app? Try putting "begin" on the top, and then "catch Exception => e; puts e.inspect; puts e.backtrace". No matter if there is an exit or interrupt this should catch it and tell you where it is (unless it comes from a thread).
<apeiros_>
paulian: it's hard to give a generic approach for such a problem
<kaspernj>
paulian, and "; end"
caveat- joined #ruby
<kaspernj>
so the end should be: "catch Exception => e; STDOUT.puts e.inspect; STDOUT.puts e.backtrace; end"
<kaspernj>
Then even if the app has hacked stdout, it should still get printed to your terminal.
Cervajz joined #ruby
pschmitz_ joined #ruby
travisjeffery joined #ruby
adamkittelson joined #ruby
Voziv joined #ruby
<Voziv>
Hello, what gem do I need to install to be able to make sha1 hashes?
matthiasgorgens joined #ruby
<Voziv>
I should also note that I am running this on windows, and since I'm fairly new to ruby, I'm not sure which gems I should have for Logger and sha1
<samuelkadolph>
Voziv: digest/sha1 is part of stdlib so you don't need a gem
<deryl>
require 'digest/sha1'
<Voziv>
ah, the require i have just says sha1
juiceman5000 joined #ruby
<Voziv>
what about logger?
juiceman5000 left #ruby
xpot-mobile joined #ruby
<samuelkadolph>
logger is part of stdlib as well, just require it
alfism joined #ruby
<Voziv>
hmm
codespectator joined #ruby
derekbarber left #ruby
<Voziv>
And lastly, I'm getting an error with aws/s3 it says "invalid multibyte escape: /[\x80-\xFF]/"
minijupe joined #ruby
<Mon_Ouie>
The encoding of your string isn't right. I guess it should be binary (though it may be something else)
Draco_ joined #ruby
<Voziv>
It's a gem I installed, works fine on my linux server
<Mon_Ouie>
Most likely because your server has an older version of Ruby (1.8.7)
<Voziv>
ah, makes sense
maxok joined #ruby
voodoofish430 joined #ruby
<samuelkadolph>
No, it's a problem with 1.9 and the gem
<Voziv>
awesome thanks, I commented out that line as the gem has code checking for versions of ruby >= 1.9 but the syntax error prevents the execution anyways
<Voziv>
works great now
<samuelkadolph>
/\x80/ gives an error since \x80 isn't a valid character
yalue joined #ruby
smgt joined #ruby
robyurkowski joined #ruby
kenichi joined #ruby
<ai9371>
what is invalid gemspec
<ai9371>
wrong date and time format
rippa joined #ruby
<ai9371>
im getting this errro everytime i tryi to do anything with gem and rails
<ai9371>
like install rails
<ai9371>
gem install rails.. get a bunch of errors
<Kiten>
vim has plugin support, Highlighting for nearly all major languages including Ruby you can smart-indent with > and < respectively
<JonnieCache>
I tried to learn vim/janus but the various plugins kept segfaulting on me. changing any aspect of its behaviour required hacking on vimscript which is the most unfriendly shit I've ever seen. so many of the plugins are disgusting hacks
<dominikh>
learn vim or emacs. I don't care which, but pick one.
<JonnieCache>
sublime on the other hand is scriptable in python
robotmay joined #ruby
<Kiten>
^^what dominkh said
<JonnieCache>
YOU'RE NOT THE BOSS OF ME!
<dominikh>
you cannot know that
<JonnieCache>
lol
<Kiten>
if you want scripting go grab excel 98 from the nearest dump and just code in spreadsheets
* JonnieCache
is going to start using visual studio out of sheer contrarianism
<Kiten>
ewwwwwwww
<shevy>
in the epic battle vim vs. emacs there are two losers always :(
pantsman joined #ruby
pantsman joined #ruby
r00t__ joined #ruby
Kiten left #ruby
Kiten joined #ruby
<Kiten>
whoops stupid ctrl-w
<cdabba>
rails active record question: Cars belongs_to projects through project_rtid
<cdabba>
but projects has a primary key of id
<JonnieCache>
lol i thought youd actually left the chan in disgust at them mention of visual studio
<Tasser>
cdabba, #rubyonrails
<cdabba>
ok
<Kiten>
JonnieCache: no but i should have ;p
<Tasser>
JonnieCache, friend of mine tells me to use it... ;-)
Hellojere joined #ruby
<Kiten>
Tasser: VS is the most overbloated piece of software i've ever used i'd rather use pinecones for toilet paper
<Tasser>
I'd have to use to really say something about it
<shevy>
Kiten pinecones aren't so bad
<shevy>
try old newspaper
<Tasser>
shevy, in the DDR they tortured people with toilet paper
<rippa>
try using pine needles
<Kiten>
the worst part especially if your a C/C++ developer is that they annoy you into using there rolled versions of some STL functions
Azure joined #ruby
<Kiten>
shevy: i'll just get some 900 grit sandpaper
KL7 joined #ruby
Manhose joined #ruby
<Kiten>
anyhow notepad++ is pretty good, personally i'd take the time to learn vim or emacs,there's also Gedit for gnome fans, nano, windows notepad in wine, Kdevelop if you really want to
<Kiten>
Code::Blocks if you take the time to setup syntax highlighting if its not already done
<Kiten>
tons of good stuff out there really
<Tasser>
there's redcard too
<Kiten>
except VS,netbeans(ONLY good for Java thats it), eclipse, are ones to stay away from
tvo_ joined #ruby
<Kiten>
never used redcard
<Tasser>
ehh redcar
<shevy>
hehe
<Kiten>
oh and traditional unix ed
<shevy>
I'd use redcar! If I wouldn't have to use JRuby for it that is ... :P
<Mon_Ouie>
You probably meant cat.
<Kiten>
me ?
rcs joined #ruby
EddieBluh joined #ruby
<shevy>
Who knows whom he meant!
shadoi joined #ruby
ChampS_ joined #ruby
ank joined #ruby
<Kiten>
bout to say ed was on unix first ;p
<Kiten>
for some reason i can't locate it in the AUR/pacman repos
<Kiten>
actually ed might have been BSD
<shevy>
no idea, never used it and wouldn't use anything like that in 2011 either
<josemota>
hey guys, I'm trying to figure out mocks with a spec I'm building, how can I set the relationships between the record being tested and the mocked events?: http://pastie.org/2879250
<Kiten>
vim's been around for ages and thousands of *nix users use it
<Kiten>
those that haven't subscribed to cult of emacs ;p
themadcanudist left #ruby
<Kiten>
literally one site i was on worshipped emacs ;p
badabim joined #ruby
paulian left #ruby
<LiquidInsect>
Tasser, JonnieCache: sorry, meeting came up. Nothing scary: I see a lot of places in our codebase where people are using eval where I'd rather see us use send something similar. But, since these are local variables, I can't just use, say, self.send(:"#{foo}_total_amount=", calculate_total)
<LiquidInsect>
I want to avoid using eval
btanaka joined #ruby
phantasm66 joined #ruby
GreaseMonkey joined #ruby
<Kiten>
copy to a global constant ?
<LiquidInsect>
you what
<Kiten>
why not just copy to a global constant ? you wouldn't need to worry about scope
<heftig>
global variable, not constant
<heftig>
$foobar
<LiquidInsect>
I am so not a fan of that
<heftig>
or Thread.current[:foobar]
<shevy>
why do they use eval? don't they use classes?
<LiquidInsect>
shevy: I wish.
justinmcp joined #ruby
<LiquidInsect>
There is so much refactoring needed here that I can't begin to describe it
<Kiten>
heftig: i meant constant not variable :P
<Kiten>
variable works though
<Kiten>
but for a temporary copy i'd make it constant
<heftig>
why?
marcuspat joined #ruby
<heftig>
doesn't sound constant.
<LiquidInsect>
it's not constant
ethndbst joined #ruby
<Kiten>
prevents outside tampering
<LiquidInsect>
doesn't matter, if there isn't a way to do it it just means we're doing it wrong in general which was my hunch to begin with
<Kiten>
eval is never the right thing to use anyway to many ways to abuse it
<LiquidInsect>
So, that works for the first person who needs their total cacluated. What happens when the second of thousands of users comes in and that constant was already set?
SegFaultAX|work joined #ruby
<LiquidInsect>
like I said. Just means a larger bit of work to be done.
<LiquidInsect>
no problem.
espeed joined #ruby
<Kiten>
set a throwaway then
<Kiten>
somevaridcabout = whatever
<shevy>
sounds as if you aren't using any classes in that project
<LiquidInsect>
what?
blueadept joined #ruby
<LiquidInsect>
I't sa local variable. Inside a method. Inside a class.
<Kiten>
then why use eval ?
<LiquidInsect>
I didn't write this code.
<shevy>
ok and what is the eval used for? and why do you want to use .send instead?
<blueadept>
quick question, if i have two arrays of utc formatted dates, what's the best way to compare both of them and only output those dates which are not in both arrays?
<LiquidInsect>
I don't want to use send. I want to do ANYTHING other than eval.
<Kiten>
LiquidInsect: well if you can't change the eval because of work restrictions work around it
<LiquidInsect>
if possible.
KL-7 joined #ruby
<LiquidInsect>
Kiten: again. All it means is I need to refactor harder.
<LiquidInsect>
Not a problem.
<LiquidInsect>
The answer to my question was "no"
<shevy>
we are getting closer, but I am still not sure why eval is used
<LiquidInsect>
Neither am I. I didn't write this.
<Kiten>
used for an interpreter ?
<Kiten>
other than that to me it seems pointless
<shevy>
what are those evals doing right now?
<Kiten>
blueadept: google rdoc: Time
<Kiten>
blueadept: there is a boat load of info on the Time class there
<Tasser>
blueadept, rubydoc.info => stdlib
<LiquidInsect>
they're using a list of symbols. Iterating on that list. Each symbol is evaled as (something like) eval("#{sym.to_s}_paid_to_date = some_other_object.inject({|sum,i| i.price})"
<LiquidInsect>
more or less.
<blueadept>
ah ok
<blueadept>
cool, ty
<Kiten>
:P
<Kiten>
LiquidInsect: looks like their using this for some accounting type ordeal
<blueadept>
got it
<LiquidInsect>
yes. Don't worry about it. I don't need help. My question has been answered, way back. Nice of you though.
<Kiten>
ok
Araxia_ joined #ruby
Vendethiel joined #ruby
ryanf joined #ruby
<blueadept>
you know ruby is ok, i dont care what they say about it
<blueadept>
:D
<LiquidInsect>
it's like the tortoise beating the hare really
<shevy>
who is they
<LiquidInsect>
you know
<LiquidInsect>
"they"
<blueadept>
zed shaw
<LiquidInsect>
^
<deryl>
The Men In Purple
<shevy>
is he now plural or what :P
<LiquidInsect>
zed's problem seemed really to be more with the community
<LiquidInsect>
which I really don't get
<Kiten>
blueadept: Ruby is awesome ;p
kirun joined #ruby
zodiak joined #ruby
adamjleonard joined #ruby
<shevy>
LiquidInsect don't know, I am using ruby because ruby is better than perl/php/python/lua for my use case
dlitvak joined #ruby
<Kiten>
I'm using Ruby simply for the fact that after i took a look at it i immediately took to it
goodieboy joined #ruby
<Kiten>
of the languages i know [C,C++,Perl,Lua] ruby is in my opinion the most flexible
<blueadept>
node.js + coffeescript is almost like ruby
jarjar_prime joined #ruby
<blueadept>
different paradigm though, with callbacks and such
jshsu joined #ruby
spacebug joined #ruby
Voziv joined #ruby
joelio joined #ruby
epochwolf|vps joined #ruby
epochwolf|vps joined #ruby
Espen-_- joined #ruby
Johannes` joined #ruby
RobotOlivaw joined #ruby
dohzya joined #ruby
ecolitan_ joined #ruby
Elfix joined #ruby
Bish joined #ruby
marienz joined #ruby
Veejay joined #ruby
<dlitvak>
python is simmillar to ruby... and i like it a little better
Thermoriax joined #ruby
Natch| joined #ruby
youdonotexist joined #ruby
<jensn>
:o
tsykoduk joined #ruby
RegEchse joined #ruby
<Kiten>
dlitvak: i couldn't get past the whitespace regime
__class__ joined #ruby
<shevy>
for me it was the explicit self
mitchty joined #ruby
<Kiten>
too tedious for me
<Tasser>
Kiten, I like the whitespace idea. ;-)
<dlitvak>
Kiten: it actually makes your life easier
dynamus joined #ruby
<dlitvak>
shevy: the python Zen states... Explicit is better than Implicit
<Kiten>
not really i make whitespace anyway having to follow one persons idea of whitespace is annoying
<dlitvak>
shevy: so... there goes for the mandatory self
releod joined #ruby
orangejuice joined #ruby
<shevy>
that is nice that there are rules that explain that deficit
<blueadept>
whitespace is not as bad as you might think
<blueadept>
honestly i dont see what the big deal is
joschi joined #ruby
<dynamus>
hello
<dlitvak>
dynamus: hi there
pschmitz_ joined #ruby
<Kiten>
blueadept: its not whitespace thats bad its the restrictions placed on it
<shevy>
class Dog # does any dog know about himself or not, not in python, no!
<Kiten>
in python
phantasm66 joined #ruby
Natch| joined #ruby
macmartine joined #ruby
<dlitvak>
Kiten, which restrictions?... just... every block of code must be contained in its own namespace...
<Kiten>
^ is annoying
mitchty joined #ruby
<dlitvak>
Kiten, in ruby you get this with the do end, or def end statements
workmad3 joined #ruby
<Kiten>
not really do and end are markers in python i feel that the whitespace "markers" are a hindrance rather than a feature
<Kiten>
err
Cervajz joined #ruby
<Kiten>
do an end are markers in rubby
<Kiten>
err
<Kiten>
ruby
<Kiten>
friggin old ass keyboard
<Kiten>
for example i can do this
<Kiten>
list.each |s|
<Kiten>
print s
<Kiten>
err
<Kiten>
list.each do |s|
<shevy>
make it valid man!
<Kiten>
print s
<Kiten>
end #no hindrance
<dlitvak>
in python...
<dlitvak>
print x for x in list
<shevy>
I tend to use {} for that :)
<Kiten>
just aint for me i've got a friend that does python but i just can't get past the whitespace issue
<dlitvak>
Kiten, its the same in ruby... if you dont use whitespace... your code gets usually unreadable...
<Kiten>
yes but in python its forced
DarkFoxDK joined #ruby
<dlitvak>
Kiten, and that is good!
<shevy>
unreadable?
<dlitvak>
it enforces readability
<Kiten>
hah shevy ;P
<shevy>
Kiten's example would still work, in python it wouldn't, but I really find the whitespace a minor thing
Draco_ joined #ruby
kevinbond joined #ruby
<Kiten>
and anyhow readability isn't an issue if a programmer can't read some one else's code they haven't learned the semantics well enough to do field work
<shevy>
people can write horrible code in any language, I usually hate code written by others
callenb joined #ruby
<shevy>
unless it is somehow elegant :)
<Kiten>
most of what i've seen from ruby coders is extremely legible
<shevy>
I've seen terrible things man
<blueadept>
there's more than one way to skin a cat
<Kiten>
now C and C++ coders on the other hand can get quite obfuscated
josh_ joined #ruby
<blueadept>
or rather, there's more than one way to interepret a model
<shevy>
thousands of $foo and hundreds of @@blas (ok not hundreds, but still)
<shevy>
and what is the *_ part... is that a splat into _ ?
<shevy>
hmm never seen that one before with _
<shevy>
:)
<Kiten>
shevy you should see a perl wizard in action you'd get mind raped
<shevy>
good old perl, still aging well even though newcomers use other languages these days
Draco_ joined #ruby
<Kiten>
thats what i wrote my irc bot in was perl which i ported to ruby today ;p
yekta joined #ruby
<Kiten>
perl is still really useful i don't see it going anywhere
<dlitvak>
perl, python and ruby share a lot of common stuff
<Kiten>
though i have to admit ruby is faster
<botam>
than python?
<dlitvak>
ruby is faster?
<Kiten>
ruby is faster than perl ;p
<dlitvak>
ruby is REALLY slow in comparison with almost everything :S
<blueadept>
^
<blueadept>
the interpreter is slow
<blueadept>
can't get around it
<Kiten>
C is most definitely faster than all if you wanna argue ;p
<Kiten>
minus asm
<samuelkadolph>
Sure you can, jruby is fast
<shevy>
Kiten every language can be useful
<dlitvak>
xD
<dlitvak>
jruby is like twice as fast than ruby
<Kiten>
shevy: yeah but there are some languages that are getting excluded from my list
<dlitvak>
but jython isnt faster than python
<Kiten>
namely Java and Python
<dlitvak>
because python interpreter is faster than JVM
<adamjleonard>
It's all about brainfuck, lets be honest here
<Kiten>
Brainfuck is pretty damn good
<Kiten>
i most say its most impressive
<Kiten>
err must
<shevy>
that's one obfuscated language
<adamjleonard>
haha
<adamjleonard>
Very much so
<dlitvak>
Kiten, yeah... i like brainfuck... i made a crazy bf implementation on python and smalltalk
zastaph joined #ruby
<Kiten>
lua is pretty awesome to super super super easy to learn
<Kiten>
a 5 year could learn lua if they sat still long enough
<dominikh>
lua is pretty disgusting
<dominikh>
but easy to learn
<Kiten>
disgusting how ?
<dominikh>
horrible syntax, horrible idoms
<dlitvak>
not object oriented!
<dominikh>
and arrays that start at index 1...
<dlitvak>
and no clojures
<dlitvak>
a language with no clojures is not a good language for me anymore
raincole_ joined #ruby
raincole joined #ruby
badabim joined #ruby
<dlitvak>
i've even started hating java when i learned the real power of clojures... and i'm a java teacher!
<Kiten>
i just learn languages for the hell of it minus python an java for obvious reasons
<Kiten>
dlitvak: dude i've hated java forever
<Kiten>
welcome to the boat
<shevy>
I never managed to overcome Java's verbosity
<Kiten>
java is just so damn slow and it take forever
<Kiten>
s/take/takes
redgetan joined #ruby
dnyy joined #ruby
<dlitvak>
Kiten, i've been hating java for about 5 years xD
<dlitvak>
it's just that now... it's even worse
travisjeffery joined #ruby
<Kiten>
yeah since you do it for a job
<Kiten>
java and python are really the only languages i hate plus whatever spinoffs of c# there are
<dlitvak>
Kiten, i actually enjoy my job... i teach design patterns, refactoring, tdd, xp and some other funky stuff
<dlitvak>
but i just hate java
Manhose_ joined #ruby
jbpros joined #ruby
<Kiten>
i started on C so i'm use to fast execution, not necessarily compile times
<dlitvak>
java is only a tool for teaching those things... as most of those things.. are really automated in java and not that much on other languages
<shevy>
C and Ruby, that's the best combination
<dlitvak>
C and Python =) :P
josh__ joined #ruby
<Kiten>
C, lua/ruby/perl
<dlitvak>
jeje
mxweas_ joined #ruby
lobo_d_b joined #ruby
jbw joined #ruby
<Kiten>
objc is pretty nice too once you get past the semantics
<Kiten>
though i wouldn't consider making that my primary language
<shevy>
way too verbose with all its interface* what nots
<samuelkadolph>
That's not why ObjC is verbose
<samuelkadolph>
It's the method names
<Kiten>
the thing about objc i don't like is that you use classes way too much
<samuelkadolph>
Then use C
<dlitvak>
i dont like c-like languages anymore... except from Python's C library... just cause i enjoy python xD
<dlitvak>
Kiten, classes are goooooood!
<dlitvak>
more classes are better
<Kiten>
[UIButton setTitle=@"somebutton" for: UIControlStateNormal]; or some nonsense like that
wyhaines joined #ruby
macmartine joined #ruby
<adamjleonard>
Ruby has spoiled me and so therefore brackets have become the devil, unless it's for hashes and related things :)
<deryl>
classes are blueprints, excellent factories for defining the commonalities for objects. gotta love that
<deryl>
define once, reuse everywhere
<Kiten>
makes ios GUI a breeze but its a bitch to debug
<aef>
can anyone imagine a way how i could test if a warning was being written which is send with the C function rb_warn ?
<aef>
that is, without having access to the STDERR stream
<deryl>
I don't like how convoluted they've made the classes, but thats not the same thing as not liking classes
<Kiten>
aef how the eff would you not have access to STDERR
<deryl>
sort of like MS's STL
<samuelkadolph>
aef: No, there is no warn hook. The best you can do is patch ruby's warn
<aef>
Kiten: well, STDERR is not opened for reading
<Kiten>
microjunks acid induced VS "secure" features suck
<Kiten>
aef are you on windows or nix ?
<dlitvak>
aef: is there no way you can launch the script doing $2 > $1??
<Kiten>
if your on nix STDERR is always open
<samuelkadolph>
You could reopen $stderr to a pipe then read from it
<aef>
Kiten: i'm on Linux, but the spec must work on Windows too
<Kiten>
the kernel prints junk to it
<dlitvak>
aef: that would redirect stderr to stdout
<Kiten>
exception anyone
<Kiten>
just catch exceptions an log it to a file
<dlitvak>
aef: using puts err??
<aef>
dlitvak: I need to test it programmatically, it's a unit test
<dlitvak>
aef: i understand that... so... then why are you printing to a file, stderr, whatever?
<dlitvak>
just assert the exception
<aef>
dlitvak: i could set $STDERR to a StrinIO object maybe
<aef>
dlitvak: maybe that works, i'll try that
imsplitbit joined #ruby
<samuelkadolph>
No it won't
<dlitvak>
aef: great!... but... still... why would you want that?
pschmitz_ joined #ruby
<aef>
dlitvak: oh
<Kiten>
aef tell your clients to install cygwin
<aef>
dlitvak: i think rubyspec's mspec has a matcher for that
lobo_d_b joined #ruby
lobo_d_b joined #ruby
<Kiten>
then you can use STDERR
<aef>
dlitvak: sorry, i think i've got my solution
headius joined #ruby
<Kiten>
although i'm pretty sure STDERR can be used on windwoes
<samuelkadolph>
r,w = IO.pipe; $stderr.reopen(w); Time.now.succ; r.gets # => "(irb):4: warning: Time#succ is obsolete; use time + 1\n"
<Kiten>
if not some wizardry can over come it
<dlitvak>
aef: never used mspec, just rspec and test/unit... but... why would you want to redirect stderr?
<aef>
dlitvak: i don't want that. and i won't do that
<aef>
dlitvak: i've found a way now, there's a built in matcher
<dlitvak>
aef: oh... great!
<aef>
dlitvak: thanks for your ideas though
<samuelkadolph>
My example works on windows
<dlitvak>
aef: no problem!
<aef>
Kiten: problem's solved, thank you too
<Kiten>
no problem
<Kiten>
though if you plan on deploying rapidly consider the cygwin approach
cjz joined #ruby
<Kiten>
err developing
<Kiten>
cygwin is basically a nix enviroment for windows
ghanima joined #ruby
sodani joined #ruby
naequs joined #ruby
<sodani>
Hello, the registered symbol, "®" is causing the error, invalid multibyte char (UTF-8). Can someone tell me what I'm doing wrong?
Adman65 joined #ruby
<Kiten>
wrong encoding used
<cbuxton>
sodani: what version of ruby are you using?
moshee joined #ruby
moshee joined #ruby
<sodani>
I'm using ruby 1.9
<dlitvak>
sodani: are u decoding the strings as unicode?
<sodani>
dlitvak: no I'm not. I guess the symbol is latin-1 and I need to use the utf-8 version?
Transformer joined #ruby
<dlitvak>
sodani: probably... though each input can always be different... so... you just might try to get some standarized input... or evalueate every possibility
cyri_ joined #ruby
manizzle joined #ruby
<sodani>
do you know how I can find the unicode version for that symbol?
<dlitvak>
sodani: string encodings are a bitch... the only way to know... is to try
<sodani>
yeah I've been trying to figure out encodings for the past 2 days and still struggling!
<sodani>
I thought that it was a UTF-8 character but I guess I'm wrong
<dlitvak>
sodani: if the symbol is as you said latin-1... you should try... latin-1
<sodani>
it works as latin-1 but I want to convert it to utf8 because, well, I thought that's the direction everything is going in
<dlitvak>
decode latin-1... encode unicode
ilyam joined #ruby
Zavior joined #ruby
hobodave joined #ruby
<samuelkadolph>
sodani: How are you getting the string? From a file?
rickmasta joined #ruby
artOfWar joined #ruby
<sodani>
yup, I just pasted it into my .rb file
<sodani>
when I set the encoding as latin-1 it works, but I want to work with utf8
<dlitvak>
sodani: decode the string with latin-1
<shevy>
Encoding is a lot of fun
<dlitvak>
encode it with unicode
<samuelkadolph>
What's your $LANG set to?
<sodani>
dlitvak: would you be able to paste an example of this?
<mike___>
julian-delphiki: got it. thx. to you too, jensn!
Draco_ joined #ruby
alfism joined #ruby
MHD joined #ruby
wmoxam_ joined #ruby
wmoxam joined #ruby
wmoxam joined #ruby
wmoxam_ joined #ruby
Fraeon joined #ruby
minijupe joined #ruby
sodani joined #ruby
<sodani>
hello. what does the #!/usr/bin/env ruby -w at the beginning of .rb files do?
TomJ joined #ruby
evantravers joined #ruby
evantravers left #ruby
evantravers joined #ruby
travisjeffery joined #ruby
trivol joined #ruby
onetonturd joined #ruby
onetonturd left #ruby
whitelogger joined #ruby
Topic for #ruby is now Ruby programming language || ruby-lang.org || RUBY SUMMER OF CODE! rubysoc.org/ || Paste >3 lines of text in http://pastie.org || Para a nossa audiencia em portugues http://ruby-br.org/
<julian-delphiki>
mike___, what is that big old if attempting to accomplish?
<mike___>
well i don't want to run the check if theres "aaa", "bbb" and so on in ima or imb
<julian-delphiki>
oh
<julian-delphiki>
ok
<mike___>
but abbac doesn't contain on of these
<mike___>
so it shouldn't be "filtered" out by that
rsampaio joined #ruby
<julian-delphiki>
I'd probably do that with ima.include?("aaa") etc
<julian-delphiki>
but w/e
apok joined #ruby
<mike___>
i haven't done any ruby in years, so i'm not that fluent in it :)
<any-key>
maggie_n: or there's the URI::URI.escape
<any-key>
maggie_n: the main difference is that the CGI one will actually escape _everything_ whereas the URI one leaves things like ampersands and slashes
<julian-delphiki>
mike___, any time
<mike___>
i think i could save some more code if i did like r = /aaa|bbb|.../ and then if !(... =~ r), right?
<mike___>
so i wouldn't have to repeat the regexp twice, since i might want to add more patterns to that
<maggie_n>
any-key: hey, that's useful - I was wondering why there were two
<maggie_n>
(both of them were coming up in searches)
<maggie_n>
thanks, that'll do the trick! :)
<any-key>
maggie_n: I stumbled into some trouble thanks to that, took me too long to figure out what was going on :P
<any-key>
no problem
<maggie_n>
yeah, it can be annoying
<maggie_n>
glad I can learn on others' mistakes, hehe
datafirm joined #ruby
<datafirm>
hi
_whitelogger joined #ruby
Topic for #ruby is now Ruby programming language || ruby-lang.org || RUBY SUMMER OF CODE! rubysoc.org/ || Paste >3 lines of text in http://pastie.org || Para a nossa audiencia em portugues http://ruby-br.org/
gearaholic joined #ruby
Voziv left #ruby
<any-key>
git clone?
<datafirm>
any-key: in a Gem Specification
Tasser joined #ruby
tomzx joined #ruby
<datafirm>
specification.add_dependency( "gem_name", [ "version" ] ) , but can one add a repo to pull the gem from?
nari joined #ruby
<any-key>
I guess I don't follow, what is being pulled from and why?
<any-key>
ah okay
<any-key>
I'm not sure
sythe joined #ruby
sythe joined #ruby
<nlew>
Any idea why gem installs rspec-{core,expectations,mocks} at 2.7 when I install remarkable, which depends only on rspec >= 1.2, with rspec 1.3 installed?
rvmeier joined #ruby
<iboB>
i'm writing a small vector class, which has "def *(scalar)" to multiply it
Pip joined #ruby
Pip joined #ruby
<iboB>
is there a way of making this work for say 7*v
skrewler joined #ruby
<iboB>
because right now it only works with v*7
<any-key>
idoru: you could monkey-patch it in, but I'm not entirely sure the "safe" way to do that
xpot-mobile joined #ruby
[2]maarten joined #ruby
apok joined #ruby
<any-key>
idoru: wrong person, sorry
<any-key>
idoB: you could monkey-patch it in, but I'm not entirely sure the "safe" way to do that
<apeiros_>
iboB: search for ruby and coerce
<apeiros_>
I'm sorry, I'd explain but I'm very tired and going to bed ATS
hacim joined #ruby
jrun joined #ruby
ph^ joined #ruby
<hacim>
why is $? == 256 when I do 'system "false"' when it should just be == 1 ?
<iboB>
apeiros_, thanks
<shevy>
hacim how do you check that
<hacim>
shevy: system "false" puts $?
<any-key>
hacim: system("false") returns false
<LiquidInsect>
any-key: that's not the question
<shevy>
hacim hmm indeed
<hacim>
yeah, I want the result code
<LiquidInsect>
the return value of false from the system is in $?
<any-key>
LiquidInsect: I get a process object when doing that
<Tasser>
hacim, on gnu, false should have thereturn code 1
xsdg joined #ruby
<LiquidInsect>
any-key: puts it
<LiquidInsect>
make it print itself
<iboB>
class X; include M; def foo; end; end; #is there a way to call the foo defined in M, from the foo in X that hides M's foo?
<hacim>
Tasser: yeah, it does. if I open a shell and type: false ; echo $? - I get '1'
<any-key>
LiquidInsect: ah there we go
<hacim>
Tasser: but if I use ruby I get '256'
<Tasser>
[3] pry(main)> $?
<Tasser>
=> #<Process::Status: pid 18554 exit 1>
<LiquidInsect>
Tasser: print it
<hacim>
Tasser: thats using backticks
<Tasser>
hacim, nah, that's using system("false")
<any-key>
iboB: There might be, but you should consider rethinking your approach if you need to do that
<any-key>
unless I'm missing something more complex
<hacim>
Tasser: ah interesting
<hacim>
Tasser: so puts $? is not putting that exit code then
<Tasser>
it is
dagnachewa joined #ruby
<Tasser>
[9] pry(main)> $?.to_i
<Tasser>
=> 256
<Tasser>
[9] pry(main)> $?.to_i
<Tasser>
=> 256
<Tasser>
ups
<any-key>
$?.exitstatus
<any-key>
Works on My Machine™
stephenjudkins joined #ruby
<hacim>
huh, yeah seems like I need .exitstatus
<iboB>
any-key, I have a vector and a quaternion, the vector is a module and the quaternion is a class that includes it, because they have a lot in common
<iboB>
any-key the exception is the multiplication
<iboB>
the vector has scalar multiplication and the quaternion has quaternion AND scalar multiplication
<sodani>
can someone help me understand what I'm doing wrong that would lead to this error? Encoding::UndefinedConversionError: "\xC2" from ASCII-8BIT to UTF-8
<any-key>
iboB: I would extend the Vector class rather than using a mixin for that, then
<iboB>
so i want def *(other); if other.is_a? Quaternon...
jarjar_prime joined #ruby
rsampaio joined #ruby
<any-key>
if you extended it you could def *(other); super; whatever; end
<any-key>
unless my sleepiness is getting the better of me
<iboB>
yes but then the return types would be bogus
<any-key>
why?
<iboB>
+ returns vector
<iboB>
i want it to return quaternion
<any-key>
I was under the assumption you were redefining it anyways
<iboB>
i'm redefining *
<iboB>
but all other methods i'm not
jarjar_prime joined #ruby
<iboB>
division, addition, etc
<any-key>
so when you do the mixin it's using vector's + which I'm guessing uses a vector
<any-key>
so you're still returning a vector in both cases
<any-key>
assuming that's what's happening
<iboB>
yes yes
<iboB>
that's true
<iboB>
i'm returning the original type
<iboB>
def +(other)
<iboB>
ret = Array.new
<iboB>
@coord.each_index do |i|
<iboB>
ret << @coord[i] + other.to_a[i]
<iboB>
end
<iboB>
self.dup.values(ret)
<iboB>
end
<hacim>
ok, how do I capture the stderr from a system("foo")?
<iboB>
that's my + in the vector
<iboB>
so it works for quaternion
<any-key>
iboB: pastebin, please
philcrissman joined #ruby
gregorg_taf joined #ruby
<any-key>
def +(other) @coord.zip(other).map {|i| i.inject(:+) }; end
<any-key>
but that doesn't duplicate what you're doing
<any-key>
iboB: I haven't tested this, but calling self is calling whatever in that class is...so you're returning a whatever subclass
<iboB>
there was a reason for me to use a mixin
<iboB>
but i've forgotten what it is
<iboB>
i'm testing it with extending the vector now
<iboB>
and honestly i don't see what it is :|
<iboB>
so... yeah... thanks :)
thomasfedb joined #ruby
<any-key>
no problem
<any-key>
I was vauge :P
<iboB>
and another question, i saw how to use coerce to make 7*vec work, but the thing is that i don't want 7/vec to work :)
<iboB>
is there a way to "coerce" only *
<thomasfedb>
iboB, generally you don't coerce opperators
yaasii joined #ruby
fayimora joined #ruby
<RubyPanther>
"If you prefer warm inter-personal dialogs in solving problems, you can dial our hotline. Technical personnel will provide help in the first time." -- Lemote Technology
<iboB>
well yeah.. wrong wording, but is there a way to make 7*x work but 7/x not
rsampaio joined #ruby
Draco_ joined #ruby
<thomasfedb>
iboB, yes, but you'd have to monkeypatch Fixnum, or Numeric, or Integer
<iboB>
ah well that's not acceptable because i need it for integers, floats, doubles and all scalar types that one can think of
<iboB>
so ok... i guess i'll make due without 7*x
<RubyPanther>
You get BIOS source code _and_ help in the first time, what more could you want?
<thomasfedb>
iboB, you could just do x*7
<any-key>
what the fuck is going on when I do reduce(:+)
<any-key>
I know it's a 1.9 thing but what is it called?
<any-key>
I feel like I'm missing out on something
<thomasfedb>
any-key, it will sum the array/enumerable
<thomasfedb>
any-key, .reduce is the same as .inject
<any-key>
thomasfedb: I'm aware, but the syntax will confuse me
<any-key>
*is confusing
<thomasfedb>
any-key, ok
<any-key>
thomasfedb: nonono the :+ part, I understand the functional stuff
<thomasfedb>
any-key, .reduce(:+) is equivalent to .reduce {|a,b| a + b }
<RubyPanther>
iboB: The idea with coerce is to covert to a common class that understands both sides and can do the right thing, so you just make a subclass Foo where foo * foo and foo / foo does what you want, and have the coerce convert both sides to foo
<thomasfedb>
any-key, what happens is inside reduce it does (:+).to_proc
<any-key>
thomasfedb: I understand
<thomasfedb>
any-key, good.
<any-key>
oooh
<any-key>
wow okay that makes sense
<any-key>
thanks
<iboB>
RubyPanther the thing is that the very idea of 7/x is invalid
<iboB>
i need an exception on 7/x
<thomasfedb>
any-key, no worries
mxweas_ joined #ruby
<RubyPanther>
iboB: it is normal when writing a numeric subclass to throw an exception on some things, or return a NaN, or whatever.
Jckf left #ruby
<iboB>
er... how can i use coerce, since 7*x should be a valid operation, whereas 7/x should not (not that both x*7 and x/7 are valid)