18:57 UTC
<  November 2011   >
Su Mo Tu We Th Fr Sa  
       1  2  3  4  5  
 6  7  8  9 10 11 12  
13 14 15 16 17 18 19  
20 21 22 23 24 25 26  
27 28 29 30
Clear selection
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?
<blueadept> yeah
<Squarepy> why not use array.uniq
<blueadept> hm, thats right
<blueadept> ty
kuadrosx joined #ruby
sepp2k joined #ruby
siksia joined #ruby
vitoravelino joined #ruby
flip_digits joined #ruby
skrite left #ruby
hbien joined #ruby
themadcanudist joined #ruby
siksia joined #ruby
chessguy joined #ruby
h4mz1d joined #ruby
kevinbond joined #ruby
MasterIdler__ joined #ruby
banister`sleep joined #ruby
replore_ joined #ruby
rsampaio joined #ruby
mxweas_ joined #ruby
devdazed joined #ruby
bwlang joined #ruby
Backsorry joined #ruby
raincole_ joined #ruby
raincole joined #ruby
RomD` joined #ruby
rsampaio joined #ruby
Backsorry joined #ruby
kevinbond left #ruby
ontehfritz joined #ruby
goodieboy joined #ruby
dcarper joined #ruby
martisj joined #ruby
derekbarbe joined #ruby
derekbarber joined #ruby
lobo_d_b joined #ruby
lobo_d_b joined #ruby
xpot-mobile joined #ruby
Draco_ joined #ruby
lobo_d_b joined #ruby
lobo_d_b joined #ruby
mxweas_ joined #ruby
kevinbond joined #ruby
marigoLd joined #ruby
norex joined #ruby
maletor joined #ruby
<marigoLd> http://pastebin.com/197TTxnp anyone can help me with this error? trying to install ffi on Mac10.7
marcuspat joined #ruby
mikepack joined #ruby
gearaholic joined #ruby
mikepack joined #ruby
nricciar_ joined #ruby
ruby_noob joined #ruby
headius joined #ruby
mxweas_ joined #ruby
Dangr_ joined #ruby
Syzygy_ joined #ruby
siksia joined #ruby
sseellff joined #ruby
aef joined #ruby
v0id joined #ruby
dyer joined #ruby
nari joined #ruby
skrewler joined #ruby
mxweas_ joined #ruby
wedtm joined #ruby
<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
<robyurkowski> true ruby programmers avoid absolutes
<robyurkowski> only the sith deal in absolutes!
<ryanf> tell that to the rails codebase I guess
yours_truly joined #ruby
<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> any-key: might I ask how you did it?
<aef> blaenk: how about this? https://rubygems.org/gems/graph
<any-key> {:node => [names of other nodes]}
<blaenk> what about the edges?
<any-key> implemented PageRank with it :P
<any-key> didn't account for edge weights
<blaenk> oh, np. just I need edge info as well haha
<any-key> throw more hashes at the problem
<any-key> this is ruby, after all
<blaenk> aef: thanks I'm looking around but they all seem overkill or inactive
<RubyPanther> blaenk: it really depends what you're doing, one potential source of examples might http://railroad.rubyforge.org/
<aef> blaenk: graph 2.3 is from october 2011
<aef> blaenk: but i don't know if its overkill
<blaenk> aef: thanks just noticed, was looking at a more outdated fork or something
<aef> blaenk: and its not in Java style
<blaenk> seems like a nice enough gem
<blaenk> thanks, seems fine enough :)
macmartine joined #ruby
excelsior joined #ruby
jay_zawrotny joined #ruby
dbgster_ joined #ruby
Araxia_ joined #ruby
dracflamloc joined #ruby
jankly joined #ruby
<jankly> What is the name of the !~ operator?
<shevy> jankly that is just a negated regex
<shevy> =~ and !~
<jankly> They do the same thing?
<jankly> Or do they actually have operational differences?
<shevy> jankly they don't do the same thing otherwise you wouldn't have them both in ruby :)
<jankly> shaatar: Obviously. Can you point me in a direction that I might be able to find out more information to differentiate the two operators?
<shevy> "foobar" =~ /oo/ # => 1
<shevy> "foobar" !~ /oo/ # => false
<shevy> "foobar" =~ /bo/ # => nil
<shevy> "foobar" !~ /bo/ # => true
<aef> jankly: i would call them match and negated match operator, but that's not official
<shevy> !~ is just negating the =~
<blaenk> if I have a string "e > *t + f", how can I find out that the character after the * is a 't'?
<jankly> shevy: Thank you.
<blaenk> oh, String#index
<blaenk> + 1
savage- joined #ruby
flip_digits joined #ruby
amacgregor joined #ruby
Phrogz joined #ruby
BrokenCog joined #ruby
<Syzygy_> so after doing this 20minute ruby thing on the website ... do I understand correctly that { } does the same as do end ?
<ryanf> yes
<Phrogz> Syzygy_: When in the context of passing a block to a method call, yes.
mxweas_ joined #ruby
<Syzygy_> can i do } or { end?
<aef> Syzygy_: no
<Phrogz> (But not when creating a hash literal, e.g. foo = { cats:true } # valid foo = do cats:true end # not valid
<Syzygy_> ok, thanks
<shevy> cats!!!
<shevy> vs. mice!
x0F_ joined #ruby
banister`sleep joined #ruby
p0y joined #ruby
incluye joined #ruby
andman joined #ruby
BiHi joined #ruby
maletor joined #ruby
Mooooo joined #ruby
Clooth joined #ruby
steph021_ joined #ruby
steph021_ joined #ruby
rohit joined #ruby
rohit left #ruby
funktronic joined #ruby
funktronic left #ruby
satyavvd joined #ruby
havenn joined #ruby
Cervajz joined #ruby
jfredett joined #ruby
GreaseMonkey joined #ruby
replore_ joined #ruby
Draco_ joined #ruby
<Syzygy_> I'm trying to check for all occurances of a string on a an url?
<Syzygy_> url as in the actuall website, not an url itself
<Syzygy_> how would i do that?
<shevy> what do you mean
<shevy> you mean you have two strings?
<shevy> how does the url look, how does the string look
<shevy> url.include? string
skrewler joined #ruby
<Syzygy_> i have a string of an url, and want to check for every occurance of another string on that particular website
manizzle joined #ruby
<Syzygy_> so url.include? string is probably not good enough :/
<shevy> I have trouble understanding "every occurance"
<shevy> your url looks like so? url = "http://mail.google.com/mail/"
<Syzygy_> yeah
<Syzygy_> and the string i'm looking for could be anything
<shevy> give an example!
<shevy> "google" ?
<Syzygy_> lets say on my website http://not-a-number.net/ I'm looking for the word hello
<Syzygy_> or University
mxweas_ joined #ruby
<Syzygy_> or whatever
<shevy> ah... you actually mean on that website
<Syzygy_> that's what i said
<shevy> well an URL is a string after all isn't it :)
<shevy> one way is to store the content of the page in a string
<Syzygy_> well I did actually say "on that particular website"
<Syzygy_> how would I load that?
<shevy> you can use open-uri I think
<Clooth> I use Curb
<Clooth> gem install curb
<Syzygy_> I'm not sure what i can actually use with heroku.com
ksinkar joined #ruby
<shevy> http://not-a-number.net/ is a very weird webpage ;)
<shevy> oh
<Syzygy_> why is that? :>
<shevy> you actually don't mean a word in the source of that page, but a word on the actual website itself? like displayed to the user?
<shevy> dunno, looks korean
wyhaines joined #ruby
<shevy> Syzygy_ wo wohnst denn btw?
<Syzygy_> wien
<shevy> so wie ich. war fr�her h�ufig auf #ruby-de :)
<Syzygy_> how does it look korean? oO
<shevy> I dunno, I thought I saw Hangul chars there
<Syzygy_> ich versuch von sprach spezifischen weg zu bleiben
<shevy> �#
<shevy> hehehe
<shevy> I didn't look at the rest of the page ;P
<Syzygy_> well, � not # number :>
thecreators joined #ruby
<blaenk> any way to see if an array contains all of the elements in another array? I know about include? but that's just for one element
<shevy> ?????
<incluye> a & b == b
<Syzygy_> braenk, you could try it with a foreach
<blaenk> perhaps an array intersection? test if the result of the
<blaenk> there you do :D
<blaenk> thanks incluye that's what I was thinking :)
<aef> blaenk: require 'set'; array.to_set == other_array.to_set
<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
<shevy> I just used the first example from there ;)
<Syzygy_> yeah i'm reading that as well but I'm new to ruby so i don't get it
<banister`sleep> aef: you oculd use ``
<banister`sleep> aef: `:a, :b, :c`
<aef> banister`sleep: that's command execution
<aef> `ls -lag`
<aef> `ls -lah`
<banister`sleep> [29] (pry) main / Hello: 1> `1, 2, 3, 4`
<banister`sleep> => #<Set: {"1, 2, 3, 4"}>
<banister`sleep> aef: you can overide the ` method ;)
<shevy> Syzygy_ well see, basically you just are interested in the HTML code from a webpage right?
<banister`sleep> aef: https://gist.github.com/1372437
<shevy> the source
<shevy> and in the example I gave you just build up a string with that html code, then use .include? on it
<aef> banister`sleep: that's not possible
<shevy> Syzygy_ I'd more write something like that http://pastie.org/2876185
<banister`sleep> aef: i just did it ;)
<banister`sleep> aef: see the gist
<shevy> returns first false, then true in that example, on that webpage
<Syzygy_> I'm not exactly sure what I'm interested in, html should be fine
<aef> i've seen it. it though it was a joke, tried it, and i doesn't work in my 1.9.3
<banister`sleep> aef: i'm running on 1.9.3 and it works fine for me
<shevy> Syzygy_ :)
<shevy> banister`sleep I progressed trying to switch to 1.9.3, slowly step by step!
<Syzygy_> yeah html is fine
<banister`sleep> aef: what's the error you get?
<aef> i tried to paste it into irb, it stayed inside the ` context
<aef> now i'm executing it from a file
<aef> it works partially
<aef> `:a, :b, :c` # => NoMethodError: undefined method `to_set' for [":a, :b, :c"]:Array
<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
<aef> banisterfiend, ryanf: https://gist.github.com/1372453
<aef> i know its still flawed
<banisterfiend> yeah your arity is messed up
bluOxigen joined #ruby
<Syzygy_> Ruby code usually confuses me :/
<Syzygy_> like what all those + and % and $ do all the time D:
<Syzygy_> but at least I understand your code shevy
imbric joined #ruby
<Syzygy_> except this line: if __FILE__ == $PROGRAM_NAME
<shevy> Syzygy_ that translates to kinda "if this .rb script is called directly, run the following code"
marcuspat joined #ruby
<ryanf> why's the arity messed up banister? `` appears to take one string?
<Syzygy_> ok
<shevy> Syzygy_ you can test a bit ... puts __FILE__ ... puts $PROGRAM_NAME ... http://www.ruby-lang.org/de/documentation/quickstart/4/ <-- in german too, look at the part: "Ansto� f�r das Skript"
<ryanf> usually the idiom is __FILE__ == $0
<ryanf> but it's the same thing
<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
Mindscrew left #ruby
<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> 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
<banisterfiend> sorry i gotta interrupt this chat with this just temporarily (sorry) http://www.youtube.com/watch?v=O8QiCqQqxnk&feature=related i wont do it again
manizzle joined #ruby
new2net joined #ruby
<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 ?
iori joined #ruby
bluOxigen joined #ruby
seivan joined #ruby
<Syzygy__> threadList << DEFAULT_URL + /res\/[0-9]+/
<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
xpot joined #ruby
<blaenk> thanks Syzygy__
<Syzygy__> no problem
<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.
apeiros_ joined #ruby
<aef> new2net: here i define a new subclass of String
<aef> new2net: which has an overridden + operator
<aef> new2net: which does add a '/' between all concatenated Paths
<blaenk> how can I make a copy of an array?
<aef> new2net: there is actually a class Pathname in Ruby which does this, plus more things
<aef> blaenk: my_array.clone
<aef> blaenk: or my_array.dup
<aef> blaenk: slightly different meaning
<shevy> blaenk array2 = array1.dup
<blaenk> ah okay thanks
<blaenk> yeah duplicate sounds more like what I want
<blaenk> beautiful it worked
<blaenk> thanks shevy and aef
<aef> new2net: away for a while
<new2net> I see. Does ruby have type hinting? For example, def +(Path other)
<shevy> what is type hinting
<shevy> new2net you probably want to check something on an object ... you can use ... foo.is_a? String or foo.responds_to? :bla
rickwinfrey joined #ruby
<new2net> Right. It's a way to say "this method only takes - kind of object, passing anything else is guaranteed to fail"
rickwinfrey left #ruby
<new2net> or actually... it takes AT LEAST - kind of object/interface, it could have extended or implemented the type
alienvenom joined #ruby
zomgbie joined #ruby
p1d joined #ruby
timonv joined #ruby
<shevy> new2net you can raise an Exception in case it is not the expected object
<shevy> if ! condition met blabla
<shevy> raise YouAreDoingThisReallyWrong
<shevy> or unless, rather than "if !"
djr_ joined #ruby
workmad3 joined #ruby
<shevy> Syzygy__ here a screenshot showing the difference between p and pp http://img689.imageshack.us/img689/4353/uploadmes.png that's from pry by the way
<shevy> even though it says "IRB module" :P
<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?
<Syzygy__> i though it's a standard library
tacrim joined #ruby
mikalv joined #ruby
<shevy> Syzygy__ you must require it first
<Syzygy__> i do
<shevy> require 'open-uri'
KL-7 joined #ruby
<Syzygy__> that's my code
macmartine joined #ruby
<Syzygy__> and my error as well
<Syzygy__> so i guess it doesn't read the url
stoffus joined #ruby
<shevy> hmm
<shevy> yeah something is odd with that webpage
<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
<Syzygy__> :/
<shevy> "goodbye".include? "hello" || "goodbye" => false
<blaenk> but I guess you can just add parentheses around the arguments
<shevy> "goodbye".include?("hello" || "goodbye") => false
SaneWarning joined #ruby
<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: exactly
<new2net> is other words, is not a Duck
<Syzygy__> line.match( %r{{res/\d+}}) threadList << defaultUrl + $1
<Syzygy__> so this?
<aef> new2net: type hinting or static typing make software very restricted
<workmad3> Syzygy__: as long as you have them on separate lines, yeah
<aef> new2net: with duck typing you can always use something else as intended
<aef> new2net: an in most of the times it simply works
<workmad3> new2net: ruby is like interface oriented programming on steroids ;)
<aef> new2net: that's another thin
<shevy> Syzygy__ but you must not forget that $1 can be nil if the regex can not find a match
<aef> new2net: in Ruby there is no formal construct of an Interface
<shevy> I'd really use two lines Syzygy__ :P
<workmad3> shevy: good point... that should be $1.to_s
<shevy> or that yeah
<aef> new2net: even if I think that would help sometimes
<aef> new2net: but you can build a thing like that if you want
<workmad3> or maybe thread_list << default_url + $1 if line =~ %r{(res/\d+)}
<workmad3> woo, oneliner :)
<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?
<Syzygy__> one second
<Syzygy__> I'm downloading right now though :>
pi3r joined #ruby
ephemerian joined #ruby
<Syzygy__> I included a break after line 14 now
burgestrand joined #ruby
<shevy> well ok
<shevy> that looks a bit inefficient
<new2net> aef, Thanks for taking the time to inform me. Does ruby have a GTK?
<shevy> the regex engine is not very light, so you should try to avoid it when you can Syzygy__
<shevy> if line =~ /#{"AGDG"}|#{"vidyadev"}/
<shevy> I am not sure what that is
<shevy> can't you use this instead?
<aef> new2net: there are bindings, but for all I know they are quite rough
<shevy> if line =~ /AGDG|vidyadev/
<shevy> Syzygy__ also, you could check with a .include? 'AGDG' first, before calling the regex
<Syzygy__> workmad3 told me to use that, but you're probably right
iocor joined #ruby
<shevy> where did he do that
<aef> new2net: most people I know who develop GUI apps with Ruby do it using Java Swing or SWT through JRuby
<aef> new2net: but there are bindings for GTK
<Syzygy__> also i guess checking AGDG and vidyadev with two includes would be even better, right?
<shevy> Syzygy__ I don't think he wrote a line like: if line =~ /#{"AGDG"}|#{"vidyadev"}/
<Syzygy__> yeah, ok i might have made a mistake when changing the code he suggested
<shevy> you could always define a new method
<shevy> but yeah
<shevy> you don't need the first regex...
<Syzygy__> workmad3> Syzygy__: if line =~ /#{string1}|#{string2}/
<Syzygy__> is what was suggested
<shevy> if line.include?("AGDG") or line.include?("vidyadev")
<Syzygy__> can i just type or?
<shevy> Yeah Syzygy__ but that was because he thought you had two variables
<shevy> called string1 = "foo" and string2 = "bar"
<aef> new2net: if you want to learn Ruby I recommend the famous pickaxe book to you: Programming Ruby 1.9
<shevy> the #{} is doing interpolation
<shevy> Syzygy__ or should work I think ... but test it
<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
<aef> KL-7: http://phrogz.net/programmingruby/lib_standard.html search for library English. don't know if thats complete
<Syzygy__> but i need two whiles :/
<aef> Syzygy__: isn't it possible to just call break 2 times?
<aef> Syzygy__: if not, try "break && break"
<Syzygy__> not in any meaningfull way because the first break would break before the second break would be accessed
adambeynon joined #ruby
<KL-7> aef, thanks
<Syzygy__> break && break is a "void value expression" and thus not valid
<aef> Syzygy__: whatever that may be
<Syzygy__> exactly
<aef> Syzygy__: how about an exit variable?
ph^ joined #ruby
<Syzygy__> yeah, doing something like that right now
trivol joined #ruby
Vyom joined #ruby
<Syzygy__> it's still not breaking though :/
iocor joined #ruby
stephans joined #ruby
ammar01 joined #ruby
heftig joined #ruby
kaspernj joined #ruby
Vyom left #ruby
lobo--d-_-b joined #ruby
BiHi joined #ruby
moshee joined #ruby
moshee joined #ruby
Sliker_ joined #ruby
trivol joined #ruby
KL-7 joined #ruby
KL-7 joined #ruby
<Syzygy__> shevy, i need help with that regex again
hinogi joined #ruby
hinogi joined #ruby
<Syzygy__> so out of a line like "..... <a href="res/117121135#117127391"....." I need to match "res/117121135"
Hellojere joined #ruby
timonv joined #ruby
[lm]distax joined #ruby
atmosx joined #ruby
coffeesounds joined #ruby
danielpunt joined #ruby
smgt joined #ruby
replore joined #ruby
workmad3 joined #ruby
p0y joined #ruby
<banisterfiend> aef: goodluck
Seisatsu joined #ruby
DarkFoxDK joined #ruby
tk_ joined #ruby
fermo joined #ruby
tuxaddicted joined #ruby
ksinkar joined #ruby
patronus_ joined #ruby
tatsuya_o joined #ruby
robotmay joined #ruby
otakutomo joined #ruby
xec joined #ruby
kedare joined #ruby
blueadept` joined #ruby
luke__ joined #ruby
NotreDev_ joined #ruby
mxweas_ joined #ruby
thecreators joined #ruby
yfeldblum joined #ruby
josephwilk joined #ruby
Hellojer_ joined #ruby
luke__ left #ruby
luke__ joined #ruby
fayimora joined #ruby
luke__ left #ruby
zomgbie joined #ruby
luke__ joined #ruby
mengu_ joined #ruby
incluye joined #ruby
<blaenk> hey can I biuld a hash dynamically?
<blaenk> lol = {} later lol[1, 2] = wut
<blaenk> oh I got it
<blaenk> key is supposed to be an array
<blaenk> forgot :D
Clooth joined #ruby
notimik joined #ruby
iocor joined #ruby
gregorg joined #ruby
gregorg joined #ruby
incluye joined #ruby
negative joined #ruby
sandstrom_ joined #ruby
zomgbie joined #ruby
<Syzygy__> shevy, are you still there?
tvw joined #ruby
mxweas_ joined #ruby
o3u joined #ruby
<o3u> hi, i'm trying to do "sudo gem install mysql2" but i'm getting this weird error: http://pastebin.com/fQEiEV4f
KL-7 joined #ruby
nari joined #ruby
TheDeadSerious joined #ruby
<whitequark> o3u: OS?
workmad3 joined #ruby
seivan joined #ruby
<Tasser> whitequark, mac ^^
<whitequark> so it uses clang then
michael_imac joined #ruby
Ch4rAzZz joined #ruby
<o3u> mac os X lion
<Ch4rAzZz> Hi, how to get this working: http://pastie.org/2877416 . I don't like to use if else, but case, when..
BiHi_ joined #ruby
jensn joined #ruby
charlenopires joined #ruby
<Afal> Ch4rAzZz: http://pastie.org/2877437
<Ch4rAzZz> Afal, thanx, good idea :-)
justinmcp joined #ruby
pusewicz_ joined #ruby
manizzle 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/
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?
tomzx joined #ruby
<Johnnus_> banisterfiend: just to examine state
<banisterfiend> Johnnus_: then look into pry, http://pry.github.com
<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
<ia9371> #rvm
Sliker_ joined #ruby
Telling joined #ruby
Hellojere joined #ruby
DaZ joined #ruby
monkey13 joined #ruby
kenichi joined #ruby
riush joined #ruby
lkba joined #ruby
macmartine joined #ruby
craigglennie joined #ruby
h4mz1d joined #ruby
austinflores joined #ruby
kenichi_ joined #ruby
apeiros_ joined #ruby
mcowan joined #ruby
dcarper joined #ruby
blischalk joined #ruby
yekta joined #ruby
KL-7 joined #ruby
diimdeep joined #ruby
Shathak joined #ruby
<Tasser> diimdeep, rails? #rubyonrails
KL-7 joined #ruby
emptyflask joined #ruby
<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
stunna joined #ruby
<apeiros_> juiceman5000: local_variables, instance_variables, …etc.
<juiceman5000> Also, project is in 1.8.7 =/
mengu joined #ruby
strife25 joined #ruby
n8ji joined #ruby
jay_zawrotny joined #ruby
<juiceman5000> TY Worked wonderfully!
<apeiros_> yw
iocor joined #ruby
mikepack joined #ruby
paulian joined #ruby
adao joined #ruby
ianbrandt joined #ruby
<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> you update to 1.9.3 ?
<ai9371> or rails server.. i get error too
<ai9371> yes i am usign ruby 1.9.2
<ai9371> im using 1.9.2
maggie_n joined #ruby
<ai9371> im using ubuntu
ksinkar joined #ruby
<Kiten> hmm lemme guess something involving custom_require.rb: 36 ?
<ai9371> no it just says invalid gemspec
<ai9371> wrong date and time format
<ai9371> than a bunnch of error
<Kiten> are you building it ? or using RubyGems ?
<Kiten> afaik gemspec is only used when your building a gem
redgetan joined #ruby
<ai9371> sim trying to get everything working on ubuntu
<ai9371> i installed rvm
<ai9371> rvm works.. i got 1.9.2 as default
marcuspat joined #ruby
<ai9371> than i type gem install rails
<ai9371> have to do that as sudo gem install rails
<ai9371> get bunch of erros
maxok joined #ruby
<ai9371> ive been getting these error though that why i trying to update ruby
<ai9371> but not rails isnt working at all
maxok joined #ruby
<Kiten> try installing a specific version of rails using gem install rails --version putversionhere
jensn joined #ruby
<ai9371> found i had to change a setting the ubuntu shells properties
MasterIdler_ joined #ruby
<ai9371> to get ruby 1.9.2 to work
<Kiten> i compiled mine so i'm on 1.9.3
maxok joined #ruby
mcpierce joined #ruby
Russell^^ joined #ruby
<Kiten> ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux] specifically
<Kiten> lemme try installing rails and see if i get the same problem
maxok joined #ruby
havenn joined #ruby
<Kiten> hmm my shell just locked up
Blackflys joined #ruby
bier_ joined #ruby
<Kiten> ai9371: how big is rails ?
<ai9371> takes like 10 minutes to install
<ai9371> yu have to wait a second
<Kiten> i'm on DSL so if its over 200mb i'll be waiting awhile
<Kiten> plus doesn't help my computer is from 1999 either
maxok joined #ruby
maxok joined #ruby
maxok left #ruby
<LiquidInsect> quick dumb question. Is there a method like const_get but for local variables?
<Kiten> oh good lord 28 gems ri and Rdoc's going to take forever
<Kiten> LiquidInsect: nonconstant = Constant ? i'm fairly new to ruby so ;p
thecreators joined #ruby
<Kiten> or $myglobal = Constanlocal
bier joined #ruby
<JonnieCache> LiquidInsect: instance_variable_get
<JonnieCache> or something like that
<JonnieCache> there's very few good reasons to use it though
josemota joined #ruby
<JonnieCache> kitten: put this in your ~/.gemrc `gem: --no-ri --no-rdoc`
<JonnieCache> without the ``
<Tasser> JonnieCache, nah, that's for instance variables
<Voziv> Anyone have a suggestion for a good ruby IDE in ubuntu?
<Tasser> LiquidInsect, you scare me. What are you trying to do?
<JonnieCache> Tasser: arent local variables just instance variables of the current binding though?
<Tasser> Voziv, eclipse / netbeans might have some plugins. But people go with vim from time to time
<JonnieCache> or I may well be confused
<Tasser> JonnieCache, binding.instance_variables
<Tasser> => []
Cervajz joined #ruby
<JonnieCache> Voziv: its not an IDE but an editor, but I cannot reccomend sublime text 2 enough
<Voziv> JonnieCache: Does it support code formatting?
<Tasser> Voziv, that's what you get with every editor
<Kiten> Vim hands down
<Kiten> :P
derekbarber joined #ruby
<Tasser> Kiten, what?
<Voziv> Tasser: code formatting, Not from what I've seen.... highlighting yes, but not formatting
<Kiten> editor wise
<Kiten> Voziv are you wanting autoformatting ?
<Tasser> Voziv, what's code formatting exactly for you? idents?
<Voziv> Yes to both questions
<Tasser> vim can do that ;-)
<Kiten> notepad++
<Kiten> or vim
<Voziv> notepad++ is available in linux? o.O
<Tasser> basically any editor.
<Kiten> notepad++ has a gui
<JonnieCache> SUBLIME TEXT 2 FTW :)
<JonnieCache> it changed my life
<Tasser> 1 aur/notepadqq 0.13.10-2
<Tasser> A Linux clone of Notepad++
<Kiten> yeah run it under wine or i think there is a naitive port i don't recal though
<Tasser> JonnieCache, compiling...
<Voziv> I can't find that in the ubuntu package manager
<Kiten> yeah ;p
<Voziv> The sublime that is
zenergi joined #ruby
<Kiten> trust me take the time to learn vim its not as hard as everyone makes it out to be
<Kiten> if you can code you can learn vim
heftig joined #ruby
<Tasser> if you learn emacs, you can code ;-)
<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
<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)
Jake232 joined #ruby
<LiquidInsect> oh ruby can get obfuscated
<Kiten> in C: typdef void* u; typdef u* r; r* t;
<new2net> triple variables
<LiquidInsect> sinatra in 9 lines
<LiquidInsect> er, 8
<Kiten> t == void *** object
<LiquidInsect> one of which is just a puts
<shevy> whoa
<shevy> .map{|m|D.(m){|*_,&b|b.try :[]}}
<shevy> that's an atrocity
<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?
<samuelkadolph> "\xAE".force_encoding("ISO-8859-1").encode("UTF-8") # => "®"
<samuelkadolph> But you should fix the real problem
<dlitvak> ^
whitequark left #ruby
otakutomo joined #ruby
<samuelkadolph> You should set your $LANG to UTF8 or put a magic comment at the beginning that lets ruby know the file is UTF8
<sodani> samuelkadolph: yeah I put a "# encoding: UTF-8" at the top of my file
<shevy> is this a good $LANG? en_US.utf8
<samuelkadolph> Probably
<samuelkadolph> Mine is en_CA.UTF-8
<shevy> hmm... does it have to be upcased and include a - ?
<sodani> how do you view the $LANG variable?
<shevy> echo $LANG
<samuelkadolph> Or ENV["LANG"] in ruby
<shevy> I'll upcase it and add a -
<shevy> :)
<sodani> hmm, I'm getting => nil
awesomenickname joined #ruby
<shevy> then you probably default to C or whatever the default is
<samuelkadolph> Then it defaults for ASCII
milkpost joined #ruby
<sodani> yeah I've been noticing that sometimes strings are encoded as ASCII when I was expecting utf8
<samuelkadolph> Assume ASCII is the default and if you include non ascii characters in your ruby file, use the encoding comment
tatsuya_o joined #ruby
robyurkowski joined #ruby
<awesomenickname> hi
<awesomenickname> I'm trying to write ruby script for file conversion
<awesomenickname> for yaml > xml
<awesomenickname> for this to work I need active_support
<Johannes`> Kiten: hi, why do you hate Python?
<awesomenickname> so I try to require^
<awesomenickname> require "rubygems"
<awesomenickname> 2 require 'activerecord'
<awesomenickname> 3 require 'active_support'
phantasm66 joined #ruby
<awesomenickname> after activesupport and activerecord gems installation
<awesomenickname> but it fails
<samuelkadolph> awesomenickname: Ot
<awesomenickname> using irb, require 'rubygems' gives me false
<samuelkadolph> awesomenickname: It's require "active_record"
<awesomenickname> oh, yes
<awesomenickname> anyway, for rubygems it's 'false'
<samuelkadolph> Irrelevant
<samuelkadolph> I don't see why you'd need ActiveRecord for this
<awesomenickname> and for two other requires its "cannot load such file"
<awesomenickname> it's like this: File.open( file_to_read ) { |yf| doc << YAML.parse( yf ).transform.to_xml }
<awesomenickname> i thought classes to work with yaml and xml are part of active_support
mklappstuhl joined #ruby
thone_ joined #ruby
stephans joined #ruby
<awesomenickname> oh, I guess gems I installed are for 1.8 ruby, and I use 1.9.3 as interpreter
cooper joined #ruby
<awesomenickname> hm, I used rvm yesterday to install 1.9.3, and gem is from standard ubuntu 10.10 repository. Should I install newer gem through rvm?
<samuelkadolph> awesomenickname: rvm use 1.9.3 && gem install activesupport should be good enough
minijupe joined #ruby
<LiquidInsect> awesomenickname: don't install gems via apt
<LiquidInsect> gem install <whatever> is going work better especially if you are using rvm
glacius joined #ruby
travisjeffery joined #ruby
<awesomenickname> but how do I change already installed apt gems for normal?
<samuelkadolph> awesomenickname: Just ignore them and rvm use 1.9.3 --default
<samuelkadolph> rvm will set that as your default ruby for each of your terminal sessions
rsampaio joined #ruby
<awesomenickname> ruby --version shows me I am using 1.9.3
j3r0m3 joined #ruby
<awesomenickname> but $ gem --version
<awesomenickname> 1.8.10
phantasm66 joined #ruby
nyuszika7h joined #ruby
<awesomenickname> so I guess every gem I install through 'gem install ...' is 1.8?
<samuelkadolph> So?
<samuelkadolph> The version of rubygems is not the same as ruby
<samuelkadolph> rails is at 3.1.1, doesn't mean you need ruby 3.1.1 to run it
<awesomenickname> oh, I get it
badabim joined #ruby
<awesomenickname> anyway, issuing 'require "active_record"' gives me "file not found" in irb
<awesomenickname> same for active support
AwesomezGuy joined #ruby
<awesomenickname> how can I track this down?
jay_zawrotny joined #ruby
<samuelkadolph> awesomenickname: gist.github.com the full output you get
tvo joined #ruby
tvo joined #ruby
workmad3 joined #ruby
<samuelkadolph> awesomenickname: add the output of `gem env` and `gem which active_support`
patrick99e99 joined #ruby
atmosx joined #ruby
trapni joined #ruby
<samuelkadolph> awesomenickname: What does `gem list activesupport` give you?
<shadoi> awesomenickname: did you re-install rails or activesupport after you switched to rvm?
<awesomenickname> rails - no, `gem list activesupport` gives me nothing
<samuelkadolph> You need to install it then
<samuelkadolph> Your rvm ruby 1.9.3 doesn't have it
nimbius joined #ruby
<awesomenickname> I do gem install active_support
<nimbius> hi ruby. got a problem with rails in nginx. using passenger, and its still not working...is there an index file that needs to be present?
<awesomenickname> it installs it
<samuelkadolph> awesomenickname: It's activesupport
<awesomenickname> Successfully installed activesupport-3.1.1
<samuelkadolph> Now try
glacius joined #ruby
<awesomenickname> and still gem list activesupport gives empty list
<shadoi> awesomenickname: sounds like your PATH has the system gem command before the rvm gem command
<shadoi> awesomenickname: try "rvm gem install active_support"
<samuelkadolph> awesomenickname: Does `ls /usr/local/rvm/gems/ruby-1.9.3-p0/gems` show activesupport-3.1.1?
mklappstuhl joined #ruby
gearaholic joined #ruby
<awesomenickname> samuel, no
jwmann joined #ruby
<awesomenickname> shadoi, trying
jwmann joined #ruby
Russell^^ joined #ruby
<awesomenickname> why rvm creates 'gem' executable for every ruby version installed via itself?
<awesomenickname> like gem-ruby-1.9.2-p290
<awesomenickname> shadoi, after your suggestion activesupport is now in rvm gems dir
atmosx left #ruby
blaenk joined #ruby
<awesomenickname> yay, require active_support works now
<awesomenickname> thanks, guys
Targen joined #ruby
<awesomenickname> but this whole gem/rvm/ruby versions thing is a mess
j3r0m3 joined #ruby
<samuelkadolph> I'd remove the ruby stuff from apt-get then
manizzle_ joined #ruby
<awesomenickname> yeah, good point
Guedes joined #ruby
Guedes joined #ruby
<Vendethiel> Isn't there a SIMPLE WAY to create my encoder ???
johan_ joined #ruby
<samuelkadolph> What would your encoder do?
badabim_ joined #ruby
<Vendethiel> sha(strtoupper(username) . ':' . strtoupper(password))
<Vendethiel> I need to encode the password like that
<Vendethiel> in order to check it
<samuelkadolph> Don't do that
<samuelkadolph> Use bcrypt
Asher joined #ruby
<Vendethiel> I can not
<samuelkadolph> Using sha1 is just asking for problems and so is not salting your hash
<Vendethiel> I can not². Sadly
GlennO joined #ruby
<samuelkadolph> Then I'd complain to your manager then slowly die inside while using Digest::SHA1.hexdigest and "abc".upcase
jrun joined #ruby
<Vendethiel> :(.
<Vendethiel> I guess I'm gonna do that
<Vendethiel> :D. dying is fun
<samuelkadolph> Everyone is slowly die, some just die faster
<samuelkadolph> dying*
<Vendethiel> yep
<hobodave> how do you control the width of a tab character when printing string data to stdout?
lobo_d_b joined #ruby
<Mon_Ouie> You configure your terminal
<samuelkadolph> You can't (other than replacing tabs with spaces), that's up to whatever is turning the stdout to text
<hobodave> strange
<hobodave> the bash guys claim that bash doesn't control the tab width
<samuelkadolph> bash doesn't either
<Mon_Ouie> bash isn't a terminal
<samuelkadolph> Bash is a shell
<hobodave> oh I see
<Mon_Ouie> If you run bash in e.g. xterm, then xterm is the one that does that
<blaenk> hobodave: try using ljust
<samuelkadolph> Terminal.app is a terminal who's job is to connect the keyboard to bash's stdin and bash's stdout to your screen
<blaenk> String#ljust
<shevy> I thought Terminal.app is the one for suicides
visof joined #ruby
visof joined #ruby
wyhaines joined #ruby
<blaenk> I like Terminal.app, a lot
jbpros joined #ruby
justinmcp joined #ruby
<hobodave> blaenk that works
<hobodave> thanks
<blaenk> you're welcome
justinmcp joined #ruby
workmad3 joined #ruby
jmartorella joined #ruby
j3r0m3__ joined #ruby
Mon_Ouie joined #ruby
nanderoo left #ruby
<awesomenickname> def self.method option1, option2
<awesomenickname> how do I call this function? @object.method(option1,option2)?
jmartorella left #ruby
king313 joined #ruby
<awesomenickname> oh, got it
Pip joined #ruby
Pip joined #ruby
Syzygy_ joined #ruby
mikewintermute joined #ruby
Indian joined #ruby
robyurkowski joined #ruby
skrewler joined #ruby
workmad3 joined #ruby
Draco_ joined #ruby
<awesomenickname> from some example I found on the internet they use following method and class: YAML.parse
<awesomenickname> but in rails api I can't seem to find it
<samuelkadolph> Because it's not from rails
dracflamloc joined #ruby
<iboB> is there any reason to still use Proc.new instead of lambda?
jim_ec2 joined #ruby
vitoravelino joined #ruby
<jim_ec2> anyone know where I can find rails 1.x api doc?
Axsuul joined #ruby
travisjeffery joined #ruby
<jrun> jim_ec2: http://apidock.com/rails?
wyhaines joined #ruby
<awesomenickname> anyone had any experience with yaml?
CannedCorn joined #ruby
<awesomenickname> my case: some smart guy dumped mysql db into .yml. Now we can't load it back, so I try to convert yaml to xml
<awesomenickname> but there are several thousand line in this file, and parser catches mistakes on some of them
<awesomenickname> like when dealing with square brackets
Draco_ joined #ruby
phantasm66 joined #ruby
trivol joined #ruby
<awesomenickname> so I'm puzzled (and probably dead soon)
johanhsfy joined #ruby
j3r0m3 joined #ruby
Araxia_ joined #ruby
havenn joined #ruby
Draco_ joined #ruby
mike___ joined #ruby
<mike___> hi
cdepue joined #ruby
<mike___> is there some nice and short way to generate all strings of length upto k over a finite alphabet with ruby?
adamkittelson joined #ruby
julian-delphiki joined #ruby
Clooth joined #ruby
<julian-delphiki> mike___, sure! you could easily do ("a".."zzzzz").to_a to get an array of every string in the range a - zzzzz
Cervajz joined #ruby
<mike___> julian-delphiki: that's sweet, but what if i want just the strings with letters a,b,c?
<julian-delphiki> and how long?
<mike___> well, upto length... 10 maybe
eignerchris joined #ruby
<julian-delphiki> with just characters 'a','b','c'?
<mike___> yep
<julian-delphiki> ("a".."cccccccccc").to_a
<julian-delphiki> done.
perryh joined #ruby
CannedCorn joined #ruby
<julian-delphiki> mike___, mind you, that will take a lot of memory while creating.
vtr joined #ruby
vtr joined #ruby
<jensn> michael_imac: Array#repeated_combination(n).
<jensn> Or Array#product, depending on what you want.
<jensn> *mike___
<julian-delphiki> mike___, you can also just do combs = ("a".."cccccccccc"), and then do things like combs.each {|word| #process-word-here}
<julian-delphiki> jensn, wouldn't it be way easier with a range object?
<mike___> julian-delphiki: i tried that one, but it produces other letters as well
<jensn> Depends on how the 'alphabet' is generated.
workmad3 joined #ruby
<jensn> ['a', 'd', 'g', ’あ’] doesn't map to a range, for example
<mike___> it's {a,b,c} actually
<julian-delphiki> oh, my bad.
pootpoot left #ruby
<johan_> night nigh everyone.
rushed joined #ruby
iocor joined #ruby
<mike___> jensn: repeated_combination is good. thx
<jensn> np.
<mike___> but i really don't get the difference between combination and permutation from the examples there
<jensn> Permutations have orders, combinations don't.
havenn joined #ruby
<mike___> ah, now i spotted it in the examples as well
<mike___> thx
<julian-delphiki> mike___, http://pastebin.com/y8NXPK6y
<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 :)
onetonturd joined #ruby
onetonturd left #ruby
eignerchris joined #ruby
<julian-delphiki> i commented out check, obvs.
<julian-delphiki> mike___,
dkr joined #ruby
any-key joined #ruby
<mike___> julian-delphiki: that's a nice shorter version, but the problem remains
Seisatsu joined #ruby
<mike___> it seems that there are no combinations generated with an "a" after a "b" for example
cjs226 joined #ruby
<julian-delphiki> hmm
<julian-delphiki> yeah
<julian-delphiki> true
<julian-delphiki> i wonder if you need permutation instead of combination then
<mike___> oh
<mike___> yeah
<maggie_n> hey
<mike___> that's why i want permutations
<maggie_n> what's Ruby's version of PHP's urlencode (like this one: http://php.net/urlencode
<any-key> maggie_n: checkout the CGI::URI.escape
<mike___> now it works like a charm. thx again :)
<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)
apok joined #ruby