Topic for #ruby-lang is now Ruby 1.9.3p0: http://ruby-lang.org | Paste >3 Lines of Text on http://pastie.org
nfxgosu has joined #ruby-lang
nfxgosu has joined #ruby-lang
wasnotrice has joined #ruby-lang
nfxgosu has joined #ruby-lang
xsdg has joined #ruby-lang
bnagy has joined #ruby-lang
dhoss has joined #ruby-lang
BadQuanta has joined #ruby-lang
nfxgosu has joined #ruby-lang
chimkan_ has joined #ruby-lang
<injekt> shortest method of building an array of 1..x including n.5 for each n?
tallship has joined #ruby-lang
turboladen has joined #ruby-lang
<heftig> (2..20).map { |x| x / 2.0 }
<shevy> :)
ontehfritz has joined #ruby-lang
<heftig> or ..21 if you want that last .5
<injekt> neat, didn't think of that
<injekt> thanks!
<ryanf> what about (1..x).step(0.5).to_a ?
nfxgosu has joined #ruby-lang
<injekt> how about strf trickery to remove the decimal place for whole numbers
<injekt> ryanf: forgot about step!
<ryanf> apparently it's %g
<injekt> apparently it is
<injekt> thanks ryanf
Karmaon has joined #ruby-lang
Stalkr_ has joined #ruby-lang
nfxgosu has joined #ruby-lang
nfxgosu has joined #ruby-lang
sloth has joined #ruby-lang
<sloth> hullo
nfxgosu has joined #ruby-lang
nfxgosu has joined #ruby-lang
robbyoconnor has joined #ruby-lang
ryanf has joined #ruby-lang
nfxgosu has joined #ruby-lang
bglusman_ has joined #ruby-lang
srbaker has joined #ruby-lang
nfxgosu has joined #ruby-lang
Karmaon has joined #ruby-lang
simon_weber has joined #ruby-lang
simon_weber has joined #ruby-lang
<sloth> how is it that people can spend 247 on twitter
nfxgosu has joined #ruby-lang
Heimidal has joined #ruby-lang
<injekt> sloth: I'm not sure many people actually spend 24/7 on it
kyrylo has joined #ruby-lang
nfxgosu has joined #ruby-lang
robbyoconnor has joined #ruby-lang
rpowell has joined #ruby-lang
<sloth> injekt: we both know that 24/7 is an overestimation, but you get the point
<sloth> !!
looopy has joined #ruby-lang
yadav has joined #ruby-lang
<injekt> heh
abuiles has joined #ruby-lang
chimkan has joined #ruby-lang
nfxgosu has joined #ruby-lang
nfxgosu has joined #ruby-lang
WillMarshall has joined #ruby-lang
mztriz has joined #ruby-lang
nfxgosu has joined #ruby-lang
zani has joined #ruby-lang
nfxgosu has joined #ruby-lang
Tref has joined #ruby-lang
nfxgosu has joined #ruby-lang
skiz has joined #ruby-lang
nfxgosu has joined #ruby-lang
nfxgosu has joined #ruby-lang
skiz has joined #ruby-lang
nfxgosu has joined #ruby-lang
takaokouji has joined #ruby-lang
gix has joined #ruby-lang
nfxgosu has joined #ruby-lang
tla_ has joined #ruby-lang
nfxgosu has joined #ruby-lang
igotnolegs has joined #ruby-lang
nfxgosu has joined #ruby-lang
<oren> should i avoid hitting my db in my unit tests?
Indian has joined #ruby-lang
nfxgosu has joined #ruby-lang
<petercooper> ideally, yes
<lianj> especially in unit tests
<petercooper> if you're uncle bob, absolutely and you shouldn't even think about your database until the day before shipping (exaggeration for comic effect)
<lianj> unless you make a db wrapper
<oren> petercooper: so do u mainly test the interaction between your objects? (with stubs)
Sailias has joined #ruby-lang
<petercooper> there are a couple of schools of thought on it, but that is one route, yes
<petercooper> That said, it's common, particularly in the Ruby world, to take the approach of running against the DB (even if it's just an in-memory one).
<oren> petercooper: what if my db is mongo or mysql? how do i do that in memory?
<oren> there is a memory-based mongo, i believe
nfxgosu has joined #ruby-lang
skiz has joined #ruby-lang
nfxgosu has joined #ruby-lang
nfxgosu has joined #ruby-lang
Weems has joined #ruby-lang
Weems has joined #ruby-lang
nfxgosu has joined #ruby-lang
nfxgosu has joined #ruby-lang
gokul has joined #ruby-lang
jacktrick has joined #ruby-lang
nfxgosu has joined #ruby-lang
muffintop has joined #ruby-lang
<oren> i use capybara-webkit for acceptance tests. it looks like capybara doesn't know about a dom element that is injected at document.ready. any ideas?
slimfit has joined #ruby-lang
nfxgosu has joined #ruby-lang
nfxgosu has joined #ruby-lang
lsegal` has joined #ruby-lang
nfxgosu has joined #ruby-lang
mikeric has joined #ruby-lang
nfxgosu has joined #ruby-lang
seanstickle has joined #ruby-lang
nfxgosu has joined #ruby-lang
brushbox has joined #ruby-lang
nfxgosu has joined #ruby-lang
csmrfx has joined #ruby-lang
<csmrfx> *Any sightings of ruby dsl for writing non-verbose, non-tautological xml?
gokul has joined #ruby-lang
<csmrfx> I'm going to working with xslt again, and I'll be damned if I have to write 120 characters of code just for a simple if-then-call-subroutine
sideshownz has joined #ruby-lang
Cherrum has joined #ruby-lang
darkf_ has joined #ruby-lang
WillMars_ has joined #ruby-lang
Sailias has joined #ruby-lang
pvh has joined #ruby-lang
solars has joined #ruby-lang
vereteran has joined #ruby-lang
guns has joined #ruby-lang
y3llow has joined #ruby-lang
17SAALGMA has joined #ruby-lang
jaimef has joined #ruby-lang
darkf_ has joined #ruby-lang
CodeBlock has joined #ruby-lang
Slackwise has joined #ruby-lang
mikeric has joined #ruby-lang
alindeman has joined #ruby-lang
codefriar has joined #ruby-lang
<codefriar> I'm working with a class and trying to dynamically define some methods. For some reason when I invoke define_method I get an undefined method error. What could cause a class to not respond to define_method ?
bglusman has joined #ruby-lang
EvilJStoker has joined #ruby-lang
<drbrain> codefriar: do you call some_class.define_method ?
<drbrain> use send
<drbrain> define_method is private
igotnolegs has joined #ruby-lang
Jay_Levitt has joined #ruby-lang
jstemmer has joined #ruby-lang
at5l has joined #ruby-lang
<codefriar> I've tried: self.class.send :define_method
<codefriar> and self.define_method
<codefriar> and self.class.define_method
<codefriar> all no go's
<csmrfx> !class
<csmrfx> !g javascript classes
<drbrain> codefriar: works fine: ruby -e 'Object.send :define_method, :foo do |x| p x end; foo "hi"'
<csmrfx> oops wrong window
<codefriar> drbrain: yeah, I'm wondering if I've hit a bug in my interpreter.
<drbrain> self.class.define_method may put the method in the wrong spot
<drbrain> depending upon what you want
<codefriar> if the class is Foo
<codefriar> should I go oldschool java and define the method Foo.define_method?
<drbrain> Foo.send :define_method, name ...
<codefriar> thanks!
<drbrain> I don't know what you mean by oldschool java, but ^^ is the only way it'll work without class Foo; define_method name …; end
slimfit has joined #ruby-lang
MistyM has joined #ruby-lang
bryno has joined #ruby-lang
<erikh> so I connected two pairs of zmq pipes at each other and fired off a message
<erikh> the resulting echo chamber was *awesome*
artOfWar has joined #ruby-lang
brushbox has joined #ruby-lang
srbaker has joined #ruby-lang
chimkan_ has joined #ruby-lang
tomzx has joined #ruby-lang
<rue> Hm, it's morning
<erikh> evening.
<erikh> I ended up having to switch to ffi-rzmq
bglusman_ has joined #ruby-lang
rajahafify has joined #ruby-lang
<rajahafify> hello, world
savage- has joined #ruby-lang
<rajahafify> quick question
<rajahafify> hello?
dreinull has joined #ruby-lang
Tref has joined #ruby-lang
<Tref> hey guys how do i make a library installation available to different rubies?
<Tref> I have a library called librets that I'm using fine under 1.8.7 but when i switch to my rvm installed 1.9 I'm getting a load error...
flip_digits has joined #ruby-lang
sora_h has joined #ruby-lang
rippa has joined #ruby-lang
amerine_ has joined #ruby-lang
<TTilus> Tref: if the rubies have separate gems, which is only approppriate, you just install it for both
<Tref> its not a gem actually
<Tref> its just a library
<TTilus> Tref: check loadpath
<TTilus> Tref: and the error
<Tref> how do i check load path?
<TTilus> Tref: the error, you see, os often a strong indication of whats wrong
<Tref> TTilus: the error is as simple as [require 'Librets' => LoadError: cannot load such file -- Librets]
<Tref> that's under rvm 1.9.3
<Tref> under 1.8.7 it loads fine
<Tref> 1.8.7 is my system ruby
<Tref> once I switch to rvm, its gone
<erikh> you need to run the setup.rb or w/e you ran to install it under rvm too
<erikh> for each ruby you're using.
<TTilus> Tref: ruby -e "puts $:"
<TTilus> Tref: special global var $: holds the loadpath
<Tref> yeah i just got it from $LOAD_PATH in my ruby console
<Tref> so what am i looking for then?
<TTilus> Tref: where do you have Librets?
<TTilus> Tref: if you installed it like erikh sai, do what he said
<Tref> that's another thing, Im not sure how to check the location of something I've required
<Tref> locate Librets gives me a few different possibilities
<Tref> sorry, I'm somewhat of a systems noob :)
<TTilus> Tref: where did you get Librets and how?
<erikh> np -- there's a var for it but I can't remember which one, heh
<erikh> corundum: quickref?
<erikh> look there -- one of them will refer to the files required
<erikh> that is, which file ruby actually picked up
<erikh> you can walk it like an array, so etc
<TTilus> Tref: was it system package, or did you download something?
<Tref> i downloaded and built it
<Tref> so it looks like it could be
<Tref> $: Load path for scripts and binary modules by load or require.
<TTilus> Tref: simply build it again with every ruby you intend to use it with
<Tref> or
<Tref> $" The array contains the module names loaded by require.
<TTilus> Tref: the latter
<Tref> getting that install configured right took me like a week
<Tref> :)
Wardrop has joined #ruby-lang
<TTilus> Tref: so now you know how to do it and it wont tae another week :)
<Tref> :)
<Tref> so $" is giving me two files
<Tref> "librets_native.bundle", "Librets.rb",
<Tref> the latter seems to be in /Library/Ruby/Site/1.8/librets.rb
<Tref> the former in "/Library/Ruby/Site/1.8/universal-darwin11.0/librets_native.bundle"
<TTilus> Tref: see that 1.8 in the path
<Tref> yeah
<TTilus> Tref: now just go build it again
<Tref> hahaha
<Tref> shit
<Tref> So here's just a question for you to help free me of a bit of ignorance
<TTilus> Tref: and this time copy the commands u use to an installation script of your own :)
<Tref> why can't I just include that with ruby 1.9?
<TTilus> Tref: u prolly still find from your command history
<Tref> somehow put it in the load path and include it in 1.9
<Tref> I trust from what you're saying that it won't work. I just don't know enough about ruby to know why
<TTilus> Tref: u cant know if the library wants to behave/install differently depending on the ruby version/platform
<TTilus> Tref: let the library decide how it wants things
amerine has joined #ruby-lang
<Tref> so what is that .bundle extension all about?
<TTilus> Tref: if you dont, believe me, you need to know whole a lot of more ruby to make things work
<TTilus> Tref: dunno
<oren> i inject DOM element in document.ready. my capybara's assertion fails if the js code is not inline. any ideas?
<oren> (capybara-webkit)
<TTilus> oren: not really, tried different drivers?
<TTilus> oren: and #cucumber or #capybara even...
<oren> TTilus: thanks, i didn't know about #capybara
ryanf has joined #ruby-lang
<Tref> TTilus: does installing this under RVM mean that this library isn't going to work in my system ruby anymore?
<Tref> Or should it still work?
<rue> erikh: Why'd you switch?
rivaler has joined #ruby-lang
thone has joined #ruby-lang
<Tref> TTilus: looks like I'm getting farther than I though
<Tref> Thought*
<Tref> but i was getting a extconf.rb:4:in `<main>': uninitialized constant PLATFORM (NameError) when trying to run extconf
<Tref> and got it to run by changing PLATFORM to RUBY_PLATFORM in my extconf.rb file
<Tref> but it appears that there's a second problem that The C macros for working with a Ruby Array changed.
gianlucadv has joined #ruby-lang
bojicas has joined #ruby-lang
bojicas has joined #ruby-lang
EvilJStoker has joined #ruby-lang
sideshownz has joined #ruby-lang
rpowell has joined #ruby-lang
JohnBat26 has joined #ruby-lang
sora_h has joined #ruby-lang
gokul has joined #ruby-lang
jxie has joined #ruby-lang
daglees has joined #ruby-lang
yxhuvud has joined #ruby-lang
<csmrfx> Given strings "foo-bar" and "foo-gib", methods foo, bar and gib, how would one generally map the strings to the functions in ruby? (ignoring string iteration and tokenizing)
nemesit has joined #ruby-lang
<csmrfx> in other words, I'd like to write my parser using a map, and some functions
<csmrfx> but not sure what would be a wise "map" to use with ruby
<Mon_Ouie> Not sure what you're trying to do. Replace foo with the result of a call to foo?
<csmrfx> well, add the results of foo to the result set
<csmrfx> but thats almost the same
<csmrfx> if you like, I can pastie the pseudocode
<Mon_Ouie> Yeah, with an example of actual input/output
<csmrfx> ok, gotta work on the output a sec
takaokouji has joined #ruby-lang
brushbox has joined #ruby-lang
h4y4shi_ has joined #ruby-lang
<ryanf> csmrfx: it sounds like you want send()
<ryanf> as in obj.send(:method_name)
<ryanf> alternately, you could make a hash with method objects in it and then .call() them
savage- has joined #ruby-lang
<ryanf> (you get method objects using obj.method(name) or klass.instance_method(name))
<ryanf> instance_method returns unbound methods, which you have to bind to an object before calling
corundum has joined #ruby-lang
<csmrfx> See from line 78 onwards for input, and 91 for output, and under it shorthand for the tokens. http://pastie.org/3365695
<csmrfx> ryanf: well, hash with methods in it sounds nice... or hashes with hashes (with hashes) with methods in them...
ryez has joined #ruby-lang
rivaler has joined #ruby-lang
<ryanf> I think you should consider send() instead, it might simplify your architecture quite a bit compared to keeping a hash of methods
<ryanf> but the hash is fine too
<erikh> rue: gc issues
<csmrfx> (I suppose you noticed there are some errors there)
<csmrfx> ryanf I dont quite follow the send -idea. How would mapping token-keys to library functions work with that?
<csmrfx> or perhaps some example code that I should see?
sideshownz has joined #ruby-lang
<ryanf> csmrfx: well, the simplest way would be to just name your methods after the tokens
<ryanf> if you need a more complicated mapping then you might as well use method objects instead though
<csmrfx> well I had a bright moment but now it is totally gone
<csmrfx> I think it went along the lines of not having to "map" tokens to methods first, instead just have a "parse-tree" that input stream traverses... but just cant wrap my head around how that would be in ruby
<csmrfx> too much ecma
<csmrfx> do you think that makes sense?
mytrile has joined #ruby-lang
<csmrfx> hmm, maybe something with method_missing as usual
mytrile_ has joined #ruby-lang
erpuds has joined #ruby-lang
csherin has joined #ruby-lang
<rue> I guess it's not the worst possible one
<rue> A parser generator is probably better at a certain point
<csmrfx> I dont need anything fancy. Just a simple to describe replace-a-with-results-of-do_a-tree and stack of open elements.
<csmrfx> +one
skiz has joined #ruby-lang
<csmrfx> but stack of case...when, or if else seems unelegant.
looopy has joined #ruby-lang
nfxgosu has joined #ruby-lang
cloud-brownies has joined #ruby-lang
kitallis has joined #ruby-lang
yadav has joined #ruby-lang
nfxgosu has joined #ruby-lang
Y_Ichiro has joined #ruby-lang
Y_Ichiro has joined #ruby-lang
<csmrfx> Instead of case, rather have something like: how would one traverse object tree with token values like: result = ""; lines.each { |l| l.tokenize!.each { |t| preset: { xml: get_xml_tmp, xsl: get_xsl_tmp }, is_eol: { eol t; }, is_fwd_slash: { is_asterisk: begin_comment, is_whitespace: close_last_elem, is_word: close_elem t }, is_word: { is_eol: { new_elem t; }, is_attr: { new_attr t; } }, is_whitespace: {} }
nfxgosu has joined #ruby-lang
<csmrfx> if input is "/foo" then execution would hit is_fwd_slash with "/"-token, then "is_word"-token would trigger 'close_elem t' inside that hash
<csmrfx> Kind of functional attempt
goodvin has joined #ruby-lang
nfxgosu has joined #ruby-lang
<goodvin> hi
<csmrfx> Am I violating some parser writing rule with this idea?
nfxgosu has joined #ruby-lang
SourJ has joined #ruby-lang
nfxgosu has joined #ruby-lang
<h4y4shi_> my classes are getting hard to read is there a better way to do this? http://pastie.org/3365996
mytrile has joined #ruby-lang
nfxgosu has joined #ruby-lang
<h4y4shi_> those are called instance variables right?
<manveru> wow
<csmrfx> h4y4shi_: you want object literal for that, and pass it around, not tons of args
nfxgosu has joined #ruby-lang
logbot52902 has joined #ruby-lang
<h4y4shi_> csmrfx: could I see an example? I dont really get explanations yet, this is my first programming language.
nfxgosu has joined #ruby-lang
frangiz has joined #ruby-lang
shevy has joined #ruby-lang
rpowell has joined #ruby-lang
nfxgosu has joined #ruby-lang
voker57 has joined #ruby-lang
voker57 has joined #ruby-lang
nfxgosu has joined #ruby-lang
toretore has joined #ruby-lang
major_majors has joined #ruby-lang
senthil has joined #ruby-lang
mikeric has joined #ruby-lang
fayimora has joined #ruby-lang
roha has joined #ruby-lang
<h4y4shi_> is bnagy on?
<h4y4shi_> manveru: thanks for the article. That was interesting to read
<h4y4shi_> bnagy: Hello
h4y4shi has joined #ruby-lang
TheInkyVoid has joined #ruby-lang
Stalkr_ has joined #ruby-lang
TheInkyVoid has joined #ruby-lang
<h4y4shi> manveru: I didnt get a chance to bookmark that article could I have another link?
yxhuvud has joined #ruby-lang
pbjorklund has joined #ruby-lang
symm- has joined #ruby-lang
jamw has joined #ruby-lang
jxie_ has joined #ruby-lang
<h4y4shi> manveru: Thanks
imperator has joined #ruby-lang
<imperator> good morning
<masterkorp> imperator: o/
<imperator> guten morgen masterkorp
benanne has joined #ruby-lang
<masterkorp> imperator: dont trust on my domain :p
<imperator> oh, sneaky
niklasb has joined #ruby-lang
bglusman has joined #ruby-lang
tekin has joined #ruby-lang
<imperator> hm, seems signal#trap is botched on windows in ruby 1.9
<erikh> I had no idea windows could manage signals
<erikh> does it deal with CHLD and STOP?
<imperator> it's supposed to manage whatever Signal.list returns
<imperator> 8 signals on xp pro
<imperator> i don't see CHLD or STOP
<erikh> makes sense I suppose
* imperator wonders if it's a mingw thing
<Boohbah> hi what do you think of my cool program? :) http://pastie.org/3366665
<manveru> Boohbah: does it play poker yet?
<Boohbah> not yet :(
<manveru> :(
<imperator> erikh, you're up early btw :)
<manveru> anyway, not bad at all
<erikh> imperator: eh, sleep is at a premium this week
<manveru> Boohbah: you used js before ruby?
<erikh> just woke up as a matter of fact
<erikh> went to bed about 4 hours ago
<Boohbah> manveru: not much
<manveru> k
<manveru> well, just about the only thing i'd improve is using #{} syntax
<shevy> erikh you cyborg! we mere humans need 8 hours of beauty sleep still
<manveru> puts "Player #{Players[i].name} has #{Player[i].hand.size} cards"
<erikh> Oh, I imagine I'll lie down later.
<manveru> Boohbah: also, Players.each do |player|
<Boohbah> manveru: ahh, in puts, instead of concatenate with + ?
<imperator> nope, not a mingw thing, msvc version does the same thing
<manveru> so the line becomes
<manveru> Players.each{|player| puts "Player #{player.name} has #{player.hand.size} cards" }
<Boohbah> puts "Shuffling #{deck.size.to_s} cards..."
<manveru> yeah, no need for to_s
<manveru> it is called automatically
<shevy> player.hand.push(@cards.pop) hmm why not player.hand << @cards.pop
<manveru> shevy: why not @cards >> player.hand
* manveru hides
<shevy> if that would work :(
<manveru> make it work? :)
bradly has joined #ruby-lang
CodeBlock has joined #ruby-lang
<erikh> beat it with a wrench!
<Boohbah> can't convert Player into Integer (TypeError)
<Boohbah> :(
<shevy> manveru impossible!
<manveru> Boohbah: http://pastie.org/3366744
uniqanomaly has joined #ruby-lang
<shevy> hmm
<Boohbah> interesting
<shevy> has anyone of you ever had the idea of mixing commandline options in ways like:
<shevy> some_program foo bar bla --no-harm ble --run-amok --kill-people -s
<Boohbah> manveru: thanks
publicvoid has joined #ruby-lang
dkannan has joined #ruby-lang
abuiles has joined #ruby-lang
<shevy> hmm
<shevy> for now I have decided to ignore all --. Have not thought about --foo=some_value much yet though.
<erikh> shevy: most option parsers do that
<erikh> handle --, - and non-dashed arguments that is
vdrab has joined #ruby-lang
tekin has joined #ruby-lang
thone_ has joined #ruby-lang
<imperator> ... --- ...
Keva161 has joined #ruby-lang
y3llow has joined #ruby-lang
<erikh> heh
FiXato has joined #ruby-lang
gokul has joined #ruby-lang
futurechimp has joined #ruby-lang
Takpar has joined #ruby-lang
Takpar has quit [#ruby-lang]
take_cheeze has joined #ruby-lang
Indian has joined #ruby-lang
m3nd3s has joined #ruby-lang
codewrangler has joined #ruby-lang
burgestrand has joined #ruby-lang
burgestrand has joined #ruby-lang
NARKOZ has joined #ruby-lang
<ddfreyne> shevy: an argument -- should be interpreted as the end of all arguments
<ddfreyne> so that you can do “touch -- --foo” to create a file “--foo” (and “rm -- --foo” too)
<shevy> hmm hmm hmm
<shevy> decisions decisions ... :/
<ddfreyne> is what I use
<ddfreyne> and wrote :)
JoL1hAHN has joined #ruby-lang
kurko_ has joined #ruby-lang
Jake232 has joined #ruby-lang
takaokouji has joined #ruby-lang
Carnage\ has joined #ruby-lang
Harzilein has joined #ruby-lang
areric has joined #ruby-lang
tbuehlmann has joined #ruby-lang
Spooner has joined #ruby-lang
gianlucadv has joined #ruby-lang
jobicoppola has joined #ruby-lang
S1kx has joined #ruby-lang
S1kx has joined #ruby-lang
rippa has joined #ruby-lang
<shevy> decisions
<shevy> that's what takes most of my brain power away
bglusman_ has joined #ruby-lang
bojicas has joined #ruby-lang
savage- has joined #ruby-lang
andrewhl has joined #ruby-lang
flebel has joined #ruby-lang
flebel has joined #ruby-lang
sternicus has joined #ruby-lang
Stalkr_ has joined #ruby-lang
<Jake232> Whats the correct way to "mix" two classes together
<Jake232> I have ClassBob in file2.rb
<Jake232> and I have ClassBob in file1.rb
<Jake232> I want to make The methods in ClassBob in file2, available in ClassBob in file1
<andrewvos> Put them in the same class
<Jake232> They have to stay seperate, file2 is actually part of a gem that I want to be able to update in the future
<Jake232> so can't edit that directly, or just rip things out of it
<andrewvos> Just open up the class in another file then?
<Jake232> Not quite sure what you mean.
nofxx has joined #ruby-lang
<shevy> Jake232 just require
<shevy> class classBob is a namespace just as module moduleBob
<Jake232> Now If I create an instance of Forem::Forum
<shevy> what is that extend part?
<Jake232> It doesnt have the methods available to it, that were in
<Jake232> require Forem::Engine.root.join('../', 'app', 'models', 'forem', 'forum')
<Jake232> Ignore the extend, should be include
<Jake232> I was trying everything
<Jake232> Oh wait, you mean the friendly id?
<shevy> no, the strangely indented extend was confusing me
<shevy> what is Forem? a module?
<Jake232> Forem is a module, which contains Forum
<Jake232> The class I want to mix with my Forem::Forum class
crankharder has joined #ruby-lang
<shevy> hmm
<shevy> I dont really see stuff like class Forem::Forum < ActiveRecord::Base
<shevy> normally it tends to be
<shevy> module Forem
<shevy> class Forum < ActiveRecord::Base
<shevy> you can extend module Forem at any time lateron too
<shevy> and if you require the files, the class will pick up all the methods
<Jake232> Does nothing either
<Jake232> undefined method `category' for #<Forem::Forum:0x007f95526b0ca8>
<Jake232> It's not picking up the methods, from the original clas
<Jake232> Which is getting required here:
<Jake232> require Forem::Engine.root.join('../', 'app', 'models', 'forem', 'forum')
<shevy> Jake232, http://pastie.org/3367768
<shevy> what is with that extend man!
<shevy> the part:
<shevy> class Forum < ActiveRecord::Base
<shevy> is that normally enough to subclass? even without super() ?
<shevy> I dont know activerecord myself
<shevy> well if I have to make a guess, you probably did not subclass properly
<shevy> I can't be of help with activerecord though, so someone else probably has to
<futurechimp> no need for super there
<futurechimp> Jake232: it looks like you're using a rails engine?
<Jake232> futurechimp: yea
<futurechimp> with what version of rails?
<Jake232> 3.2
<futurechimp> ok, i haven't used an engine with a version that recent
<Jake232> If I uncomment all the stuff thats in the Engine class
<Jake232> It works
<Jake232> But, I need it to stay there, so I can update the gem
<futurechimp> it used to be the case, back in the old days of engines, that it was necessary to do something like: require_dependency 'foo/bar/blah' in order to get an engine to load certain kinds of subclasses
<futurechimp> but i would tend to doubt that this is still the case, since engines are now merged into rails since v3.x
<Jake232> This is my first xperience with an Engine
<Jake232> and it hasn't been great
<Jake232> lol
thoradam has joined #ruby-lang
<Jake232> Wait
<futurechimp> ah wait a moment, yeah you'll need to unfortunately put all that stuff in the AR class, if engines still work the same way they used to
<Jake232> I think that if you require something in your models
<Jake232> it doesn't require them unless you restart the rails app
<futurechimp> the AR model in your actual application totally overrides the model in the engine
<Jake232> even though it should
<Jake232> because it's supposed to reload every file in /app, in dev mode
<Jake232> It seems it doesn't fire the require calls
JoL1hAHN has joined #ruby-lang
curtism has joined #ruby-lang
<Spooner> I always have problems with namespacing if I use shorthand in class defs ('class A::B::C' rather than 'module A;module B; class C'). Can anyone explain why these are different, because as far as I know they "should" be the same.
roha has joined #ruby-lang
<Jake232> Alright, its officially screwing with me
<Jake232> it worked
<Jake232> I havent even gone back to the text editor yet
<Jake232> and now it doesnt
<thoradam> Hello everyone, I was wondering about the |pipe| in ruby, is there no substitute for in common situations like this: array.map! { |i| i == 0 ? i : i/3 } ?
<rippa> why do you need a substitute?
<Jake232> futurechimp: Using require_dependency has actually worked
<Jake232> I would have never found that, thanks
<futurechimp> ah, great :)
<thoradam> It could be more concise like this: array.map! { _ == 0 ? _ : _/3 }
<rippa> thoradam: array.map! { |i| i/3 }
<thoradam> But I guess there is nothing like that right?
<rippa> that's more concise
<Jake232> futurechimp: Now I just have to implement this to the other 4 models.
virunga has joined #ruby-lang
<thoradam> rippa: That was just an example really :)
<rippa> no, blocks don't have parameters in a default var
slyphon has joined #ruby-lang
<futurechimp> Jake232: engines are great, but there is a bit of folklore associated with using them - happy it worked for you!
<thoradam> Ok thought so, thanks!
heftig has joined #ruby-lang
skiz has joined #ruby-lang
MistyM has joined #ruby-lang
symptom has joined #ruby-lang
chimkan has joined #ruby-lang
fayimora has joined #ruby-lang
krz has joined #ruby-lang
thoradam has quit [#ruby-lang]
sirfilip has joined #ruby-lang
aki__ has joined #ruby-lang
<csmrfx> Any idea where to find example source for parse-rules defined as an object (-tree), and for code that then traverses that tree with tokenized strings?
<csmrfx> or, definitive example, even
nemesit|osx has joined #ruby-lang
<whitequark> csmrfx: can you elaborate?
any-key has joined #ruby-lang
<csmrfx> Ok I have a string representing a document. Then I have a set of rules that define what to return for each string-token. Example: "-html -p =hello" would be parsed with the tree rules = { html: { div: do_div(token), p: do_p(token), h1: do_header(token) }, xml: { foo: etcetc() } }
<csmrfx> At least in my mind that seems the most attractive solution to parsing stuff
<csmrfx> I guess simple and succinct are aims here
<csmrfx> Making a shorthad dsl for representing xml in least verbose way possible (templating, kinda)
<shevy> csmrfx shouldn't succint and terseness always be the aim anyway ;)
<shevy> *succintness
<andrewhl> i'm trying to write a prime sifter. The idea is to take a range of numbers (e.g., 2..20), and check for the multiples of each number by incrementing by that number value. All multiples except the first number will be set to nil or something. When the range is exhausted, move on to the next prime number, increment that by its own value, and repeat. What's the best way to do this? Should I use inject?
<andrewhl> I'm not sure how to modify an array or a range that I am currently looping through
<csmrfx> shevy: well, sometimes you have complexity to deal with or safety or robustness > simple+powerful (but perhaps miss some edge cases)
<Jake232> andrewhl: Sounds like Sieve of Eratosthenes?
<andrewhl> so... [2, 3, 4, 5, 6, 7, 8, 9] would become [2, 3, nil, 5, nil, 7, nil, 9], which would then become [2, 3, nil, 5, nil, 7, nil, nil]
<Jake232> If my memory serves correctly anyway, maybe thats somethign else
<andrewhl> jake232: exactly that. I'm just not sure how to approach it
<andrewhl> like, I'm not sure what method to use to modify an array as you loop through it
<injekt> create a new array?
<rippa> andrewhl: use second array
<injekt> boom
<rippa> also, map!
<andrewhl> jake232, did you just write that?
<injekt> does all code work if you add a comment at the top saying # this works ?
<andrewhl> impressive
<Jake232> I used it a while ago
<Jake232> and the #this works comment is because theres another one in there
<Jake232> that I tried making faster
<Jake232> than doesnt work
<injekt> :)
<andrewhl> what does .compact do?
<Jake232> [1,2,nil,4].compact #=> [1,2,4]
<andrewhl> cool
<Jake232> Basically, removes nil
<Jake232> Although, depending on what youre using this for
<Jake232> I can think of more suitable languages
<Jake232> If speed is really important
<Jake232> But I guess it depends how many primes you're wanting to find ;)
<andrewhl> what language would you recommend?
<Mon_Ouie> You can use the standard library if you don't feel like you have to implement it yourself
<Mon_Ouie> require 'prime'
<Mon_Ouie> Prime.prime? 13 #=> true
<andrewhl> lol, neat
* Jake232 never knew there was reqire 'prime'
wyhaines has joined #ruby-lang
<csmrfx> Haha, looks like parser coding is too difficult for ruby-lang
<injekt> ??
* csmrfx evil
csmrfx has quit ["goes to #scheme"]
<injekt> what a tragic loss
<Jake232> andrewhl: Well, Ruby isn't known for being fast. It certainly wouldn't be my first port of call
<Jake232> for a huge prime number generator
<andrewhl> would python be better?
<nofxx> C
darkf has joined #ruby-lang
<injekt> Fortran
<Jake232> It all depends on whether you're after a few hundred thousand, or a few hundred million.
<nofxx> python is slower than 1.9
<Jake232> And Python would likely be similar
<andrewhl> I'd be happy with about 10k primes
<Jake232> for 10k, don't worry about it
<Jake232> Ruby will do it in no time
<andrewhl> jake, can you explain why you do Math.sqrt(top)?
<andrewhl> is that an efficiency thing?
<Jake232> Anything Above the square root can't be a multiple
<Jake232> Well
<Jake232> I'll explain in a minute, unless somebody else does
<Jake232> I can smell my food burning
<andrewhl> ok
<Jake232> brb
<injekt> nofxx: really? I highly doubt that, at least not in all areas
<andrewhl> no rush:)
<Mon_Ouie> The numbers above the square root don't need to check them, because each of them will be matched by a number below it
<nofxx> injekt, I'm remembering some benchs around while I browse for the great shootout
<andrewhl> so if I have 2..100, all the primes between 2..100 will be found between 2..sqrt(100)?
<andrewhl> that's kind of awesome
<Mon_Ouie> No
<andrewhl> ok then I'm not getting something:)
<Mon_Ouie> But you are sure you won't find a multiple of 100 after sqrt(100) if you haven't found one before
<Mon_Ouie> Because if there's a number greater than sqrt(100), then there's also a number smaller than sqrt(100) so that a * b == 100
<Jake232> ^ What he said.
rippa has joined #ruby-lang
<nofxx> injekt, its a huge improve over 1.8, but about the same, loosing and winning http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=yarv&lang2=python3
<nofxx> nice the memory footprint, winner
darkf has joined #ruby-lang
<injekt> nofxx: yeah
<injekt> lol @ mandelbrot and fannkuch-redux
publicvoid_ has joined #ruby-lang
capcook has joined #ruby-lang
m3nd3s has joined #ruby-lang
darkf has joined #ruby-lang
tomzx has joined #ruby-lang
GiambalaGiambala has joined #ruby-lang
lordofthedance has joined #ruby-lang
csherin has joined #ruby-lang
JohnBat26 has joined #ruby-lang
h4y4shi has joined #ruby-lang
Stalkr_ has joined #ruby-lang
heftig has joined #ruby-lang
gentz has joined #ruby-lang
daglees has joined #ruby-lang
codewrangler has joined #ruby-lang
chimkan has joined #ruby-lang
codewrangler has joined #ruby-lang
fayimora has joined #ruby-lang
Luxx_ has joined #ruby-lang
codewrangler has joined #ruby-lang
codewrangler has joined #ruby-lang
savage- has joined #ruby-lang
rushed has joined #ruby-lang
darkf has joined #ruby-lang
codewrangler has joined #ruby-lang
gianlucadv has joined #ruby-lang
roha has joined #ruby-lang
jbsan has joined #ruby-lang
nicknovitski has joined #ruby-lang
nicknovitski has quit [#ruby-lang]
chendo_ has joined #ruby-lang
Mchl has joined #ruby-lang
Carnage\ has joined #ruby-lang
Fiel has joined #ruby-lang
Indian has joined #ruby-lang
TheInkyVoid has joined #ruby-lang
Jake232 has joined #ruby-lang
sideshownz has joined #ruby-lang
Sailias has joined #ruby-lang
EvilJStoker has joined #ruby-lang
brownies has joined #ruby-lang
capn_kryptonite has joined #ruby-lang
Heimidal has joined #ruby-lang
kith_ has joined #ruby-lang
Minimalist has joined #ruby-lang
skiz has joined #ruby-lang
seanstickle has joined #ruby-lang
chendo_ has joined #ruby-lang
naz has joined #ruby-lang
<Tref> hey guys how do i run a configure script to target a ruby under rvm?
<Tref> is that something that's generic across all configure scripts or does it vary based on the library you're installing?
mephux has joined #ruby-lang
<shevy> Tref what do you mean
savage- has joined #ruby-lang
<shevy> target a ruby under rvm? usually you set the version to use in RVM
mephux has joined #ruby-lang
<shevy> rvm --default use 1.9.3
<shevy> I think rvm compiles into a standalone directory and then switches context
nark-1 has joined #ruby-lang
Keva161 has joined #ruby-lang
S2kx has joined #ruby-lang
empity has joined #ruby-lang
TheInkyVoid has joined #ruby-lang
Dreamer3 has joined #ruby-lang
lsegal has joined #ruby-lang
nemesit has joined #ruby-lang
S1kx has joined #ruby-lang
<Tref> I know this is a longshot but has anyone ever used the librets library?
<ddfreyne> Is it considered a good idea to require 'bundler/setup' in the binary?
rivaler has joined #ruby-lang
<ddfreyne> e.g. I don’t really have an idea what effects this would have: https://github.com/jingoro/nanoc/commit/55846594575e7647e056a77adf77fc8d15e978e7
<ddfreyne> any Bundler experts around?
tla has joined #ruby-lang
andrewhl has joined #ruby-lang
<jorgenpt> "string".to_hash seems to change between interpreter launches - is there a way to get a consistent hash of a string?
<jorgenpt> String#hash says that it's generated based on the "length and content" of the String, which is obviously not true - there must be something else involved too.
<shevy> guys
<shevy> I have a class with about 20 @instance variables
<shevy> is that too much?
<jorgenpt> I guess I'll have to use digest.
S2kx has joined #ruby-lang
mephux has joined #ruby-lang
mephux has joined #ruby-lang
postmodern has joined #ruby-lang
<ddfreyne> shevy: that seems like a lot, but if you think they all belong together, no problem i guess
Dreamer3 has joined #ruby-lang
dejongge has joined #ruby-lang
elitheeli has joined #ruby-lang
looopy has joined #ruby-lang
<shevy> ddfreyne yeah well ... I dont know :(
<shevy> what is making it worse is ... that I use that class to tie together many other smaller classes
<shevy> and there are things like:
<shevy> @use_foobar = some_other_object.use_foobar?
<shevy> and then in actual code:
<shevy> if @use_foobar
<shevy> enable_this; disable_that
<shevy> but I could also use ...
<shevy> if some_other_object.use_foobar?
<shevy> enable_this; disable_that
<shevy> instead
<shevy> :\
<ddfreyne> can you not delegate #use_foobar? to some_other_object and not use it as an instance var?
<ddfreyne> yeah
<shevy> I started this class perhaps 6 years ago... it confuses me what I did back then
<shevy> yeah ddfreyne
<ddfreyne> i’d do the latter (DRYer, and if some_other_object changes then you don’t need to update the instance var
<ddfreyne> s
<shevy> oh that's a good point
<shevy> yeah spam attack
<ddfreyne> shevy: and don’t be afraid to rewrite 6 year old code :P
<shevy> ddfreyne hehe doing this right now
<shevy> but some changes in that class trigger changes in other classes ... :/
<elitheeli> Can someone help me with an issue with threads? I don't really understand how they work in relation to IO.
<andrewvos> Everyone: Just ask the question don't ask to ask.
<Defusal> does anyone know of a way i can detect if an image is missing data? ie. downloaded incomplete and a part of the visible image is missing
<shevy> what is that ddfreyne ?
<shevy> aha
<shevy> "nanoc is a web publishing system written in Ruby."
<ddfreyne> shevy: 5 year old code
benanne has joined #ruby-lang
<ddfreyne> icky :)
* ddfreyne is off, night!
<theconartist> elitheeli: sure
<Defusal> cschneid, thanks that looks hopeful
<cschneid> NO IT DOESNT
<cschneid> heh
<csherin> :D
<elitheeli> theconartist: here's what I'm working with: https://gist.github.com/b83351ff0e349f49e5a8 -- I want it to print Tick every second regardless of whether or not I'm typing
<csherin> hey cschneid :)
mrb_bk has joined #ruby-lang
<cschneid> csherin: we're gonna have to fight over the cs prefix on our names
<cschneid> didn't we collide yesterday too?
<theconartist> oh
<csherin> yeah ;-)
<theconartist> more specific i see
<Defusal> elitheeli, depending on your project, i'd suggest looking into using EventMachine rather than threads
<theconartist> what's the problem elitheeli
Wardrop has joined #ruby-lang
<elitheeli> theconartist: I'm writing a wrapper around a really crapper interpreter in another language. I want readline support. I want to print things from the interpreter as they come.
josh9 has joined #ruby-lang
<elitheeli> Defusal: does EventMachine stop the Readline.readline call from blocking?
<Defusal> argh i just realized i cant check the images :|
<Defusal> elitheeli, you use EventMachine to asynchronously read from the keyboard, you never use any blocking methods with EM
<burgestrand> elitheeli: the reason is that Readline.readline is broken
<Defusal> elitheeli: look at the keyboard example on this page if you choose to go that route, https://github.com/eventmachine/eventmachine/wiki/Code-Snippets
<burgestrand> elitheeli: as you’ve noticed, it blocks the entire ruby VM when waiting for input
<burgestrand> which is also why other threads won’t run, as they need to acquire the GIL that the thread running Readline.readline is holding
<elitheeli> Does that mean that I need to implement all the magic of things like Control-A, Control-U, history, etc. myself?
<csherin> burgestrand: wouldn't it work in Rubinius in that case. it doesn't have a GIL right ?
<burgestrand> elitheeli: not all systems have this issue, are you on a mac?
<elitheeli> yessir
<burgestrand> csherin: upcoming 2.0 does not, but the current 1.x does
<burgestrand> elitheeli: you can work around the issue in two ways; either you install GNU readline and reinstall the readline extension, or you can use a pure-ruby implementation of readline named rb-readline
qpingu has joined #ruby-lang
roha has joined #ruby-lang
<elitheeli> burgestrand: that works great
wallerdev has joined #ruby-lang
looopy has joined #ruby-lang
MistyM has joined #ruby-lang
<josh9> what does it mean 'a driver' in the context of capybara?
<burgestrand> josh9: it’s what runs the web browser, or rack::test
<burgestrand> josh9: selenium, or capybara-webkit for example
<josh9> burgestrand: i know about the different drivers, but not sure what a driver is. why do we need 2 codebases? capybara codebase and a driver codebase?
rpowell has joined #ruby-lang
<burgestrand> josh9: it allows you to write your own driver for capybara without needing to change capybara itself
<burgestrand> the drivers themselves become plug-and-play
<josh9> raise NotImplementedError nice! so a driver must implement those public api
srbartlett has joined #ruby-lang
<burgestrand> josh9: indeed :)
flebel has joined #ruby-lang
erpuds has joined #ruby-lang
gregf has joined #ruby-lang
<josh9> from some reason i get the wrong status code with capybara-webkit. instead of 200 i get 7536755. i am going to add some breakpoints in https://github.com/thoughtbot/capybara-webkit/blob/master/lib/capybara/driver/webkit/browser.rb#L83
tla_ has joined #ruby-lang
judofyr has joined #ruby-lang
Sailias has joined #ruby-lang
robotmay has joined #ruby-lang
ghjdkvf has joined #ruby-lang
<andrewvos> hahaha
Guest__ has joined #ruby-lang
<andrewvos> 7536755
<andrewvos> bwahahaha
Keva161 has joined #ruby-lang
<mrb_bk> can anyone help me out with a question about rb_define_alloc_func in a c extension?
<burgestrand> mrb_bk: just ask
<mrb_bk> burgestrand: thanks, i'll put a gist together
<burgestrand> mrb_bk: that’s an awful big question then
<mrb_bk> haha
<mrb_bk> i'll try to state it simply
<burgestrand> always the hard part :)
<mrb_bk> if the c class i'm wrapping needs arguments passed to the method used to initialize the structs, and i want to use rb_define_alloc_func
<josh9> andrewvos: assert has_content("whatever") is working. it's only the status_code
<mrb_bk> should i just allocate the memory in rb_define_alloc_func, and pass that pointer to Data_Wrap_Struct?
<burgestrand> mrb_bk: yes
<mrb_bk> burgestrand: and then use Data_Get_Struct in the initialize method and pass the args there?
<burgestrand> mrb_bk: you then use Data_Get_Struct in your initialize function to get the pointer to your struct, which you can then use to fill with data
<mrb_bk> :) okay
<mrb_bk> i thought that's what i was doing but i guess i fucked something up because it keeps crashing
<burgestrand> mrb_bk: remember, if you store any VALUEs in your struct you should supply a marking function in Data_Wrap_Struct
ttilley has joined #ruby-lang
ttilley has joined #ruby-lang
<burgestrand> mrb_bk: an example of how I’ve used it
<burgestrand> mrb_bk: oa_allocate is the function I passed to rb_define_alloc_func, and the oa_initialize below that is the initialize method
<burgestrand> initialize doesn’t take any arguments here, but that should not matter
<mrb_bk> burgestrand: awesome, thanks!
<Asher> w/ fork shouldn't child processes die when the parent process is killed?
niklasb has joined #ruby-lang
<burgestrand> Asher: don’t think so, no
<rue> Dat not how et work
<Asher> oh ok
<Asher> cool
<Asher> i thought that's what made it a "child"
jefflembeck has joined #ruby-lang
<burgestrand> It becomes a zombie when the parent dies, so in effect its closer to spawn of sorts, perhaps a vampire
<andrewvos> How do I make a process happen in the background under thin?
<andrewvos> Well, some code really
<andrewvos> Want to execute some code every request
<burgestrand> but you don’t want it to block the request from returning?
<burgestrand> or, well, response :)
<burgestrand> andrewvos: ^
<andrewvos> hmmm, I'm starting to think this is a stupid idea...
<andrewvos> Ok so what I really want is
<whitequark> if you want to do it synchronously, just execute it in a request handler
<whitequark> if you want it asynchronously, use resque
<whitequark> if you want it to be synchronous, but don't block the whole thin server for i/o, look at EM/EM::Synchrony
<andrewvos> My data store is a text file on the web. I don't want it to update on every request so I want to cache it, but then release the cache after like 5 minutes.
<josh9> does it make sense to use vcr for acceptance testing?
<andrewvos> So I was thinking on every request launch a background job that updates the item
<andrewvos> But that means 1 request for every request
<andrewvos> Which seems silly
<whitequark> andrewvos: do I understand you right way? you have a document on a same server with thin with some kind of data
<burgestrand> josh9: why would you use vcr for acceptance testing?
<whitequark> andrewvos: which sometimes changes because of requests routed to thin
<josh9> burgestrand: to make them fast?
<andrewvos> whitequark: I have a document somewhere else. My app requests it every time and parses it for its data.
<burgestrand> josh9: and only work as long as you don’t change something? :P
<josh9> but i guess the purpose of acceptance is on the real site
<whitequark> andrewvos: ok. that doesn't seem a case for a background job
<andrewvos> whitequark: Indeed.
<whitequark> andrewvos: if you're not afraid of Redis, I personally would just cache it with an expiration time of 300 sec
<whitequark> like 1 command of Redis
<andrewvos> whitequark: I can't cache it
<andrewvos> It's coming from an external url whitequark
<whitequark> andrewvos: why not?
<josh9> burgestrand: also, am i suppose to test for status codes in my acceptance or is it more a controller test?
<andrewvos> Well, because it's not on my server
<whitequark> andrewvos: keeping an external piece of data locally to speed up access time is called "caching"
<andrewvos> whitequark: Oh I thought you meant cache the data file
<burgestrand> josh9: status codes does not matter to your users unless it’s an API, so I would not test them
<josh9> burgestrand: ok
mephux has joined #ruby-lang
<whitequark> andrewvos: the browser cache, the processor cache, the filesystem cache and any other kinds of cache are just the same thing
<whitequark> may them work on files
<whitequark> bytes
<whitequark> whatever
<shevy> on boobs
<whitequark> keeping a pair of boobs locally to speed up access?
<andrewvos> whitequark: Yeah I get you.. So basically I'm looking for an easy way to cache the data for a certain amount of time
<whitequark> that's called "relations" by some
<whitequark> andrewvos: sure. should it be in pure ruby? should it be shared/synced between different worker instances?
<andrewvos> whitequark: Pure ruby would be nice
<andrewvos> whitequark: Don't really want ot have to install anything locally
<andrewvos> whitequark: And this project isn't exactly mission critical
<burgestrand> andrewvos: do you need to share the cache between multiple instances of the application?
<andrewvos> whitequark: This is basically what I'm doing now: https://github.com/AndrewVos/fuckingawesomesongs.com/blob/master/lib/songs.rb#L6
<andrewvos> burgestrand: Nope there's only one instance
<mrb_bk> burgestrand: ah, Data_Make_Struct is nice for that one step initialization
<whitequark> andrewvos: ok. http://pastie.org/3369929
<burgestrand> andrewvos: in that case I’d probably stick to what you have there, but build in some way to expire the cache, especially
<whitequark> err, refresh it
<burgestrand> andrewvos: pretty much what whitequark just pasted :)
<rue> andrewvos: What?! This is critical! Everything depends on this!
<burgestrand> mrb_bk: yup :)
<burgestrand> mrb_bk: mostly because you should avoid initializing stuff inside the allocation function, it’s for allocations… the allocation function
<andrewvos> rue: You want me to add that song?
<mrb_bk> burgestrand: totally, makes sense
<andrewvos> whitequark: Ok seems good enough
<rue> andrewvos: Fucking awesome songs. Final Countdown. Need you ask?
<andrewvos> whitequark: Thanks!
<andrewvos> haha
<andrewvos> rue: Ok I'll ask the team
<whitequark> shevy: you know, your stupid comment somehow opened me a clear look at some facets of life
<whitequark> lol
<andrewvos> rue: Sorry that song isn't fucking awesome :)
<josh9> burgestrand: i am scraping some websites, so if i don't use vcr, the url might have different content each time i run my test.
<rue> It IS more ultra-awesome
Heimidal has joined #ruby-lang
<rue> Also, effing kids…
<burgestrand> josh9: sure, you can use vcr to make sure the content of those external websites will always be the same
<burgestrand> josh9: that’s pretty much what it’s made for
<josh9> ok
<h4y4shi> manveru: Are you there?
<shevy> whitequark lol
<manveru> h4y4shi: i guess
<manveru> :)
<h4y4shi> manveru: I made a github will you take a look at my rpg its come a long way Im kind of proud of it.
<andrewvos> rue: I'm 28!
<manveru> h4y4shi: which one?
robbyoconnor has joined #ruby-lang
robbyoconnor has joined #ruby-lang
lsegal has joined #ruby-lang
<h4y4shi> manveru: I named the repository neg
<manveru> h4y4shi: isn't that "omae ha mo shinda" ?
s0ra_h has joined #ruby-lang
<h4y4shi> manveru: Well on the anime Fist of the North Star Kenshiro always says Omae ha mo shindeiru
<manveru> yeah
<manveru> but not shinderu
<Asher> how do i check if a process exists before sendign it a signal?
FastJack has joined #ruby-lang
<manveru> you send it a signal
<whitequark> kill -0
<whitequark> iirc
<Asher> and test for?
<manveru> 0 0 n/a exit code indicates if a signal may be sent
<whitequark> an exception
<manveru> >> Process.kill(0, 123234)
<manveru> Errno::ESRCH: No such process
<whitequark> ^ that
Oloryn_lt1 has joined #ruby-lang
* manveru bows
<Asher> thanks
<manveru> whitequark: thanks, i didn't even know 0 :)
<manveru> i'd have just sent the signal
takaokouji has joined #ruby-lang
<whitequark> nah. he asked for a method to check for the existence of a process
<whitequark> I did not read further
<whitequark> ignorance sometimes leads to enlightenment, doesn't it? :D
m3nd3s has joined #ruby-lang
melter has joined #ruby-lang
h4y4shi_ has joined #ruby-lang
<manveru> damn, i wish websites would stop trying to be helpful and selecting stuff for me
<manveru> messes with my clipboard
<whitequark> there's an addon for that
<manveru> for opera?
<whitequark> ahh, opera...
<whitequark> does it support addons at all?
amerine has joined #ruby-lang
<manveru> well, or firefox, or chromium
<manveru> i use all of them anyway
<whitequark> I bet there's one for ff/chrome
<manveru> yeah
<manveru> opera even has lastpass these days :)
amerine has joined #ruby-lang
<manveru> dunno why i always end up with minority stuff
EvilJStoker has joined #ruby-lang
Jarred has joined #ruby-lang
looopy has joined #ruby-lang
<manveru> maybe i should just try to find a better way to paste the clipboard buffer
<whitequark> ah
<whitequark> do you mean middle-clicking to paste?
<manveru> that pastes the primary buffer
<manveru> the clipboard buffer is what you usually use when you ^C ^V
<whitequark> X clipboard buffers have always driven me crazy
<whitequark> primary? secondary? clipboard? and combined with a clipboard manager?
<whitequark> like a minefield
<manveru> github annoys me to no end because they preselect the input field with the repo url
<whitequark> nothing wrong with it
<manveru> whenever i click it, it selects for me
<manveru> so the content doesn't end up in the primary buffer
wmarilync9 has joined #ruby-lang
<manveru> which means i can't paste it into my terminal
<wmarilync9> hello
<whitequark> manveru: that means it's your terminal which is fucked up
<whitequark> sane ones have C-V
<wmarilync9> are there anybody?
<manveru> ^V is used for example in vim to input meta chars
<whitequark> wmarilync9: nope. no one is here
<wmarilync9> what?
<whitequark> for example, I'm not present
<manveru> any control char is used in some way by some app :)
<wmarilync9> you are bad
<whitequark> and you don't read my messages
<whitequark> manveru: anything wrong with using a popup menu? given you've already using a mouse to select text
<manveru> yeah
<manveru> i'll add it to my context menu
<manveru> just requires some perl :(
<whitequark> perl?
<whitequark> what terminal do you use?
<bougyman> for urxvt
<manveru> urxvt is scripted in perl
capn_kryptonite has joined #ruby-lang
<wmarilync9> what is perl?
symm- has joined #ruby-lang
<manveru> that has a fix
<whitequark> wmarilync9: http://google.com/search?q=perl
<wmarilync9> where are you from whitequark
<whitequark> heaven
Stalkr_ has joined #ruby-lang
<kyrylo> manveru, awesome. Thanks! :)
Karmaon has joined #ruby-lang
Sailias has joined #ruby-lang
<whitequark> manveru: configuring a terminal via Xresources is... perverted. at least.
<wmarilync9> are there anybody from Perú????
wmarilync9 has quit [#ruby-lang]
fayimora has joined #ruby-lang
<manveru> whitequark: yeah, gotta love it
brushbox has joined #ruby-lang
twittard has joined #ruby-lang
alexh_ has joined #ruby-lang
countskm has joined #ruby-lang
gregf has joined #ruby-lang
<alexh_> hi, it seems that in a class method one can refer to a class instance variable with an @ or without. which is considered better practice?
<manveru> without @ it's not a class instance variable
<alexh_> @manveru, that doesn't really help
<manveru> your question is ambigous
<alexh_> well thx (not)
<manveru> can your provide an example of either?
<manveru> *you
kyrylo_ has joined #ruby-lang
kyrylo_ has joined #ruby-lang
vesan has joined #ruby-lang
ryanf has joined #ruby-lang
<whitequark> alexh_: you cannot
<countskm> @ is an object instance variable - one way it is different is that an instance variable can be shared between the superclass and subclass (if defined in superclass)
<whitequark> if you have an attr_accessor, that's an entirely different story
<whitequark> or cattr_accessor, or any similar method
<josh9> Benchmark.realtime{ Nokogiri::HTML(open("http://www.target.com/p/Zoe-Thermal-Pouch/-/A-12436920")) } # => 0.5 seconds is there a faster way to find a text on an html page other than using Nokogiri?
wilo has joined #ruby-lang
<manveru> countskm: you mean class variables
<drbrain> josh9: don't use open-uri
<whitequark> josh9: your benchmark includes I/O time
<drbrain> josh9: use net-http-persistent
<drbrain> and, you can always use =~
<manveru> as if nokogiri was the slow part :)
<countskm> @ is an instance variable @@ is a class instance variable
<drbrain> countskm: no
<josh9> drbrain: how to avoid using open-uri?
<manveru> countskm: no
<drbrain> @@ is a class variable
<countskm> right
<whitequark> josh9: str = open("http://google.com").read; Benchmark.realtime{ Nokogiri::HTML(str) } => 0.072309196
<whitequark> (your URL 403's for me)
<josh9> whitequark: drbrain thanks. i'll look into it
<drbrain> josh9: you should use mechanize
<lianj> why is open-uri so bad for just a short fetch?
<drbrain> if you're doing web scraping, don't reinvent mechanize
<drbrain> lianj: no persistent connections
TheInkyVoid has joined #ruby-lang
<drbrain> lianj: almost nobody does just one HTTP connection
<josh9> drbrain: mechanize is using nokogiri. i am cofused..
<manveru> mechanize is not using open-uri
<drbrain> you're not going to find a better HTML parser than Nokogiri for ruby
<whitequark> josh9: nokogiri isn't the slow part
<whitequark> I/O is
<whitequark> blocking I/O, that is
<drbrain> unless you know exactly the HTML so you can write a custom regular expression, use nokogiri
<josh9> whitequark: ok. so open is the issue?
<manveru> any I/O is blocking if you can't do stuff before it's done :)
<drbrain> josh9: and ^^ what whitequark says
<whitequark> josh9: in your testcase, yes, it's open, and #read, which gets indirectly called inside Nokogiri::HTML
<manveru> no matter how async your code is, you can't parse stuff that hasn't arrived yet
<whitequark> I've made it explicit, as you see
<whitequark> manveru: if you're doing web scraping, you gotta do it asynchronously
<manveru> whitequark: but he's only got one url
<whitequark> if that's just one script, I doubt the 0.5s delay is that bad
<whitequark> so I assumed he is doing some scraping
senthil has joined #ruby-lang
<postmodern> async all the things!
<whitequark> postmodern: wrong. there is no silver bullet
<manveru> postmodern: honoring your name, i see :)
<josh9> whitequark: it's many requests. each one using nokogiri to find the name of the product.
<whitequark> josh9: then you really should listen to drbrain
<whitequark> he knows more than me on the topic
<postmodern> whitequark, if your concerned about web-scraping perf, i would just use a thread pool and mechanize/net-http-persistant
<drbrain> josh9: with open-uri, most of the I/O time is spent waiting for TCP syn/ack and slow-start
<whitequark> postmodern: sure. thread pool is a way to do things asynchronously
<josh9> whitequark: use net-http-persistant and chose mechanize instead of nokogiri?
<postmodern> whitequark, it's still synchronous technically
<drbrain> josh9: mechanize uses nokogiri and net-http-persistent, it's exactly what you want
<postmodern> mechanize combines net-http-persistent and nokogiri
<wilo> hola a todos buenas noches
<manveru> wilo: gn8
<josh9> drbrain: ok. so the connection will stay open for longer time?
<whitequark> josh9: you're going to rewrite parts of mechanize anyway
<whitequark> without knowing it
<alexh_> so I think I have it… one can essentially refer to a class instance variable in a method without the @ if it is an attribute. Doing so is refering to the attribute rather than the actual class instance variable. Sorry for the nooby question.
<whitequark> so yes
<drbrain> josh9: for many requests
<whitequark> alexh_: correct
<alexh_> many thx!
<wilo> soy novato en ruby y quiero trabajar con ruby y opengl para hacer un programa que simule el cubo de rubik de forma grafica
<josh9> drbrain: postmodern thanks guys. i had no idea nokogiri and mechanize are so different in that aspect.
<wilo> pero no se como integrar esa libreria al lenguaje
<whitequark> josh9: these are just different things
<wilo> estoy bajo wiindows
<lianj> wilo: english please
<wilo> ohh im sorry
simon_d has joined #ruby-lang
<wilo> ok
<whitequark> josh9: nokogiri is an HTML parser. it does not know _anything_ about network. mechanize is a library for interacting with websites
<drbrain> josh9: mechanize handles all the HTTP details and all the HTML details you need
<whitequark> err, nokogiri is HTML/XML parser of course
<drbrain> so it's no more than ageent.get("http://example/...").search "CSS or XPath query here"
<manveru> wilo: you wanna make a rubik cube with opengl in ruby?
<josh9> got it. looking into it
<wilo> I am new to ruby and want to work with the OpenGL library to create the rubik's cube
<wilo> yes
<manveru> and on windows?
<wilo> I am new to ruby and want to work with the OpenGL library to create the rubik's cube
<manveru> cool, i knew i learned italian for something :)
<lianj> hehe
<drbrain> wilo: do you already know OpenGL?
mikeric has joined #ruby-lang
<whitequark> manveru: I determined that without even knowing italian, heh
<manveru> whitequark: i was mostly kidding :)
<drbrain> wilo: ruby-opengl primarily supports the fixed-function pipeline, not the modern shader pipeline
<drbrain> wilo: there's no OpenGL 3+ support (yet)
havenn has joined #ruby-lang
<manveru> opengl code looks the same in any language :P
<wilo> mmm
<simon_d> I've got a bit of a problem with an application I'm trying to install (gitlabhq). With the install there were syntax issues and now trying to run the program (after fixing the initial issues with my extremely limited ruby). With so many syntax issues I'm thinking the problem might be something else, maybe a ruby gem I might need or something or a different version of ruby
<wilo> means that it is not very compatible opengl in ruby?
<whitequark> simon_d: $ ruby -v. Is it 1.8? if it is, install 1.9
<simon_d> 1.8.7?
<whitequark> wilo: there's nothing in your Rubik cube which cannot be done with opengl currently available. I doubt you really need shaders
<wilo> I'm working with Ruby 1.9.2
kyrylo has joined #ruby-lang
kyrylo has joined #ruby-lang
<whitequark> simon_d: 1.8.7 is 1.8, yes.
<whitequark> either use your package management system, if any, or use rvm
<drbrain> wilo: there are some shader-pipeline features in opengl 2, so you can either write ancient-style fixed-function or modern-style shader pipeline
<drbrain> but all the latest features aren't yet mapped.
<drbrain> wilo: I'm working on updating ruby-opengl here: https://github.com/drbrain/opengl
<drbrain> but I haven't released it yet
<wilo> I could provide some web site to show me how?
<drbrain> how to write opengl?
<drbrain> wilo: for fixed-function tutorials, see: http://nehe.gamedev.net/tutorial/lessons_01__05/22004/
<simon_d> the errors are - syntax error, unexpected ':' - this is the line that is causing it, can you see an issue with the syntax, what is the line doing: redirect_to [:admin, @admin_project], notice: 'Project was successfully updated.'
<drbrain> simon_d: notice: 'Project was …' is a 1.9 hash syntax
<simon_d> ahhh nice one that makes sense then!
<wilo> thank you very much
<drbrain> lianj: thanks!
<wilo> =)
<drbrain> I'll add that to my bookmarks
<simon_d> what is the easiest way to upgrade ruby?
<lianj> its pretty awesome. a bit more in depth as the one from http://duriansoftware.com though
<simon_d> I'm not suing RVM
<drbrain> simon_d: depends on your OS
<manveru> pacmcan -S ruby
<manveru> of course :)
<drbrain> simon_d: I usually download and unpack the tarball then ./configure; make; sudo make install
<simon_d> debian
<simon_d> if I upgrade ruby will I then have to upgrade gem, bundler...?
<manveru> rubygems is part of ruby now
<drbrain> simon_d: yes, since ruby 1.8 and ruby 1.9 store gems in separate directories
<manveru> bundler... i'm still working on a plan to assassinate it
kyrylo has joined #ruby-lang
kyrylo has joined #ruby-lang
<drbrain> simon_d: but you can gem19 install -f `gem18 env home`/cache
<simon_d> and what does that do?