ChanServ changed the topic of #ruby-lang to: Ruby 1.9.3-p125: http://ruby-lang.org | Paste >3 lines of text on http://pastie.org or use a gist
<erikh> I dunno, something like perl's use/no warnings would be really good.
<erikh> also with blocks.
<erikh> e.g. no_warn("vars") do .... end
<ged> Woo, hoe 3.0!
<erikh> .. kind of like C#'s unsafe { }
enebo has joined #ruby-lang
ttilley has joined #ruby-lang
<WillMarshall> Can Ruby natively handle datetime arrays?
<WillMarshall> Or is that a Rails thing...
<erikh> arrays of DateTime or ?
<WillMarshall> Arrays that represent one
<WillMarshall> Like ["2012", "3", "21"]:Array
<WillMarshall> That's a Date, not a DateTime
<WillMarshall> My bad
<WillMarshall> But can I cast it to a date easily?
<erikh> honestly, I can't remember.
enebo has joined #ruby-lang
<erikh> you could write your own code, but I would check the rdoc and see if #new accepts that form.
<imperator> erikh, well that's what served as the basis for my article
<imperator> i definitely don't want a pragma system though, blech
<erikh> imperator: it's a pretty awesome system
<erikh> yeah, not sure how best to do it -- maybe overload $-w with a whitelist and provide ruby to drive it
<erikh> I don't want it to balloon into a pragma system either.
<erikh> anyhow, I'll mull it over. I've a few other things i need to finish before I can even think about this.
<drbrain> WillMarshall: ruby -rdate -e 'p Date.new *[2012, 3, 21]'
wmoxam has joined #ruby-lang
<rue> Erm, ‘blacklist-default’ meaning that if you do nothing, there's no effect… only using (ahah) use or specifying something else would toggle it into whitelisting
<rue> Or strftime or whatever it is?
<drbrain> WillMarshall: if you use DateTime, it'll be at midnight
<WillMarshall> Date.new *[2012, 3, 21] does it
<WillMarshall> Thanks!
shevy has joined #ruby-lang
}0 has joined #ruby-lang
<drbrain> WillMarshall: actually, you'll probably want some parens to avoid the warning
<rue> Warnings schmarnings
<WillMarshall> 1.8.7 - no warning!
<WillMarshall> What is the warning?
<WillMarshall> Complaining about a lack of parens?
<drbrain> WillMarshall: ruby -wrdate -e 'p DateTime.new *[2012, 3, 21]'
<erikh> 1.8.7 is a little more liberal when it comes to the parens IIRC
<erikh> not much, just a little.
thermalbaric has joined #ruby-lang
thermalbaric has quit [#ruby-lang]
thermalbaric has joined #ruby-lang
seanstickle has joined #ruby-lang
rolfb has joined #ruby-lang
lynrix has joined #ruby-lang
H2H has joined #ruby-lang
Luxx_ has joined #ruby-lang
Teddy2steper has joined #ruby-lang
gsav has joined #ruby-lang
Karmaon has joined #ruby-lang
takaokouji has joined #ruby-lang
}0 has joined #ruby-lang
}0 has joined #ruby-lang
thone has joined #ruby-lang
imperator has quit ["Leaving"]
achiu has joined #ruby-lang
QoQOoO has joined #ruby-lang
t has joined #ruby-lang
dfr|mac has joined #ruby-lang
postmodern_ has joined #ruby-lang
seydar has joined #ruby-lang
<seydar> i gots a question on cuckoo hashing with two hash functions
<seydar> let's say we have an element i that is already in its secondary position
<seydar> and then j comes in and wants i's secondary position
<seydar> where does i go to?
rubyplusplus has joined #ruby-lang
havenn has joined #ruby-lang
neoesque has joined #ruby-lang
Tukeke has joined #ruby-lang
looopy has joined #ruby-lang
twelvechairs has joined #ruby-lang
[[thufir]] has joined #ruby-lang
<twelvechairs> Anyone point me to a good explanation of using regular expressions for string substitution?
<twelvechairs> I am trying to convert eg "foo[$VARIABLE]bar" to "bar[$VARIABLE]foo" in some text
wallerdev has joined #ruby-lang
<drbrain> corundum: regexp?
<corundum> regexp is learnable interactively at http://rubular.com/ or http://www.zenspider.com/Languages/Ruby/QuickRef.html#11
<drbrain> twelvechairs: ^^
<drbrain> that will help
<drbrain> twelvechairs: to get you started, [ and ] are the characters you care about as they're the borders of your replacement
<drbrain> but, they're also regexp special characters
<twelvechairs> conceal_rs, : thanks. I know how to build the regular expression, just not how to extract 'variable' from the middle to keep it
<drbrain> ah, great
<drbrain> there's a couple ways, one is to use capturing groups
<drbrain> with sub
<drbrain> the other is to use split + reverse (if it'll always be those three things)
<drbrain> here is the split way:
<drbrain> "foo[$VARIABLE]bar".split(/(\[.*?\])/)
<twelvechairs> drbrain, : thanks heaps. anything you know which explains the backreferences properly? Its the "(" and ")" which confuse me in that line.
<drbrain> twelvechairs: have you read http://ruby-doc.org/core-1.9.3/Regexp.html ?
postmodern has joined #ruby-lang
<drbrain> particularly Capturing and Grouping?
QoQOoO has joined #ruby-lang
<twelvechairs> ahhh. thanks. Sorry. stupid of me to miss the core documentation! :) Wasn't expecting such a full explanation there.
<drbrain> if you do it with sub, you put a group around the part before, a group around the middle, and a group around the part after
<drbrain> then glue them back together in the right order
<drbrain> twelvechairs: the docs explain how captures work, and by combining it with the String#sub and String#gsub docs, you should be much further along
jmfcool has joined #ruby-lang
<twelvechairs> drbrain, : Thanks a lot :)
<drbrain> twelvechairs: also, with sub, you can replace from captures in two ways
<drbrain> with a block, like { [$3, $2, $1].join }
<drbrain> or with a string like , "\\3\\2\\1"
ericmuyser has joined #ruby-lang
<twelvechairs> drbrain: thanks!
shtirlic_ has joined #ruby-lang
_inc has joined #ruby-lang
headius has joined #ruby-lang
rdavila has joined #ruby-lang
Lite_ has joined #ruby-lang
wmoxam has joined #ruby-lang
_santana has joined #ruby-lang
<_santana> hi there
<Lite_> Nice to meet you.
gix has joined #ruby-lang
brianpWins has joined #ruby-lang
<twelvechairs> drbrain, : nother quick question if you are able to answer. Is there a way of creating a regular expresion to capture the first of something? eg. the line 'capturethisFOOdontcapturethisFOO'. If i do /.*FOO/ it captures the whole string but I only want the first part
<drbrain> ^ anchors to the beginning of the line
<drbrain> \A anchors to the beginning of the string
<_santana> twelvechairs: /^(.*)FOO$/
<rue> Also for added fun, \a
<_santana> twelvechairs: you'll get what you want in $1
<twelvechairs> thanks both :)
<_santana> twelvechairs: http://rubular.com/
<twelvechairs> _santana: still matching to the second FOO though rather than the first. Unless Im doing something wrong?
<drbrain> twelvechairs: * is greedy by default
<_santana> oh
<drbrain> twelvechairs: if you add a ? after it, it becomes non-greedy
<drbrain> so, .*?
<_santana> you don't even need a regexp actually. you can use split :)
<twelvechairs> Fantastic! 'greedy', that is the term I was looking for....
<twelvechairs> _santana: yeah. could do with a split, but part of a larger example :) thanks. has helped immensely!
<_santana> 'k
<Lite_> Earlier today I was trying to get something to work.
<Lite_> The date class function... "Date.day_fraction_to_time" apparently no longer works in the current version of Ruby.
<Lite_> It used to work for me, but after googling I read somewhere that it's now a private class, but I don't know what you have to write instead of access such a thing.
<Lite_> to* access
headius has joined #ruby-lang
dv310p3r has joined #ruby-lang
<Lite_> Anyone familiar with that?
krz has joined #ruby-lang
Phrogz has joined #ruby-lang
urbanmonk has joined #ruby-lang
headius has joined #ruby-lang
<shevy> Date.day_fraction_to_time ? did this work?
<shevy> oh indeed
<shevy> I am on ruby 1.8.x though
srbartlett has joined #ruby-lang
<drbrain> Lite_: what did you use it for?
<drbrain> Lite_: you should not be calling it, and it probably doesn't exist anymore
l0st1 has joined #ruby-lang
jmontross has joined #ruby-lang
looopy has joined #ruby-lang
swarley has joined #ruby-lang
Joeysomo has joined #ruby-lang
msisk has joined #ruby-lang
hagabaka has joined #ruby-lang
hagabaka has joined #ruby-lang
pp01bit has joined #ruby-lang
Phrogz has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
<Phrogz> Earlier today I made this: http://phrogz.net/simplest-possible-ruby-web-server anyone got a better/shorter one-liner to accomplish the same goal?
<swarley> that seems to be cheating a little lol
<drbrain> Phrogz: ruby -rwebrick -e 'WEBrick::HTTPServer.new.start'
<Phrogz> drbrain: I need a sudo on that 'cause I guess it's going for port 80 by default.
<drbrain> yeah
<Phrogz> Got a variation that sets the port simply?
<swarley> ruby -e "`sudo ngnix`"
<Phrogz> :p
<Phrogz> drbrain: Ouch...ctrl-c does not kill that!
<drbrain> hrm, but it doesn't load the current directory, so: ruby20 -rwebrick -e 'WEBrick::HTTPServer.new(DocumentRoot: ".").start'
Phrogz has joined #ruby-lang
<Phrogz> LOL note to self: when you press ctrl-z to kill drbrain's evil process, do not then mistype sudo kill 1 in an attempt to kill the job.
<drbrain> Phrogz: yeah, but that's not really part of serving web pages now, is it?
headius has joined #ruby-lang
<Phrogz> I mean...it's effective and all.
<drbrain> Phrogz: LOL
<Phrogz> drbrain: No, but it is part of quickly serving, stopping serving, and moving to another directory to serve from there.
Tukeke has quit ["Hackers and Proletarians of the World! Unite!"]
imperator has joined #ruby-lang
ericmuyser has joined #ruby-lang
<drbrain> Phrogz: that's why I have ~/bin/webrick
bryancp has joined #ruby-lang
jalljo_ has joined #ruby-lang
ramonmaruko has joined #ruby-lang
phlipper has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
igotnolegs has joined #ruby-lang
gregmore_ has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
<shevy> is anyone of you using ruby statically or is that possible? I seem to not have managed to compile ruby statically yet
<drbrain> shevy: it's possible
<drbrain> shevy: I have /usr/local/lib/libruby.1.9.1-static.a
<shevy> cool, okies
<drbrain> shevy: I think the static lib gets built by default
<drbrain> there's ./configure --enable-shared to force building of the shared library
<shevy> hmm is http://bugs.ruby-lang.org/projects/ruby/issues/new working for you? I want to report an issue but it tells me "No tracker is associated to this project. Please check the Project settings."
<drbrain> oops
<drbrain> damn focus stealing
<shevy> ah yes, that works. thanks drbrain
<drbrain> I'm not sure how you move stuff to the ruby tracker
<drbrain> I think it has to start on ruby-trunk
Indian has joined #ruby-lang
dr0id has joined #ruby-lang
Phrogz has joined #ruby-lang
_santana has joined #ruby-lang
rippa has joined #ruby-lang
gnufied has joined #ruby-lang
Heimidal has joined #ruby-lang
Teddy2steper has joined #ruby-lang
QoQOoO has joined #ruby-lang
ericmuyser has joined #ruby-lang
burns180_ has joined #ruby-lang
_santana has joined #ruby-lang
Heimidal has joined #ruby-lang
wyhaines has joined #ruby-lang
gaivs has joined #ruby-lang
crudson has quit [#ruby-lang]
Technodrome has joined #ruby-lang
<Technodrome> i have something made for ruby 1.8 ….i would like to use it …i only have ruby 1.9.3 installed …how much will i probably have to change here ?
<erikh> usually not much
<erikh> but if you're new to ruby, it's not for the weary
<Technodrome> i mean i'm not new but i'm not super experienced either
<imperator> run your tests with 1.9, see what happens
<erikh> ^
<Technodrome> my tests?
<imperator> YES, YOUR TESTS
<Technodrome> I did not write any tests, I didn't even create this
<erikh> ok; do they have any tests?
<Technodrome> I'm not sure
<Technodrome> this is quite old
<Technodrome> 2003-2004
<erikh> yeah. not sure what to tell you then
<erikh> maybe start writing some
<imperator> does it have tests?
<Technodrome> i will just try it and see what happens
<Technodrome> i do not see any no
<imperator> may we ask what it is?
<Technodrome> sure
<Technodrome> its a web framework called cgikit
<erikh> hrm
<erikh> what's the attraction to such old code? legacy app @ work?
<Technodrome> a very unique web framework
<Technodrome> its a change erikh
<Technodrome> erikh: do you remember apples web objects?
<erikh> not fondly
<Technodrome> hard to explain then
* imperator thinks he remembers someone giving a talk on it a long time ago
<erikh> dunno. unless you're willing to maintain that software, you're basically screwing yourself
<Technodrome> all web frameworks are the same these days ….mvc rails style or super minimal sinatra
<erikh> try sinatra or rails or roll something atop rack
<erikh> or ramaze.
<Technodrome> ramaze is ok but
<Technodrome> same thing
<Technodrome> cgikit is different and still innovative in my opinion
<shevy> well rails is significantly larger
<erikh> well, look. let's be pragmatic about this
<shevy> it even cooks tea
<erikh> you're going to be maintaining two things
<erikh> this cgikit and your application.
<erikh> if you're willing to do that, that's great, but be aware of what you're in for.
<Technodrome> its a fairly small code base
<Technodrome> i could get it running on rack as well
<erikh> for a lot of good reasons I'd consider ... right
<erikh> that's exactly what i was going to suggest.
<shevy> 2004/4/15: 1.2.0 released.
<shevy> cgikit!
<shevy> 8 years!
<Technodrome> before even webrick
<Technodrome> and still there is no other component based ruby frameworks :)
<shevy> Technodrome will you takeover cgikit and move it to github? :)
<Technodrome> i believe so yes
<erikh> honestly, I'd think about this a bit more if I were you
<erikh> but I don't want to beat a dead horse.
<shevy> cool
<Technodrome> you must understand I'm bored to death with web dev right now
<erikh> I was too
<erikh> that's why I don't do it anymore.
<Technodrome> rails ramaze even sinatra all the same thing
<shevy> hehe
<shevy> true
<imperator> erikh, you don't?
<shevy> well
<shevy> more or less true
<Technodrome> erikh: yes ….but cgikit is different, its like webobjects
<erikh> imperator: nope i'm a devops guy these days
<drbrain> erikh: I imagine the only thing that would break for code written for ruby 1.6/1.8 is the handling of String#each
<erikh> it honestly a lot closer to my mindset than web dev ever was.
<Technodrome> i have never saw so many brain dead frameworks …..any time i see a new framework i can almost bet its a rails clone
<erikh> drbrain: Enumerable with hashes
<erikh> Technodrome: totally not discouraging you. just asking you to think about it before you dive in head first
brownies has joined #ruby-lang
<drbrain> Enumerable wasn't quite so useful back in the olden days, so you'll see much fewer uses of it
io_syl has joined #ruby-lang
<erikh> I've taken over my fair share of dead code and it was a painful exercise.
<Technodrome> erikh: if it was some huge web framework then of course i would think about it ….but it gives me interest in web dev
<erikh> drbrain: fair enough.
<imperator> drbrain, this reminds me, what's the state of Borges these days?
<drbrain> imperator: abandoned
<drbrain> imperator: also, callcc is largely abandoned in ruby, too
<imperator> ah
<Technodrome> erikh: if you would like to see another way of doing things and don't mind a bit of change in mind set on web dev, its a good way
<imperator> hm, i guess i was thinking of patrick may's talk on narf
<drbrain> you must require 'continuation' to get it, and there are many people reporting bugs when using it
<erikh> honestly, for my needs sinatra is usually overkill
<drbrain> ah, narf!
<drbrain> bedtime for me
<erikh> later.
<imperator> g'night
<Technodrome> erikh: ever use any compoenent based framework?
<erikh> not sure
<erikh> I'm not really interested in web dev anymore
<Technodrome> when you never do anything you become a slave to other peoples styles and tastes erikh
<imperator> looks like there's even a narf gem!
<imperator> no gem for cgikit, though, that can't be good
<imperator> downloaded cgikit 1.2.1, nope, no tests
<imperator> Technodrome, well, if you feel strongly about it, then i would suggest taking it over and updating/refactoring it
<Technodrome> i feel pretty strong, let me see what i can get just from trying it out
<imperator> please do
<erikh> Technodrome: there is more kinds of programming than web programming.
pygmael_ has joined #ruby-lang
<imperator> crazy talk
<imperator> there is only rails, LOL
<Technodrome> erikh: this is what i'm paid to do
<erikh> I've written four in-house MVC frameworks from scratch in mod_perl & apache primitives. web programming bores me.
<Technodrome> and i hate rails
<erikh> some of them powering sites you've probably heard of.
<Technodrome> i've worked on some high profile stuff as well
<erikh> that's great. now stop asking me about a project i'm not interested in.
<Technodrome> huh?
<imperator> hah! i've worked on....look, over there, a squirrel!
<erikh> imperator: :P
<Technodrome> mvc frameworks get boring because they are all the same thing ….people get tired of mvc pattern and just blame web dev
<imperator> Technodrome, is it the mvc pattern? or is it just slapping yet another web page in front of yet another database?
<imperator> regardless of framework
dc5ala has joined #ruby-lang
<Technodrome> imperator: db's are common in all programming
<imperator> true
<imperator> btw, i recommend starting with a test suite and then, once you've got everything where you want it, a gem
<erikh> sorry for popping my cork, i just really don't feel like talking about this anymore
<erikh> :)
<Technodrome> looking at this horrible code I'm loosing interest
<imperator> lol
<imperator> well, it's like 8 years old
<imperator> Technodrome, in that case, i encourage you to write your own
ericmuyser has joined #ruby-lang
<imperator> you may not be alone, maybe others are looking for the same thing you are
* imperator slaps erikh just to start something
gregmoreno has joined #ruby-lang
<imperator> actually, the copyright is set at 2002
<imperator> 8 space indentation, yeesh
JohnBat26 has joined #ruby-lang
<erikh> imperator: I challenge you to fisticuffs!
<Technodrome> imperator: not sure if this matters but the framework works in 1.9 so far with no changes
<imperator> Technodrome, cool!
<imperator> erikh, don't even mess with me man; i have a green belt...in tae kwan doe....that i got when i was 14
<Technodrome> and it works with webrick as well ….i didnt know webrick was even out back then
<imperator> Technodrome, yeah, it was a standalone lib that got integrated into 1.8.0
<Technodrome> what year did it come out?
<erikh> imperator: oh yeah? I wear thick glasses which means I can see you better -- for more precise swinging
<imperator> glasses? what are those? lasik baby
<imperator> of course, i think everyone has their high beams on at night now, but nevermind that
<imperator> Technodrome, been around since 2002 at least
<imperator> looks like webrick.org is no longer around
<Technodrome> imperator: what was the site at one time?
<Technodrome> hasn't had a release since 03?
<Technodrome> jeesh
<imperator> i think it has, that's an old site that no one really uses any more and probably isn't up to date
<imperator> raa was the place people originally listed stuff, before rubyforge came around
<imperator> although....webrick 1.3.1 is the gem listed
gianlucadv has joined #ruby-lang
<imperator> i guess it's stable (?)
havenn has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
H2H has joined #ruby-lang
x0F__ has joined #ruby-lang
<Technodrome> ok that was fun …..cool beans
<Technodrome> R.I.P cgikit
<Technodrome> i'm not setting routing manually with webrick calls
<imperator> time to write your own library!
<erikh> imperator: yeah, I have a lazy eye. lasik no workie.
<erikh> it's fun at parties though, I can really creep people out.
* imperator plans to use that to his advantage
<erikh> kind of surprised raa is still up
H2H has joined #ruby-lang
postmodern has joined #ruby-lang
<erikh> probably a good argument to start retiring that stuff.
<imperator> i still have entries there
<imperator> sybase-ctlib - 19-mar-2012
<imperator> still being used it looks like
<imperator> i like how a warning from 2005 is still there
<Technodrome> erikh: what do you mean you have a lazy eye?
<Technodrome> you have amblyopia ? or you have strabismus?
pygmael has joined #ruby-lang
<erikh> man I'm not a doctor. I just have a condition where the muscles in my right eye are weak
<erikh> I have good control of it, I have to "relax" to let it wander.
yxhuvud has joined #ruby-lang
<Technodrome> so you have strabismus
<erikh> had it since 10 months of age or so
<Technodrome> which is not lazy eye
<imperator> it means he looks like jack elam when he's slightly off
postmodern has joined #ruby-lang
<imperator> for those too young to remember jack elam: http://www.youtube.com/watch?v=85PcMJ9D8X0
<erikh> man I'm going to be 34 next month and I don't remember that
<erikh> you old fart.
<rippa> Technodrome: strabismus is lazy eye
<imperator> cannonball run, forever etched into my memory
<erikh> I was more of a big trouble in little china kid.
<Technodrome> rippa: not exactly
<Technodrome> amployopia is the actual condition which is called lazy eye
<Technodrome> people just always just it as a laymans term for strabismus
<rippa> Lazy eye may refer to:
<rippa> Amblyopia, a visual disorder in which the brain partially or wholly ignores input from one eye
<rippa> Strabismus, the most common cause of amblyopia
<rippa> Ptosis, drooping or falling of the upper or lower eyelid
<Technodrome> The colloquialism "lazy eye" is frequently used to refer to amblyopia. The term "lazy eye" is imprecise because it is a http://en.wikipedia.org/wiki/Layman's term for http://en.wikipedia.org/wiki/Strabismus, particularly http://en.wikipedia.org/wiki/Exotropia.[3
<rippa> so, you can't say that strabismus is not lazy eye
<erikh> guys
<rippa> because lazy eye refers to both
<erikh> can we argue about whether batman or wolverine would win in an epic battle now?
<rippa> no
<rippa> batman would win if he was given time to prepare
<erikh> lies.
<rippa> and he always has time to prepare
<rippa> but jackie chan would beat them both on a ladder factory
<erikh> heheheheh
sora_h has joined #ruby-lang
<erikh> <3 you.
<Technodrome> rippa: lazy eye is when the power of the eye is lower than the other …strabismus is a muscle condition …the eye itself vision is not lazy , it can be , but you can have strabismus and have perfect vision in that eye
<imperator> jackie chan, also in cannonball run
<imperator> the circle of irc is complete
shtirlic has joined #ruby-lang
uniqanomaly_ has joined #ruby-lang
thrcka has joined #ruby-lang
kitallis has joined #ruby-lang
|Vargas| has joined #ruby-lang
Technodrome has quit [#ruby-lang]
toretore has joined #ruby-lang
sora_h has joined #ruby-lang
timbleck has joined #ruby-lang
brianpWins has joined #ruby-lang
JohnBat26 has joined #ruby-lang
Joeysomo has joined #ruby-lang
tjadc has joined #ruby-lang
cdnz has joined #ruby-lang
imperator has quit ["Leaving"]
mixandgo has joined #ruby-lang
tjadc has joined #ruby-lang
frangiz has joined #ruby-lang
gaivs has joined #ruby-lang
gnufied has joined #ruby-lang
Foxmaster has joined #ruby-lang
woollyams has joined #ruby-lang
owen1 has joined #ruby-lang
Asher has joined #ruby-lang
zmack has joined #ruby-lang
solars has joined #ruby-lang
senthil has joined #ruby-lang
thrcka has joined #ruby-lang
workmad3 has joined #ruby-lang
sandbags has joined #ruby-lang
[[thufir]] has joined #ruby-lang
s0ber has joined #ruby-lang
y3llow has joined #ruby-lang
apeiros_ has joined #ruby-lang
y3llow has joined #ruby-lang
y3llow has joined #ruby-lang
gaivs has joined #ruby-lang
beiter has joined #ruby-lang
gray has joined #ruby-lang
Hakon|mbp has joined #ruby-lang
Indian has joined #ruby-lang
r3dskade has joined #ruby-lang
wlfman2k1 has joined #ruby-lang
futurechimp has joined #ruby-lang
futurechimp has joined #ruby-lang
<gray> Symbol is not object in ruby?
<gray> "my_string" - string object
<gray> :my_string - not object?
<TTilus> gray: everything is
<gray> hm okay, but when i should use symbols and why?
vmoravec has joined #ruby-lang
<TTilus> gray: rule of thumb, if you operate on the contents, use strings, otherwise symbols
workmad3 has joined #ruby-lang
<gray> thanks!
morozovm has joined #ruby-lang
<TTilus> gray: or other way round another rule of thumb, use symbols for labels, otherwise strings
<TTilus> gray: what about it?
<gray> this example is from railstutorial.org (route.rb) file
<TTilus> gray: ...and?
<gray> so, i don't understand next:
<gray> what does mean: resources :users
<TTilus> gray: it is a method call
morozovm has quit [#ruby-lang]
<gray> and as argument pass symbol?
<TTilus> gray: :users is an argument to the method
<gray> okay
<gray> thanks
morozovm has joined #ruby-lang
<gray> TTilus: and where i can read about scope? :: ?
<TTilus> gray: in ruby you can leave parenthesis out from method calls most of the time (excluding e.g. nested(calls(to(several), methods))
<TTilus> gray: pickaxe book?
morozovm has quit [#ruby-lang]
<TTilus> gray: what do you wanna know about scope?
morozovm has joined #ruby-lang
<rippa> TTilus: p p p p p p 1, 2
<rippa> it's just hard to parse visually
<rippa> but works
<gray> TTilus: i just wans understand how it works.
<gray> TTilus: i don't understand what does this mean: DemoApp::Application.routes.draw do
<rippa> same thing as DemoApp.Application.routes.draw
<rippa> only :: is used by convention to get constants from modules
<rippa> and if there's both method and constant with same name in scope, . will fetch the method and :: the constant
<gray> rippa: but i can't find Application description in api
<rippa> you probably create it yourself
<rippa> I'm not familiar with rails
gaivs has joined #ruby-lang
<gray> okay, thanks guys
rue has joined #ruby-lang
Hakon|mbp has joined #ruby-lang
<rippa> heh
<rippa> splat operator uses recursion
<[[thufir]]> Am I calling a non-existent method? http://pastebin.mozilla.org/1531149 from sample at: http://nntp.rubyforge.org/
<rippa> gives SystemStackError: stack level too deep on huge array
<workmad3> rippa: ooh, fun :) example?
<rippa> def foo *; end; foo *(1..1000000).to_a
<[[thufir]]> how can I simply test that the NNTP gem is being ?invoked? correctly? Running 1.9.3 ruby RVM, have that gem installed.
roadkith has joined #ruby-lang
<rippa> I decided to check that thing
<rippa> about strings, hashes and lookup speed
<apeiros_> woah, the usual Thread.new do i += 1 end example for race conditions no longer works in ruby…
<apeiros_> had to use something more complex than a simple +1 to get the race condition to show…
<rippa> I thought GIL prevents that sort of thing
<apeiros_> gil has nothing to do with that
<workmad3> rippa: GIL doesn't stop pre-emptive context switches, it just means only one thread is ever active in the interpreter at once
<apeiros_> the problem is that either scheduling changed, leaving a large enough slice for i += 1 to become pseudo-atomic, or that it has simply become too fast compared to the rest
<workmad3> apeiros_: I take it that += definitely hasn't become an atomic op?
<apeiros_> I had tried it with i = i + 1, and that already didn't work. I'd bet my money on scheduling change.
<workmad3> monkey-patch Integer + so that it sleeps for a second before doing the addition? :)
roadkith has joined #ruby-lang
<apeiros_> I use i = Math.sqrt(i**2).round + 1
<apeiros_> so I still do effectively i+1, but it "burns" more time doing so
<workmad3> that works too :)
<apeiros_> but even with that, I still need to do more than 100K iterations for the problem to show :)
rue has joined #ruby-lang
<workmad3> apeiros_: that makes it a perfect example IMO :)
<dominikh> so, your race condition has a race condition now? :P
roadkith has joined #ruby-lang
<apeiros_> my race condition had a race condition before already, ruby was just too lazy to let it show ;-)
<workmad3> apeiros_: maybe you just needed to run it more times...
francisfish has joined #ruby-lang
<rippa> i+=1 works for me
<rippa> almost always returns 0
<rippa> somehow
<rippa> why does it return 0?
<workmad3> i = -1; i += 1 #=> 0
fragmachine has joined #ruby-lang
<apeiros_> not -= 1?
machine2 has joined #ruby-lang
kitallis has joined #ruby-lang
<fragmachine> Hello I'm trying to solve some problems on Rubeque. I'm trying to write a queue class but I'm stumped on the last method. Any ideas how to get an instance of a class to retrun it's values without a method? - http://pastie.org/3646792
<injekt> fragmachine: write the to_a method
<fragmachine> man so obvious...
<fragmachine> thanks haha
<apeiros_> now I'm curious… *waits*
<injekt> I also recommend switching arguments in your assert_equals, it's more common to use (this, that) than (that, this) and I think it's easier to read
<injekt> ie assert_equal 5, queue.pop
<fragmachine> ok yea that makes sense
<apeiros_> fragmachine: you've got an answer now for a couple of minutes, and you've asked the question in another channel too… don't you think you should tell the other channel that you've got an answer?
<fragmachine> apeiros_: Ok no worries, oops
<apeiros_> fragmachine: I pondered whether I should ask you or just kickban you right away
<injekt> lol
<fragmachine> I'm not trying to upset anyone...
<injekt> I think you got the better end of that deal
<apeiros_> and I was --->|<---- this close to just kickban
<injekt> wait, | would be fingers pinched
<dominikh> injekt: "this, that"? The right term would be "expected, actual" :P
<injekt> dominikh: this terms would be stfu
<injekt> the
<injekt> dammit it's too early
<dominikh> :D
<injekt> fragmachine: also, I dont think your push does what you think it does
<fragmachine> doesn't it just append to the back of the array?
<injekt> yeah, but if you feed it an array it'll push in an array, not the values inside that array (that's what #concat does)
<injekt> that is, on line 9 you send an array to push
<injekt> which means your queue would look something like [5,6,7,8,[4,2]]
<fragmachine> oh that's right I forgot about that. I didn't know concat was what I was after, I was just gonna do arr.flatten!
<injekt> :)
<injekt> you also don't need to use slice! on line 24
<fragmachine> how else can I grab the elements and then remove them?
<injekt> well, you know ruby arrays have a push and pop method which work on the tail end of the array, there's also methods which work from the front of the array
<injekt> that is, the method in question is identical to slice!(0, n)
<injekt> in return value
<fragmachine> ok cool, I didn't know you could do arr.shift(n)
Wardrop has joined #ruby-lang
<Wardrop> Does anyone know if there's a way to prevent a before block running for static files? Additionally, is there a way we can prevent sessions from being loaded for static files?
<Wardrop> I understand that a proper server like apache with phusion passenger would serve static files without touching the application, I'm just wondering if there's some way we can emulate similar behaviour on our development boxes which just run the app with Webrick.
Stalkr_ has joined #ruby-lang
<workmad3> Wardrop: #rubyonrails
<Wardrop> Ha? I using Sinatra (well actually Padrino)
<canton7> Wardrop, use some rack middleware like Rack::Static maybe?
mixandgo has joined #ruby-lang
heftig has joined #ruby-lang
roadkith_ has joined #ruby-lang
roadkith has joined #ruby-lang
kitallis has joined #ruby-lang
paul0` has joined #ruby-lang
My_Hearing has joined #ruby-lang
Hakon|mbp has joined #ruby-lang
seoaqua has joined #ruby-lang
<seoaqua> could anyone help me to crack x-amf data of some website
havenn has joined #ruby-lang
<yorickpeterse> what?
<seoaqua> some encrypted flash data
<yorickpeterse> "help me crack some encrypted flash data of some website" doesn't sound too legit