<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/* ?
<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.
<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.
<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.
<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?
<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
<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)
<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
<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
<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
<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
<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
<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.
<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>
"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
<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
<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*)
<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_>
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: 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
<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 :(
<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)
<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
<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 ?