Feb 162012
 

<KhimBerLyNsVzla_> :/ <yoklov> oh wow. i had no idea something like ->((a,(b,d)),c){puts a,b,c,d}.call([1,[2,4]],3) was valid. <yoklov> that is _awesome_ <banisterfiend> yoklov: this is my fave trick: head, *tail = array <banisterfiend> since we’re talking about destructuring ;) <yoklov> yeah, i was aware of that one <yoklov> oh hm does the destructuring work in method argument lists <yoklov> it seems like it does. <yoklov> i had no idea. time to start using that all the goddamn time. <yoklov> oh wow, i didn’t realize that destructuring was so much like car/cdr <Blaskow3> Well, RVM rocks <thomasfedb> Blaskow3, this is true * hkhalid slaps Blaskow3 around a bit with a large trout * thomasfedb chases hkhalid around a bit with a large pitchfork <Blaskow3> Slap me harder! I ilke it * Blaskow3 winks <Jarred> How do I get the development tools for Ruby installed on Arch Linux? <Jarred> I’ve already installed base-devel <td123> Jarred: what do you need? <td123> can you be more specific which development tools you’re speaking of? <td123> I consider vim a development tool for ruby also :) <Jarred> Well, that’s the thing. It’s just the compiler I’m pretty sure <Jarred> It’s inspecific <Jarred> I’m trying to install eventmachine <Jarred> It complains about a lack of development tools <Jarred> I looked at the makefile log <Jarred> It said it couldn’t find any compiler <td123> Jarred: install ruby from archlinux and run sudo gem install eventmachine <Jarred> I did that as root <Jarred> and it had the same error <td123> did you install base-devel? <td123> nvm, I see you did.. <td123> Jarred: check what’s getting run right before that message is called (exact command) and you will be better prepared to fix it :) <td123> i g2g sleep <Guest343> i have a string, which looks like a hash. How can i convert it to hash? <zxiest> Hello :-) <zxiest> Is there a way to check for syntax errors with ruby prior to running the code? <thomasfedb> yes <thomasfedb> run the code <thomasfedb> or use a syntax checker such as the ones built into some editors <zjhui> I’m new to ruby on rails. When I use the command: rails console, it comes the problem: “no such file to load — readline (LoadError)”. <zjhui> So I searched google, and followed this http://rails3blog.com/2010/09/error-no-such-file-to-load-readline-loaderror/, but it didn’t work for me. <zjhui> My OS is Ubuntu 11.10 with Ruby 1.9.2p290 and Rails 3.2.1 <zjhui> I have install the readline with the command: rvm –skip-autoreconf pkg install readline. <zxiest> thomasfedb I love Ruby and I’ve been using it for almost a year now <zjhui> can anyone help me ? <thomasfedb> zxiest, good. <zxiest> thomasfedb I miss certain things from my prior development languages when I’m working with big projects <zxiest> thomasfedb sometimes compile time type checking saves me a lotta time <zxiest> but then again, when I code with something other than Ruby, I miss Ruby’s dynamicity <thomasfedb> zxiest, sure. you should invest in a test suite <thomasfedb> zxiest, there are trade-offs to be made <zxiest> thomasfedb I have been wanting to do Test Oriented Development but every time I start doing it, it looks very redundant <thomasfedb> zxiest, sure, you write twice the code. i’d suggest that however you spend MUCH less time dealing with bugs <thomasfedb> and it’s a supprisingly fluid way to write once you get into it <zxiest> thomasfedb okay… so I want to give testing oriented design a shot. What do you recommend? <looopy> zjhui: i believe you have to uninstall ruby…install readline THEN install ruby. <thomasfedb> zxiest, rspec <thomasfedb> zxiest, and if you’re doing rails then cucumber wont hurt either <zxiest> thomasfedb cool! Thanks :-) Will take a look at both. I just need to start forcing myself to do this… Bugs have been KILLING me with ruby <zxiest> I didn’t really have this problem with compiled languages <zxiest> Most of my bugs are stupid ones that can be caught by the compiler <thomasfedb> zxiest, then they’ll be caught by good tests also <zxiest> thomasfedb cool then! I’ll start working on this good habit :-) <banisterfiend> thomasfedb: hey friend, doy ou use rspec <thomasfedb> banisterfiend, yep. <thomasfedb> banisterfiend, sure do <banisterfiend> thomasfedb: what ruby version do you use <thomasfedb> banisterfiend, 1.9.3-p0-falcon <banisterfiend> thomasfedb: oh ok <thomasfedb> banisterfiend, why? <banisterfiend> thomasfedb: just i wrote a gem that might be very useful to people on pspec and ruby 1.9.2+ <thomasfedb> banisterfiend, do tell. <banisterfiend> thomasfedb: https://github.com/banister/plymouth <banisterfiend> i would be interested if it runs ok on falcon as i hvaen’t tested that b4 <thomasfedb> banisterfiend, falcon is basically just faster =P <thomasfedb> banisterfiend, ooh. I know you love pry. I don’t really. Cool idea though. <zjhui> looopy: you mean i should install readline before ruby? <looopy> zjhui: yeah <banisterfiend> thomasfedb: hehe how could oyu not love pry <thomasfedb> banisterfiend, i feel at home when it says ‘irb’ on the left <banisterfiend> thomasfedb: Pry.config.prompt = proc { “irb(main)> ” } ;) <Joost> Hi guys! <Boohbah> hi <Joost> I’m new to Ruby, and I’m running into a bit of a problem, perhaps you can have a look <Joost> Im trying to extract png’s from a binary file <Joost> now I found a snippet online that does this for the _first_ png that occur <Joost> occurs* <Joost> and I’ve been trying to edit it to loop through all PNG’s (which shouldnt be so hard, I thought) but Im failing horribly <Joost> http://pastebin.com/ssPr4dcG http://pastebin.com/WiYnMdTw <Favx> Hi. Can someone recommend a good book for learning Ruby for someone with little programming experience? <Joost> uhh, http://pastebin.com/9Nsf6WpM <zjhui> looopy: but it seems that i can install the readline as this blog says http://rails3blog.com/2010/09/error-no-such-file-to-load-readline-loaderror/ <zjhui> looopy: they seems have solved the problem, but i cannot… <looopy> it looks like they’re rebuilding ruby as well <looopy> which in your case with rvm you aren’t doing o_O; <zjhui> looopy: OK, now you men i should install the readline with the command: rvm –skip-autoreconf pkg install readline . And then reinstall the ruby? <looopy> hmm i’ve never used –skip-autoreconf. unforunately my ubuntu days predate rvm. but I do remember that error and having to start from scratch <banseljaj> zjhui: try installing all the software in “rvm requirements”, and then just use “rvm reinstall 1.9.x” <Guest343> i have an array [[a,b],[c,d]], i want to make hash {a => b, c => d} <zjhui> banseljaj: now the problem is that i can’t install the readline … <Joost> Anyone got any insights on my png problem? :O <banseljaj> zjhui: which OS? <zjhui> banseljaj: ubuntu 11.10 <Boohbah> hi, i am getting deck.rb:38:in `block (2 levels) in deal’: undefined local variable or method `deck’ for main:Object (NameError). How should i access the deck object from the deal method? http://pastie.org/33<banseljaj> zjhui: I am using the same. This is from my pc <Boohbah> ok, i made deal a method in my Deck class, thanks! <senthil> calling return 2 methods deep just returns to the 1st method, how do I stop execution from 2nd method? <thomasfedb> senthil, you cant. <thomasfedb> senthil, unless you raise an excaption <burgestrand> or throw <burgestrand> senthil: look at throw/catch <senthil> thomasfedb: ah damn <senthil> i think if i use a block, then i can call return from second method and have it return everything <senthil> burgestrand: never really did understand throw and catch <senthil> yep, if i wrap 1st method and return from 2nd method before yielding to 1st method, it returns everything <banisterfiend> burgestrand: burgie have you seen ‘kikis delivery service’ ? <banisterfiend> senthil: throw/catch is the normal way to do it <banisterfiend> i use it a lot to break out to a certain stack level <banisterfiend> def my_method1; catch(:baby_duck) { my_method2 }; end now any method called under my_method2 which throws :baby_duck will break out to the my_method1 method <burgestrand> senthil: it’s like raise/rescue, but instead of throwing an error you just throw yourself to somewhere else <banisterfiend> burgestrand: have you been to visby? <burgestrand> banisterfiend: and no to delivery service and no to visby :) <banisterfiend> burgestrand: ah too bad <burgestrand> banisterfiend: why? :P <banisterfiend> burgestrand: just that the town in studio ghibli film i discovered is based on visby, in fact i saw a photo of visby and it looks exactly the same, even the clock tower :) <burgestrand> banisterfiend: hehe <senthil> burgestrand: oh nice, think that’s what I really wanted, thanks <banisterfiend> burgestrand: i have a friend who is obsessed with that cartoon for about 3 years now, and when she learned she can actually visit the village, she was very excited :) <banisterfiend> burgestrand: hey did u ever publish that blog post u were working on? <burgestrand> banisterfiend: yeah, it was the one about writing C extensions to handle asynchronous callbacks <burgestrand> banisterfiend: haven’t written anything for about a year though <banisterfiend> burgestrand: speaking of async, do uhave much experience with eventmachine? <burgestrand> banisterfiend: a little bit but not extensively, wrote a web scraper/worker/queuer with it about a year ago <banisterfiend> oh ok <burgestrand> banisterfiend: why? <banisterfiend> burgestrand: just getting into it :) particularly interested in Deferrables <banisterfiend> burgestrand: sort of fun, i think <burgestrand> banisterfiend: yeah, it is :d <burgestrand> banisterfiend: the only thing that sucks with it (imo) is that exceptions just bork the whole shit out <burgestrand> instead of crashing the process <banisterfiend> burgestrand: have you looked into the alternatives like cool.io? <burgestrand> a little but but not very much <burgestrand> but cool.io is what previously was called rev, isn’t it? <senthil> burgestrand: doesn’t error_handler catch them? <burgestrand> senthil: where were you two years ago? :( <burgestrand> or a year ago <burgestrand> : <burgestrand> :P <senthil> two years ago i was learning rails <senthil> a year ago i was unlearning rails <senthil> :) <burgestrand> ;) <burgestrand> looks like something I should’ve used, in my defense the documentation was kind of hard to follow back then, still is <burgestrand> wonder what the default way of handling errors is then… <ExtremeDevilz> Hello <senthil> burgestrand: indeed, i found the lack of non-trivial examples infuriating <ExtremeDevilz> is Ruby a good Programming languges for Beginners ? <burgestrand> ExtremeDevilz: yes <senthil> very! <burgestrand> it’s fairly easy to get started and most of the time when you guess how something should be written it’s usually not that far from what it should be <senthil> burgestrand: have you checked out the work ilya grigorik did with eventmachine? <senthil> i’ve been meaning to sit down and take them apart one of these days <burgestrand> senthil: I read pretty much all of his posts (more than once) when I was using eventmachine <burgestrand> senthil: and yeah, I looked into em::synchrony source as well, awfully simple when you grok the idea <senthil> burgestrand: me too! pretty informative; think i saw a screencast about goliath by him somewhere <ExtremeDevilz> uh I mean compare to Java etc = ? Im actually kinda new to Computer Science.. my school teaches VB.Net and Java but I only Learned VB.Net.. I kinda lost Interest in Java.. <senthil> burgestrand: i never could understand em’s implementation even now <burgestrand> senthil: hehe <senthil> burgestrand: synchrony is using fibers right? <burgestrand> senthil: back when I read the source it was a tangled web of stuff <burgestrand> senthil: yeah <csherin> remember fibur ? ;-) https://gist.github.com/1498215 <burgestrand> too bad fibur won’t work with more than a few dozen callbacks active at the same time :o <burgestrand> ExtremeDevilz: yes <burgestrand> ExtremeDevilz: it’s a different mindset in ruby in comparison to java, and VB.net as well <burgestrand> ExtremeDevilz: ruby itself was written to make programming more fun, java was written because nothing like it existed at the time <senthil> csherin: is this an em-synchrony alternative? <burgestrand> senthil: it’s threads <burgestrand> senthil: or rather, a joke :) <csherin> senthil: you should checkout the source ;-) <senthil> hahahaha! <senthil> Fibur = Thread <senthil> need to sleep; later guys <burgestrand> o, <alem0lars> I have defined this Treetop grammar: http://pastie.org/3366408 . When I try to match it against the string @tsr:full=asd&&@tsr:full=asd it doesn’t match. I’m trying to figure out what fails but I didn’t fin<banisterfiend> burgestrand: visby known for being a nice place? <burgestrand> banisterfiend: yeah, I guess, it’s considered more like a village and not a city <ExtremeDevilz> uh guys can I use Ruby And WINAPI ? <banisterfiend> burgestrand: does sweden still have many quaint and sweet places like that? <burgestrand> banisterfiend: yeah a bunch, most of them are up north though (imo), I was raised on one but it’s turned sour the past few years when they built more houses on the island <lampe2> hey iam a java dev. and now i wanne get into ruby. i got a problem. i wanne write a libary to parse xml files from the lom standard into a DB. what are good DB’s for metadata in ruby ? <burgestrand> banisterfiend: but yeah, you can definitely find those places around as long as you stay outside the big citiies; archipelagos are great places for finding them <banisterfiend> burgestrand: they can speak english ok there too? it’s good for tourist or will i struggle? <burgestrand> banisterfiend: I’d say most swedes fare extremely well with english, you can get around pretty much anywhere except for perhaps very small and remote villages, but even there people understand and speak<burgestrand> they will have a very funny accent though <banisterfiend> cool:)) <burgestrand> I know first-hand because for some reason strangers speak english to me after they’ve said hello to me on the streets, I have no idea why <ExtremeDevilz> anyone can answer my question ? <burgestrand> ExtremeDevilz: you can use the windows api from ruby but I have not used it myself so I have no idea how it is to use it <ExtremeDevilz> uh okay I think I will pick up Ruby then <ExtremeDevilz> :) <HarimaKenji> hi, is there someone who knows about ruboto under ubuntu? I always get “ruboto: command not found” <cek> hi. how do I notify admins when a process restarted in God? <cek> it doesn’t have events enabled as i don’t want to run it as root <cnf> hi, can anyone suggest a good markdown parser for octopress that supports markdown extras? <golberg> ciao <golberg> !list <gp5st> sorry, wasn’t sure if this should be here or in #ubuntu. I did an apt-get install ruby1.9, but I don’t know how to install rubygems. apt-get install rubygems gives gems for 1.8 <shevy> gp5st it is a debian issue, if you continue to use debian packages <gp5st> any reason i shouldn’t <shevy> in general debian cripples and splits things a lot. It should be their responsibility to clean the shit up. Alternatively you could decide to not use the debian packages and use RVM http://beginrescueend.com/ -<shevy> gp5st, ruby 1.9.x has rubygems integrated though <gp5st> hmm, maybe i need to play and figure if it’s sufixed like ruby (it’s ruby1.9 not ruby:-) <shevy> try to install rubygems from rubyforge though <shevy> yes, that is another debian shit <shevy> the idiocy of versioned binaries <shevy> it is just a symlink though <shevy> ruby1.8 -> ruby or ruby1.9 -> ruby <gp5st> there isn’t a ruby though:-p <shevy> normally there is <gp5st> i use rvm locally and since this is a production box i thought it might be better to use the os binaries <gp5st> i should just switch back to rvm:- <__null> or you can check out rbenv, whichever one seems more interesting to you <shevy> when I install some debian-based distro, they usually have a symlink from ruby1.8 pointing to /usr/bin/ruby (or, if they are super-funny, into /etc/alternatives, which is another shit I can’t find any word for.<shevy> yeah gp5st <shevy> though rubygems is really a small addon <shevy> http://rubyforge.org/frs/download.php/75711/rubygems-1.8.15.tgz <gp5st> it’s more that i want to keep everything coming from the same place and not me just installing and compiling things as a one-off <shevy> yeah <shevy> the prisoner begins to enjoy his prison ;) <burgestrand> srsly, rvm, it was built for production systems <gp5st> yeah, i don’t have any problem with it, i just thought that if i could use the standard repos for the os, that would be a bit easier <burgestrand> hehe, installing ruby through the package managers is just pain <burgestrand> pain, death and despair <shevy> heeh <shevy> I am just amazed that ubuntu is unable to solve those problems <banisterfiend> anyone recommend any nice two player web games? where i can play against a friend <burgestrand> banisterfiend: browser-based? <burgestrand> nvm, don’t know any myself anyway <td123> is there a way to get the vender_ruby directory using ruby? <td123> something like Gem.default_dir for gems <shevy> hmm perhaps the guys on #rubygems know <burgestrand> td123: rbconfig might have something for you, $ RbConfig::CONFIG.keys.grep /vendor/ # => <burgestrand> => ["vendorhdrdir", "vendordir", "target_vendor", "host_vendor", "build_vendor", "vendorlibdir", "vendorarchdir"] <habermann24> anybody know of a neat way to flatten an array or arrays of integers … in a way that i only get the “intersection”. so [[1,2,3], [1,2]] —> [1,2] <td123> burgestrand: thanks <habermann24> i know i can do [1,2,3]&[1,2] … <habermann24> but how do i apply this to all so i can flatten it that way <td123> habermann24: one way I could think of is to use folding <td123> forgot what it’s called in ruby :P <td123> injecting? <habermann24> .inject(&:&) ?? <habermann24> yea that works!! <habermann24> thanks :) <habermann24> that is so awesome :D <habermann24> gotta love ruby <burgestrand> reduce/inject <burgestrand> :o <habermann24> [[1,2,3], [1,2]].inject(&:&) => [1,2] <habermann24> great :) <kpshek> basic question for a ruby newb — I’m trying to run the unit tests for a gem I’ve downloaded (source). Is ‘rake test’ the de-facto way to run test for a given project? <shevy> omg <shevy> never saw .inject(&:&) before <shevy> that looks like a smiley <habermann24> love it :D <td123> now if only I could figure out how to install gems to vender_ruby :) <burgestrand> kpshek: there is no standard, often it’s rake test or rake spec <burgestrand> kpshek: it’s good practice to include a default task that runs the tests though, so just “rake” would run the tests as well <kpshek> thx — I saw that this gem has that too <kpshek> I must not have things setup properly as I’m getting this error on ‘rake test’: http://pastebin.com/63S2CEvs <kpshek> The gem I’m trying to run the tests on is github.com/jnunemaker/mongomapper (trying to contribute some bug fixes back to the author) <burgestrand> kpshek: try running it in ruby 1.9.2 instead of 1.9.3 <kpshek> k <burgestrand> kpshek: or if that’s not an option, get rid of ruby-debug in the Gemfile for the time being <kpshek> would that just be commenting those two gems out (ruby-debug & ruby-debug19) and then running ‘bundle install’ again? <burgestrand> kpshek: yes, sorry :) <kpshek> np <kpshek> burgestrand: removing the ruby-debug gems didn’t work (another error about the perftools bundle). I’m going to install 1.9.2 and try that <burgestrand> kpshek: alright, should probably be alright to remove perftools as well though <td123> anyone familiar with gem installation? I’m trying to figure a clean way to seperate gems installed through the distros package manager and gems installed through the user <td123> by user, I mean a user running gem install foo <td123> debian installs gems to vender_ruby, but they wrote a 3000 line program in ruby to package it for them :P <burgestrand> could use rvm with user-managed gemsets <kpshek> burgestrand: thanks for your help – removing ruby-debug & perftools I was able to ‘rake test’ with 1.9.3 <burgestrand> kpshek: :) <td123> burgestrand: I do use rvm, I’m just looking for a distro-wide solution :P <alphabitcity> is it possible to get a list of instance variables declared using attr_accessor from the class object? <burgestrand> td123: I mean, you can have each user have their own set of gems independent from the others, but still share available ruby versions, using rvm <dagnachewa> hello everyone <Ienpw_III> hey, would someone be able to help me with this: http://www.reddit.com/r/ruby/comments/phce8/regex_help_beginner_question/ <kpshek> alphabitcity: are you talk about something different than the instance_variables method? <Ienpw_III> I’ve searched and searched but I can’t find anything :( <alphabitcity> kpshek: yea, instance_variables works when you call it on an instance of the class..but i’d like to be able to inspect the class for the instance methods defined with attr_accessor <td123> burgestrand: nah, that won’t work, I’m trying to figure out a standard for a distro :P <burgestrand> alphabitcity: attr_accessor is just a method that creates methods, and there’s nothing special about them methods