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
darkf_ has joined #ruby-lang
achiu has joined #ruby-lang
Tukeke has joined #ruby-lang
bryancp has joined #ruby-lang
gregf has joined #ruby-lang
Tukeke has quit [#ruby-lang]
retro|cz has joined #ruby-lang
slyphon has joined #ruby-lang
<zenspider> minitest 2.11.4 released!
burns180 has joined #ruby-lang
crudson has joined #ruby-lang
Sailias has joined #ruby-lang
Zolrath has joined #ruby-lang
thone_ has joined #ruby-lang
scampbell has joined #ruby-lang
darkf_ has joined #ruby-lang
darkf_ has joined #ruby-lang
<zenspider> EXCITING!
<zenspider> or... something
Luxx_ has joined #ruby-lang
looopy has joined #ruby-lang
t has joined #ruby-lang
<rue> Meh
<rue> 67% excitement level
postmodern has joined #ruby-lang
QoQOoO has joined #ruby-lang
[[thufir]] has joined #ruby-lang
<zenspider> rue: ping on IM
<davpoind> anyone use ruby for system scripting? link me to some best practices similar to setting up bash aliases? Goal: write my aliases using ruby, not just bash. thx
<rue> You can't write *aliases* in Ruby, per se
<rue> There's a book about Ruby for sysadmins or scripting, think it's PragProg even
<davpoind> i've seen it, not bought/read that one yet though
<davpoind> just testing the waters here
<davpoind> my system is getting a little out of hand :|
<rue> Maybe you need something like Chef/Puppet instead?
<rue> Or what was that new thing, Squiggles or Squidder or something like that
<davpoind> lol wut?
<davpoind> oh, is that the name?
<rue> It's something like that.
<telemachus> I thought the Ruby for sysadmins book was Apress. Maybe both?
<rue> Probably both
<davpoind> no, i know which one you mean
<davpoind> it's prag prog
<davpoind> trying to find it
<telemachus> davpoind: I'm currently holding "Practical Ruby for System Administration" in my hands. It's Apress. So, they definitely have one too. ;)
<davpoind> ha, well done!
<davpoind> my mind is all over with creativity tonight
<davpoind> or beer
Teddy2steper has joined #ruby-lang
<davpoind> i'm not gonna argue
<rue> I think the apress one got better a-press
<rue> But I've not read either
<davpoind> ah, crap, here's what i was thinking: http://pragprog.com/book/bmsft/everyday-scripting-with-ruby
<davpoind> ok, so you got that book
<telemachus> rue: The Apress one is meh-ish. I read about half and gave up on it.
<davpoind> do you see a way to solve the issue I'm asking about anywhere in it? Or a hint... im resourceful and not as noobish as a few years ago
<telemachus> Which issue again? Aliases?
<davpoind> the thing i struggle with is having something fast, on every shell
<davpoind> right
<telemachus> Well, the shell itself is probably more everywhere than Ruby.
<davpoind> so, i'd like to make things a bit more complex than what I know how to do in shell
<telemachus> And as rue said, you can't really use Ruby to make shell aliases.
<davpoind> but not necessarily it's own gem with binary
<rue> Maybe just a ~/bin with scripts
<telemachus> yup - those go nice with Ruby
<davpoind> that's what i've done for a bit
<davpoind> maybe i'm just having namespace issues then
<davpoind> i can reference those scripts via bash aliases just fine
<rue> Sure
S2kx has joined #ruby-lang
BHensley has joined #ruby-lang
dv310p3r has joined #ruby-lang
shtirlic_ has joined #ruby-lang
cdnz has joined #ruby-lang
wyhaines has joined #ruby-lang
mikeric has joined #ruby-lang
andrewhl has joined #ruby-lang
looopy has joined #ruby-lang
gregf has joined #ruby-lang
neoesque has joined #ruby-lang
machine2 has joined #ruby-lang
FACEFOX has joined #ruby-lang
looopy has joined #ruby-lang
shtirli__ has joined #ruby-lang
looopy has joined #ruby-lang
shtirlic has joined #ruby-lang
shtirlic has joined #ruby-lang
verto_ has joined #ruby-lang
nofxx has joined #ruby-lang
gix has joined #ruby-lang
<nebbie> https://gist.github.com/2143705 this code does what it is supposed to do, but it's quite ugly, anybody got a better way to do this?
<drbrain> nebbie: I like %w[…] over other bracket characters because it reminds me of Array
<erikh> fields_of_interest.any? { |field| field == key }
<erikh> you can get rid of the whole temp variable.
<erikh> also, about to assign pager duty to the apps team if this damn memory leak doesn't get fixed
<erikh> being chained to my computer is not idea.
<erikh> ideal.
<drbrain> nebbie: I think line 6 should be fields_of_interest.any? { |field| field == key }
wlfman2k1 has joined #ruby-lang
<drbrain> nebbie: then you can remove line 5 and 7
Swimming_Bird has joined #ruby-lang
<nebbie> erikh,drbrain: wow, thanks.. this problem comes up a lot for me and it is always so ugly.
joelstim has joined #ruby-lang
joelstim has quit [#ruby-lang]
tonesfrommars has joined #ruby-lang
havenn has joined #ruby-lang
bryancp has joined #ruby-lang
chimkan has joined #ruby-lang
dreinull has joined #ruby-lang
dr0id has joined #ruby-lang
brownies has joined #ruby-lang
krz has joined #ruby-lang
QoQOoO has quit [#ruby-lang]
retro|cz has joined #ruby-lang
robbyoconnor has joined #ruby-lang
<dr0id> who knowz japanese
<erikh> translate.google.com
<dr0id> not workin good enough
dfr|mac has joined #ruby-lang
<shevy> lol
<shevy> dr0id manveru does
<dr0id> do you think he'll help ?
<shevy> let me find out
<dr0id> btw, its kanji :/
* shevy closes his eyes and concentrates ...
* shevy reads manveru's mind carefully.
<shevy> dr0id, from my greater mind deducing powers, the answer is YES
<drbrain> dr0id: guess your way to success!
Sailias has joined #ruby-lang
<dr0id> hi manveru
<lianj> chances are high he is asleep
<dr0id> but it is only noon
<lianj> not in our timezone
andrewhl has joined #ruby-lang
dfr|mac_ has joined #ruby-lang
<shevy> lol
<shevy> dr0id u r a funny guy
crudson has quit [#ruby-lang]
seanstickle has joined #ruby-lang
<dr0id> nvm, figured out in #japanese
mikeric has joined #ruby-lang
cdnz has joined #ruby-lang
burns180_ has joined #ruby-lang
Rakko has joined #ruby-lang
burns180 has joined #ruby-lang
khannz has joined #ruby-lang
burns180_ has joined #ruby-lang
burns180 has joined #ruby-lang
imperator has joined #ruby-lang
erpuds has joined #ruby-lang
cdnz has joined #ruby-lang
takaokouji has joined #ruby-lang
slimfit has joined #ruby-lang
looopy has joined #ruby-lang
gnufied has joined #ruby-lang
havenn has joined #ruby-lang
jmfcool has joined #ruby-lang
burns180 has joined #ruby-lang
Cherrum has joined #ruby-lang
brianpWins has joined #ruby-lang
Cherrum has joined #ruby-lang
rippa has joined #ruby-lang
Cherrum has joined #ruby-lang
t has joined #ruby-lang
dc5ala has joined #ruby-lang
darkf has joined #ruby-lang
chimkan_ has joined #ruby-lang
darkf has joined #ruby-lang
ilyam has joined #ruby-lang
io_syl has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
shtirlic has joined #ruby-lang
toretore has joined #ruby-lang
retro|cz has joined #ruby-lang
khannz has joined #ruby-lang
khannz has quit [#ruby-lang]
achiu has joined #ruby-lang
Karmaon has joined #ruby-lang
burns180 has joined #ruby-lang
wolflee has joined #ruby-lang
wolflee has quit [#ruby-lang]
JohnBat26 has joined #ruby-lang
DiseaseHF has joined #ruby-lang
DiseaseHF has quit [#ruby-lang]
x0F_ has joined #ruby-lang
wlfman2k1 has joined #ruby-lang
erpuds has joined #ruby-lang
yxhuvud has joined #ruby-lang
|Vargas| has joined #ruby-lang
cdnz has joined #ruby-lang
Cherrum has joined #ruby-lang
pygmael has joined #ruby-lang
pygmael has joined #ruby-lang
kitallis has joined #ruby-lang
rue has joined #ruby-lang
frangiz has joined #ruby-lang
jmfcool has joined #ruby-lang
WillMarshall has joined #ruby-lang
butchanton has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
gnufied has joined #ruby-lang
Indian has joined #ruby-lang
Torrieri has joined #ruby-lang
Torrieri has joined #ruby-lang
looopy has joined #ruby-lang
patant has joined #ruby-lang
patant has quit [#ruby-lang]
jxie_ has joined #ruby-lang
<lucas> hi
<lucas> in ruby, I have a file with "k1 v1\nk2 v2\nk3 v3\n...". How do I read it and build a hash such as { k1 => v1, k2 => v2, k3 => v3 } ?
<lucas> I'm quite sure there's a nice way to do that :)
<chendo_> you want pro hax?
<lucas> pro hax ?
<chendo_> hash = Hash[*File.readlines("path/to/file").map { |line| line.split(/\s+/, 2) }.flatten]
jrwesolo has joined #ruby-lang
<lucas> nice
<Mon_Ouie> Remove both the splat and the #flatten
zmack has joined #ruby-lang
<lucas> I always forget about that Hash[] construct
<Mon_Ouie> I'd personally build the hash directly, rather than create two arrays before that
<chendo_> Mon_Ouie, why remove the splat and the flatten?
<Mon_Ouie> Unnecessary noise
<chendo_> needed noise
<chendo_> it won't work otherwise
<Mon_Ouie> Try it: Hash[ [[1, 2], [3, 4]] ]
<chendo_> ah
<chendo_> looks like i've always used * and flatten because Hash[ [1,2] ] never worked for me
<chendo_> noted
<Mon_Ouie> It used not work, indeed
<lucas> indeed, Hash[File::readlines('buildtime.list').map { |l| l.split }] works
jrwesolo has joined #ruby-lang
<rippa> my super-happy-fun way
<rippa> string.enum_for(:scan, /.*/).each_with_object({}) {|s, h| s = s.split; h[s[0]]=s[1]}
WillMarshall has joined #ruby-lang
<rippa> it adds a free nil => nil too!
<Mon_Ouie> I'd go with /(\S+) (\S+)/
banisterfiend has joined #ruby-lang
<Mon_Ouie> That way you don't need a call to split, you can just use $1 and $2 in the block
<rippa> great thinking
<banisterfiend> Mon_Ouie: hey
uniqanomaly_ has joined #ruby-lang
<Mon_Ouie> 'alut banisterfiend
<banisterfiend> Mon_Ouie: ill buy you a new schoolbag if you fix pry-coolline :D deal?
melter has joined #ruby-lang
<Mon_Ouie> Hm… no?
<Mon_Ouie> I guess you're talking about the up arrow part?
<banisterfiend> Mon_Ouie: yes
<banisterfiend> Mon_Ouie: is it fixable?
<Mon_Ouie> Probably, I just don't know what's causing it yet
<kke> rvm pkg install ree_dependencies -> half of the urls to packages are not working
<banisterfiend> Mon_Ouie: did you see the japanese blog post saying they liked coolline?
<Mon_Ouie> Nope
<kke> ah, rvm get head fixed it
<kke> i like to get head
s0ra_h has joined #ruby-lang
<banisterfiend> Mon_Ouie: are you interested or not really?
<Mon_Ouie> If it's written in Japanese, not really; I'd need Google to understand every single word
<banisterfiend> Mon_Ouie: you can translate the whole page into french if u like, it does an ok job into english anyawy
headius has joined #ruby-lang
<Mon_Ouie> Which is why you so often ask for a translation on IRC? :p
Arsen7 has joined #ruby-lang
jrwesolo has joined #ruby-lang
<banisterfiend> Mon_Ouie: haha how do u know that
<banisterfiend> Mon_Ouie: you spy on me
<banisterfiend> Mon_Ouie: i bet you have photos of me all over your walls
<Mon_Ouie> How do you know that? You spy on me! I bet you have photos of me all over your walls!
<banisterfiend> Mon_Ouie: shhh, i dont want everyone to know im a pervert
<banisterfiend> ;)
<banisterfiend> Mon_Ouie: what are your objc chops like
<Mon_Ouie> Haven't used it in a while now
solars has joined #ruby-lang
thrcka has joined #ruby-lang
sandbags has joined #ruby-lang
neoesque has joined #ruby-lang
Fullmoon has joined #ruby-lang
roadkith has joined #ruby-lang
PatrixCR has joined #ruby-lang
francisfish has joined #ruby-lang
PatrixCR has quit [#ruby-lang]
meise has joined #ruby-lang
d3vic3 has joined #ruby-lang
pp01bit has joined #ruby-lang
workmad3 has joined #ruby-lang
apeiros_ has joined #ruby-lang
<shevy> banister is just making up for neglect during childhood
vmoravec has joined #ruby-lang
futurechimp has joined #ruby-lang
PatrixCR has joined #ruby-lang
PatrixCR has quit [#ruby-lang]
batmanian has joined #ruby-lang
PatrixCR has joined #ruby-lang
rue has joined #ruby-lang
dragonkh has joined #ruby-lang
kings has joined #ruby-lang
dkam has joined #ruby-lang
<dkam> Hello people. I'm having an issue determining character encoding in ruby 1.9.3 : http://stackoverflow.com/questions/9799728/determine-character-encoding-in-ruby-1-9-3 Anyone know the right way to do this?
d3vic3 has joined #ruby-lang
<apeiros_> dkam: the correct way is to get your client not to give you input in the wrong encoding in the first place
<dkam> apeiros_: How do you do that? It's Googlebot
<apeiros_> you do that by a) providing proper links, b) setting the encoding in both the response header and the <meta> tag
woollyams has joined #ruby-lang
<dkam> apeiros_: Can you point me to some kind of web resource?
<dkam> apeiros_: Currently using '<meta http-equiv="content-type" content="text/html;charset=UTF-8" />'
<erikh> send a Content-Type header with that same data.
<erikh> anyhow, bedtime for bonzo
<erikh> later.
sora_h has joined #ruby-lang
PatrixCR has quit [#ruby-lang]
DEac- has joined #ruby-lang
<headius> someone bored enough to answer me some JS questions like a newb
<headius> ?
PatrixCR has joined #ruby-lang
futurechimp has joined #ruby-lang
morozovm has joined #ruby-lang
morozovm has joined #ruby-lang
fjfish has joined #ruby-lang
<andrewvos> headius: ergh I can try
cbm has joined #ruby-lang
<andrewvos> Someone tell me why rack is being a bitch and throwing Lint errors with "Content-Type" not specified?
<andrewvos> I'm writing a simple rack app
<andrewvos> Code inside .call doesn't get executed.
<andrewvos> So it means that before call some sort of assertion is denying entry
<headius> andrewvos: just trying to get the basics...
<headius> so people generally do OO-like stuff by having a function act as a constructor that returns a set of key/function pairs, right?
woollyams has joined #ruby-lang
<workmad3> headius: javascript OO is... interesting
<headius> I suppose OO isn't my primary question, but I'm trying to understand typical usage with an eye for optimization similar to how V8 does it
<headius> like, there's also nested scopes, but my general impression is that most stuff doesn't use many levels of scoping
<headius> at least not for heavy-hit properties
<headius> some of that might be optimizable anyway...once closing over a scope it never changes
<headius> hmmm
<workmad3> headius: ok, I think you're wanting answers to questions that are deeper than 'newbie' level :/
<workmad3> headius: may I suggest #jquery or #javascript? :)
<headius> curses!
<workmad3> headius: you're wanting to know about byte-code optimisation and JIT stuff if you want to get into the sort of optimization that v8 does... that's not newbie! :)
<andrewvos> Right, please disregard teh previous question
<chendo_> lol
<headius> oh I suppose not
<chendo_> headius is looking for ideas for jruby
<chendo_> amirite?
<workmad3> andrewvos: you were doing something silly? :)
<headius> I guess I'm coming from the direction of optimizing JS and trying to learn the language :)
<workmad3> headius: yeah... I would suggest that you forget about optimisation stuff when learning JS... start from scratch again :)
<workmad3> headius: and also decide if you're more interested in JS on something like node (so server-side) or in the browser... they are quite different beasts in my experience (mostly browser)
<headius> well, I'm not so interested in it as a user
<headius> I'm interested in implementing it
<workmad3> oh... err, ok
<andrewvos> Ok so that is my problem
<andrewvos> Those variables in the first class aren't accessible between requests in heroku
<andrewvos> But they are localy
<andrewvos> locally*
<andrewvos> I assume something is different here
<workmad3> headius: if you don't want to use JS, why implement it? :)
<headius> well, if you don't want to build houses, why make a better hammer?
<headius> so others can build houses
<workmad3> headius: without building houses, it's very hard to actually appreciate what makes a better hammer? ;)
<workmad3> andrewvos: maybe lines 10 and 11 should be changed to ||= ?
<andrewvos> workmad3: Oh my god
* andrewvos smashes his computer up
<workmad3> andrewvos: bit extreme? :)
<andrewvos> workmad3: :(
<workmad3> headius: I mean kudos on wanting to do an implementation of JS... and as a learning exercise I'd say go and do it... but if you want to improve on something like v8, you're going to be hard pressed as an individual I believe
<headius> workmad3: well, I don't have to build a house to make a better hammer...I just need to understand the physics of nails and wood
<headius> that's how much of JS I want to learn right now :)
<headius> I don't think it would be difficult to beat V8 building atop JVM
<chendo_> haha
<workmad3> headius: seriously? heh
<chendo_> laying down the gauntlet?
<headius> yes, seriously
<chendo_> workmad3, headius works on jruby
<chendo_> he knows things
<workmad3> chendo_: fair enough :)
<headius> V8 has nothing on Java for perf, and invokedynamic makes dynamic calls as fast as Java
<headius> so it's just a matter of getting invokedynamic to do what JS needs
* workmad3 bows out of the fight
<chendo_> brb
<headius> I'm working on a prototype of what V8 does, in a very simple form
<workmad3> I don't know enough about this side of things... I'm under the impression that v8 is a pretty solid, performant implementation of JS, but I don't know many details
<headius> if not for JS then for some new prototype language for when I don't have enough other stuff to work on :D
ioga_wrk has joined #ruby-lang
<headius> V8 is definitely good
<headius> I just have this thing for the JVM
<workmad3> :)
<chendo_> headius, can you add docstrings to jruby? :D
<headius> easily
<chendo_> sweet
<chendo_> someone suggested something along the lines of %d{Docs here}
<chendo_> kinda looks ugly though
<workmad3> headius: quick question. Are you wanting to avoid current JS implementations on the JVM, or are you already looking at things like mozilla rhino?
gray has joined #ruby-lang
<chendo_> holy shit, i think i just came up with a way to make python-style docstrings work in ruby
<headius> %d would be easy to add to parser, but % stuff is still a little ugly to me
<chendo_> yeah i don't like it
<chendo_> i only use %Q or %r
<headius> I don't want to get into a bikeshed about it, buy I have thought of stuff like &"..." and whatnot
<headius> there's no unary &
<headius> ruby used up all the good symbols
<headius> hmmm
<headius> @@@
<headius> @@@This is a docstring@@@
<headius> sorta like triple-quoting
<chendo_> well yeah
<chendo_> """ works
<headius> maybe it's too noisy
<chendo_> so """ blah """ is valid syntax
<chendo_> all you need is a parser to get it out
<chendo_> hold on
<apeiros_> what purpose does it serve?
* apeiros_ thinks he's missing context…
<matti> :>
tekin has joined #ruby-lang
<headius> the reason I wouldn't try to do triple quotes is because ruby already has heinously complicated string parsing
<headius> for heredocs and the like
<headius> but I'm not a parser guy
_inc has joined #ruby-lang
<chendo_> well it's not that bad i'm pretty sure
rue has joined #ruby-lang
<chendo_> cause """ hello there """" evaluates to "" + " hello there " + ""
<dominikh> that's hideous :/
<chendo_> so?
<headius> heheh
<chendo_> it'll work
<chendo_> i'm trying to write a parser for that now lol
<Mon_Ouie> What about documentation that contains quotes that don't always match?
<chendo_> theeen it's not so great heh
<chendo_> use single quotes :D
<Mon_Ouie> What if a method had an example like… gsub('"', '\\\\"')?
* apeiros_ still doesn't get the purpose of yet another string literal…
<apeiros_> what would it do that current strings don't/can't?
<Mon_Ouie> apeiros_: I guess the point is having the syntax for documentation actually be part of the language
<matti> Hi Mon_Ouie
<Mon_Ouie> 'alut matti ;)
<workmad3> apeiros_: yeah, it was a discussion about docstrings, python style ):
<apeiros_> Mon_Ouie: ok, but then why invent something new?
<workmad3> *:)
<apeiros_> I mean we already *have* doc tools, which extract "docstrings"…
<apeiros_> so why not standardize over that? o0
gray has joined #ruby-lang
c0n has joined #ruby-lang
<workmad3> apeiros_: about the only thing I can think of that a python-style docstring adds is the ability to get it easily within code... however, I think you're right, especially as tools like pry let you get to docs within code and calling .docstring on a method isn't as nice in ruby as it is in python
Eising has quit [#ruby-lang]
<workmad3> (well, pry lets you get to the docs within the REPL, which is about all the docstring stuff from python is really useful for :) )
<apeiros_> workmad3: well, I think the use-case for docs accessibility is indeed only in REPL & debugging envs, so it'd be up to those to provide "nice" syntax for retrieval, for anything else, I wish for an inverted way of introspection for a while now
<apeiros_> i.e. Introspection.instance_variables(object)
<apeiros_> that'd allow inspecting things like BasicObject instances as well…
<dominikh> well, and in testing
<apeiros_> (and docs are just one kind of introspection)
<apeiros_> dominikh: you mean as in automated testing of examples? or what's the use case there?
<dominikh> apeiros_: right.
<dominikh> I think Python/Python test frameworks do that
<chendo_> Mon_Ouie, won't matter
<chendo_> because unless the first line after the def method; starts with """
<chendo_> it won't look for it
<apeiros_> anyway, my 2 cents @ doc strings: just enhance existing doc comments, e.g. #doc to start a doc comment, I wouldn't hinge that on strings
<chendo_> mine won't require a syntax change though :D
<apeiros_> (especially since if you want anything halfway more decent, it'll be a structure anyway, see yard…)
<apeiros_> chendo_: using comments doesn't either :-p
<workmad3> dominikh: there are tools that let you run examples in docstrings as test cases... but you could probably do the same with a ruby tool looking at yard or similar
<chendo_> yeah but that's no fun :p
<apeiros_> also it gives the opportunity to easily harvest existing docs
<dominikh> workmad3: true.
ttilley has joined #ruby-lang
<manveru> does anybody know whether rtomayko has a new nick or something?
achamian has joined #ruby-lang
<shevy> who is rotomoko
<chris2> manveru: afaict no
<chris2> manveru: but havent seen him on irc for a long time
<manveru> nickserv says he hasn't been around in a year
<chris2> he also didnt blog for a year :P
<manveru> he hasn't merged my pull request for two months :P
Indian has joined #ruby-lang
francisfish has joined #ruby-lang
r3dskade has joined #ruby-lang
gianlucadv has joined #ruby-lang
dejongge has joined #ruby-lang
beiter has joined #ruby-lang
<chendo_> so
<chendo_> i present: python style docstrings in vanilla ruby
<darix> chendo_: how do you handle generated code?
batmanian has joined #ruby-lang
<chendo_> people use docstrings in generated code?
DMKE has joined #ruby-lang
rue has joined #ruby-lang
dr0id has joined #ruby-lang
<Defusal> 10000 calls to Process.getpgid take real: 0.001128
<Defusal> a lot longer if the pid does not exist, probably because of an exception being raised
<Defusal> but im very happy with that performance, it means i can poll many pids status very often without an issue
<chendo_> okay...
pygmael has joined #ruby-lang
<manveru> chendo_: been there, done that :)
<Defusal> since EventMachine only supports kqueue for watching pids, which is only supported by OSX and BSD, this is great news for anyone who needs it
<chendo_> manveru, hmm?
<Defusal> maybe ruby can have an implementation which does not raise an exception one day, as exceptions are costly
<manveru> Defusal: ffi?
<Defusal> manveru, never used that
<Defusal> i was considering implementing a eventmachine netlink interface for realtime process status updates
<Defusal> but thats far too much effort, and now that i've benchmarked this, its more than good enough
<chendo_> what are you writing?
<Defusal> a daemon that installs, configures, spawns, watches and manages gaming servers
<manveru> on failure you just get -1
<chendo_> wow
<chendo_> nice
<Defusal> manveru, cool, but slower than using getpgid
<manveru> aaww :(
pygmael has joined #ruby-lang
<Defusal> oh wait
<chendo_> really?
<chendo_> mapping to a C function is slower?
<chendo_> impossible
<Defusal> ok erll
<Defusal> well*
<manveru> well, ruby is mapping to a C function too, but it doesn't do dynamic dispatch i think
<chendo_> yeah, but it'll throw an exception
<chendo_> which is slow
<chendo_> this should be pretty low level and faster
<Defusal> manveru, it takes the same amount of time regardless of whether it exists or now
<Defusal> not*
<Defusal> so thats double as long when it does exist
<manveru> Defusal: the ruby one?
<Defusal> but 33.5x faster when it doesn't exist
<Defusal> the C one
<manveru> both are C
<Defusal> well the ffi one
<manveru> hm
<manveru> lemme try the fiddle one
<Defusal> i guess the performance hit is with the dynamic dispatch
<Defusal> but the speed increase without the exception is cool
<Defusal> im benchmarking 1 million calls
<chendo_> i need to use that someday
<Defusal> when it doesn't exist, stdlib versions takes 6.230000 0.130000 6.360000 ( 6.375920 )
<Defusal> compared to ffi: 0.180000 0.010000 0.190000 ( 0.190158 )
<andrewvos> What's a good pattern for launching a process at the beginning of a cucumber test run, ten killing it afterwards. The process is not a binary it's ruby code that has to be executed.
<andrewvos> So, I don't mean "process" at all
<darix> chendo_: no. but your code might encounter such thing
<chendo_> what?
imajes has joined #ruby-lang
<chendo_> if it doesn't have a source_location
<chendo_> it will bail
<Defusal> andrewvos, i'd say fork { require ... }, but you'll have to remember to kill the process afterwards
headius has joined #ruby-lang
<andrewvos> Defusal: What's the best way to kill it afterwards?
<andrewvos> Process.kill("KILL",meh) ?
<Defusal> yeah, 'TERM' should work fine too
<andrewvos> Defusal: That worked great thank you
<Defusal> :)
Hakon|mbp has joined #ruby-lang
<chendo_> you should trap signals etc to ensure that process gets killed properly
<manveru> phew
<manveru> srsly, DL is a PITA
<Mon_Ouie> DL as in stdlib's FFI library?
<manveru> yeah
<manveru> took me ages to find out how to bind that
<andrewvos> chendo_: THanks
<manveru> Defusal: wanna bench that too?
<chendo_> np
<manveru> Defusal: that's MRI 1.9.3 only though, worse even than FFI
<Defusal> manveru, will do
<Defusal> worse how?
tekin has joined #ruby-lang
<Defusal> i quite like 1.9.3
<manveru> well, it won't run on jruby i think :)
<manveru> or rbx
<headius> we have a partial impl of DL atop FFI
<headius> I don't know how good it is
<manveru> headius: highlights ftw :)
<headius> it is pretty gross though
<headius> DL I mean
<manveru> indeed
<matti> manveru: !
<matti> manveru: Have have you been? ;]
<manveru> matti: yes, i've been :D
<matti> ;p
<manveru> still am, in fact
<manveru> what about you?
<headius> I am therefore I am
<matti> s/Have/How/
<Defusal> no matter how many times i read about the advantages of jruby, i still wouldn't want to run ruby on the JVM
<matti> manveru: I am too tired :P
<matti> manveru: Apologies.
<headius> Defusal: your loss
<chendo_> headius, implemented python-like docstrings in pure ruby: https://gist.github.com/2146319
<manveru> np
<matti> headius: :)
<Defusal> in fact, i try very hard to avoid ever installing that bloated thing on my servers
<Defusal> headius, not really
<matti> manveru: I fail when it goes to English when I am sleep-deprived :)
<headius> I'm not sure what your point is bringing it up other than to troll me
<matti> manveru: Its my second language :)
Sailias has joined #ruby-lang
jimmyy111 has joined #ruby-lang
<Defusal> headius, are you talking to me?
<manveru> matti: parle italiano?
<headius> Defusal: yes
<matti> manveru: No.
<headius> chendo_: hah, nice
<Defusal> you're the one that brought it up, i was not speaking to you
<manveru> matti: 日本語はどうですか
<headius> not bad for a prototype
<chendo_> it's pretty hackish
<chendo_> i thought there was a method on Method to get the source?
<chendo_> or maybe i just saw that in pry and assume it existed
<headius> Defusal: manveru brought it up and I answered his implicit question
<manveru> chendo_: pry goes to greeat lengths to get that ':)
<manveru> chendo_: 1.9 provides Method#source_location
<chendo_> yeah that's what i'm using to get it
<chendo_> i just thought there was a built in rather to do what i'm doing
<Mon_Ouie> banister wrote the method_source gem Pry uses to get it
<headius> I still think .source should just be added to Method and Proc
<headius> it really wouldn't be hard to add to any impl
<manveru> i'd be happy getting the arguments :)
<chendo_> it'll use more memory though
<matti> manveru: はい、そうです~ では、私は日本語を少しだけ話します。
<manveru> but that was removed as well :(
<manveru> matti: それでもたりる
<headius> a bit more, but it could be compressed
<matti> manveru: I am at begginer level in Japanese.
<headius> as it is the AST holds on to almost the entirety of parsed bytes from files in one way or another
<Defusal> headius, i guess i missed that then, i saw no question, i was just responding to what manveru said to me
<manveru> matti: my wife is japanese, so we raise our son trilingual
<headius> so i doubt it would be that much more
<Defusal> manveru, interesting.. fiddle tried to require 'rails/engine'
<manveru> the... what?
<Defusal> i have rails 3.2.2 installed but it fails
<chendo_> lol
<headius> Defusal: if you'd like to actually talk about jruby, I'm happy to do so, but I'm satisfied having told manveru that we have DL partially supported in JRuby
<chendo_> he's installed the fiddle gem
<Defusal> => /usr/local/lib/ruby/gems/1.9.1/gems/fiddle-0.3.2/lib/fiddle.rb:2:in `require': cannot load such file -- rails/engine (LoadError)
<yorickpeterse> chendo_: perhaps you can abuse Method
<manveru> what on earth, fiddle is in stdlib
<rippa> rails fails
<yorickpeterse> Though I'm not sure if you can do so from the inside of a method itself
<chendo_> there's also a gem
<Defusal> manveru, oh
<Defusal> well it couldnt require
<manveru> Defusal: i don't mean the gem :P didn't even know that exists
<Defusal> so i had to install the gem
<headius> what is the fiddle gem anyway? is it the same thing?
<Defusal> manveru, how do i use it then?
<chendo_> yorickpeterse, well that's what i'm doing at the moment
<chendo_> nah
<headius> I think we might have partial fiddle support, dunno
<chendo_> fiddle gem is some rails engine
<manveru> Defusal: just require fiddle?
<headius> well, it requires ok
<headius> I dunno what it does
<Defusal> => /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- fiddle (LoadError)
<manveru> hm
<manveru> 1.9.3?
<Defusal> ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
<manveru> do you have libffi installed?
<matti> manveru: Sweet :)
<Defusal> i installed it less than a week ago
<matti> manveru: Are you Italian?
<headius> yeah, need libffi on your system somewhere
<headius> except in JRuby :P
<manveru> matti: austrian
<Defusal> i don't think so
<bougyman> ahahaha
<matti> manveru: :)
<headius> FFI gem oughta be good everywhere, that's what I'd recommend
<manveru> headius: it's not on rbx :(
<matti> manveru: I'd love to move to Japan. I think I told you this before? Then you've said, that I should not :)
<headius> well, rbx FFI support has improved a lot
<manveru> they have their own FFI that isn't fully compatible either
<matti> manveru: Hehe
<chendo_> does anyone actually use rbx in production?
<headius> few folks have patched some major things recently
<headius> like callbacks, etc
<Defusal> manveru, exactly what package must i install?
<bougyman> Defusal: for what?
<manveru> Defusal: archlinux?
<headius> Defusal: you need libffi somewhere on your system
<Defusal> ubuntu
<Defusal> i tried installing libffi-ruby1.9.1
<Defusal> it still doesn't work
<manveru> uh, no
<headius> is there no libffi package?
<bougyman> you're using ubuntu's ruby?
<Defusal> bno
<Defusal> no*
<bougyman> that package is an ubuntu package, made for ubuntu's ruby
<headius> libffi is a weird library
<manveru> you need something like libffi-dev or something
<Defusal> ah, right
<headius> nobody really owns it anymore
<bougyman> manveru is correct.
<headius> we ship our own copy in jruby
<Defusal> manveru, surely that wont help unless i recompile ruby
<manveru> Defusal: aye
<Defusal> bleh
<Defusal> ok
<bougyman> Defusal: you don't have to recompile ruby.
<bougyman> are you using rvm or system ruby?
takaokouji has joined #ruby-lang
<headius> does it use DL to load libffi?
<bougyman> ubuntu doesn't have 1.9.3, where'd you get that from?
<Defusal> bougyman, manually compiled
<headius> this is getting a little chickeneggy
<bougyman> ok, then install libffi-dev then gem install ffi ?
<manveru> headius: how can it use dl to use libffi when dl is now implemented with libffi?
<Defusal> ok
<manveru> bougyman: no, the ffi gem was working fine
<Defusal> i didn't know there was an ffi gem
<manveru> he's trying to use dl/fiddle
<bougyman> ok, confused.
<Defusal> ah
<bougyman> i don't know a thing about fiddle.
<Defusal> ok so then i must recompile ruby
<manveru> fiddle makes dl a bit less disgusting
<headius> meh, just use FFI
<Defusal> manveru, so i need to do anything else?
<headius> pretty sure fiddle isn't even implemented on rbx, so that's a non-argument :)
<headius> chendo_: I dunno (about rbx in production)
<Defusal> headius, trying to find better performance
<manveru> libc = DL.dlopen('/lib/libc.so.6')
<manveru> getpgid = Fiddle::Function.new(libc['getpgid'], [Fiddle::TYPE_INT], Fiddle::TYPE_INT)
<headius> Defusal: hmmm...dl and FFI oughta be mostly a wash
<matti> FFI \o/
<manveru> even the dlopen line makes me shiver
<headius> and fiddle for that matter
<headius> FFI has had a lot of work to be fast though
enebo has joined #ruby-lang
<Defusal> manveru, recompiled ruby and it still doesnt work
<manveru> headius: we're looking for the fastest way to call getpgid
<Defusal> must need to do an extra step
<manveru> Defusal: sorry, no idea
<manveru> it's always working here
<headius> module Getpid; extend FFI::Library; ffi_lib 'c', attach_function :getpgid, [:int], :int; end
<manveru> headius: been there, done that :)
<headius> heheh
<manveru> just wanted to compare performance of dl
<headius> ahh ok
<Defusal> manveru, ext/fiddle/extconf.rb
<Defusal> headius, that is 2x slower than Process.getpgid when the process exists
<headius> hmmm
tommyvyo has joined #ruby-lang
<headius> may I see the bench?
<Defusal> once i get this working :P
<Defusal> `initialize': /lib/libc.so.6: cannot open shared object file: No such file or directory (DL::DLError
<manveru> yay
<Defusal> guess i don't have libc \o
<manveru> yours is probably in /lib/local or something
<Mon_Ouie> Or /usr/lib
<Defusal> theres no /lib/local and its not in /usr/lib
<manveru> /usr/local/lib ?
<manveru> debuntu always haas fun places to hide things
<manveru> might just be called libc.so
<manveru> but i dunno if dl can resolve symlinks
<Defusal> did a full filesystem search, theres /lib32/libc.so.6, /lib/x86_64-linux-gnu/libc.so.6 and /lib/i386-linux-gnu/libc.so.6
<manveru> any of those should be fine
lsegal has joined #ruby-lang
<manveru> you just need a libc.so
<Defusal> `initialize': /lib32/libc.so.6: wrong ELF class: ELFCLASS32 (DL::DLError)
<Defusal> :P
<manveru> yay
<manveru> so it's the second one
<Defusal> yeah, x64 one looks fine
lsegal has joined #ruby-lang
<manveru> FFI does all that for you :P
<Defusal> fiddle is a looooot slower
<Defusal> like 9x
bryancp has joined #ruby-lang
<manveru> great
<manveru> i pledge to never recommend it to anyone anymore :)
slyphon has joined #ruby-lang
<headius> Process.getpgid and FFI version are about same on JRuby...midway between the same two on 1.9.3
<Defusal> headius and manveru, http://pastie.org/3641200
<headius> rbx is way slower on both
<headius> Defusal: thanks
<Defusal> ok, so ffi is great if you need to check pids that may not exist
<Defusal> but the stdlib version will be fine for watching pids until they disappear
<headius> the overhead for missing is probably all exception raising
<Defusal> yup, like my comment says :)
<headius> comment?
<headius> wow, fiddle is slow on 1.9.3
<Defusal> next to that row on the benchmark results
<headius> it's basically the same on jruby, and a lot faster than 1.9.3
<kke> how come "foo" "bar" => "foobar"
<headius> Defusal: ah
<headius> kke: because shut up
<headius> :)
<headius> just one of those oddities in Ruby
<headius> some other langs probably do it
<Defusal> oh wow
<Defusal> something i did not know about ruby :D
<Mon_Ouie> That's useful in languages like C that don't have that many string literals
<Mon_Ouie> In Ruby I'd use heredocs more often
<Defusal> yeah
Joeysomo has joined #ruby-lang
<chendo_> lol
<chendo_> i'm abusing that oddity for my docstrings
Progster has joined #ruby-lang
<yorickpeterse> meh, I personally would just stick with YARD docs
<Defusal> im so happy i took the time to implement my interactive console over DRb
<Defusal> makes working on the eventmachine platform a lot either, has coloured output and even autocomplete since its live
<Defusal> cant compare to any editor, which can hardly ever complete anything, since the code is very dynamic
achamian has joined #ruby-lang
<chendo_> Defusal, so.. pry-remote?
<chendo_> which Mon_Ouie wrote
beiter has joined #ruby-lang
<Defusal> i didn't know there was such a thing, im sure it would have saved some effort
gray has joined #ruby-lang
msisk has joined #ruby-lang
Fullmoon has joined #ruby-lang
<Defusal> what would be the better option here: store database id in websocket connection instance and query the database everytime you need to interact with the model, or store the model instance and have the model make the cached instance reload everytime it writes to the db?
<Defusal> i guess the best approach is an identity map and store the id
dv310p3r has joined #ruby-lang
headius has joined #ruby-lang
Sailias has joined #ruby-lang
bglusman has joined #ruby-lang
Tukeke has joined #ruby-lang
Tukeke has joined #ruby-lang
voker57 has joined #ruby-lang
voker57 has joined #ruby-lang
judofyr has joined #ruby-lang
<judofyr> \o/
mdiedric has joined #ruby-lang
mztriz has joined #ruby-lang
<rue> pry-remote-em no less.
fvollero has joined #ruby-lang
msisk has joined #ruby-lang
soahccc has joined #ruby-lang
JEG2 has joined #ruby-lang
<judofyr> rue: interesting
jxie has joined #ruby-lang
mistym has joined #ruby-lang
noru has joined #ruby-lang
io_syl has joined #ruby-lang
outoftime has joined #ruby-lang
achamian has joined #ruby-lang
tekin has joined #ruby-lang
A124 has joined #ruby-lang
DMKE has joined #ruby-lang
rayners has joined #ruby-lang
<Defusal> hmmm
<Defusal> anyone know what under circumstances Process.kill('KILL', pid) will fail to kill the process
<Defusal> i've just noticed it happen again
<rue> When you use the wrong pid?
<Defusal> oh that is a very good point :|
<Defusal> i thought i had fixed the consistency issues
<Defusal> guess not
<Defusal> chances are the database just got out of sync while i was testing, hopefully that wont happen again
headius has joined #ruby-lang
<judofyr> Defusal: sounds fun to debug when suddenly random processes (with recycled pids) gets killed
<Defusal> indeed :P
<judofyr> headius: what are your thoughts on the "we need a new (async) Rack" btw?
<Defusal> im all for an async rack
<headius> I hadn't heard about it
<Defusal> neither had i
<Defusal> but i havn't written a synchronous web application in years
<headius> I know this has been going around and around in various forms though
<headius> async frameworks are for people who can't afford threads
<judofyr> and I think tenderlove is working on something secretly
<judofyr> headius: or for long-running IO :)
gray has joined #ruby-lang
<gray> hi, i understand syntax Ruby
<gray> but now i start learn ruby on rails
<gray> and wtf...
<Defusal> gray: #ror
<Defusal> good luck :)
<judofyr> gray: what part are you wtf-ing on? it's quite complex if you've never played with HTTP, HTML or anything like that
<headius> judofyr: well yeah, but people seem to think they need async everywhere
<headius> take the extra five minutes and implement a simple state machine rather than use wacky native tricks like setjmp
msisk has joined #ruby-lang
<headius> your CPU will thank you for not pulling the rug out from under it every 10ms
<judofyr> hm, is it coroutines you're talking about now? :S
<gray> judofyr: i undrestand html, css, http
<Defusal> gray, its a powerful, highly abstracted framework. theres a lot to learn, start with http://guides.rubyonrails.org/
<Defusal> i learnt rails at the same time as ruby, back before rails 2... yet i have hardly used it ever :P
<Defusal> i still keep up to date with it though, at the very least i can give some of my friends advice on it and gems to use with rails
<Mon_Ouie> class Micropost < ActiveRecord::Base is just the syntax for inheritance in Ruby
Tukeke has joined #ruby-lang
Tukeke has joined #ruby-lang
<headius> judofyr: async usually seems to lead people into coroutines
<headius> because they want the execution stack to maintain state for them
<headius> there's no way that's good for execution pipelines and memory caches
<rue> But ASYNC IS FASTER THAN EVERYTHING
<Defusal> gray, validates is an ActiveRecord helper method, all methods are documented on the above link i gave you
<gray> judofyr: sorry, don't understand you
<rue> Also, indeed, #ror
<headius> rue: I've queued up your comment and will respond asynchronously some time in the future
<rue> headius: Well, I dispute that
<rue> headius: OK, I've queued my response
<judofyr> headius: the truth is, when you have code that works in a purely sync-manner, using coroutines leads to easier-to-read code than state machines…
Tukeke has quit [#ruby-lang]
<judofyr> headius: (and by "sync" I mean "fetch this thing from HTTP", "then fetch this thing from another place" and "then respond"
<judofyr> )
<headius> I exclude IO from my async wrath
<headius> it's all the other crap people make async that's just silly
<Defusal> the truth is, when your codebase is heavy on IO, threads are just unnecessary overhead and syncing is unnecessary complexity
<headius> Defusal: syncing is necessary to use multiple cores on any shared resource
<Defusal> headius, well thats their own faulty, people will do stupid shit no matter what tools they use
<headius> async doesn't do crap to change that, either
<judofyr> headius: aaaah. is this some rant against Celluloid?
<headius> async just lets you slice your one core into finer chunks
<headius> judofyr: no, celluloid actually does it right...it uses threads plus fibers
<Defusal> headius, indeed it is, but you can design the platform with that in mind from the start
<judofyr> headius: then I wonder where you've seen people doing async wrong…
<judofyr> (if you're not talking about I/O)
<headius> fibers are just there to allow worker threads to defer on some IO resource that's not ready
<headius> judofyr: mostly stuff like ilya's making the entire rails request pipeline async with fibers just so it can defer on database queries
<Defusal> database queries are still IO
<headius> yeah, so maybe abstract the logic of sending queries to the database rather than swapping out the entire rails call stack to wait for it
<headius> post queries to a queue for some smaller worker pool to handle
d3vic3 has joined #ruby-lang
<headius> no, let's save off 100-odd call frames and swap them out every time
<headius> that will be fast
<headius> anyway
<judofyr> headius: you still need the Rails stack to support asyncness though (you either need callbacks or fibers in the controller
<headius> I think it's the third drink talking
<headius> I should get dinner
adambeynon has joined #ruby-lang
dr0id has quit [#ruby-lang]
dous has joined #ruby-lang
outoftime has joined #ruby-lang
andrewhl has joined #ruby-lang
rolfb has joined #ruby-lang
<rue> Where in the world is headius? India?
<headius> You never know from day to day
Stalkr_ has joined #ruby-lang
<headius> tomorrow I might be in Finland
<headius> impossible to tell
_inc has joined #ruby-lang
<headius> as it happens, yes, I'm in India
<rue> Sweet, timezone extrapolation success
<headius> listening to the wives of relocated american professionals gripe about the room service
<headius> it's a thrill, let me tell you
dfr|mac has joined #ruby-lang
gray has joined #ruby-lang
wmoxam has joined #ruby-lang
<shevy> hmmm
morozovm has joined #ruby-lang
rippa has joined #ruby-lang
havenn has joined #ruby-lang
shtirlic has joined #ruby-lang
igaiga has joined #ruby-lang
ridders24 has joined #ruby-lang
<ridders24> hi all
<judofyr> hi ridders24
rushed has joined #ruby-lang
mixandgo has joined #ruby-lang
headius has joined #ruby-lang
<ridders24> is it possible in ruby to give it a .txt input containing colums of data which are part of file names, which is could then search network drive volumes and then produce an html output with the filepath of where that file is?
Indian_ has joined #ruby-lang
<mixandgo> it's the first time ever I hear about dRuby and there's a book out from pragprog... any advice on what is it good for ? (I am mostly doing web app development with rails)
<headius> there's a book on dRuby?
<headius> I think you may be confusing your druby's
<headius> or I am
<headius> weird
<workmad3> ah, DRb :)
<headius> ok...so dRuby to me means Diamondback Ruby, a research project to statically analyze and optimize Ruby code
Heimidal has joined #ruby-lang
scampbell has joined #ruby-lang
<headius> so I guess it was my confusion
<mixandgo> to me it sounds like wannabe nodejs :) but what do I know
<workmad3> mixandgo: hardly
cdnz has joined #ruby-lang
<workmad3> mixandgo: node.js is a concurrency model, DRb is a distributed computing model
<mixandgo> workmad3: so in practice what would you use it for ?
<headius> node.js is a ball of snot
<Defusal> mixandgo, i used it a day ago to implement a remote console
achamian has joined #ruby-lang
<headius> actually I think node is pretty clever, but bashing it is the fashion these days
<headius> and I loves me some fashion
<workmad3> mixandgo: I'd probably consider it for a grid-computing style system where I couldn't easily put the problem into map-reduce
<headius> I still have a hard time recommending ruby for anything compute-intensive
<workmad3> mixandgo: but basically, the difference between DRb and node.js is like the difference between scaling out and scaling up ;)
<Defusal> mixandgo, i have a console that executes on my live EventMachine based platform and returns the result and anything output to std streams while its executing, it also colours the output and provides autocomplete by inspecting constants and methods when i press tab
<headius> though if you're doing compute-intensive and not using JRuby, you're just playing in the dirt
<chendo_> heh, ruby for anything compute intensive
<Defusal> its just a easy way to run methods over a network on another ruby process
Jay_Levitt has joined #ruby-lang
<mixandgo> I think I have a clearer picture now, thanks
<workmad3> Defusal: well, that's one way to use it if you're not creating a drb cluster anyway ;)
<headius> everyone should pump everything through Rinda
<headius> it's the only way to be sure
<Defusal> workmad3, i try use it as little as possible since the EM implementation of it sucks really badly :(
<Defusal> and all my apps are EM
<Defusal> so i only use it to connect to locally spawned processes
<Defusal> the EM version basically doesn't only fail to reconnect when the connection is lost, but it actually never detects the connection being lost some of the time
<headius> it's 100% wrong 50% of the time
<rue> Welcome to TCP/IP
CarlosAkaRubyNoo has joined #ruby-lang
<Defusal> rue, i have countless tcp protocols implemented just fine with EM ;)
<Defusal> i spend 80% of my time working with such stuff when im using ruby
kain_ has joined #ruby-lang
<Defusal> the EM version of DRb just seems to have been abandoned
<Defusal> and not even after it was stable
<wmoxam> headius: I'm going to switch a Rails app server to jruby and I want to be able to track the perfomance. Any tips as to what metrics I should track? I'm thinking render time, memory+CPU usage. Anything else?
<chendo_> newrelic
<chendo_> best tool for monitoring
<wmoxam> (basically want to compare if it's worth switching)
slyphon has joined #ruby-lang
<Defusal> wmoxam, let me know what results you find
* wmoxam needs to read up on jruby+rails best practices
<wmoxam> Defusal: I have a suspicion that it really depends on the app
andrewhl has joined #ruby-lang
<wmoxam> the app that I'm going to try is Rails2+Ruby 1.8.7. I suspect that the results could be different for a Rails 3.x+Ruby 1.9 app
<Defusal> yeah as far as i know, you'll only start seeing such a big difference if you use parts of the java framework
<Defusal> but i'd be interested to hear performance and ram usage
<wmoxam> yeah
<Defusal> but yeah, 1.8 is many times slower than 1.9
<wmoxam> Defusal: I've got a surplus of RAM ATM
kitallis has joined #ruby-lang
<Defusal> should should upgrade to 1.9.3 first
<Defusal> so do i.. my host gave me 16GB on my 8GB contract
<wmoxam> as I can't run enough instances to use it (it's pointless to run more instances than cores)
toertore has joined #ruby-lang
<wmoxam> RAM is super cheap
<Defusal> yeah it is, but i don't like to waste it on java
<wmoxam> I bought 8GB for my desktop for like $35
<Defusal> i have far better things to waste it on :P
<Defusal> hence why i don't even install JVM on my servers
<wmoxam> Defusal: I'm totally willing to trade RAM for speed
<chendo_> wmoxam, oh i wouldn't say it's pointless running more instances than cores
<chendo_> unless your ruby does no IO whatsoever
<wmoxam> chendo_: I would
achamian has joined #ruby-lang
<chendo_> assuming your DB is on another box
<chendo_> and assuming you're using standard mysql driver (non async)
<wmoxam> yeah, I thought that too
<chendo_> a core will be sitting there doing nothing while it waits for IO
<Defusal> yeah better have a few extra instances since they're threaded
otertore has joined #ruby-lang
<wmoxam> chendo_: in my testing it hasn't worked out that way
<wmoxam> :/
<wmoxam> you mostly end up with processes fighting for CPU time, making all requests slower
Teddy2steper has joined #ruby-lang
<chendo_> what was your test app doing?
<wmoxam> it's just a straight up web app
<chendo_> if it was just a simple app that did nothing but render, then sure, since it's not really doing any IO
<wmoxam> it was under heavy load
<wmoxam> (this was a production app)
<imperator> wmoxam, unless you have a mac, then ram is like $1500 per stick
<chendo_> only if you bother buying from apple
<chendo_> which nobody smart does
<imperator> :-P
<wmoxam> imperator: lol
* wmoxam has a mac
* chendo_ too
<chendo_> wmoxam, what were you using to monitor?
<chendo_> we run 6 instances on a 2 core machines
<chendo_> works great
<chendo_> load stays below 1
<Defusal> bleh
<wmoxam> chendo_: this was an 8-core box
<Defusal> something is making my spawned processes die on signal
<Defusal> i thought i fixed this yesterday, but perhaps i didn't test manual ^C
<Defusal> any ideas?
<Defusal> i am using Process.detach(pid)
<chendo_> wmoxam, what was the monitoring?
<wmoxam> chendo_: munin
<wmoxam> had a couple of boxes
<chendo_> does it do deep app monitoring?
<wmoxam> chendo_: I know about New Relic. I've used it before (f that's where you were going)
<chendo_> yeah
looopy has joined #ruby-lang
<wmoxam> basically I had one box with 8 instances, and one with 12. The one with 12 couldn't keep up
<wmoxam> the one with 8 was fine. Same traffic to both (50/50 split)
<chendo_> all depends on the app
<chendo_> if your app doesn't do much IO, then it may well use more CPU time
<wmoxam> rendering time > db time. :p
<chendo_> lol
<chendo_> well then
<Defusal> render less?
<chendo_> his point is that his app doesn't do much DB
<wmoxam> ...
<Defusal> yeah :P
<wmoxam> most of the traffic, yes
tr-808 has joined #ruby-lang
<wmoxam> chendo_: you run the db on the same box?
<chendo_> lol hell no
<wmoxam> k, :D
<wmoxam> yeah, that'll kill your box pretty quick :D
<chendo_> step 1 of scaling: move db onto its own box
jmfcool has joined #ruby-lang
darkf has joined #ruby-lang
<wmoxam> chendo_: I do a lot of stuff asyncronously
<chendo_> nice
<chendo_> threads?
<wmoxam> queue + queue runner
<wmoxam> seperate box
<chendo_> i was thinking of doing my next app SOA
<chendo_> a service for every part of the system
<Defusal> wmoxam, you should look at moving the heaviest async stuff to an EventMachine platform
<chendo_> rofl
<wmoxam> Defusal: why is that?
<chendo_> Defusal, EM is not your hammer
<chendo_> well, not a hammer
<andrewvos> How do I change the http host used in rack test?
<Defusal> well, im assuming by "queue runner" you mean threaded
<chendo_> so yeah, then in the web app itself, when you want something, you fire off the request in a thread, then wrap it in a future
<chendo_> Defusal, it can be on another machine
<chendo_> slash a cluster
<wmoxam> Defusal: no, I mean a service that sits there and watches the queue for jobs to do
<Defusal> it'll still scale better on the other machine if its EM based
<wmoxam> and then does them
<chendo_> why?
<chendo_> why will it scale better?
<Defusal> wmoxam, yeah well a threaded service
* wmoxam blinks
<Defusal> well again, it depends on the type of work
<chendo_> wmoxam, i know, right?
<wmoxam> there are no threads involved
<Defusal> i guess i bad a bad assumption
<Defusal> when he said he does a lot of stuff async
<Defusal> i assumed that is IO
<wmoxam> sure it is
<Defusal> im guessing now it is not
<Defusal> well then it will scale better with EM
<chendo_> wat
<wmoxam> like when I need to send an email I do it async
<chendo_> reasons, Defusal
<chendo_> use them
<Defusal> faster, less overhead
Hakon|mbp has joined #ruby-lang
<wmoxam> when I need to make calculations for a reporting table, I do it async
<chendo_> when all you want is a distributed job processing system
<wmoxam> basically anything that's not needed to service a request I do it async
<chendo_> you wouldn't go straight to EM
<Defusal> calculations are not IO, so if they are very heavy then threading is better of course
<chendo_> cause that's a waste of time
<wmoxam> lol
<chendo_> lol
<Defusal> chendo_, if you say so
<Defusal> i start with EM
<chendo_> Defusal, have you ever worked on a big production environment?
<Defusal> and use threads later if heavy processing is needed
<wmoxam> Defusal: are you an EM sales person?
<wmoxam> WHAT ARE YOU TRYING TO SELL ME? ;)
<chendo_> well, sizable production environment
<Defusal> chendo_, yes, i designed it, EM based :P
<Defusal> that was a while ago already
<chendo_> how many servers?
<Defusal> that depends how far up they are scaled
<chendo_> how many physical servers?
<chendo_> or virtual
<Defusal> i was just contracted out for a few months to design and develop the backend and an interface to the frontend
<Defusal> back then it was still beta, they'll have a few servers by now
<Defusal> wmoxam, don't mind me, i just have a strong hatred towards using threading for IO-heavy stuff
<chendo_> …. what?
<Defusal> i hate unnecessary overhead
<chendo_> why?
<Jay_Levitt> Any Sublime Text 2 users? I just updated from 2189 to 2190 on Mac and now ST crashes at startup when the Ruby package is installed.. and the sublime forum is down :/
<Defusal> same reason i hate bloated frameworks and languages
<wmoxam> Defusal: I'm not threading anything
<Defusal> wmoxam, yeah ok, well then you're doing one thing at a time i guess
<wmoxam> unless you have a totally different definition of threading than I do
<Defusal> in which case, if speed isnt an issue, it doesnt matter
<chendo_> yeah i'm also confused
<chendo_> there's nothing wrong with using threads for IO
<Defusal> chendo_, keep telling yourself that :P
<Defusal> theres a reason all the best scaling servers are async
<Defusal> and there are many
<Defusal> same reason i would never use apache, but nginx is awesome
<wmoxam> whatever, Ruby doesn't scale, Rails definately doesn't scale, lets move on
<Defusal> it uses a tiny fraction of the ram, and scales to the moon
* wmoxam wanders off to be productive
<Defusal> all the large platforms that were designed with scaling in mind scale perfectly well
<Defusal> you just have to know how to approach scaling
* Defusal goes back to getting nowhere with debugging this child process spawning
<chendo_> Defusal, yeah i think you mean evented when you mean async
<Defusal> yeah, i do
<Defusal> it is often used in place of evented, so i guess i have picked up a bad habbit over the years
wallerdev has joined #ruby-lang
<Defusal> my first async experience was hacking a windows scripting language to use winsock with windows gui events for sockets
<Defusal> evented*
<Defusal> a while after that i worked with a plain C evented game server, implementing new protocol that i reverse engineered
<Defusal> but since moving from python and other languages to ruby, i use EM for almost every project, twisted just wasnt as nice
<chendo_> so the thing is, most people don't like reinventing the wheel
<chendo_> there's no real point for wmoxam to use EM because it's more work then necessary
<chendo_> delayed job or resque will scale perfectly well and easily
<chendo_> if you're looking for super duper ricing performance, then don't use ruby
<Defusal> yeah well, it depends on many things
<Defusal> but yeah, if you're not familiar with async evented architecture, the learning curve is gonna be too much of a pain
<chendo_> it's not even the learning curve
<chendo_> it's the actual effort required to implement it
<chendo_> why not just use a job queuing system when you want one?
<chendo_> unless it doesn't do something you want
<Defusal> well for most of my personal platforms, they are a single application, so queuing jobs and getting data back after they are completed would be a lot more effort than using a single EM platform
<Defusal> but mostly, what i do 90% of the time is IO-related
<Defusal> and EM scales great with IO, has little overhead and doesn't require syncing
<chendo_> so with your EM platform, does each part run in its own process?
<Defusal> like i just said, most of my personal projects are a single EM reactor
<chendo_> what about production?
<chendo_> like apps that make money
<Defusal> if it needs to scale more for ajax requests or something, seperate requests can be moved to a second reactor
<Defusal> and so on
tsp has joined #ruby-lang
<chendo_> is any of your EM stuff tested?
<Defusal> of course...
tsp_ has joined #ruby-lang
mixandgo has joined #ruby-lang
ridders24 has joined #ruby-lang
<ridders24> Im totally new to ruby, When i try and run this but of code http://pastie.org/3642271 I get the error "undifined method 'find' file:class <nomethoderror
khan12345674000 has joined #ruby-lang
khan12345674000 has quit [#ruby-lang]
thrcka has joined #ruby-lang
sandbags has joined #ruby-lang
jstemmer has joined #ruby-lang
<Defusal> ok looks like i have finally pinpointed the issue
<Defusal> even with Process.detach, the signals are being forwarded to the spawned process
rolfb has joined #ruby-lang
<Defusal> does anyone know how to stop this? i'm already trapping the signals in the daemon so that it can exit cleanly
H2H has joined #ruby-lang
Indian has joined #ruby-lang
<Defusal> i suppose i could try using a small ruby script that is spawned, which does the spawning and returns the actual processes id
<Defusal> pid*
<Defusal> but that should be unnecessary.. hopefully someone knows how to stop this behaviour
<rue> Are you sure it's that way?
<Defusal> i replaced the process with a ruby -e script rue
<Defusal> if that script uses trap("INT", "IGNORE"); it is not killed when the daemon that spawned it traps a signal
Teddy2steper has joined #ruby-lang
<Defusal> i'll be back in a bit, if anyone can think of anything else i can try, please let me know
achiu has joined #ruby-lang
<rue> No, I mean that signals shouldn't be getting to a detached child
<rue> So either you're not signaling right, or you're misinterpreting the problem
havenn has joined #ruby-lang
solars has joined #ruby-lang
io_syl has joined #ruby-lang
darkf has joined #ruby-lang
jmontross has joined #ruby-lang
butchanton has joined #ruby-lang
hagabaka has joined #ruby-lang
hagabaka has joined #ruby-lang
Tukeke has joined #ruby-lang
apeiros_ has joined #ruby-lang
mrneighborly has joined #ruby-lang
<Defusal> rue, hence the test i described to you..
ascarter has joined #ruby-lang
Tukeke has quit [#ruby-lang]
mrneighborly has joined #ruby-lang
<Defusal> the signal is definitely reaching to detached process, an only on ^C not when the daemon is killed in other ways
<Defusal> so Process.detach does not actuall detach signals :(
deryl has joined #ruby-lang
<Defusal> rue, i will make you a test case, since you don't believe me
<Defusal> and anyone else who is interested, or may have some idea for a workaround
<Defusal> still appears to me as if Process.detach is bugged
mrsolo_ has joined #ruby-lang
havenn has joined #ruby-lang
mssola has joined #ruby-lang
Tukeke has joined #ruby-lang
achiu has joined #ruby-lang
wallerdev has joined #ruby-lang
jasiek has joined #ruby-lang
malev has joined #ruby-lang
vpamulap has joined #ruby-lang
urbanmonk has joined #ruby-lang
Tukeke has quit ["Hackers and Workers of the World! Unite!"]
<rue> .detach isn't the same as your typical double-fork detach, I think
<Defusal> rue, well then, what is the solution?
<Defusal> i need the pid, and i can't make the server binary that is spawned trap and ignore signals... so then the only way is to spawn a proxy script with traps signals, spawns the real process and returns its pid?
<Defusal> *that traps signals
tbuehlmann has joined #ruby-lang
<Asher> i'm confused what doesn't work with the standard approach?
<Defusal> if that is the case, it is a pity ruby has no way to accomplish that
<Defusal> Asher, did you look at my test case?
<Asher> didn't see it - link me?
<Defusal> i think Process.detach is just flawed and should be detaching those signals
<Defusal> but either way, i need a workaround
<rue> The .detach description clearly says what it does
joshkraemer has joined #ruby-lang
<Defusal> rue, well then what is the best workaround you can suggest?
<Defusal> a proxy ruby process?
<Asher> i'm looking for code where i did similar recently give me a sec
<Defusal> ok
havenn has joined #ruby-lang
<rue> I'm really not sure this is even a fundamentally sound technique. It sounds like you have ever-increasing problems from trying to force an unsuitable solution
<rue> But I haven't really been paying attention, sorry. I'm preoccupied by the airbender currently
Nss has joined #ruby-lang
<rue> Lessee what Asher's got
<Defusal> i see posts about this issue dating back to 2007, http://www.ruby-forum.com/topic/124429
<Defusal> no solutions
<Asher> so you want child processes to detach such that when the parent process ends they continue?
<Asher> is that the issue?
publicvoid has joined #ruby-lang
francisfish has joined #ruby-lang
<Defusal> Asher, yes, but specifically when the parent is killed with SIGINT
<rue> Double-fork is the usual solution
<Defusal> because Process.detach works, until i ^C
<Asher> well if you trap INT before you fork then obviously both processes will trap the signal
<Defusal> Asher, look at my test case :|
<Asher> i am
<Asher> you are forking on the signal
<Defusal> rue, then a proxy script is the best solution
<Defusal> since i need the pid
<rue> How about pidfiles?
<Defusal> Asher, that is for proving the process exists later
<Defusal> please try actually read the whole testcase :|
<Asher> i mean i set up a program recently that you load the main program, launch subprocesses, quit
<Asher> the subprocesses continue
<Asher> and i store a pidfile (although it's actually a yaml file w/data including the pid)
<rue> Asher: That's not a problem if the processes are properly detached. In that case, signaling the parent has no effect on the child
<Asher> right - so what prevents that here?
<Defusal> rue, worse than a proxy process... the pids are stored in a database, almost identical instance can be spawned
<Asher> i used Process.detach to achieve that
<Defusal> Asher, run my test case and press ctrl + c
<Defusal> and you will see exactly what the problem is
<Defusal> like i said Asher, if you use Process.detach, the child continues after the parent exits, but if you sent the parent SIGINT, it is still forwarded to the children
<Defusal> i'll go with a proxy spawner script then, looks like there is no better solution
Indian has joined #ruby-lang
tekin has joined #ruby-lang
Heimidal has joined #ruby-lang
Gekz has joined #ruby-lang
Gekz has joined #ruby-lang
ericmuyser has joined #ruby-lang
<countskm> was wondering if someone might give me feedback what im doing wrong:
<countskm> trying to eval a datastructure and introduce it as expected in an rspec test
<countskm> line 10 is what i am having problems w/
<apeiros_> you can't introduce new local variables with eval
<countskm> ah
<apeiros_> just do expected = eval(…)
<countskm> ah
<apeiros_> also, why eval?
<countskm> gotcha - perfect
<rue> You can't introduce them into the normal context
<rue> They'll still persist in eval space though
<countskm> the data structures are getting big and clutter up the test
<countskm> i want to try this and move only what varies inline in the tests
<apeiros_> countskm: I wasn't asking why you put them outside of the test
<apeiros_> I asked why you use eval as your way of choice to load them
<countskm> ah - right like using a marshalling package
<countskm> new to ruby - used to perl
<rue> Ah, perl
<countskm> i have one ds in yaml
<rue> The universal explanation
<countskm> hehe
<countskm> but i like looking at the ds as a ruby construct from a file - is there something that would marshall it in and out in that format?
<countskm> i might just rewrite it in yaml that does look nice and works nice too :-)
<countskm> rue: believe me perl is an ancient memory after learning ruby ;-)
Nisstyre has joined #ruby-lang
rolfb has joined #ruby-lang
kings has joined #ruby-lang
<countskm> thanks expected = eval(...) worked like a charm
thrcka has joined #ruby-lang
<Defusal> this is turning out to be a lot harder than i could ever have hoped it would be
<Defusal> bleh
litejk has joined #ruby-lang
litejk has quit ["399 Ruby 1.9.3-p125: http://ruby-lang.org | Paste >3 lines of text on http://pastie.org or use a gist"]
<countskm> :w
gianlucadv has joined #ruby-lang
Gekz has joined #ruby-lang
<Defusal> at this point, im not even sure why its behaving like this
<uniqanomaly_> 1.8.7-p352 :1899 > data.read("res0910.txt")
<uniqanomaly_> ArgumentError: wrong number of arguments (1 for 0)
<uniqanomaly_> from (irb):1812:in `floor'
<uniqanomaly_> from (irb):1812:in `read'
<uniqanomaly_> from (irb):1899
<uniqanomaly_> from :0
<uniqanomaly_> 1.8.7-p352 :1900 > data.read
<uniqanomaly_> ArgumentError: wrong number of arguments (0 for 1)
<uniqanomaly_> rotfl
<Defusal> uniqanomaly_, please read the topic before spamming the channel
tekin has joined #ruby-lang
<uniqanomaly_> k
ericmuyser has joined #ruby-lang
<uniqanomaly_> syntax error ;>
<Defusal> ok so rue, i can't even get this to work
benanne has joined #ruby-lang
<Defusal> if i don't use Process.detach on the spawner proxy script, it goes defunct until its child process ends, if i do use it, EM doesn't fire the callback for EM.system once the proxy process ends and the event only fires when the application is shutting down :|
<Defusal> if anyone has any ideas, i'm all ears :|
<Defusal> i mean, i could make a DRb interface for the proxy script to connect to, but goodness, i really don't want to.. the proxy script is bad enough as is
ridders24 has joined #ruby-lang
<ridders24> hi all
<ridders24> anybody know how I get file.find to provide an output?
fukushim_ has joined #ruby-lang
ericmuyser|air has joined #ruby-lang
Phrogz has joined #ruby-lang
<Phrogz> What is the ~least amount of code (without golfing) I can write to get a web server up that only serves static files from a directory?
<apeiros_> Phrogz: about 5 lines was mine, using webrick
brianpWins has joined #ruby-lang
<apeiros_> there's faster servers around for ruby nowadays, though
<Phrogz> Damn; I'm looking for a one-line to kick off the command line.
curtism has joined #ruby-lang
curtism has joined #ruby-lang
<apeiros_> write a gem? :)
davpoind has joined #ruby-lang
Torrieri has joined #ruby-lang
<Phrogz> :)
<Phrogz> I'm assuming it will involve Rack::Directory, but I only use Rack indirectly through Sinatra and Thin; I have no idea how to boot up the simplest possible Rack app and "go".
<Phrogz> This yak-shaving brought to you by my persistent desire to not do the work I so desperately need to do.
<Phrogz> ...and Chrome's sucktaculor/"safe" inability to perform XHR over file://
<Phrogz> Thanks. Now fighting the rack docs to figure out how to bootsrap somethng, let's see how small that gets.
kyrylo has joined #ruby-lang
kyrylo has joined #ruby-lang
<Asher> what's to fight?
frem has joined #ruby-lang
t has joined #ruby-lang
<apeiros_> rack has some middleware that ships with the default, which can serve data from the filesystem
<Phrogz> Asher: the lack of documentation for methods and/or any examples related to this edge case I'm shooting for.
<Phrogz> Rack::Handler::Thin.run Rack::Builder.new{ run Rack::Directory.new('.') } # Closer!
l0st1 has joined #ruby-lang
<apeiros_> Phrogz: so where does that obsession come from anyway?
<Phrogz> ruby -rrack -e "include Rack; Handler::Thin.run Builder.new{ run Directory.new'' }"
<Phrogz> apeiros_: I just need to serve some files from various directories and shaving this yak and having this in my command history is more informative than writing or relocating a mini ruby file.
<apeiros_> Phrogz: as said, write a gem then and install it
<apeiros_> call it something mnemonic, like serve, or servedir
<Phrogz> That's an uninteresting and lumpy yak in my opinion :)
<Phrogz> But I appreciate your advice.
<apeiros_> pffff
<apeiros_> actually… might be a nice hack-night adventure for next wednesday
<apeiros_> write a small rack-serverpages based gem
Austin__ has joined #ruby-lang
<Phrogz> That would be nice to have around in the wild. :)
<apeiros_> yeah, I imagine something like `rackdir` to serve the current directory, interpreting a couple of suffixes, have a flag like '-p, --plain' to stop it from interpreting anything
_inc has joined #ruby-lang
pemeon has joined #ruby-lang
<Phrogz> Here's my blog entry about it, in case you make one and want to clearly win with a simple `rackdir` :) http://phrogz.net/simplest-possible-ruby-web-server
mytrile has joined #ruby-lang
mssola has joined #ruby-lang
nofxx has joined #ruby-lang
<Defusal> rue, i've ended up having to replace EM.system(cmd) {|output| } with EM.defer { output = `#{cmd}`; EM.next_tick { pid = output.to_i; do_stuff_with(pid) } }
<Defusal> and "cmd" spawns a ruby -e process which ignores sig INT, spawns the actual process, detaches from its pid and then prints the pid
<Defusal> one hell of a mission to spawn and properly detach from a process
<Defusal> and i hate to have to use another thread, but at least it works :/
<Defusal> hopefully ruby will have better support for properly detaching from spawned processes one day
dejongge has joined #ruby-lang
justinmcp has joined #ruby-lang
dejongge has joined #ruby-lang
pygmael has joined #ruby-lang
Hakon|mbp has joined #ruby-lang
Indian has joined #ruby-lang
Indian_ has joined #ruby-lang
crudson has joined #ruby-lang
paul0` has joined #ruby-lang
batman has joined #ruby-lang
<Guest51966> hello?
<imperator> yes, this is internet
<mistym> welcome to internet!
<apeiros_> what what what?
<apeiros_> damit! I thought I was on the tubes!
* apeiros_ goes away
<rue> Hello, Internet residence, random dude speaking
mrsolo_ has joined #ruby-lang
mrsolo_ has joined #ruby-lang
gaivs has joined #ruby-lang
<Guest51966> i'm stuck
<mistym> Guest51966: What's the issue?
<epitron> physically or mentally
<Guest51966> trying to do a exercise
<epitron> and you got stuck in the exercise equipment?
<Phrogz> So...physically
<Guest51966> for a tutorial i was going through
* epitron gets some lard
<Phrogz> Damn weekday warriors.
<Guest51966> on ruby
<gaivs> hello world
<Guest51966> it's a grandma application
<epitron> hello! internet speaking. how may i direct your call?
<Phrogz> Guest51966: Don't mind the side chatter; keep on asking your question.
<epitron> (hat-tip to rue)
masterkorp has quit ["WeeChat 0.3.2"]
<Guest51966> well it says i have to say bye 3 times before the application quits
<Guest51966> i can't figure out how to do it
<Phrogz> Guest51966: 3.times{ puts "bye!" }
<epitron> unless you mean, the user has to type 'bye' 3 times
<Phrogz> Oh :)
<Guest51966> it says 3 times in a row
<Phrogz> That does sound like a grandma application
<Guest51966> lol
<Guest51966> i can give the link
<Guest51966> to the website if you want
<Phrogz> Guest51966: have a variable "bye_count". Each time the user says something other than "bye", set it back to 0. Each time they say bye, bye_count += 1
<Guest51966> hmmm
<Guest51966> ok
<Guest51966> thanks
<Guest51966> i'll give it a go
simon_weber has joined #ruby-lang
<epitron> there are many ways to do this example
<epitron> you'll probably hit upon a few weird ones :)
<epitron> here's a way you may not have considered: http://codepad.org/m6vgNEYA
<epitron> it's a little bit clever though
<Guest51966> thant's
<gaivs> Hello people. I searching for a library for statical analysis of Ruby Code. I.e., an ruby library that parses a ruby code and try to identify his classes, fuctions, et cetera. I didn't find it anywhere. Someone can help me?
<epitron> also it's broken
<Guest51966> oh
<manveru> gaivs: ripper
<manveru> gaivs: ruby stdlib
<Guest51966> so what does += mean?
<Phrogz> Guest51966: x += 1 is x = x + 1
<manveru> x += y is like x = x + y, also see *= and /=
<Guest51966> say = gets.chomp
<Guest51966> while say != "BYE"
<Guest51966> if say == say.upcase
<Guest51966> puts "NO, NOT SINCE 1938!"
<Guest51966> say = gets.chomp
<Guest51966> else
<Guest51966> puts "HUH?! SPEAK UP, SONNY!"
<Guest51966> say = gets.chomp
<Guest51966> end
<Guest51966> end
<epitron> hahah
<Guest51966> that's what i got so far
<Phrogz> Here's another way to check to see if the last three inputs are "bye" :) history = []; loop{ history << gets; ... exit if history.last=="bye" && history[-3,3].uniq.length==1 } :)
<Phrogz> Guest51966: In the future, please do not paste more than 2-3 lines of code in the channel.
<Guest51966> ok sorry
<epitron> Phrogz: oooooooo.. i like that one :)
r3dskade has joined #ruby-lang
<epitron> Guest51966: we also lost all the indenting
<mistym> Guest51966: No worries. There are websites that are good for that, like gist.github.com and pastie.org
<Phrogz> Guest51966: http://pastie.org
<manveru> you think there was indenting? :)
<Phrogz> lol :)
<Phrogz> Hey manveru, you're up at an odd hour, no?
<manveru> Phrogz: i moved to europe
<Phrogz> !
<Phrogz> Whereat?
<manveru> very south germany
<Phrogz> I mean, specifically. SO I CAN GOOGLE MAPS YOU.
<Phrogz> :p
<manveru> lol
<Phrogz> That's a surprising change. Was it a good choice?
<manveru> mother got sick, so we help her now
<epitron> so much shorter
<Phrogz> manveru: I'm sorry to hear it, and good for you.
<Phrogz> What does southern Germany have going for it in your opinion? Besides a nice drive to Italy :)
<imperator> i know a little german, his name is manveru
<epitron> *rimshot*
<manveru> imperator: i'm austrian :)
<epitron> g'day mate!
<epitron> LULULUL
vpamulap has joined #ruby-lang
<epitron> jk
<imperator> a dumb & dumber fan i see
<manveru> Phrogz: not much i think
<manveru> i mean, it's not as crazy hot and humid as tokyo
<manveru> and i can actually understand what people are talking about
* imperator has been to bad aibling, that's it
<Phrogz> manveru: I thought your Japanese skillz were mad, yo?
<manveru> i've only learned for 3 years so far
<Defusal> epitron: :austrian != :australia
<Phrogz> Well, you're 3 years ahead of me, anyhow.
<manveru> Defusal: i think that was the point of his joke
<Phrogz> We hope, anyhow.
<manveru> now you runined it :P
<Phrogz> You Defusal'd his joke.
<imperator> yeah, way to go joke explainer
<Phrogz> It defusal'd out.
<Defusal> manveru: his joke was invalid from the start :P
<imperator> oh, look, another osx update that forces me to reboot, how windowsy
<manveru> Phrogz: anw, it's not bad, yuma was 3 when we got here, and now he's speaking japanese, english, and learning german :)
<Phrogz> imperator: You make my heart sad. And yes. How very. :(
<imperator> IT'S 2012, WHERE IS MY MICROKERNEL?
<Phrogz> manveru: Did he get the Japanese from you guys or school friends?
<manveru> the HURDacolypse is upon us!
<manveru> Phrogz: from us
<Phrogz> Wow; good for you. :)
<manveru> Phrogz: i'm learning alongside him, my wife is japanese
<imperator> grumble...grumble...something...something...beos
<manveru> haiku got a microkernel?
<Phrogz> Oh, I forgot that. More sense it makes, yes.
<imperator> yeah, i should look at haiku again, see where it's at
<manveru> it's booting on sandybridge now, mostly
<Phrogz> You crazy kids and your dreams.
<Phrogz> THE OS WARS ARE A TWO PARTY SYSTEM. DON'T WASTE YOUR VOTE ON A WORTHLESS DREAM.
* manveru gets wasted on coffee
<mistym> Phrogz: Don't blame me, I voted for Plan 9.
<imperator> manveru, hey, hey, begeistart will be in dusseldorf on april 2
<imperator> *begeistert*
<manveru> imperator: do i know her?
<manveru> oh
<imperator> http://www.begeistert.org/faq - actually, march 30th - april 2
<manveru> yeah, düsseldorf is just like 5 hours from here
<rue> manveru: Do you know Peter Schmidt? He lives in Bavaria
<manveru> rue: do you know hans söllner?
<rue> I'm sure I do
<manveru> hm, more like 7 hours :(
<manveru> rue: and i have no idea who peter schmidt is... sounds like there must be 500 of him
<rue> I didn't like Düsseldorf much, but München is great. And Frankfurt(-am-Main) isn't too bad either
<rue> manveru: ;)
<imperator> manveru, train an option?
<rue> Though that's only marginally “southern”
<manveru> imperator: i think i have to go into that area for work anyway
<manveru> will see
chimkan_ has joined #ruby-lang
* imperator downloads the latest haiku .iso
<imperator> manveru, does "begeistart" mean something else and i've missed a joke? i get no translation for it
<imperator> (or geistart)
Stalkr_ has joined #ruby-lang
mixandgo has joined #ruby-lang
<rue> Geist is a spirit
tekin has joined #ruby-lang
Stalkr_ has joined #ruby-lang
msisk has joined #ruby-lang
<rue> Which doesn't really help
<imperator> yeah, i translated begeistert as "Be Haunt" :)
<rue> Could be haunted
<rue> Actually that would be -ert
<rue> (If it were)
<rue> Languages are great.
canton7 has joined #ruby-lang
imperator has joined #ruby-lang
<imperator> reboot complete, computer now fully operational
woollyams has joined #ruby-lang
gregf has joined #ruby-lang
<rue> imperator: IRCing from Haiku, then?
malev_ has joined #ruby-lang
<imperator> nope, had to install an osx update....HAD TO
<drbrain> imperator: that damned webkit is in everything ☹
<Phrogz> Sense, it makes none.
<Phrogz> Version your shit, link to the right version on launch. Or something.
<Phrogz> (Implementation details are left as an exercise to competent engineers.)
<apeiros_> imperator: begeistart is probably a misspelling of begeistert
<apeiros_> which means excited
<rue> Spirited
<drbrain> Phrogz: for a security fix, I'm happy knowing that all exploitable versions are no longer running
<drbrain> Phrogz: waiting for launch for other updates would be fine with me
<Phrogz> Oh. Well, yeah, for that.
<apeiros_> na, spirited is semantically futher away I'd say
<apeiros_> ethused/enthusiastic/excited is more in the sense of the common use of begeistert
<imperator> drbrain, webkit? who? what?
<rue> apeiros_: I mean in the sense of a "spirited speech". It's close enough that there's probably a common root
<drbrain> imperator: on OS X, webkit renders HTML, and many processes use it since it's a very flexible and fast way to create a UI
s0ber_ has joined #ruby-lang
y3llow_ has joined #ruby-lang
<imperator> drbrain, ah, thanks
<apeiros_> any good classes/modules to handle versioned ruby objects, with the ability to "travel in time", i.e. get the object back into the state of a given moment?
<rue> Someone did a functional lib that had that implemented for some things (to support immutable data structures), but that was a long time ago…
<rue> apeiros_: Is this data only or data, methods[, visibility, …] ?
<apeiros_> oh, data only
rdavila has joined #ruby-lang
<apeiros_> it's sufficient if it works for a plain {string => string/int} hash
<rue> So basically def set_something(smth); @smth << smth; end; def get_something; @smth.last; end ?
WillMarshall has joined #ruby-lang
<apeiros_> hm, like: data = {:at => Time.mktime(2000), :data => 123}; data.update(:at => Time.mktime(2001), :data => 255); data.travel_to_time(Time.mktime(2000))[:data] # => 123
Defusal_ has joined #ruby-lang
Defusal_ has joined #ruby-lang
<imperator> hm, anyone checked ruby for this one? http://news.ycombinator.com/item?id=3730348
cored has joined #ruby-lang
cored has joined #ruby-lang
darkf_ has joined #ruby-lang
<drbrain> imperator: seems sane even back to 1.8.7: http://paste.segment7.net/rw.html
<imperator> drbrain, looks good, thanks
martha has joined #ruby-lang
}0 has joined #ruby-lang
shtirli__ has joined #ruby-lang
<rue> apeiros_: Interesting. And needs to be fast enough that versioning on(to) disk won't work?
<apeiros_> I currently have no performance expectations
<rue> Actually, I wonder if anyone's made an in-memory version of git
Austin__ has quit [#ruby-lang]
}0 has joined #ruby-lang
<apeiros_> hm, that's actually an additional problem. keeping that completely in-memory doesn't scale. the dataset is relatively small (a couple of dozen KB, which ruby naturally inflates to a one digit MB number), but since the data could easily be used over a decade…
<apeiros_> soooo… kiss and deal with the scale problem later? or overengineer and have a perfect solution that can be left untouched for decades? :)
<rue> I'd probably go with the former with the “twist” of just gitting it ;)
<apeiros_> the bigger problem is probably that traveling in time over the whole dataset will be expensive… so I can either work with snapshots (I happen to know that the data currently is only updated monthly anyway), or I keep deltas…
<apeiros_> or I could go with a combination
<apeiros_> so you have a maximum of deltas to apply…
<epitron> apeiros_: how about just keeping the current versions in memory, and putting the old version on disk.. w/ deltas
<apeiros_> oh, I guess I just figured out, why they provide a sequence number, by which the changes have to be processed. foreign-key integrity…
<apeiros_> epitron: yeah, that'd be towards "overengineered perfect first try" :)
<epitron> really? :)
<epitron> the deltas shouldn't be too hard to generate
<apeiros_> sure. mixed approach >> more complex than >> single mechanism
<epitron> you can just override the []= method on hash
<epitron> and update() i suppose
<apeiros_> I have custom classes already, so that's not a big deal
<apeiros_> I mean, I don't have to go extend hashes
<apeiros_> and yes, generating deltas is trivial
<epitron> oh man
<epitron> you could do this really easily with json
<epitron> it would be very fast too :)
<apeiros_> eeeeew
<apeiros_> and, eh, no, you couldn't
<epitron> your revisions would be a textfile where each line is a json hash
<apeiros_> json can't even represent date/time
<epitron> and if you want to go back in time, you'd do "reverse_each" on the file :)
<apeiros_> lol, ok…
<epitron> and if you need to access specific revisions, you can generate a secondary index file
<apeiros_> wouldn't quite work out ;-)
<epitron> BTree style
<epitron> BDB
<epitron> well, the serialization is a problem
<apeiros_> I think I'll go with custom implementation, in-memory only. I can add "swapping" later
<epitron> but you said you wouldn't mind { "string"=>int/string}
<apeiros_> (famous last words)
<epitron> haha
<rue> epitron: You're well on your way to implementing a DB, good work :P
<epitron> hahaha
<epitron> well, the reverse_each thing is pretty easy
<epitron> the whole thing, without Btree indexing, would be pretty short
<epitron> i'm just thinking of a structure that would be really fast to update, and fast to roll-back
<epitron> you can't beat appending to flat files for speed
<epitron> and reverse_each is quite snappy
Nisstyre has joined #ruby-lang
<epitron> i bet tokyo cabinet would be good if you want to use some kind of marshal database
rolfb has joined #ruby-lang
Guest48483 has joined #ruby-lang
srbartlett has joined #ruby-lang
<martha> hi
<imperator> hi martha
<drbrain> hi martha
<martha> I'm learning ruby and I'm trying to figure out how to do something,but I'm not sure how to call it
<martha> maybe dynamic variable name?
<drbrain> martha: we use a Hash where PHP would use a "variable variable"
RickHull has joined #ruby-lang
<drbrain> martha: you can dynamically create instance variables, but using a Hash is much better
<drbrain> def foo(name, args) @objects ||= {}; @objects[name] = Module::Class.new(args) end
<apeiros_> "I can" != "it's a good idea to"
<drbrain> def quux(name) @objects[name].do_something end
<apeiros_> variable variables effectively means that you downgrade the whole lvar system to the performance of a hash
<apeiros_> (or that you have to add in additional code analysis to optimize on a case-per-case base)
<drbrain> apeiros_: martha and that it is much harder to maintain than using a Hash
<apeiros_> but due to the nature of php, parse-time matters a bit more, that's also a bad idea…
<apeiros_> oh, yeah, don't get me started on maintainability of such code :)
<apeiros_> "oh hey, where did that lvar come from?"
<apeiros_> also security implications
<rue> And the dead kittens :(
kitallis has joined #ruby-lang
<RickHull> question about constant scope / lookup: http://pastie.org/3644065
<RickHull> (on 1.8.7)
<RickHull> actually, i haven't tested the pasted code, but it's distilled from my actual code. :/ running now
<RickHull> hmm, i do get "x" like I expect
<drbrain> RickHull: I get "x" on 1.8.7 in irb
<RickHull> yeah, i have something else going on
H2H has joined #ruby-lang
<martha> drbrain: thanks, that works!
darkf_ has joined #ruby-lang
<martha> drbrain: I'm still trying to figure out the ruby way of doing things :-)
slaytanic has joined #ruby-lang
havenn has joined #ruby-lang
jacobwg has joined #ruby-lang
dkam has joined #ruby-lang
futurechimp has joined #ruby-lang
martha has quit [#ruby-lang]
<TTilus> just stick with the non-stupid way ;)
nazty has joined #ruby-lang
curtism has joined #ruby-lang
Hakon|mbp has joined #ruby-lang
<apeiros_> hm, Timeshiftable an understandable name? :)
<apeiros_> (an item that can be shifted in time includes Timeshiftable)
<rue> Timeshiftabletable
<rue> Timeshiftabletableable
<drbrain> apeiros_: TimeBandit
<apeiros_> drbrain: is that a ruby library?
<drbrain> apeiros_: unfortunately ☹
io_syl has joined #ruby-lang
<apeiros_> hm, didn't find it on rubygems, neither via google - got a link?
<apeiros_> I only found time bandits, which seems to be a performance logger for rails…
<drbrain> apeiros_: I mean, the name is used, but I don't think it overlaps at all with what you want https://rubygems.org/gems/time_bandits
<drbrain> yeah
<apeiros_> ah
<drbrain> using the name "Time Bandits" for a fancy logger?
<drbrain> shameful!
<rue> We should go back and fix this
<RickHull> drbrain: http://pastie.org/3644065
<RickHull> it's surprising because Foo::Bar::Razz::X has a value
<drbrain> RickHull: yeah
<rue> apeiros_: I'm not sure ‘timeshift’ is the best name (although presumably people using it will know what it's about)
<apeiros_> rue: better names welcome… I find naming stuff always the hardest thing…
<apeiros_> how about Historizable?
<RickHull> 2 hardest things in CS: cache invalidation, naming things, and off by 1 errors
<rue> I'd just call it versioned
<rue> Well, maybe. I guess that's a little vague about the time aspect
<apeiros_> was just going to say
<apeiros_> the navigation is time based
<apeiros_> with versions, you usually deal with revision-numbers or tags or somesuch
<Asher> time slip!
<imperator> apeiros_, primer ;)
<rue> Dateable :)
<apeiros_> rue: it's not a girl!
<apeiros_> imperator: hu?
<rue> Could be a boy
postmodern has joined #ruby-lang
<imperator> apeiros_, it's a movie that involves time travel
<apeiros_> imperator: ah
<imperator> low budget, but pretty good, popular and brain burning
<apeiros_> yeah, low budget & successful usually means good story
<rue> I think I'd still go with versioned since the date is (I think?) incidental in that it's not the determining factor when the version is created, it's the other way around
<rue> But, given that a user will already know what they're getting, I think Timeshift is fine
woollyams has joined #ruby-lang
msisk has joined #ruby-lang
JEG2 has joined #ruby-lang
boxmo has joined #ruby-lang
NOKAH has joined #ruby-lang
WillMarshall has joined #ruby-lang
Tearan has joined #ruby-lang
RickHull has quit [#ruby-lang]
igaiga has joined #ruby-lang
ericmuyser has joined #ruby-lang
RickHull has joined #ruby-lang
<imperator> hm, looks like "timecop" is open ;)
<apeiros_> hm? timecop gem exists, no? at least I use it :)
<apeiros_> it's quite nice for testing
Carnage\ has joined #ruby-lang
}0 has joined #ruby-lang
nofxxx has joined #ruby-lang
takaokouji has joined #ruby-lang
mackk has joined #ruby-lang
boxmo has joined #ruby-lang
Jay_Levitt has joined #ruby-lang
qpingu has quit [#ruby-lang]
Dreamer3 has joined #ruby-lang
phlipper has joined #ruby-lang
knightMBP has joined #ruby-lang
<cored> which json engine do you guys prefer to use
<cored> I'm using multi_json but I want to elimiate the warnings
<rue> Warnings schmarnings
bryancp has joined #ruby-lang
andrewhl has joined #ruby-lang
<drbrain> cored: I use the one that comes with ruby
Hakon|mbp has joined #ruby-lang
<cored> drbrain: ok, thanks
<drbrain> cored: also, I never use #to_json
<cored> active resoure is the one that use it
<drbrain> JSON.dump
<drbrain> 4life
<rue> You misspelled lyf
<rue> cored: Seriously, though, users should never run -w (except when debugging)
<rue> Structured warnings would make that easier, of course.
<drbrain> rue: I'm too busy programming to be gangsta
<rue> Good point, it takes a lot of work to achieve the correct level of sloppiness
mrsolo_ has joined #ruby-lang
bglusman has joined #ruby-lang
rushed has joined #ruby-lang
tomzx has joined #ruby-lang
tekin has joined #ruby-lang
<imperator> structured warnings!
<rue> Senior Warning Architect
<imperator> at least there's a gem for it
<rue> Is there? Hm, I think it was someone that wrote that one
<erikh> use warnings
<erikh> use warnings 'vars'
<erikh> etc.
<erikh> if I knew it was desired it'd be worth taking the time to patch it in
<imperator> i don't think anyone would mind it; many would appreciate it i'll bet
rdavila has joined #ruby-lang
<imperator> erikh, please, for the love of all that is holy, patch it in!
<erikh> hahaa
<imperator> rue, gem install structured_warnings
* erikh adds to backlog
<rue> Ah, gregor
S1kx has joined #ruby-lang
S1kx has joined #ruby-lang
_bryanp has joined #ruby-lang
<rue> I'd definitely use (ahah) a blacklist-default version
_bryanp has quit [#ruby-lang]
Kichael has joined #ruby-lang
tla_ has joined #ruby-lang
darkf_ has joined #ruby-lang