Topic for #ruby-lang is now Ruby 1.9.3p0: http://ruby-lang.org | Paste >3 Lines of Text on http://pastie.org
<zenspider> argh. files are stupid. we should get rid of all files
<zenspider> hard drives should only be swap
<zenspider> all objects, all the time. nothing but
<rue> Objects as files
* zenspider lights rue on fire
<josh9> how to tell rvm not to show the warning when i cd into a folder? i tried rvm_trust_rvmrcs_flag=1 in my .rvmrc file but it doesn't work.
<josh9> i need it since i run it from a cron.
<rue> josh9: #rvm
<zenspider> beat me to it
<josh9> rue: i tried but i don't think it exist
<erikh> rvm_project_rvmrc=0
<erikh> unless you like that feature
<erikh> but yeah, really, #rvm
<josh9> erikh: i still see the warning. and i can't find #rvm
<rue> erikh: Doesn't that just disable it?
<erikh> type /join #rvm in your irc client
<erikh> rue: yes
<josh9> erikh: gotcha. thanks
<rue> I think he was looking for autotrust :/
<josh9> rue: yeah
yfeldblum joined #ruby-lang
<edwardsharp> is there an issue with .length in Ruby 1.8.7
<imperator> which class?
stepnem joined #ruby-lang
<edwardsharp> string
<rue> No
<rue> Are you having an issue with it?
jkprg joined #ruby-lang
<edwardsharp> yes, i think so, it's friggen subtle
<rue> It's so subtle I can't see it at all!
<rue> It's not just a chars != bytes thing?
igotnolegs joined #ruby-lang
<edwardsharp> might be, just found this awesome work around to remove_method :chars with a tring.class_eval inside Rails::Initializer
<edwardsharp> String.class_eval, that is
<edwardsharp> wow, that was cryptic as hell...
<edwardsharp> <-- sleepy
<rue> That doesn't sound very awesome
tomzx joined #ruby-lang
<zenspider> in fact, that sounds terrible
sulo joined #ruby-lang
Austin__ joined #ruby-lang
S1kx joined #ruby-lang
S1kx joined #ruby-lang
<imperator> redefining core class methods, what could go wrong?
<andrewvos> /meme joke
<andrewvos> Redefine all the core class methods?
Natch| joined #ruby-lang
Kero joined #ruby-lang
s3mi0 joined #ruby-lang
plusk joined #ruby-lang
headius joined #ruby-lang
<Austin__> imperator.
<zenspider> headius: there you are
<headius> here I am!
<zenspider> ok. so you have all 3 of us arguing over here
<zenspider> our biggest hurdle right now is that minitest didn't even know what files WERE before this feature... mapping from class name to a file is ... icky. that said, we're not coming up with a very good solution to that
tenderlove joined #ruby-lang
<zenspider> lemme repeat that for tenderlove's sake
<zenspider> our biggest hurdle right now is that minitest didn't even know what files WERE before this feature... mapping from class name to a file is ... icky. that said, we're not coming up with a very good solution to that
<zenspider> I do think I'm gonna refactor this out of the code and make it a pluggable feature
<Asher> anyone happen to know any good programming-related (especially object-oriented) science fiction?
<zenspider> also, I've gotten rid of the text file format entirely
<headius> I never liked the class#method mapping much myself, but it was a simple approach
<zenspider> yeah
<zenspider> and it is currently winning
<headius> it's unlikely to collide, so it's not a *bad* approach
<zenspider> we're now doing ruby files instead, so that guard logic can be... *gasp* ruby
<headius> I have no objection
<headius> pluggable feature means what?
mikeric joined #ruby-lang
<zenspider> like benchmark, it isn't there unless you load it
<headius> file + class + method would obviously be guaranteed unique, but file wasn't propagated through anything I could find
<imperator> Austin__, yo
<zenspider> the ruby approach is nice too, because we're rewriting the method as a skip so you can see a report if you run in verbose mode
<zenspider> no, I have no idea what the file is (and in some cases, there aren't any)
<headius> this is a RUG night for you guys, right?
<zenspider> no, that's tuesdays
<Austin__> imperator: how goes?
<headius> oh no, it's wednesday
<headius> I'm all screwed up
<zenspider> haha
<headius> 3AM remote presentations will do that to ya
<headius> so yeah, sounds like you're back on the "tag" path, but tags will just be ruby code run in concert with the tests to filter things
<headius> I like ruby code better than a custom text format anyway
<imperator> Austin__, it goes well, just got back from florida, was there for 2 weeks eating turkey and stuff
<zenspider> yeah. it feels better other than being less readable in english
* imperator wonders what headius and zenspider are referring to
<Austin__> imperator: That's good, I guess ;)
<zenspider> imperator: that's a young turkey!
<zenspider> imperator: adding exclusion support to minitest
<zenspider> headius: ya know... I had a thought. even if I add this, there is no guarantee that it works under 1.9's test/unit. :(
<zenspider> they've munged everything up so bad it isn't funny
<headius> I don't know anything about that
the_great_cornho joined #ruby-lang
<headius> if I can run their tests with miniunit it won't matter, but I have no idea the relationship between the two anymore
<tenderlove> omg
<zenspider> their tests subclass Test::Unit::TestCase and have all their baggage associated with it
Weems joined #ruby-lang
Weems joined #ruby-lang
<zenspider> and yeah. I don't know what all they do either.
<zenspider> it is SO gross I can't understand the code
<imperator> exclusion support?
<zenspider> imperator: not running certain tests for conditional reasons
<andrewvos> Why would you want to do that?
<imperator> oh, thought you had that already
<tenderlove> zenspider: your implementation should work with t/u
<imperator> test-unit 2 has omit_if, omit_unless; i use that :|
<tenderlove> /should/
<tenderlove> imperator: it inherits from m/t, so it will support skip
<tenderlove> I've got skips in the rails tests, and they use t/u
<tenderlove> ;-)
<imperator> tenderlove, gem install test-unit
<Austin__> andrewvos: lots of reasons you'd want to exclude tests. There's a test I'd like to exclude from running on JRuby sometime.
<tenderlove> o_O
<imperator> tenderlove, oh, you want to convert?
<andrewvos> Austin__: Put it in a different file?
<tenderlove> to minitest, yes
<andrewvos> Or an if statement?
<headius> Austin__: that's the exact use case for this
<headius> I want to be able to run MRI's test/* on JRuby, but filter out MRI-specific stuff and things we don't support yet
<Austin__> andrewvos: if not JRUBY_VERSION; def test_foo; …; end; end isn't exactly clean.
<headius> since I've accepted they're never going to embrace rubyspec
<zenspider> in my case, I wrap some of my tests with "if windows? then ... end"
<headius> andrewvos, Austin__: this feature would have those filters in a separate file, so you can maintain them independent of the test suite
<andrewvos> Well, you're going to be storing the names of tests that shouldn't run under "ENV". Why not just overwrite those tests or undefine them?
<headius> I did a first dumb patch to minitest, and zenspider et al are refining it now
<andrewvos> I mean, you're going to be storing them *somewhere*
kz-moon joined #ruby-lang
<erikh> hrm
<erikh> how about using blocks?
<tenderlove> headius: according to the developer howto, rubyspec is better than just test-all
<imperator> headius, i thought you guys had your own test suite? what do you care about MRI's test/* ?
<erikh> e.g., windows_test("some description") { assert(...) }
<headius> we have a dozen test suites
<headius> including MRI's
<headius> but we have to patch MRI's for tests we don't/won't pass
<headius> this will eliminate that need
<Austin__> tenderlove: ew.
<imperator> has MRI's test suite improved lately? because otherwise i'm confused why you care
<rue> tenderlove: I don't feel like that's a strong-enough statement
<headius> tenderlove: I think that only makes people run it...the majority of tests still end up in test/* first (and possibly only)
<headius> imperator: they have gotten better about adding tests to test/*
<headius> not great, but better
<rue> tenderlove: You should add a “pretty please” to it
<headius> I'm just looking for every possible way to get test coverage, and I'm not going to whine about ruby-core not using rubyspec
<headius> I've given up on that debate
<tenderlove> headius: I tried to add to rubyspec once and gave up
<tenderlove> I'm just trolling anyway. nobody reads this page
<zenspider> I've never seen it :P
<headius> I can't say my rubyspec experience is always a pleasant one
ryanf_ joined #ruby-lang
* imperator uses berger_spec, the one true spec!
<zenspider> hah
<zenspider> yeah... not exactly an open and welcoming culture there... :/
<headius> we still run your ruby_test stuff, though it's pretty old now
<headius> we removed bfts last year :)
<zenspider> hah
<headius> zenspider: you're one to talk about open and welcoming :)
<headius> but yeah, I feel ya
<zenspider> I'm totally open and welcoming.
<zedUNDginger> lol
<zenspider> what was ruby_test?
<zenspider> gah. these specs never quiT!
<headius> ruby_test was a suite imperator wrote for some reason...to support facets or something?
<headius> was/is
<zenspider> oh right. I remember that
<headius> I'm sure we've got a gross amount of overlap between the suites, but who knows
<zenspider> and bfts was a fork of... that thing... with those people... who never accepted cotributions
<zenspider> I don't even remember the name anymore
<headius> jruby actually still has most of rubicon in our suite
<zenspider> contributions even
<headius> though it's largely been absorbed into our suite
<imperator> i think ruby_test was abandoned, i've had my own thing for a long time
<zenspider> rubicon... that' sit
<zenspider> damn my fingers
<imperator> man i've been programming ruby a long time, can't even remember the stuff i wrote any more
<headius> we ripped out most of the stuff you didn't like in rubicon, like the ugly version guards
<headius> ruby_test was whatever suite you were maintaining
<zenspider> imperator: bah! I've forgotten more than you :P
<headius> I think I just called it that because it had no name
<imperator> ok
<headius> it wasn't even in its own repository, if I remember right
<zenspider> I thought that was bfts... I still love that name
<headius> == Author
<headius> Daniel J. Berger
<imperator> ah, i renamed it
<imperator> yeah, ok, berger_spec == ruby_test
<drbrain> RUN ALL THE TESTS!
dejongge joined #ruby-lang
<zenspider> haha
<headius> I'd be happy to reincorporate what you have, probably using this new tagging
<headius> we have patched this a bit
<zenspider> imperator uses test-unit2 iirc
<headius> I'm pretty sure JRuby runs more tests than any other impl
<imperator> zenspider, yup
<headius> like 7 suites in total, though some have shriveled over time
<headius> we still have tests that use minirunit
<headius> we're hard-fucking-core
<erikh> heh
<rue> Come now, contributing to rubyspec isn't so bad
<rue> Well, provided you only have to deal with code :/
<headius> once you've been beaten into line, it's not so bad
<headius> the beating takes some of the fun out of it though :)
<imperator> rubyspec is a mixed bag, some good stuff (which i've borrowed), but it largely just seems to confirm existing behavior for typical code
<Austin__> so… realizing it's a purely religious question, what's the best choice for unit testing these days?
wmoxam joined #ruby-lang
<imperator> whereas i try to break shit based on a reading of MRI's source
<erikh> ruby test.rb || echo "failed!"
<imperator> find weird edge cases and whatnot
<headius> Austin__: jesus, I abstain with prejudice on that question
<headius> I want no part of it
<slyphon> Austin__: i use rspec, because i have a lack of imagination
<Austin__> headius: Let me rephrase it: what do you use?
<headius> I guess I fall into that category too
<Austin__> I've been using rspec lately because it reads well, but something about it has always made me uncomfortable.
<imperator> headius, berger_spec is on hiatus atm, until i'm gainfully employed :)
<Austin__> imperator: you're funemployed, too?
<imperator> yup
<slyphon> Austin__: possibly because it's the most complicated metaprogramming ever?
* slyphon exaggerates
<headius> rspec is incredibly complicated
<imperator> oof, rspec, tried it, really did, just couldn't get into it
<headius> rspec's test suite is one of the most brutal Ruby compliance tests around
<Austin__> headius: oh, god yes.
<headius> we routinely fail the most obscure shit
<imperator> should.it.be.this or should.it == this or... FUCK IT
<Austin__> and I can't even get it to pass on MRI.
<imperator> eh?
<headius> yeah, it's a miracle we pass it, what with #caller and #backtrace post-processing it does
<tenderlove> I feel sorry for implementors because you can't respond with "don't do that"
<tenderlove> Dr it hurts! Don't do that.
<slyphon> every time i try and extend rspec, i wind up confused and humbled
<Austin__> I recently made a change to Diff::LCS and tried to get someone—anyone—from the rspec team to tell me how I need to do some verification.
ryanf joined #ruby-lang
<Austin__> because I'm a responsible maintainer and don't want to break something that other people (like rspec) depend on.
* slyphon nods
<slyphon> i really like the "contexts that stack" style in rspec
<Austin__> didn't get an answer; tried to run the tests, and they wouldn't run all the way through on a single Ruby implementation I tried without at least one red mark.
<headius> tenderlove: I try to hide deep in the compiler/optimizer
<slyphon> the rest is "meh"
<headius> at least there I'm just twiddling bits
<tenderlove> headius: maybe you could write an "opinionated implementation"
<tenderlove> ;-)
<headius> I certainly could
<imperator> i've been telling him that for years!
<headius> but I might as well just make it a new language for all the people that would use it
* imperator supports this
<slyphon> headius: c'mon ya pussy, do it!
<headius> if I could convince olabini to tone down his language design principals, we could probably come up with something really nice
* slyphon tries peer pressure
<zenspider> headius: have you played with minitest/spec at all?
<headius> zenspider: I have not, actually
<Austin__> So what I'm trying to figure out is whether I should keep banging my head against rspec and convert my gems to use that, or whether I should switch to minitest or minitest/spec or …
<zenspider> rumor mill says it is pretty zippy and clean
<headius> for no reason other than we have an existing corpus of rspec stuff
<erikh> heh
<slyphon> hahaha
<slyphon> zenspider: subtle
<Austin__> heh.
<zenspider> ;)
<slyphon> :D
<headius> Austin__: smaller is better, though I still maintain that "refute" is the wrong word (ahem zenspider)
<zenspider> Austin__: any reason to stick with rspec if you're fighting with it?
<slyphon> i've been meaning to check minispec out, actually
<zenspider> size of test corpus would be about the only reason I could think of
<Austin__> zenspider: conversion time. The real question for me is whether I keep the spec-style (which I'm only marginally fond of) or take the time to convert.
<zenspider> but I've had pretty good luck doing a mechanical conversion of rspec to minitest/spec
<zenspider> and then converting from spec to unit later
<zenspider> depends on how the rspec tests are written
<headius> we're not doing anything particularly odd
<slyphon> zenspider: how pluggable is the output?
<zenspider> I have an emacs function to rewrite most of the file... then it is a bit of manual touch-up and you're good to go :)
<slyphon> i like to hook each test to have it insert the name in test.log so i know what test produced what log output
<zenspider> slyphon: go look at minitest/pride
<slyphon> it's in 1.9.2-p290?
<zenspider> I believe so
* slyphon goes to look
<zenspider> tho that doesn't have the 256 color version :(
<slyphon> pfft
<zenspider> I don't think... 1.9.3 does tho :)
* slyphon pisses on it
<slyphon> i demand a minimum of 88 colors
<zenspider> Austin__: what editor do you use?
<Austin__> zenspider: vim, but I can fire up an emacs long enough to run a script over it.
<rue> I'm sure you could vimscript the same thing
<rue> Not that anyone would
<Austin__> ok.
<zenspider> hrm. I should publish that on emacswiki
<zenspider> *shrug* you can write the same thing in ruby in about 5 minutes... prolly works better too :)
<zenspider> but the idea is there
<Austin__> I was just thinking that.
<andrewvos> Whoa. zenspider really is an emacs user.
<andrewvos> TIL
<erikh> I thought he used ed, personally
<jaimef> if you have a gem listed in Gemfile.lock but not Gemfile is that an issue?
edwardsharp joined #ruby-lang
<erikh> no
<jmontross1> zenspider: why the perl posting?
* Austin__ last dealt with emacs seriously around 18.50 something.
<jmontross1> err - pythoni mean
<andrewvos> jaimef: Define "issue"
<zenspider> jmontross1: that's elisp
RickHull left #ruby-lang
<jaimef> missing dependency
<headius> ok, enough fun... dinner
<Austin__> early 18.50s, that is. 1989.
<tenderlove> headius: GOOD NIGHT!
<zenspider> dinner sounds good
<headius> zenspider: if you want me to look at something, update the pull request or ping me here...I'll leave it up
<jaimef> bundler install bombing on not finding something in the lock file
<zenspider> Austin__: heh. I cut my teeth on emacs in 91... so yeah
<zenspider> headius: will do
<Austin__> I had done some interesting things with elisp, but didn't have access to emacs at the next major uni. I went to, so I had to go vi, and I haven't really looked back.
<erikh> I just ended up working with a guy who made me look like a fool with vim
<andrewvos> jaimef: Delete the lock file and bundle install. Never a bad thing.
<erikh> kind of hard to come back from that
<andrewvos> erikh: You have to learn it some day. Why not now?
<erikh> andrewvos: eh? I used emacs for around 8 years
<erikh> the guy was just fast
<erikh> anyhow, editor arguments are dumb
<andrewvos> I mean vim
<erikh> that's what I've been using for hte last 7 years or so
<Silowyi> I've programmed exclusively in vim for the last decade... and I still feel like an idiot in it XD
<andrewvos> Wait what? Clearly thinking you're someone else. I need sleep. Sorry.
<erikh> no worries, I'm hungry and a bit cranky myself.
<erikh> cow-orker is providing delicious bbq at his place
<erikh> I love california
<andrewvos> Mmm delicious bbq
<Austin__> zenspider: I'll give the conversion a try.
<andrewvos> I'll be in california in a few weeks. Can't wait!
<Silowyi> I would have to contend that Texas is known for bbq more hthan california
<erikh> andrewvos: bay area?
<erikh> Silowyi: oh, i'm just remarking that the concept of BBQ in december is even probable
<Silowyi> that said, I'd definitely trade our bbq for your temperatures :P
<andrewvos> erikh: Santa Barbera
<andrewvos> erikh: Is that bay area? I don't even know to be honest.
<erikh> aha
<zenspider> Silowyi: that's not even up for debate
<Silowyi> Dec 1st... weatherman says it will be 73F here
<andrewvos> I was in Mountain View last year. Sister lived there but moved to SB recently.
<erikh> yeah I'm in menlo park
<erikh> 61 here and it's dark
* Austin__ had to use his car's snow brush for the first time this winter, today.
<erikh> last year in philly around this time I was covered in a foot of snow
<andrewvos> Hmm, tht sounds familiar. Possibly because there's a place called Menlo in South Africa.
<Silowyi> it's actually somewhat chilly tonight here, 49
<andrewvos> Anyway night everyone.
<mitchty> snow is all melted here yay! its nearly 30F
<zenspider> now I want brai (sp?)
<Austin__> mitchty: it's all melted here, too. didn't last long.
<andrewvos> braai?
<zenspider> that
<zenspider> I knew something doubled up
<Silowyi> what is braai?
<andrewvos> zenspider: Yes. Best thing in the world.
<zenspider> and the silly beef-jerky-esque thing they have
<andrewvos> Silowyi: It's a man bbq
<zenspider> not enough vowels
<zenspider> Silowyi: south african bbq
<andrewvos> Biltong zenspider
<zenspider> that!
<zenspider> tasty stuff... a bit wrong... but tasty
<andrewvos> Once you get used to it, it's the best thing in the world.
<zenspider> not if you try to make it here...
<zenspider> we don't have the proper weather for it
<andrewvos> What in the US?
<zenspider> but I had some imported as well
<zenspider> in seattle, specifically :)
<andrewvos> Oh, it gets cold there.
<zenspider> it's the humidity ... it um... rots
<andrewvos> Whoa. Gross
Vie_zHy_aZa joined #ruby-lang
<andrewvos> Right sleep time
Vie_zHy_aZa left #ruby-lang
<slyphon> great thing about south african bbq is ...
* slyphon doesn't have the heart to make a joke about apartheid
<slyphon> i thought i did
flip_digits joined #ruby-lang
<andrewvos> slyphon: Damnit I keep getting drawn into conversations
<andrewvos> But what's the joke????
<slyphon> oh, i dunno, i was gonna make some reference to District 9 but it didn't come quick enough
Banistergalaxy joined #ruby-lang
<andrewvos> What the movie or the place?
<slyphon> there's a place?
<andrewvos> Heh
<Banistergalaxy> Tripoli
<andrewvos> District 6
<slyphon> i thought that was just for the movie
<andrewvos> slyphon: It's a thing.
<Austin__> slyphon: District 9 was…strongly based on reality.
<slyphon> OMFG
<slyphon> THOSE BUGS ARE REAL?@!
<zenspider> I hang out with a bunch of south africans here... one has a friend who was in district 9. he was one of the first to splatter
<slyphon> i KNEW IT!
<zenspider> they're doing a sequel soonish, aren't they?
<andrewvos> slyphon: Heh. The place the aliens live in very much resembles a lot of areas around SA.
<jmontross1> metaphors.
<Austin__> Hadn't heard.
<slyphon> andrewvos: ouch
<zenspider> dude... SA is a fucking hard place to live
<zenspider> everyone I know describes growing up there as "survival"
<slyphon> yeah, i know, they have flamethrower attachements to prevent carjacking
<erikh> I've been told they're cleaning it up significantly in recent years
<erikh> one of my co-workers is ZA
<Austin__> My wife has been friends with someone who had family in the ANC back in the 80s, and she was apparently getting ready to be a shit disturber herself, so they shipped her to Canada to keep her out of jail or worse.
<andrewvos> slyphon: Why does everyone think that? That's bullshit
<andrewvos> Flamethrowers
<slyphon> andrewvos: it was an article in the register
<slyphon> plus
<slyphon> i mean, they're friggin' *flamethrowers* ffs
<slyphon> that's awesome
<erikh> designed to throw flame on people
<Austin__> andrewvos: I don't know the car thing, but my wife's mom's ex-husband slept with a gun under his pillow in the transvaal.
<zenspider> holy shit. I didn't realize that the protagonist in district 9 was murdoch in the a team movie
<andrewvos> Flamethrowers are expensive. Guns aren't. I call bullshit.
<slyphon> !!!
<slyphon> zenspider: holy crap
<andrewvos> zenspider: Hah that guy is awesome
<erikh> I couldn't go see that
<slyphon> first google hit
<erikh> just the tank thing
<Austin__> andrewvos: don't disagree with you. What probably happened is that some rich shithead got such a thing for his car, and then it sort of went viral from there.
<erikh> my nerd alert went off big time
<zenspider> I didn't detect his accent at ALL
<imperator> slyphon, sweet, i could use a flame job on my car
<slyphon> :D
<andrewvos> :)
<andrewvos> Right night everyone
<slyphon> lata
<erikh> andrewvos: night!
<zenspider> andrewvos: south africa...
stamina_ joined #ruby-lang
<slyphon> haha
<zenspider> did it work?
<imperator> flamethrowers? i picked up my Space Balls Flamethrower back in the 80's cheap
<erikh> did it come with a dark helmet?
jmontross joined #ruby-lang
<slyphon> imperator: the kids love it!
<imperator> that was extra
<erikh> collector's edition
<zenspider> dinner...
<slyphon> moichendizing!
<erikh> yeah, wondering when my partner in crime will arrive
<erikh> I need BBQ
<imperator> erikh, who be that?
<erikh> co-worker
<erikh> staying at my place for the next week
malev joined #ruby-lang
Sailias joined #ruby-lang
<rue> Wouldn't that be “associate in crime”, then?
andrewhl joined #ruby-lang
<andrewhl> I'm trying to parse a single string of HTML. It's a table, basically, and I want to parse it so I can insert its contents into a database. The HTML has no whitespace whatsoever. Can someone suggest a good approach for parsing this? https://gist.github.com/1412826
<erikh> rue: correct
<rue> andrewhl: Use Nokogiri
<andrewhl> Nokogiri? I haven't heard of that
<erikh> it's a HTML and XML parser.
<andrewhl> ok, I'll look into it. Thanks
<lianj> its THE html and xml parser
jmontross1 joined #ruby-lang
<imperator> well, time for ze gym
jxie joined #ruby-lang
<zedUNDginger> anyone else find that rubygems.org is reporting way overinflated download numbers for today?
srbaker joined #ruby-lang
<jmontross1> overinflated?
Banistergalaxy joined #ruby-lang
<zedUNDginger> jmontross1: yeah it's reporting i hvae 2.4K downloads for one of my gems today
<zedUNDginger> but i dont believe it
<zedUNDginger> also for a fwe other gems that typically get 20 dl a day it says it has 400
<zedUNDginger> and so on
Sailias joined #ruby-lang
krz joined #ruby-lang
Banistertab joined #ruby-lang
Banistertab` joined #ruby-lang
Banistertab- joined #ruby-lang
Banistergalaxy joined #ruby-lang
<rue> #humblebrag ;)
macmartine joined #ruby-lang
<shevy> hmm will there be a funeral ceremony when 1.8.x is buried?
mkscrg joined #ruby-lang
mikeric joined #ruby-lang
wyhaines joined #ruby-lang
ilyam joined #ruby-lang
<rue> ™
wyhaines joined #ruby-lang
<Banistergalaxy> Rue Nice twitter pic
r0bby joined #ruby-lang
retro|cz joined #ruby-lang
<Banistergalaxy> Good face you've got there
nuclearsandwich joined #ruby-lang
r0bby_ joined #ruby-lang
<rue> Ah, but maybe it's a decoy?
<Banistergalaxy> Your demon equal
<Banistergalaxy> Devil double
<rue> Evil rue
<rue> Eviler*
<Banistergalaxy> Rue haha you look like nietzsche
<Banistergalaxy> Just grow out your moustache a little bit more
<Silowyi> heh June 2012
<Silowyi> I wonder if RHEL will ship with a version of ruby more recent than 1.8.5 by then :P
wmoxam joined #ruby-lang
zedUNDginger joined #ruby-lang
tomzx_ joined #ruby-lang
<rue> Nah
brianpWins joined #ruby-lang
wyhaines_ joined #ruby-lang
infid joined #ruby-lang
WillMarshall joined #ruby-lang
twittard joined #ruby-lang
jaimef joined #ruby-lang
dr0id joined #ruby-lang
neoesque joined #ruby-lang
x0F_ joined #ruby-lang
densebits joined #ruby-lang
Tref joined #ruby-lang
toretore joined #ruby-lang
nuclearsandwich joined #ruby-lang
tomzx_ joined #ruby-lang
arooni-mobile joined #ruby-lang
Ruthenium joined #ruby-lang
ABK joined #ruby-lang
arooni-mobile joined #ruby-lang
pabloh joined #ruby-lang
ecin joined #ruby-lang
phlipper joined #ruby-lang
sulo joined #ruby-lang
<andrewhl> is anyone here familiar with nokogiri?
<lianj> whats the question?
robbyoconnor joined #ruby-lang
krz joined #ruby-lang
<shevy> hmm when I install a remote gem, where is it kept locally?
<lianj> depends :)
<lianj> usually /usr/lib/ruby/gems/1.9.1/cache/
<shevy> ah yes
<shevy> they are all there, thanks lianj
sulo joined #ruby-lang
ryanf joined #ruby-lang
Tref joined #ruby-lang
ecin joined #ruby-lang
io_syl joined #ruby-lang
sopheak joined #ruby-lang
Austin__ left #ruby-lang
macmartine joined #ruby-lang
Banistertab joined #ruby-lang
mikeric joined #ruby-lang
zedUNDgi_ joined #ruby-lang
kitallis joined #ruby-lang
jmontross1 left #ruby-lang
rkk joined #ruby-lang
sulo joined #ruby-lang
achamian joined #ruby-lang
duckinator joined #ruby-lang
sopheak joined #ruby-lang
<sopheak> hi all
<sopheak> please help me
<duckinator> If I have articles=["August 2, 2011", "November 30, 2011", "January 1, 2011"] ...how can i sort them by date (earliest date -> latest date)? i've been wrestling with this for probably 30 minutes now and have absolutely no ideas that aren't nasty split-/map-tastic monsters that make me want to set my monitor on fire
<sopheak> why i could not use UsefulFeatures.class_name as i saw it is possible in the e-book
yumike joined #ruby-lang
Banistertab` joined #ruby-lang
<wilkie> duckinator: fun
<duckinator> wilkie: yea, apparently Time.parse() does the trick but I forgot to do `require 'time'` so it told me it didn't exist :P
<wilkie> right, that was what I would have tried
<wilkie> so you got it?
<duckinator> yea
<wilkie> cool
kitallisii joined #ruby-lang
<wilkie> sopheak: def UsefulFeatures.class_name
yxhuvud joined #ruby-lang
<duckinator> wilkie: couldn't he use self.class_name, too?
<wilkie> yep
<wilkie> but that's a bit unusual for a module
<duckinator> mmm, alright. i've not used modules too much, myself :P
<bnagy> hrm, I find self.class_name wayyy less ugly
<bnagy> you can also do module_function :class_name
<sopheak> wilkie : that's correct now
<wilkie> cool
<sopheak> then i extend something more
<sopheak> could you check it again?
<sopheak> then how can i call the class_name method for the person object?
infid joined #ruby-lang
sulo joined #ruby-lang
sulo_ joined #ruby-lang
<burgestrand> sopheak: class methods does not come along when extending/including a module
gregmoreno joined #ruby-lang
<burgestrand> sopheak: http://codepad.org/ldJ08dOw
<sopheak> burgestrand : actually it works fine if you follow this
<burgestrand> sopheak: it’s the same thing I have in my pastie, but not the thing you had in your previous paste
postmodern joined #ruby-lang
<burgestrand> But yes, it does
<sopheak> actually, in my previous paste, i just want to use UsefulFeatures.class_name itself to call the method
<sopheak> then wilkie told me to add UserfulFeatures before the class_name method
<sopheak> thus it works fine if i call UserfulFeatures.class_name
<sopheak> but later, when i call p.class_name, i got the error
<sopheak> so any solution that i can create a class_name method which enable these to calling?
<burgestrand> You want to be able to call UsefulFeatures.class_name *and* p.class_name?
<sopheak> yep
<sopheak> is it possible?
<bnagy> define it twice
<bnagy> self.blah and blah
<burgestrand> Sure; you could extend UsefulFeatures in itself if you wanted all methods to be available on it
<burgestrand> sopheak: http://codepad.org/FZjnd38b
<burgestrand> You can also use module_function but that makes it private in the Person, might not want that
<sopheak> ah, perfect it works :)
<sopheak> anyway, what is extend self mean?
<lianj> it will always return Module :D
<burgestrand> lianj: it’s kinda funny :p
<burgestrand> sopheak: inside UsefulFeatures, it’s the same as ”extend UsefulFeatures”
<sopheak> whenever we extend self mean all the method in module/class are same as def self.mothod_name...?
<burgestrand> sopheak: yeah
<lianj> thats the effect, yes
<sopheak> ah thanks :)
<sopheak> that's fun :D
<sopheak> One more thing i didn't understand the solution for duckinator's question yet
<sopheak> about sorting this articles=["August 2, 2011", "November 30, 2011", "January 1, 2011"]
<duckinator> sopheak: basically what i did is created a hash where blah[Time.parse(x)]=x ...and i'll probably find a way to clean it up tomorrow (it's at 1:45am here, i tend to write bad code after 12:30am.. :P)
<bnagy> require 'time' articles.sort_by {|str| Time.parse str}
<duckinator> like that
<duckinator> bnagy: that's...about a million times cleaner than my attempt :P *makes note to try that tomorrow*
<bnagy> sort_by rules
<lianj> group_by too
Weems joined #ruby-lang
<sopheak> ah many thanks to you help :)
JohnBat26 joined #ruby-lang
Banistergalaxy joined #ruby-lang
s3mi0 joined #ruby-lang
mikeric joined #ruby-lang
s3mi0 joined #ruby-lang
sulo joined #ruby-lang
[zaf]-Coral joined #ruby-lang
AndChat- joined #ruby-lang
Banistertab joined #ruby-lang
zcdny joined #ruby-lang
havenn joined #ruby-lang
sulo_ joined #ruby-lang
<zcdny> Hi, there, who has more experience with the RDOC, how to highlight a line or puts the text into a blokc, just like this effect [code] gem install rails [/code] on the post of BBS
setmeaway joined #ruby-lang
krz joined #ruby-lang
rippa joined #ruby-lang
sulo joined #ruby-lang
workmad3 joined #ruby-lang
mytrile joined #ruby-lang
sulo_ joined #ruby-lang
burgestrand joined #ruby-lang
zedUNDginger joined #ruby-lang
heftig joined #ruby-lang
<levifig> folks: any of you running ruby-1.9.3-p0 on ubuntu?
sulo joined #ruby-lang
robotmay joined #ruby-lang
sulo joined #ruby-lang
heftig joined #ruby-lang
hagabaka joined #ruby-lang
hagabaka joined #ruby-lang
io_syl joined #ruby-lang
io_syl joined #ruby-lang
<zedUNDginger> andrewvos: you here?
fridim_ joined #ruby-lang
sulo_ joined #ruby-lang
thrcka joined #ruby-lang
<bnagy> so I didn't have much luck yesterday, but I'll ask again... I need to allow users to specify a message hook class as a config option, and I'd like a nice(r) way to do it. Right now I require the file they give me and assume the class is called MessageHook
dc5ala joined #ruby-lang
<heftig> bnagy: you could eval the contents of the file, that way you can get a return value
<heftig> e.g. the class you want
<bnagy> oh.. interesting
<ryanf> you could also provide a method they can call with the class as an argument
<ryanf> or a setter on an object that you provide
<ryanf> stuff like YourGemName::Config.message_hook = MyMessageHookClass
<bnagy> no it's for a system, not a lib that they would use
<bnagy> like they run the thing with a config file
<ryanf> not sure I follow. they're giving you a ruby file with a class in it right?
<ryanf> so they can just put a line under the class that assigns the class to your config object
<bnagy> I see what you mean, but it sounds a bit ugly
<bnagy> to me, anyway
<ryanf> I wonder if you could eval their class definition in such a way that it was scoped inside a module that you create?
<ryanf> then you could just call MyModule.constants to get it
<bnagy> that's possible as well
jkprg joined #ruby-lang
srbartlett joined #ruby-lang
<bnagy> evaling the file as a string doesn't seem to return anything
<ryanf> yeah class definitions don't
<bnagy> I could also just diff Object.constants before and after the require :S
<bnagy> but why does that make me feel a bit ill
<ryanf> yeah that's bad
<ryanf> imo
<ryanf> actually you could do even better and let them just write the contents of the class in the file
<ryanf> I mean why make them write "class Whatever"?
<ryanf> just do class MessageHook; end; MessageHook.class_eval(File.read... etc
<ryanf> and then they can just write method definitions in the file
<ryanf> and the whole name thing isn't an issue
<bnagy> constant diffing is horrible - I forget I get all the constants from any stuff they require in their file etc
<DefV> why not just make it a default class-name and let ppl require their own version
sulo joined #ruby-lang
<DefV> class WhateverHook; end
<DefV> and let them overwrite the class
<bnagy> well I have a fixed classname now
<bnagy> I was hoping not to
<ryanf> did you look at the gist I linked?
<ryanf> you can load their class into an empty module and get it out of there. there's no need to do constant diffing
sulo__ joined #ruby-lang
brianpWins joined #ruby-lang
<bnagy> yeah that seems to work properly
yorickpeterse joined #ruby-lang
gnufied joined #ruby-lang
<bnagy> OK, good enough for now, thanks :)
molgrew joined #ruby-lang
roadkith joined #ruby-lang
Banistertab` joined #ruby-lang
<sopheak> i want to implement my People class to use like people[0],people[1],...
<sopheak> please see in this example
<sopheak> any solution?
zedUNDgi_ joined #ruby-lang
<ryanf> def [](idx)
<bnagy> no no no
<bnagy> class People < Array
sulo joined #ruby-lang
<bnagy> then you get all of Array etc for free
<ryanf> subclassing array is not usually the right answer
Axsuul joined #ruby-lang
<ryanf> ruby does have convenient ways of delegating to another class though
<ryanf> so that you don't have to reimplement every part of the Array interface that you want to use
<bnagy> this is clearly homework, I think it's exactly the right answer :)
<sopheak> actually def[](idx) is work fine :)
<sopheak> and People<Array cound not work :(
<bnagy> soahccc: your implementation is already broken and you're only going to make it worse
<bnagy> sopheak sry
<bnagy> all those class vars etc ew
<bnagy> if you want something that behaves almost exactly like something that's in the language then don't reinvent the wheel
<sopheak> bngay, sorry, i didn't get your point :(
<sopheak> i'm quite new to this
yumike joined #ruby-lang
saLOUt joined #ruby-lang
<bnagy> it's fine
<bnagy> personally I would start with subclassing Array, but yeah you could look at delegators later as well
<bnagy> then just use existing stuff like people << Person.new; people.find {|person| person.name=='Mary'} etc
<bnagy> all of which is built into Array / Enumerable
<sopheak> ah mean there is the solution for People class
<sopheak> and my style is broken now,right?
<bnagy> well you won't find much love for @@class_vars
nuclearsandwich joined #ruby-lang
dnjaramba joined #ruby-lang
<sopheak> could you help me to give me an example around this?
<sopheak> i just want to create a class people which is the collection of class person
Pip joined #ruby-lang
Pip joined #ruby-lang
<roadkith> i havent had a need for class variables yet
<roadkith> also i noticed that i for some reason i dont know yet try to avoid instance variables
yumike joined #ruby-lang
srbartlett joined #ruby-lang
<roadkith> which is somewhat dumb at times :D
yumike joined #ruby-lang
<sopheak> wow, it's awesome
<sopheak> just only extends from Array without implement any code
yumike joined #ruby-lang
sirfilip joined #ruby-lang
<shevy> hmm how to find out the name of today's day with ruby?
<shevy> like "Wednesday"
<heftig> Date.today.strftime("%A")
<molgrew> today is thursday!
<shevy> oh
<roadkith> ah %A
<shevy> that one works, thanks heftig. I was confusing myself with Date::DAYNAMES[Date.today.day] which apparently wouldn't work
<sirfilip> :D molgrew
<molgrew> it'd be wday
<roadkith> <--tired %m
<molgrew> for day of week
<roadkith> tried
<roadkith> totaly off :D
<shevy> hmm
<shevy> indeed molgrew
<shevy> now I know of two ways!
Mchl joined #ruby-lang
<sirfilip> shevy: map the weekday number with some list
<shevy> already solved sirfilip
<shevy> Date::DAYNAMES[Date.today.wday] # => "Thursday"
<bnagy> ryanf: http://codepad.org/n3JbK9Ds is that what you'd recommend?
<bnagy> I haven't used the delegator stuff much tbh... why is it better?
<roadkith> actually i dont quite get the difference between Person < Array and Person < DelegateClass(Array)
<shevy> DelegateClass(Array) looks ugly as hell
<roadkith> hmm why is it ugly?
<ryanf> it's not really any different from like Array(stuff) or whatever
<ryanf> or Hash[] for that matter
<heftig> it will allow you to modify Person without affecting how Array does things internally
<ryanf> bnagy: I guess in this case it doesn't really matter since there is literally no other functionality
<ryanf> oh
<heftig> as in, any methods the Array instance calls on itself would stay unaffected by whatever you override in Person
<ryanf> yeah that's what I was gonna say :P
<roadkith> oh so if you modify Person in Person < Array it will affect Array too?
<bnagy> heftig: wouldn't subclassing do the same thing?
<ryanf> no
<ryanf> if you define a method on person with the same name as a method on array
<ryanf> you are replacing it
<ryanf> which means that if methods from array call that method, they'll break
<heftig> if Array#foo would call Array#bar, and you redefine Person#bar, Person#foo would now also use the new implementation
<ryanf> whereas with delegation, stuff that is internal to Array won't see your stuff
<bnagy> ohok I see
<roadkith> hmmm
<roadkith> then, why would one want Person < Array?
<bnagy> probably wouldn't matter much unless you are overloading important internals
<heftig> indeed
<roadkith> yeah you could be accidentally overriding parent methods no?
<bnagy> I can see where the delegator stuff would be better when you want to delegate some stuff to obj1 and other stuff to obj2
<roadkith> supposed this: if i have X < Array and Y < Array and then overload a method in X will it affect Y too then?
<bnagy> roadkith: when you subclass you can only break your own subclass, not the parent
<heftig> roadkith: no.
zmack joined #ruby-lang
<roadkith> bnagy: hmmm then i didnt understand i guess
<roadkith> (the above)
<bnagy> roadkith: they're saying that if you subclass Array and overload a method that Array uses internally in itself then you might break some methods in your subclass that you didn't expect to break
<ryanf> it could also be semi-deliberate, like if you wanted to add extra functionality to some existing method
<bnagy> imho it's not something you're likely to hit unless you're screwing with deep internals of the class you're subclassing
My_Hearing joined #ruby-lang
<ryanf> without realizing that it would break the internal stuff
erenrich joined #ruby-lang
<ryanf> nah you could easily want to do something like wrap a common api call
<bnagy> in which case you would probably know why it broke :)
<roadkith> hmm
<sopheak> btw, what's the different between class People < Array and class People < DelegateClass( Array )?
<roadkith> lol?
<bnagy> that's what we were just discussing
zmack_ joined #ruby-lang
<roadkith> i'm actually laughing in our office :D
<roadkith> coworkers looking at me
<bnagy> it's a bit subtle. One creates a new class based on Array, the other creates a class that delegates methods to an instance of Array
<bnagy> I don't want to sound condescending, but if you're just learning then I wouldn't worry too much if that didn't make sense
zmack joined #ruby-lang
<heftig> also, the delegateclass lets you substitute the instance anytime
<heftig> that's probably the main feature: you can decide to delegate to another object
<bnagy> it's like having a guy in a bear suit.. or something. You can change the guy and it still looks and acts like a bear
<bnagy> ok that's a terrible analogy, but I just like bear suits
zmack_ joined #ruby-lang
<heftig> e.g. say you have a set of Logger objects that log to different backends
<heftig> you could do a class LogDelegator < DelegateClass(Logger)
<heftig> then you could switch out the log backend at runtime
<heftig> without using global variables
<heftig> i think the global variable would probably be a better pattern
<heftig> at least in this case
<heftig> or maybe your loggers are slow and synchronous and logdelegator provides asynchronous logging, buffering the messages until the (new) backend is ready
khaase left #ruby-lang
zmack joined #ruby-lang
Indian joined #ruby-lang
cyri_ joined #ruby-lang
adambeynon joined #ruby-lang
tla joined #ruby-lang
WillMarshall joined #ruby-lang
<sopheak> i didn't see any change after overide method sort in each class
<sopheak> is it not the point that you were saying?
<sopheak> i was thinking that you said, if we extend from array dirrectly, sort method that array instance call itself will be overiden in that subclass
<sopheak> but i didn't see any change at all
<sopheak> so i think i was not understand your point
<bnagy> oic
<manveru> aloha
<bnagy> yeah that freaked me out for a bit - your overridden sort is not getting called
<bnagy> sopheak: you're calling sort on a normal Array instance, so it's using Array#sort
<sopheak> but as you said, if we extend < Array directly, sort is overridden?
<bnagy> it is, for instances of the People class
<bnagy> but when you do [3,4,10].sort, [3,4,10] is an Array not a People
<sopheak> so mean the same thing to Delegation as well
<zenspider> being inside a delegated class doesn't magically change method calls
<zenspider> so you're calling [...].sort
<zenspider> call self.sort instead and you'll see a difference
<sopheak> can i talk latter?
<sopheak> abit busy now
WillMarshall joined #ruby-lang
<sopheak> sorry
ik_5 joined #ruby-lang
<ik_5> hello
<ik_5> I'm using xmlrpc client in Ruby, and sometimes I get SIGHUP on a connection answer, and no answer returned to me
<ik_5> have anyone had such problems as well ?
<ik_5> ruby 1.8.7
benanne joined #ruby-lang
mytrile_ joined #ruby-lang
<manveru> ik_5: huh?
<ik_5> manveru, on an xmlrcp client request i have a SIGHUP signal, when trying to have an answer back to me.
mytrile joined #ruby-lang
<manveru> what xmlrpc client?
<ik_5> the one that arrive native with stdlib
<manveru> ok
<manveru> so, what other process is sending a SIGHUP?
<manveru> are you on a VPS or something?
<ik_5> manveru, it's an Asterisk agi, so Asterisk execute the program
<manveru> oh my
<ik_5> manveru, so you are saying that asterisk might be the problem ?
<manveru> yeah
<ik_5> :/ thanks
<manveru> if you don't send the signal in the script, it must come from elsewhere
<manveru> i'm not very familiar with AGI, but i figure it's some kind of timeout setting
<ik_5> i do not use signals at all in my script, and i could not find any "kill" with hup on the ruby lib ...
<ik_5> manveru, it's a way to execute external code, in a blocking manner
<manveru> yeah, that i know
<manveru> there's an async variant as well, but i guess not very useful for you?
<manveru> sorry, i'm all freeswitch these days :)
<ik_5> nop, it does not
<ik_5> i need time to learn freeswitch :)
<shevy> freeswitch?
<manveru> yeah, takes a few days, but i'm glad i don't have to put up with all the * crappiness anymore :)
<shevy> hey manveru do you have good use cases for using BEGIN and END? I am trying to find a good use case for it since some days, but haven't come up with anything where it seems really useful or needed
<ik_5> manveru, how better is it ?
rkk joined #ruby-lang
<ik_5> shevy, to catch exceptions ?
<manveru> nope
<shevy> I can catch exceptions with begin;rescue;end already?
<shevy> manveru are you still changing home location every few weeks :P
<manveru> dunno, the only real usecase i've seen is in bacon
<shevy> ah ok
<shevy> will look at that source, thanks
<manveru> damn
<manveru> at_exit is an alias for END
<ik_5> shevy, "begin" is the way to work with exceptions, however without "rescue" etc.. it is useless
<shevy> oh
<shevy> didnt know that about at_exit
<shevy> ik_5 that's nice ;P
<burgestrand> ik_5: not at all, value = begin … end
<shevy> need to write that at_exit info down else I forget it
<manveru> ik_5: well, it doesn't crash randomly, doesn't lose recordings, is easy to talk to from ruby, the config makes sense and is parseable, and it actually handles our volume
<ik_5> manveru, what is your volume and how do you write external code for it using Ruby ?
<burgestrand> There’s also the actual BEGIN which takes a block and executes it at the start of the program
<burgestrand> Which might’ve been what shevy was talking about
<ik_5> burgestrand, right, it's capital, sorry :)
<shevy> well
<shevy> I think I will use at_exit from now on, if it is an alias to END
<manveru> ik_5: i think we have about 300 calls concurrently, and we wrote a library called freeswitcher
<shevy> :)
<burgestrand> For the regular begin I can think of these two: http://codepad.org/YHFr7qRD :)
<heftig> shevy: it's not the same
<heftig> END is a language feature
<heftig> compare:
<heftig> 3.times { at_exit { puts "foo" } }
<heftig> 3.times { END { puts "foo" } }
<Tasser> heftig, never heard of END - where is it mentioned?
<heftig> the same END block will only be executed once, no matter how many times it is passed by execution
<shevy> hmm
<manveru> Tasser: man awk
<shevy> ok so it is not an alias?
<heftig> nope
<chris2> END{} is set up during parsing
<chris2> same as in perl
<chris2> and awk
<heftig> chris2: actually, no
<manveru> if it's inside a method?
<heftig> BEGIN is set up during parsing
<heftig> END isn't actually enabled until it is at least executed once
<chris2> mmh
<chris2> makes sense
<manveru> ah, you can't use it inside methods
<chris2> just a warning in 1.9
<shevy> burgestrand, odd... haven't seen something like "value = begin" before yet
<manveru> so you can use BEGIN/END outside, and at_exit inside
jkprg joined #ruby-lang
<burgestrand> shevy: it’s not very often you actually use it, but it’s good for memoization
<manveru> begin without rescue/while/if/until ?
<shevy> yeah manveru http://codepad.org/YHFr7qRD
<burgestrand> shevy: http://codepad.org/jghT8uoG
<shevy> the second form I see quite a lot, haven't seen the first one before though
<manveru> yeah, that doesn't make sense
<shevy> wheeee
<shevy> never saw "@result ||= begin" before either
<manveru> that makes more sense :)
<manveru> i think i'd still use () instead
<shevy> epic comment ... "# spend lots of time"
thone joined #ruby-lang
<Tasser> sleep 5 ^^
<Tasser> shevy, there's #tap in 1.9
<shevy> what is that used for?
<manveru> debugging
<burgestrand> Tasser: I tried to sleep (for 5s, funnily enough) but codepad does not allow sleep :p
<manveru> (1 + 3).tap{|result| p result: result }
<manveru> oO
<Tasser> burgestrand, uh
<Tasser> manveru, what did you expect?
<manveru> burgestrand: http://ideone.com/cnKIy
<ik_5> manveru, i found two "freeswitcher" libraries on gem: freeswitcher and FreeSWITCHeR
<manveru> the first one
<manveru> the other one is an old version
<ik_5> manveru, thanks :)
<matti> manveru: ;]
Squarepy joined #ruby-lang
Squarepy joined #ruby-lang
robotmay joined #ruby-lang
tomzx joined #ruby-lang
Manhose joined #ruby-lang
sepp2k joined #ruby-lang
hebz0rl joined #ruby-lang
dnjaramba joined #ruby-lang
<burgestrand> manveru: oO
<burgestrand> *an hour later*
dhruvasagar joined #ruby-lang
heftig joined #ruby-lang
<manveru> burgestrand: ?
<burgestrand> manveru: you sent me a link close to 1.5 hours ago, I just felt the need to reply *something*
<manveru> heh
<manveru> just wanted to tell you that ideone does sleep
Guest81456 joined #ruby-lang
Guedes joined #ruby-lang
rpall joined #ruby-lang
leopard_me joined #ruby-lang
beiter joined #ruby-lang
kain joined #ruby-lang
Banistertab joined #ruby-lang
zedUNDginger joined #ruby-lang
felixrabe joined #ruby-lang
<felixrabe> question: i have this function:
<felixrabe> def f x, &y ; end
<felixrabe> and this works:
<felixrabe> f // do ; end
<felixrabe> but this doesn't:
<felixrabe> [f // do ; end]
<felixrabe> (i want the result in a fresh array)
<felixrabe> any hints why this is so?
<felixrabe> (yes, the // is a blank regexp right there)
<felixrabe> SyntaxError: (pry):11: syntax error, unexpected tREGEXP_BEG, expecting keyword_do or '{' or '('
<felixrabe> i get this error with the latter:
<felixrabe> this is with ruby 1.9.3
<rippa> [f(//) do ; end]
<felixrabe> thanks, that works - but i'm still puzzled why there should be a syntax error
<rippa> probably it's somehow ambiguous
<felixrabe> also, this does not work either: arr << f // do ; end
workmad3 joined #ruby-lang
<felixrabe> but assignment works:
<felixrabe> x = f // do ; end
<rue> Precedence?
<rue> You should probably just write cleaner code >.<
<felixrabe> probably
yalue joined #ruby-lang
arubis joined #ruby-lang
judofyr joined #ruby-lang
<judofyr> RUUUUUUUUUUUUBY
<judofyr> RUBYYYYYYYYYYY
<arubis> arooooooooo?
Manhose_ joined #ruby-lang
<zedUNDginger> judofyr: hey homie we finally used the BEGIN trick in pry, where did u get that from btw? is it yours?
* arubis thinks of the RVM logo
<judofyr> zedUNDginger: what happened to banister btw? :)
<judofyr> zedUNDginger: nope, I don't think it's mine
<zedUNDginger> judofyr: banisterfiend was too prosaic :) ah interesting, im curious where u learned about it cos it's pretty nifty
<judofyr> zedUNDginger: it's indeed very nifty. I think someone in here wrote it.
<judofyr> maybe manveru?
<zedUNDginger> oh ok
<zedUNDginger> cool
sopheak joined #ruby-lang
<judofyr> zedUNDginger is definitely less prosaic :)
<zedUNDginger> hehe it's designed to look like a pterodactyl
<judofyr> I just keep thinking of Zed Shaw
<judofyr> and Pulp Fiction's Zed
rpall joined #ruby-lang
<rue> I'm going to claim credit for whatever it is you're talking about before others have the chance
jensn joined #ruby-lang
malev joined #ruby-lang
mark_locklear joined #ruby-lang
shevy joined #ruby-lang
mkscrg joined #ruby-lang
Diaoer joined #ruby-lang
diegoviola joined #ruby-lang
poga joined #ruby-lang
wyhaines joined #ruby-lang
apeiros_ joined #ruby-lang
Diaoer joined #ruby-lang
Diaoer joined #ruby-lang
Indian joined #ruby-lang
Diaoer joined #ruby-lang
tommyvy__ joined #ruby-lang
sopheak joined #ruby-lang
<arubis> sooooooo....anyone alive here?
<apeiros_> arubis.zombie? # true
<arubis> I've got an incredibly stereotypical ruby newbie question.
<arubis> rahr. brainz.
<apeiros_> User.where(:channel => '#ruby-lang').all? { |user| user.zombie? } # => true
<arubis> brainz.waint? # RHAR
<apeiros_> I think no, nobody's alive here.
<arubis> well, undead and active is close enough.
<arubis> I'll just treat it as $SAFE=2.
<judofyr> apieros was recently resurrected, no?
<shevy> apieros is my hero
<apeiros_> juodfyr, no, I was never alive to begin with
<apeiros_> so *re*surrection is technically impossible
<judofyr> true
<judofyr> oops, I mistyped your nick
<judofyr> I meant: apieros_
andrewhl joined #ruby-lang
<arubis> Anyway. Still trying to make my Ruby-fu suck significantly less, ideally by contributing to an OSS project. Just poking around for suggestions on where to point my git stick.
<apeiros_> that sounds gross…
<arubis> the results probably would be, at first.
<jensn> I think he is referring to the 'git stick'.
<arubis> gotta walk before you run, gotta sit around drooling like a retarded mutant before you walk.
<zedUNDginger> arubis: https://github.com/pry/pry fix issues
robbrit joined #ruby-lang
* arubis *salutes*
yfeldblum joined #ruby-lang
<zedUNDginger> apeiros_: update on that issue btw
<zedUNDginger> if you're interested
<apeiros_> sure
<apeiros_> interesting
nofxx joined #ruby-lang
<shevy> wait what
<shevy> git stick
<shevy> what is that, tell me more about it please
<arubis> man. name a thing well and it just...ah, sticks. clearly this is a name in need of a thing to be.
<shevy> instance_exec is 1.9.x only right?
<apeiros_> shevy: I think 1.8.7 has it backported too
<shevy> oh indeed
<zedUNDginger> apeiros_: the point about the backtrace is also a good one
<shevy> I shouldn't trust anymore blogs without testing first myself, from now on!
malev joined #ruby-lang
<zedUNDginger> such an exceptino would begin with: "in GET /blah"
Squarepy joined #ruby-lang
<zedUNDginger> as the method itself is called "GET /blah"
Squarepy joined #ruby-lang
<apeiros_> zedUNDginger: I see
dv310p3r joined #ruby-lang
<apeiros_> seems ugly, but sounds reasonable
malev joined #ruby-lang
<zedUNDginger> Yeah
<zedUNDginger> i think im convinced
<shevy> zedUNDginger are you in a coding frenzy again
<zedUNDginger> shevy: not really ive been kind of burnt out recently
<shevy> hmm
<zedUNDginger> need a new project
malev joined #ruby-lang
malev joined #ruby-lang
Pip joined #ruby-lang
<rue> No, you don't
<shevy> :D
<shevy> zedUNDginger how about a simple game?
<judofyr> I've been trying to cut down on the number of parallel projects
<shevy> yeah
<judofyr> I still sneak work on some other stuff
Sailias joined #ruby-lang
<shevy> I think I have about 6 projects that I like and work on regularly... trying to avoid getting burned by any of them
wyhaines joined #ruby-lang
malev joined #ruby-lang
<judofyr> zedUNDginger: new projects are great for the *feeling* of getting shit done, but usually you just end up with useless (but interesting) stuff :)
<zedUNDginger> Yeah that's true actually
<judofyr> that's my experience at least
<zedUNDginger> yeah i have a bunch of interesting hacks on my github that noone cares anything about hehe
<zedUNDginger> and i dont take them seriously enough to bother maintaining them either
<zedUNDginger> like free(), remix, and so on, all broken in 1.9.3 and i dont think i can be bothered fixing them
zmack joined #ruby-lang
zwerg joined #ruby-lang
Manhose_ joined #ruby-lang
<shevy> zedUNDginger hmm. I am sure there are MANY interesting things out there, the problem is, finding them... and also finding out whether they are interesting or not
<shevy> perhaps if there would be a community-review process it would be nicer
<judofyr> shevy, zedUNDginger: one project I want to work on: implement a CFL-parser in Ruby and implement Ruby in it. then add some modularity and provide custom syntax :D
imperator joined #ruby-lang
<shevy> I don't even know what a CFL parser is
<judofyr> context-free language
<shevy> ah
<imperator> it's like an NFL parser, only canadian
<shevy> what
<judofyr> also: implementing Ruby in JavaScript
<shevy> nation football league
<shevy> whoa
<shevy> implementing ruby in javascript?
<judofyr> also: a new HTML/CSS editor/template-language where you edit a tree instead of text
<judofyr> also: some relational model awesomeness
<shevy> ok now I know
<shevy> it won't happen!
<judofyr> also: implement a language fully based on regexes
<judofyr> also: Dropbox-alternative
<arubis> can we have ruby in processing and then plug all that into processing.js?
thrcka joined #ruby-lang
<judofyr> arubis: there's processing in Ruby already
<judofyr> running on JRuby
<arubis> judofyr: I'm aiming for a ridiculous a setup as possible :)
<judofyr> :)
rpall joined #ruby-lang
empity joined #ruby-lang
<shevy> oh I know that
<shevy> that is the kind of thing where more and more is added to it right
<judofyr> shevy: yeah
<judofyr> and nothing gets done
<shevy> yep
<shevy> I have it here too. I always say to myself "ok, I have to clean up here today" and then I move it to the "todo list"
<judofyr> shevy: but it's not actually a todo-list though
<judofyr> more a list of "what I'm thinking/working/want-to-do"
rippa joined #ruby-lang
<arubis> ....okay, anyone know what happened to date::delta in 1.9.3?
<arubis> just offhand?
<judofyr> nope
<arubis> I'll find it eventually but require 'date/delta' magically stopped working.
<shevy> I dont even know what is dat::delta
<judofyr> arubis: I think it's a private API, no?
RomD joined #ruby-lang
<judofyr> arubis: it's probably related to the home_run-rewrite
Weems joined #ruby-lang
Weems joined #ruby-lang
<judofyr> or, switch_hitter was implemented
<arubis> don't think so? I'm not the sort that'd even know where to look up private APIs.
<judofyr> arubis: you don't look up private APIs :) that's the point
<arubis> made doing math on dates/times nice and easy.
zmack joined #ruby-lang
<arubis> well, fair enough. but I would _have_ to look stuff up.
<judofyr> "i'm planning to remove this undocumented feature"
kitallis joined #ruby-lang
<arubis> well I'll be damned.
<shevy> haha
<arubis> guess I get to read up on date and time classes again.
Spooner joined #ruby-lang
<shevy> but you know what
<shevy> why do undocumented features even manage to go in the first place
<judofyr> shevy: it was undocumented because it's an internal/private API
<shevy> aha
<shevy> I guess I am a documentation whore :(
<arubis> in fact I think I used ::delta because the datetime class didn't take kindly to my trying to manipulate its UTC offset
<judofyr> yeah, I think timezones are pretty immutable :/
<arubis> even on creation?
<judofyr> I think you can only choose between UTC and local
<judofyr> at least the previous time I tried to work around that :/
<arubis> so speaking as a rank amateur how is that not stupid?
<judofyr> it's pretty stupid
alindeman joined #ruby-lang
<arubis> huh. at least I get a side of smugness with my dish of breaking my code.
imajes joined #ruby-lang
<arubis> there's got to be some sort of justification. the amount of thought that goes into a class that can be adjusted for calendars that haven't even been used in a few hundred years is pretty unreal to then forget that sometimes people talk to people in other timezones.
<manveru> i always store time in epoch
<manveru> when i need to present it, a Time.at is way easier
<judofyr> manveru: the same epoch in different timezones can mean different time/date :)
<apeiros_> epoch is utc
leonL joined #ruby-lang
<judofyr> true
<manveru> it's not the best way, but imho the most pragmatic, in particular if you have to use JSON as well
<judofyr> my point was: "storing as epoch" isn't always a solution
<judofyr> or actuallu
<judofyr> *storing* as epoch makes sense
<judofyr> it's the presenting which is tricky
<manveru> yeah
<apeiros_> actually it is not tricky at all
<apeiros_> rubys Time class just sucks ass
<manveru> :)
<arubis> also, not spotting documentation on Time.at.
<manveru> orly
outoftime joined #ruby-lang
<judofyr> apieros: it *is* kinda tricky. at least when you need to compare times from different timezones
<apeiros_> judofyr: isn't tricky at all
<apeiros_> it is not any trickier than comparing numbers in different bases
<manveru> judofyr: time1.to_i == time2.to_i
<apeiros_> again, as said before, rubys time class just sucks ass.
<manveru> agreed :)
<apeiros_> timezone is only a representation
<manveru> i just wish Time.at took a timezone for the resulting instance
<apeiros_> 12:00 UTC == 13:00 UTC+01:00 == 14:00 UTC+0200
<apeiros_> etc.
<judofyr> apieros: (Time.at(n)-1) != Time.at(n+1) in certain timezones for certain values of n :)
mnoble joined #ruby-lang
mnoble left #ruby-lang
<manveru> ?
<judofyr> ehm
<apeiros_> judofyr: what?
mnoble joined #ruby-lang
<judofyr> I meant
mnoble left #ruby-lang
<judofyr> (Time.at(n)+1) != Time.at(n+1)
<manveru> that's why you don't compare time objects
<apeiros_> how's that related to timezones?
zmack joined #ruby-lang
<manveru> he resets TZ somewhere in between, i think
<judofyr> manveru: no
<judofyr> it's not about time objects
<shevy> Back to the Future was a nice movie
<judofyr> it's because people turn clocks backwards
<judofyr> I know it sounds silly
<judofyr> apieros: ^
<judofyr> "Basically at midnight at the end of 1927, the clocks went back 5 minutes and 52 seconds. So "1927-12-31 23:54:08" actually happened twice"
<manveru> well, good luck representing that
<apeiros_> judofyr: again, how's that related to *timezones*?
<apeiros_> it's a representational problem too
<shevy> why is he calling you apieros :(
<manveru> because he's not using tab completion
<shevy> hehe
<judofyr> apieros: because it changes #- based on which timezone your in? because it means that if people type in dates/time there might be several possible epoch's depending on their timezone.
<judofyr> shevy: apieros is special. I never tab-complete him <3
<apeiros_> judofyr: I think you're confusing stuff
<shevy> it makes me want to murder something every time I read apieros
<arubis> well anyway. using delta was nice because I could actually do delta(some_datetime_object, another_datetime_object) and get a datetime object out in a way that, when I hacked together that particular piece of crap that I could've fixed by now had I not been complaining, made sense at the time. :P
<judofyr> shevy: murder him, not me!
* shevy begins to stab at apeiros_ with a stiletto
<shevy> yeah ok
<shevy> I stab him until I get swiss chocolate
<manveru> apeiros_ is dead already
<shevy> arubis are you still sad about delta
<manveru> what's delta?
<shevy> that undocumentat feature thing in 1.9.3
<arubis> over it. thanks for the pointer to .at.
<shevy> *undocumented
<arubis> was barely following the conversation, had stuff going on irl too
QaDeS joined #ruby-lang
<apeiros_> judofyr: your basic problem is that one time has multiple possible representations
<shevy> we spoke that time things in ruby suck
<manveru> tbh, i love the time handling in lua, they just pretend that timezones other than UTC and your local one don't exist
<arubis> time in general sucks
<arubis> live in the now people
<apeiros_> Time.at(n+x) is *always* == Time.at(n)+x
<apeiros_> however, the *representation* changed may not
<apeiros_> you already have that with DST
zmack joined #ruby-lang
<apeiros_> during dst, 02:00 and 03:00 can be 2h apart
<apeiros_> at is *unrelated* to epoch or UTC
<judofyr> apieros: sure, but you're always going to deal with representation (both parsing and showing stuff)
<apeiros_> it's related to the representation of the time
<apeiros_> judofyr: sure
<apeiros_> that doesn't make dates or times tricky
<judofyr> which makes thing complex :)
<apeiros_> it doesn't make comparing the tricky either
<judofyr> apieros: sure, not comparing in the strictest sense. but think about this: if two people (in different timezones) decide on calling each other at some time. so they add it to their calendar (who stores it in *local* time because that's the most common scenario). a few month later, those two entries are not longer in sync.
<judofyr> apieros: stuff like that makes software and communication *complex*
<judofyr> because you need to handle things like that
plusk joined #ruby-lang
<judofyr> (added it to their calendar *as a repeated entry*)
<apeiros_> judofyr: um, yeah, no
<apeiros_> this is a communication problem
<judofyr> yes, but the software also needs to handle it
<apeiros_> no
<apeiros_> software can't handle it
<apeiros_> if you miscommunicate, no amount of software is going to help you
<judofyr> true
<apeiros_> if you share the calendar, and one timezone goes into dst while the other does not, the local time *will* shift by 1 hour for one of the parties
<judofyr> but software still needs to handle it. you must be able to say "10 o'clock in UTC"
<apeiros_> that's entirely unrelated to software
<judofyr> yes, but SOFTWARE STILL NEEDS TO HANDLE THAT
<apeiros_> dude, no
rayners joined #ruby-lang
<apeiros_> software needs to handle time correclty
<apeiros_> *correctly
<judofyr> yes
<darix> we should stop the whole timezone mess and use UTC everywhere.
kmeehl joined #ruby-lang
<darix> what would be the problem if the US guys get up at 1800?
<judofyr> apieros: when you write software you need to take in account that people can mean "10 o'clock in local timezone" or "10 o'clock in UTC"
<apeiros_> darix: @beat
<manveru> :)
<apeiros_> or ebeat?
<apeiros_> judofyr: it won't save your from miscommunication
<judofyr> apieros: no it won't
<judofyr> I've never said that software alone can solve it
<judofyr> just that it needs to handle timezones
<apeiros_> oh dear
<judofyr> :)
arooni-mobile joined #ruby-lang
<judofyr> apieros: do you disagree that software needs to handle timezones? :S
<sopheak> hi all
<shevy> DO NOT FIGHT WITH A SWISS
<shevy> THEY INVENTED THE CLOCK
<judofyr> hi sopheak
<apeiros_> judofyr: please, scroll back, reread what was going on
<apeiros_> we went from "hey, comparing times is tricky" to a totally different problem "hey, software needs to handle timezones so people understand what's going on!!!"
<sopheak> can anyone tell me what the different between class People < Array & class People < DelegateCalss(Array) ?
<apeiros_> sorry, but that makes no sense.
<apeiros_> yes, software should handle timezones
heftig joined #ruby-lang
<apeiros_> no, comparing times is not tricky.
<shevy> DelegateCalss
<shevy> today is funny day
<apeiros_> and no, having timezones doesn't make comparing times any more difficult
<shevy> apieros can you please DelegateCalss for me
<apeiros_> but yes, YOU, that's that guy in front of the computer, MUST know what you want to compare.
<sopheak> sorry, it's DelegateClass
<apeiros_> software can't handle that for you. it can't read your mind.
<shevy> my software will be able to do that one day!
macmartine joined #ruby-lang
<apeiros_> true. software can't *yet* read your mind.
<imperator> sopheak, iirc in the second use People will not be an instance of Array
<apeiros_> (well, technically it'll be hardware anyway)
<judofyr> apieros: I already said "sure, not comparing in the strictest sense". and I gave you an example where two entires did not end up being equal because of timezones (and miscommunication).
<imperator> it will simply behave like an array
<judofyr> that was what I meant about "comparing"
<apeiros_> judofyr: in your example, what will happen…
desmovalvo joined #ruby-lang
<sopheak> imperator, then can you give me an example that make things differents?
<sopheak> coz, i try to override some method of the Array, still i get the same result from both class
<apeiros_> if you have international stuff and don't account for it, of course you'll run into problems. not a software problem.
<apeiros_> judofyr: consider this: you're in san francisco and enter a 10.00 meeting with X next week. next week you're in boston. it's not a software problem to understand whether you mean *local time* in san francisco or 10.00 in boston
<judofyr> apieros: I didn't say that. I just said that timezones makes things like these *tricky* to handle in software. yes, it's because they are tricky to handle in real-life.
<apeiros_> that'd be a case opposite to yours, you mean "10.00 local time wherever I am"
<judofyr> hm.
<judofyr> not quite sure that "I didn't say that" was a reply too…
<judofyr> all I'm saying is that "dealing with time is tricky"
<apeiros_> judofyr: yes, but not in the software part
<apeiros_> it's the human part where it starts to suck
<judofyr> in the software part too
<apeiros_> no
<judofyr> because you often can't just store an epoch
<judofyr> you must also store the timezone
<apeiros_> I wasn't the one saying you should store epoch
<judofyr> I know
<apeiros_> and no, what you store depends on your problem at hand
<shevy> bad manveru bad!
<judofyr> apieros: true
<apeiros_> but it is NOT tricky
<apeiros_> there's nothing *difficult* about it
<judofyr> no, but it's tricky because you need to always take care of it
<apeiros_> the difficulty all lies in *communicating*, getting all involved parties to understand on what they agreed with.
<apeiros_> oh dear
<apeiros_> this is useless.
<judofyr> hehe
<shevy> the final consensus is
<shevy> time is easy
<apeiros_> look, I did implement a datetime class, I've got a *leeettle* bit of insight.
<apeiros_> comparing times is. not. difficult. period.
<judofyr> I agree
<apeiros_> if you have difficulties, you suck. end of discussion for me.
* apeiros_ goes take a shower
outoftime joined #ruby-lang
<sopheak> sorry imperator, did you here me? could you help me please
jxie joined #ruby-lang
<judofyr> sopheak: first of all, there's a performance hit with a delegator.
<judofyr> some operations that takes an array might want to convert a delegated-class into an array, while a subclass of array already is an array
* judofyr tries to come up with an example
<judofyr> actually
<judofyr> that won't be too much of a problem
<judofyr> sopheak: or maybe. there's a rule that say #to_ary returns a true Array
<sopheak> judofyr, i couldn't make it clear. so i want an example of the different
<judofyr> sopheak: so code might do: ary = thing.respond_to?(:to_ary) ? thing.to_ary : [thing]
<judofyr> sopheak: wait
<judofyr> here's a good example:
<judofyr> A == delegated, B == subclass
<judofyr> Array(A.new).class == Array
<judofyr> Array(B.new).class == B
<judofyr> so if you override e.g. #push
<judofyr> that could make a difference
<sopheak> judofyr, thanks for your idea, i'm so new to Ruby, can you make a real code for the example? :D
<imperator> sopheak, you want to override some of the methods?
reddyweb joined #ruby-lang
<sopheak> imperator, actually i just want to know that what exactly effect for both style of inheritance
<sopheak> what's the different i mean
<judofyr> sopheak: example: http://pastie.org/2950134
<judofyr> sopheak: with a DelegateClass you actually have two objects
<judofyr> class A < DelegateClass(Array); end
<judofyr> a=A.new
<judofyr> err
<judofyr> a=A.new []
<judofyr> now you have two objects: a and the Array that's hiding behind a
<judofyr> a simply forwards all methods to the Array that's hiding
<judofyr> with class B < Array; end
<judofyr> the b = B.new is just *one* object
<sopheak> actually in your example, the instance a is create like a=Array(A.new [])
<judofyr> sopheak: oh. that example in IRC wasn't meant to be the same as in the pastie
<judofyr> sorry
<judofyr> sopheak: with a delegate it's also pretty easy to change the delegated Array
<sopheak> so what a=Array(A.new []) mean?
<sopheak> sorry, i'm new so i couldn't catch up fast :(
nofxx joined #ruby-lang
dv310p3r joined #ruby-lang
<judofyr> sopheak: Array() is simply a method which converts anything to an Array
<sopheak> is it the same to .to_a?
Skif joined #ruby-lang
<judofyr> nope
<judofyr> but kinda
<judofyr> not all methods define .to_a
<burgestrand> 5.to_a # => Error
<judofyr> so it's safer to use Array()
<judofyr> Array(5) # => [5]
<burgestrand> But it does use to_a, which might not always be what you want
<burgestrand> Array({a: 5}) # => [[:a, 5]]
Silowyi joined #ruby-lang
RickHull joined #ruby-lang
<sopheak> ok :)
butchanton joined #ruby-lang
<shevy> hmm
<shevy> but .to_a reads nicer than Array() :(
<sopheak> judofyr, cocerning to your pastie, i just found that a.push is calling the push which you override in class A<Array
<judofyr> sopheak: yup
<sopheak> but b.push which the class delegate from Array act like Array
RickHull joined #ruby-lang
<sopheak> the push method that overiden is not effect
<sopheak> and a.class == A , b.class == B
<sopheak> sorry, b.class ==Array
<judofyr> sopheak: the questions are: how much do you want it to look like an Array? do you need to change the "delegated" object?
<judofyr> sopheak: I would generally advise you to *not* override core classes unless you know what you're doing
RomD` joined #ruby-lang
<judofyr> sopheak: class A<Array; end; A.new.compact.class # => Array
<burgestrand> even then I’d advise you to not do it
<judofyr> sopheak: that's one example which often doesn't work the way you want
<sopheak> i want to have a class that act like Array
<burgestrand> if you know what you’re doing you know you’re insane so you won’t take the advice anyway
<judofyr> sopheak: why?
<judofyr> sopheak: if it's an Array, why not just use Array?
<sopheak> hmm, if have a class Person
<sopheak> with :name, :age, :gender
<sopheak> then i want a class People
<judofyr> sopheak: why can't you just use an Array?
<imperator> that seems unnecessary to me
<judofyr> [Person.new(:name => 'sopheak')]
<sopheak> using like this, if i want to sort those people i need to write people.sort_by{|person| person.age}
<sopheak> right?
<sopheak> but i just want to right only people.sort to sort people by age
<sopheak> so, any idea?
<judofyr> sopheak: class Person; def <=>(o); @age <=> o.age end end
Banistertab joined #ruby-lang
zedUNDginger joined #ruby-lang
<sopheak> ah i see
<apeiros_> judofyr: so, after the shower - the things that are difficult about time: dst in future datetimes (not defined) and leap seconds. not difficult but tiresome: keeping the dst database up to date.
<sopheak> mean we just override def <=> (o) in person class?
<apeiros_> so to sum it up, things that suck about datetime: dst & leapseconds.
<judofyr> apieros: agree :)
<apeiros_> oh, and communication/interfaces
<judofyr> sopheak: yes.
<apeiros_> judofyr: great, so now you only suck for typoing my nick :-p and sorry for freaking out before.
<judofyr> sopheak: <=> is the comparison operator
<judofyr> apieros: I'm just giving you a special treatment :(
<apeiros_> spaceship operator!
<erikh> hell yes
<judofyr> sopheak: so that's saying "Person should be compared according to its age"
wyhaines joined #ruby-lang
<judofyr> sopheak: #sort will use <=> on the elements in the array
<sopheak> yep i get it
<judofyr> apieros: and now I simply can't stop. my fingers just can't type "ap<TAB>"
<sopheak> then it will be problem if we want to use person1 > person2 in term of comparing by name, right?
<judofyr> sopheak: heh, yeah
<sopheak> :D
<sopheak> then could you tell me when is nessary to have a class inherit from Array?
<sirfilip> night
<sopheak> why you guys advice not to do so?
sirfilip left #ruby-lang
<sopheak> any bad effect?
<judofyr> sopheak: because B#compact (and similar methods) will return an Array, not a B
<judofyr> so it's really easy to "break" out of that class
<judofyr> let's say I use B somewhere: dostuff(b.custom_method)
<judofyr> and then a realize: "I don't want nil objects!"
<judofyr> so I do: dostuff(b.compact.custom_method)
<judofyr> but no, that doesn't work
NemesisD joined #ruby-lang
Jake232 joined #ruby-lang
Swimming_Bird joined #ruby-lang
<sopheak> hehe, could you make a real example again. what result will we get if we do the inheritance and what if we did't do
<robbrit> sopheak: the thing is you shouldn't create classes needlessly
<robbrit> so there might be no difference if you just do class People < Array; end, but since you have one extra class there it's not as good a solution
beiter joined #ruby-lang
<Jake232> Anybody using Sublime Text 2 with Ruby?
<sopheak> robbrit, I accept all of you guys advice about this
<sopheak> but i just want to see the real impact from the code :D
<sopheak> so that i can remember and be caution to that
darkf joined #ruby-lang
havenn joined #ruby-lang
srbaker joined #ruby-lang
<sopheak> judofyr, is it what you said above?
<judofyr> sopheak: yup
io_syl joined #ruby-lang
io_syl joined #ruby-lang
<sopheak> then to solve this we need to use like people.compact.each{|person| p person.name| where as people just and object of normal Array
<sopheak> im i right?
<robbrit> sopheak: you don't need .compact
<sopheak> i mean if nil is there
<sopheak> ok thanks guys i have some clue though :P
jasox joined #ruby-lang
<sopheak> it's just my 3rd day with Ruby anyway
<judofyr> sopheak: you're doing great :)
<judofyr> sopheak: I hope we haven't confused you more
<sopheak> nope, it's not a confusion
<sopheak> it's just i mess you guy :D
thone_ joined #ruby-lang
<sopheak> sorry for such kind of question
arooni-mobile joined #ruby-lang
dv310p3r joined #ruby-lang
<sopheak> judofyr, concerning to add def <=> (o) in Person
<sopheak> i need to include Comparable,correct?
<judofyr> sopheak: not if you just want it to be sortable
kitallis joined #ruby-lang
<judofyr> but if you want <, >, <=, >=, then yes
sulo joined #ruby-lang
<sopheak> thank you! :P
<sopheak> anyway I should be time to end my day. It's over 1AM here
<sopheak> night
yorickpeterse joined #ruby-lang
Spooner joined #ruby-lang
singpolyma joined #ruby-lang
diegoviola joined #ruby-lang
thrcka joined #ruby-lang
thone joined #ruby-lang
flip_digits joined #ruby-lang
<imperator> ffi help requested: http://pastie.org/2950548
<imperator> btw, works on osx, but fails on linux
slackstation joined #ruby-lang
<rue> Damnit, where's khaase gone
shapeshed joined #ruby-lang
saysjonathan joined #ruby-lang
kyrylo joined #ruby-lang
<imperator> he an ffi guy?
<manveru> hm, looks correct just from comparing to the headers
<manveru> oh sweet mother of glibc
<manveru> imperator: puts already calls to_s
<manveru> seems to fail earlier though
saLOUt joined #ruby-lang
<imperator> manveru, yeah, nm that, doesn't seem to affect anything
<imperator> (the to_s)
<manveru> yeah
burgestrand joined #ruby-lang
<manveru> still, memory corruption sounds weird
<manveru> i think i got it
sulo joined #ruby-lang
dejongge joined #ruby-lang
robotmay joined #ruby-lang
<imperator> oh?
<manveru> well, not very elegant
slackstation_ joined #ruby-lang
Pip joined #ruby-lang
kitallis joined #ruby-lang
<manveru> not sure how you'd get BUFSIZE across platforms without https://github.com/ffi/ffi/wiki/Automatic-Struct-Layout
<manveru> imperator: http://pastie.org/2950684
ecin joined #ruby-lang
brianpWins joined #ruby-lang
t4nk099 joined #ruby-lang
Manhose joined #ruby-lang
mrchrisadams joined #ruby-lang
<imperator> whats that "@@@" stuff?
Banistertab joined #ruby-lang
zedUNDginger joined #ruby-lang
<manveru> ?
<imperator> in the auto struct layout example
<manveru> oh, they are .ffi files
<manveru> dunno if that should be in there
<manveru> sorry, haven't tried that myself, it's only feasable if the target platform has a compiler :(
<burgestrand> I missed the original question, mind filling me in?
<manveru> burgestrand: porting http://pastie.org/2950548 to linux
<imperator> manveru, yeah that solution will work on linux, but i think i'll have to use a managed struct since it varies platform to platform
<manveru> yeah, no easy way around it
<burgestrand> bufsize is declared in the uname header?
<manveru> #define _UTSNAME_LENGTH 65
<manveru> from /usr/include/bits/utsname.h
<imperator> yeah, i'm not sure how to dig that out even with a managed struct, though
<burgestrand> Ah, yeah, that’s a bit annoying, and I’m assuming this is not written with a C extension for a reason?
<manveru> shelling out might be easier, you only need it once anyway
<imperator> nah, already got a C version (sys-uname)
<imperator> just thought it might be nice for jruby
<burgestrand> I was more thinking you could write a C extension that returns the value of the actual bufsize, but keep the rest in Ruby using FFI :p
<manveru> lol
<imperator> burgestrand, well, the problem is that even using the correct bufsize doesn't work with my original example
jensn joined #ruby-lang
<burgestrand> That’s… odd.
<burgestrand> Or, well, I didn’t see your original example, I only saw manveru’s code
Manhose_ joined #ruby-lang
<manveru> yeah, i think it needs more members
<imperator> on linux?
<burgestrand> Could always check out the header file, it could be different between different flavours on linux too, no?
<manveru> yeah
<manveru> add one member and it works
<manveru> # ifdef __USE_GNU
<manveru> char domainname[_UTSNAME_DOMAIN_LENGTH];
<manveru> yay for variable size structs
<imperator> wtf, works fine on osx, and that has additional members
<burgestrand> C extension to get sizeof(utsname) it is
<burgestrand> :x
<imperator> (with a 256 bufsize i mean)
<imperator> burgestrand, i could do it with mkmf-lite
amerine joined #ruby-lang
<burgestrand> Huh, cool, hadn’t seen that before, thanks imperator :)
<imperator> wrote that mainly for use with ffi
<burgestrand> No links to the source though ¬¬
<manveru> that doesn't glibc here
<manveru> and i doubt it'd fail on platforms with less
Manhose__ joined #ruby-lang
<manveru> hm, maybe segfault if the last isn't initialized
<imperator> that worked for me, thanks
kitallis joined #ruby-lang
<imperator> burgestrand, https://github.com/djberg96/mkmf-lite
<burgestrand> imperator: I unpacked it from the gem but that’s even better, thanks
sepp2k1 joined #ruby-lang
<imperator> hm, don't have anything for getting a struct size, may have to add that
kyrylo joined #ruby-lang
<manveru> much simpler :)
* manveru hides
<burgestrand> and you still get to use a struct
<burgestrand> ;)
<imperator> but you're missing members on some platforms, and it won't work on winders ;)
<imperator> sys-uname does :)
<imperator> and shelling out is the devil!
<manveru> you do it once...
<manveru> uname doesn't change that often
<manveru> anyway, i'm glad that i usually don't have to worry about non-linux
hagabaka joined #ruby-lang
<burgestrand> I’m guessing nobody knows of an audio library for ruby capable of playing streaming audio? ^^
<imperator> manveru, thanks for your help
<imperator> actually i was wrong, osx doesn't have extra members, i was getting model via sysctl, nm
<apeiros_> icanhazaudio?
<apeiros_> no idea really
<apeiros_> (I mean, there is something called icanhazaudio, or similar, but no idea whether that does what you want)
<imperator> burgestrand, i'd start with gem search -r audio
<manveru> hm, did gem search change recently?
<manveru> ah, nm, that was gem list
<burgestrand> I’ll check both those ideas out; I’ve been searching for one for about… 9 months, I think I ask once every second month or so :)
<manveru> burgestrand: i think lianj has streaming of video in ruby
<manveru> via ffmpeg if i remember right
<burgestrand> apeiros_: thanks, it seems it’s merely a decoder though
<burgestrand> manveru: hm, interesting
lsegal joined #ruby-lang
<burgestrand> in essence, I receive a pointer to a bunch of audio frames with a given format and I want to play that through the speakers, I’ve managed to do it by writing an interface to openal with ffi that… needs to be cleaned up
<burgestrand> just hoping to avoid having to write my own driver but it’s closing in on the time to do it
<imperator> write it, publish it :)
<MistyM> burgestrand: What platform?
<burgestrand> MistyM: as many as I can, eventually, starting with mac os though because it’s my development machine
<MistyM> Audio output does seem to be one of the weak points for gems :(
<MistyM> For OS X, I've used this CoreAudio driver: https://github.com/nagachika/ruby-coreaudio
<burgestrand> Aye I’ve been checking it out for my Mac OS needs, I found it back when it still would not even compile :d
<burgestrand> Had forgotten about it, actually!
<MistyM> It works now!
<MistyM> I use it in my MDX chiptune player. It's still pretty early, but works well.
<burgestrand> Awesome!
<imperator> chiptunes, blech
<MistyM> For other platforms, there are a couple of SDL interfaces, though that requires that you have SDL installed on the deployment environment(s). I haven't used them myself.
<imperator> vocal trance all the way! :-P
<MistyM> Trance, blech :b
tenderlove joined #ruby-lang
<MistyM> burgestrand: What's the program you're writing?
<burgestrand> MistyM: Ruby bindings for Spotify (music streaming service) C API
<MistyM> burgestrand: Ah, neat.
<imperator> using ffi? brave man
<burgestrand> Finished coverage for all the C functions earlier this week, now I need to clean up the API and after that it’s pretty much audio support. :)
<imperator> good job!
<burgestrand> imperator: yeah, well, it has a lot of asynchronous callbacks, there’s no way I’m doing that as a C extension, it’s simply not worth the time to reinvent FFI :p
<burgestrand> I started out doing it as a C extension, but switched to FFI about 1/6th of the way in and rewrote it
<imperator> i don't even know how to do callbacks with ffi
<burgestrand> Same as attach_function, and then after that you pretty much pass procs to the functions that takes callbacks, just make sure the proc itself does not get GC’d by ruby or it’s bye-bye
<burgestrand> There’s a special ”callback” method in FFI that tells FFI that it is a callback
<imperator> oic
<burgestrand> imperator: http://goo.gl/M3JH9 <- like so, and then you can use :albumbrowse_complete_cb as any other type
<imperator> ah, cool
huug joined #ruby-lang
Sailias joined #ruby-lang
nuclearsandwich joined #ruby-lang
Skif joined #ruby-lang
DEac- joined #ruby-lang
ecin joined #ruby-lang
Foxmaster joined #ruby-lang
Jake232 joined #ruby-lang
robotmay joined #ruby-lang
[zaf]-Coral joined #ruby-lang
Pip joined #ruby-lang
<imperator> crimeny, doesn't work on freebsd now
<imperator> buffer size is correct, but getting blanks
MendelGusmao joined #ruby-lang
jbsan joined #ruby-lang
hexo joined #ruby-lang
Axsuul joined #ruby-lang
mikeric joined #ruby-lang
<imperator> variable struct member size, awesome
mikeric joined #ruby-lang
Vicegrip joined #ruby-lang
<imperator> screw it 32, you get a chopped release method
dnyy joined #ruby-lang
locks joined #ruby-lang
jmontross joined #ruby-lang
whoops joined #ruby-lang
Carnage\ joined #ruby-lang
benanne joined #ruby-lang
jbsan joined #ruby-lang
dejongge joined #ruby-lang
<dreinull> anybody here with a github organization?
<jmontross> yeah… used one
<jmontross> not with the github, but use one for work… it's nice
Austin__ joined #ruby-lang
workmad3 joined #ruby-lang
<dreinull> jmontross: can you commit to the repo as that organization or do you have to use a regular user for thet?
<dreinull> that
dv310p3r joined #ruby-lang
<jmontross> u get to use a regular user….. if you want you can make an org user that all the devlopers share and commit as that as well
dustacio joined #ruby-lang
nuclearsandwich joined #ruby-lang
<Jake232> Whats the best way to generate a random number, of length x.
Skif joined #ruby-lang
<dreinull> jmontross: ok, thanks
<yxhuvud> length exactly x or up to x?
<Jake232> x exactly
<apeiros_> length?
<apeiros_> as in: decimal digits?
<apeiros_> or hexadecimal digits?
<Jake232> Well, integer
<Jake232> so
<apeiros_> or bytes?
<apeiros_> or…
<Jake232> x = 6
<Jake232> 392032
nofxx joined #ruby-lang
<Jake232> 384920
<Jake232> 448292
<apeiros_> integers don't have a length.
<Jake232> ^ WOuld be valid
<apeiros_> ff is the same as 256…
<yxhuvud> rand(10**(length-1)) + 10**(length-1) ?
<apeiros_> which in turn is the same as 11111111
<yxhuvud> though if you generate many you may want to precompute the constants
<apeiros_> (and as you can see, all 3 have different lengths, while being the same integer/number)
<Jake232> True
<Jake232> yxhuvud: That works perfect
<Jake232> Actually
<Jake232> It's not so random.
<Jake232> First digit is always 1
<yxhuvud> I may have missed at an index
<workmad3> Jake232: rand(10**(length-1)..10**length)
<workmad3> (tested in ruby 1.9.3)
<Jake232> Breaks in ruby 1.9.2
<Jake232> can't convert Range into Integer
<Jake232> :/
<Jake232> Seems rand only started taking a range in 1.9.3
<apeiros_> "%010d" % rand(10) # random number with 10 digits…
<apeiros_> all initial ones will be zero, though :)
<yxhuvud> :D
* apeiros_ loves vague specs
<apeiros_> too bad that - when I was a freelancer - I was too nice a person to exploit it…
ilyam joined #ruby-lang
<Jake232> Hmm, surely theres a simple way to do this...
<Jake232> I figured it'd be built in
<Jake232> Well, I guess it is in 1.9.3.
<workmad3> Jake232: hmm, then (10**(length-1)..10**length).to_a.sample
RickHull joined #ruby-lang
<workmad3> (although that's not particularly efficient)
RickHull joined #ruby-lang
<yxhuvud> Jake232: use mine, but remove the -1 in the rand part
<apeiros_> yxhuvud: that's not correct, though. can overflow.
<apeiros_> yours was rand(10**n)+10**(n-1), right?
<apeiros_> (the -1 fix applied)
<yxhuvud> hmm. subtract as well? :(
<Jake232> Screw this, I'm going to work some magic with a timestamp, it'll be easier, and random enough.
<apeiros_> yeah
<Jake232> Actually, maybe it wont.
* apeiros_ shrugs
<apeiros_> n random digits are easy… but the spec should be clear.
<workmad3> Jake232: two possible ext methods: https://gist.github.com/1419831
<apeiros_> workmad3: uuuh, that Range#rand is nice for float ranges :D
<Jake232> Is it "bad" to just add methods to the stdlib like that?
<apeiros_> that'd be core, not stdlib. and yes, it's playing with fire a bit.
<Jake232> I guessed so x
<Jake232> :x*
<workmad3> Jake232: yeah, if I was going to do it properly, I'd actually check that the methods didn't exist first to protect against a rand method being added to range in the future
nuclearsandwich joined #ruby-lang
<apeiros_> http://pastie.org/2951582 (why am I even doing that?)
<MistyM> class Fixnum; def +(foo); self / foo; end; end
<apeiros_> MistyM: yeah, I'd let it just return 0 whatsoever. more fun.
<apeiros_> alternatively, reimplement / in terms of +. also funny.
<yxhuvud> reutrn the correct answer most of the time, but negative correct answer 1% of the time.
<MistyM> I can just imagine the person "debugging" that one.
<apeiros_> I think "debugging" isn't the appropriate term there anymore.
<apeiros_> more like "detrolling"
postmodern joined #ruby-lang
<steveklabnik> def rand(num_or_range)
<steveklabnik> 4 # this value was chosen by a die at random
<steveklabnik> end
<apeiros_> steveklabnik: you should properly attribute that one…
nofxx1 joined #ruby-lang
<steveklabnik> http://xkcd.com/221/
<apeiros_> I also like dilberts version of that…
<steveklabnik> ;)
<yxhuvud> pretty easy to find though
<dreinull> what about this solution: a = ""; 6.times {a << rand(9).to_s}
<apeiros_> you discriminate the 9's and you can get leading zeroes
<apeiros_> (rand(9) means 0..8)
<dreinull> zero is a valit number in my maths :)
<dreinull> valid
<Jake232> 6.times {a <<  1+rand(9).to_s}
<Jake232> ?
<apeiros_> dreinull: yes, but Jake232 was too f'ing lazy to specify properly
<dreinull> :)
<apeiros_> so 00123 = 123, length requirement not met.
<dreinull> ok
<apeiros_> but as said in the very beginning, the spec was not really given.
<Jake232> I figured you'd know what I meant by integer length.
<yxhuvud> jake: no, you can't get any zeroes that way
<apeiros_> Jake232: I figured my answer pretty much *showed* that it is not
<apeiros_> Jake232: and again, integers do not have a length.
<Jake232> I still don't understand how integers don't have a length.
<apeiros_> yxhuvud: you can get an exception that way, though
robbrit left #ruby-lang
<apeiros_> Jake232: tell me, what length does 1111111 have?
<Jake232> 7
<apeiros_> oh, I typed. anyway, tell me, what length does 128 have?
ilyam joined #ruby-lang
<apeiros_> gah
<apeiros_> 127
<TTilus> (10000+random(90000)).to_s (assuming "integer length" means the length of base 10 representation as string)
<Jake232> 3
<apeiros_> Jake232: so you just said that the *same integer* had two different lengths. how come?
<apeiros_> 111111 == 127
<apeiros_> first one is binary, second is decimal…
<TTilus> apeiros_: you just "accidentally" forgot to specify the base =D
<Jake232> Maybe I should have said "amount of characters"
<apeiros_> I could add a third "length", by asking you for the length of 7f…
<TTilus> apeiros_: good counter to Jake232 not specifying "length"
<Jake232> Would that be clearer?
<apeiros_> Jake232: an integer *does* *not* *have* characters. a representation of it does.
<Jake232> I see where you are comming from, but the likely hood of me specifying my length to you in binary, was pretty slim.
<TTilus> ...and my chrystal ball shows Jake232 is talking about base 10 string representation of an integer without leading zeroes
<apeiros_> TTilus: sure, so did he, could have been he wanted base32, hex or whatever…
<TTilus> apeiros_: exactly
<apeiros_> Jake232: also, you didn't specify whether leading zeroes were ok
hahuang65 joined #ruby-lang
<TTilus> apeiros_: and thats what we programmers have the chrystal ball, right? =D
<TTilus> s/ball/ball for/
<apeiros_> TTilus: actually, we irc helpers got our super psychic ultra powers!
<Jake232> apeiros_: Well, any number is fine. ;D
<TTilus> apeiros_: oh my! you win!
<Jake232> Well, not floats. Don't want them.
<apeiros_> alternatively, it was "oh, wasn't it obvious?!?"
<apeiros_> Jake232: so 00123 is fine?
<TTilus> apeiros_: thats a good one too
<Jake232> That doesn't have a length of 6, but if that was generated randomly, then sure.
<apeiros_> then just use "%0*d" % [n, rand(10**n)]
<TTilus> Jake232: just repeat after me: "base 10 representation of an integer without leading zeroes" ;)
resetexistence joined #ruby-lang
<apeiros_> that generates n random digits in base 10.
<apeiros_> and I guess if your n == 6, then you don't need SecureRandom either…
<TTilus> Jake232: why leading zeroes are out of question?
<TTilus> Jake232: or are they?
thrcka joined #ruby-lang
<Jake232> I never said they were ;D
firmasaga joined #ruby-lang
<TTilus> Jake232: ok, then i'd go with apeiros_'s solution
<apeiros_> I'd go with my solution too, but I'm so biased…
scottschecter joined #ruby-lang
<TTilus> its good to be biased towards being right =D
<Jake232> On another note, did you actually think when I specified length, did you actually think I meant binary / hex? Ussually, I'd just pressume somebody was working with denary
<Jake232> Unless otherwise specified.
<dreinull> ok, this one here is good: r=Random.new;r.rand(100000..999999)
<apeiros_> Jake232: I very often use hex for padded stuff
<Jake232> But, if you were asking for a random number, and working with hex. You would state hex.
<Jake232> However working in denary, would you explicitly state denary?
<apeiros_> Jake232: but I would state decimal too…
<apeiros_> and what's 'denary'?
<apeiros_> ah, decimal
<apeiros_> interesting…
firmasaga joined #ruby-lang
tdmackey joined #ruby-lang
<apeiros_> didn't know the term 'denary' existed
<Jake232> Hmm, that's a pretty standard term, or it was in my education.
<Jake232> Maybe it's a UK thing? Unless of course you're from the uk too
lenilson_dias joined #ruby-lang
<apeiros_> nope
<Jake232> in which case, maybe it's just me being wierd.
<apeiros_> I'm not a native english speaker
<TTilus> never heard of "denary"
<Jake232> If somebody stated decimal, I'd immediatly think of a float.
<Jake232> Which is wrong, but that's the term most people would use
<TTilus> but that makes perfect sense now that i see it
<Jake232> in everyday speech.
<havenn> Array.new(6) { rand(10) }.join
firmasaga joined #ruby-lang
* apeiros_ wonders whether Array.new(6) { rand(10) }.join and rand(10**6) would have different distribution properties…
firmasaga joined #ruby-lang
* TTilus would be pretty disappointed if they had
Jake232 joined #ruby-lang
<Jake232> Internet unrealiable as ever it seems..
<Jake232> I need a new iSP
<apeiros_> me too, too bad there's none that'd be useful…
<Jake232> i wish I could get Cable / Fibre optic
<TTilus> you just need to duplicate the uplink
<Jake232> The other side of my road has it, yet they refuse to implement it on this side of the street.
<imperator> time for some cable splicing and mission impossible music
firmasaga joined #ruby-lang
firmasaga joined #ruby-lang
<dreinull> Stalin had a daughter who lived and recently died in Wisconsin.
vicegrip joined #ruby-lang
<MistyM> Good to know?
edwardsharp joined #ruby-lang
firmasaga joined #ruby-lang
<dreinull> can't tell. Interesting fact. She didn't like her father. Too cruel.
firmasaga joined #ruby-lang
firmasaga joined #ruby-lang
firmasaga joined #ruby-lang
<jmontross> wow… didn't know stalin's daughter came to us… did she have kids?
zennny joined #ruby-lang
cored joined #ruby-lang
cored joined #ruby-lang
firmasaga joined #ruby-lang
firmasaga joined #ruby-lang
<MistyM> I can only imagine how hard it'd be to have to cope with knowing what her father had done.
firmasaga joined #ruby-lang
<dreinull> jmontross: yes three I think. Search for Svetlana Allilujewa. Just read her obituary in the papers.
firmasaga joined #ruby-lang
gix joined #ruby-lang
Sailias joined #ruby-lang
<jmontross> ""wherever I went I was a political prisoner of my father's legacy"
huug joined #ruby-lang
headius joined #ruby-lang
cored joined #ruby-lang
wyhaines_ joined #ruby-lang
wyhaine__ joined #ruby-lang
Mch1 joined #ruby-lang
rufsketch1 joined #ruby-lang
<rufsketch1> Hello everyone
<rue> HI THERE
<rufsketch1> I'm new to Ruby. Does it have any function that allows me to specify where in an array to put an element, and then automatically have all elements past that point shifted one spot over to accommodate?
<rue> It does indeed
<rufsketch1> rue, neat! any chance you could tell me what that function is called?
<injekt> insert
mksm joined #ruby-lang
<rufsketch1> injekt, thank you. I read that online, but the description wasn't super clear.
mksm joined #ruby-lang
<rue> (Or #[]=)
<rue> You using pry or irb, rufsketch1?
<rue> Read: do if you don't yet :)
<injekt> []= wont push the items up
<rufsketch1> rue, irb
<injekt> it'll replace
scottschecter joined #ruby-lang
resetexistence joined #ruby-lang
<rue> a = [1,2]; a[1,0] = 3; a
<injekt> oh yeah
<injekt> duh
uniqanomaly joined #ruby-lang
singpolyma joined #ruby-lang
babinho joined #ruby-lang
JoL1hAHN joined #ruby-lang
singpolyma joined #ruby-lang
nofxx joined #ruby-lang
statim left #ruby-lang
caio joined #ruby-lang
mztriz joined #ruby-lang
<caio> Hello I have to object DateTIme, how could I compare how many hours has been passed between them ?
<drbrain> caio: subtract them
<mztriz> Could someone help me with this short program? http://pastie.org/private/nbulhqeipltm9ai7ksiabw
<drbrain> then convert to hours
<mztriz> gsub isn't working as I expect it to
<imperator> solaris tasks me
<imperator> it tasks me and i shall defeat it!
<drbrain> mztriz: line 19 seems to have a typo
Oloryn_lt1 joined #ruby-lang
<mztriz> drbrain, hm your'e right but I don't have that in my actual file... one second
<injekt> also
<injekt> ls is a string
<drbrain> looks like the gsub jumped up one line
<injekt> Kernel#` returns a string
<injekt> mztriz: is there a reason you're shelling out and not using ruby?
<caio> I have subtracted how do I convert to hours again ?
<drbrain> mztriz: you probably want to use Dir["#{dir}/**/*"]
<injekt> wouldn't that be ls -R? :D
<injekt> Dir.entries(dir).grep(...)
<mztriz> injekt, no there isn't that's just how I thought if it when I was writing it
<injekt> mztriz: well, you dont need to :)
Mch1 joined #ruby-lang
<drbrain> injekt: right
Mch1 left #ruby-lang
<injekt> mztriz: for f in Dir.entries(dir).grep(regex)
<injekt> you wont need to chomp them strings, either
<drbrain> caio: multiply
<mztriz> injekt, ah that's good to know. thanks
<drbrain> caio: the difference is in fractional days
<injekt> mztriz: and FileUtils has a mv method
<drbrain> so, try *24
<caio> this is what I don't understand fractional days
<rue> Fraaaaactionaaaal ♫
<drbrain> caio: ruby -rdate -e 'd1 = DateTime.now; d2 = d1 - 1; p ((d1 - d2) * 24).to_i'
<imperator> hm, there a way to force extensions to use gmake instead of make when using gem install?
<drbrain> caio: ½ fractional days is 12 hours
<drbrain> imperator: offhand, I don't think so
<drbrain> imperator: oooh
<drbrain> make=gmake gem install ...
<drbrain> it prefers the make that ruby was built with
<imperator> doesn't seem to be actually
curtism joined #ruby-lang
<imperator> but that did the trick, thanks!
<drbrain> imperator: I'm judging based on:
<drbrain> RbConfig::CONFIG['configure_args'] =~ /with-make-prog\=(\w+)/
<drbrain> make_program = $1 || ENV['make']
<imperator> it must have picked it up during configure, but i used gmake to build it
<imperator> maybe i should rebuild it so i don't have to keep doing that
beiter joined #ruby-lang
perryh_ joined #ruby-lang
kain joined #ruby-lang
ilyam_ joined #ruby-lang
macmartine joined #ruby-lang
<caio> ok I didn't understand what you mean "� fractional days is 12 hours" in your calc you have used 24
ilyam_ joined #ruby-lang
sulo joined #ruby-lang
<RickHull> 1/2 (i.e. 0.5) fractional days
RickHull left #ruby-lang
tomzx joined #ruby-lang
wyhaines joined #ruby-lang
<mztriz> injekt, would you mind taking a look at my code now? http://pastie.org/private/cfxexh8cwmfdqvq8ohyqw
tomzx joined #ruby-lang
<injekt> mztriz: you're passing a block to grep() rather than to each()
<injekt> also, you dont need to quote those variables
<injekt> and you dont need to move into the directory
<injekt> Dir.entries(dir).grep(regexp).each do { |filename| ... }
<mztriz> injekt, hm. I'm using ruby 1.8.7 but I tried it without quotes and it wasn't working
<mztriz> I'll try it again
<injekt> why wasn't it working?
<mztriz> injekt, I'm not sure it was awhile ago I'll give it a try again
<injekt> you also have filename and fileName
<mztriz> injekt, That's what I get for changing varnames T__T;; Thanks.
caio left #ruby-lang
<mztriz> injekt, I tried your file and it doesn't list any of the filenames either