« Back to channel list

#ruby - 24 June 2013

« Back 1 day Forward 1 day »
[00:31:36] Liverpudlian: is this channel active??
[00:32:01] matti: People might be asleep etc.
[00:32:24] Liverpudlian: im on nightshift
[00:43:01] _bart: Woop woop, wrote a crappy hacky script at midnight: https://github.com/bartolsthoorn/ruby-nasa-wallpaper
[00:43:16] _bart: It sets the NASA wallpaper of the day as the wallpaper
[00:43:23] _bart: image of the day*
[00:45:40] Liverpudlian: ha, funny, but ive been meaning to write myself a quick script that changes my background image on interval basis
[00:46:10] popl: I wouldn't be proud of that. :)
[00:46:35] popl: Maybe if you made it portable…
[00:48:38] _bart: popl: linux version has already been made
[00:50:25] _bart: Liverpudlian: https://github.com/kertap/OS-X-Background-Changer
[00:50:59] _bart: Anyway, night!
[00:51:21] Liverpudlian: _bart: thanks man, I run Ubuntu but I also need few tweaks to it.
[00:52:38] Liverpudlian: Its been 10 years since i have used IRC...
[00:52:45] Liverpudlian: not joking...
[03:12:54] ikk-: how to pp(obj) to a file
[03:13:12] ikk-: File.new('/tmp/web2.x','wb').puts pp(obj)
[03:13:25] ikk-: not this
[03:13:32] ikk-: how to pp(obj) to a file ?
[07:25:12] Kelet: I'm sure this has been asked a million times but:
[07:25:38] Kelet: Do I really have to install a development environment for ruby and compile something native to use sqlite3?
[07:26:16] Kelet: What exactly does 'gem install sqlite3' do, when I do 'require sqlite3' it gives me LoadError: cannot load such file -- sqlite3/sqlite3_native despite having sqlite3.exe, sqlite3.dll, sqlite3.def in my PATH
[07:30:11] bnagy: Kelet: for windows, possibly the easiest option is jst to use RailsInstaller
[07:30:28] bnagy: having said that I have never used it and I don't know anything about rails or sqlite on windows
[07:31:42] Kelet: Unfortunately RailsInstaller doesn't yet have a Ruby 2.0 option (which I'm interested in), and I have no interest in Rails. Just kind of surprising that to use a common db in Ruby you have to step through so many hoops, unless I'm missing something.
[07:32:07] sevenseacat: i wouldnt call sqlite a common db.
[07:32:23] bnagy: unless by common you mean lower class
[07:32:29] sevenseacat: and isnt that the nature of windows, everything is jumping through hoops?
[07:36:38] Kelet: sevenseacat, Shrug, I would assume it isn't the fault of Windows when many other language implementations don't need a development environment to compile a library to use a library.
[07:36:57] Kelet: But maybe it is and the other languages have spent the effort to avoid such things, either way
[07:37:42] bnagy: every language needs a dev environment to compile a librarry
[07:38:26] bnagy: but if there's a sqlite dll you could see if someone has done an FFI binding, that is usually a hell of a lot less fiddly imho
[07:39:59] Kelet: sqlite3 is described as an FFI binding
[07:41:30] Kelet: Oh well I appreciate the help, I guess I'll just need to install the dev environment and compile it up if I want to use it. Thanks.
[07:43:02] bnagy: if it's an FFI binding you don't need to compile anything
[07:43:19] bnagy: so if it's no working it's probably just path mania of some kind
[07:43:44] bnagy: basically FFI allows you to call into exportts from binary libs ( dll here ) from native ruby
[07:44:01] bnagy: man I am really typing like crap today
[08:39:29] Xeago: Anyone any experience with railskits?
[10:00:05] SparkyFlary: hey what's the difference between ruby and nimrod?
[10:02:43] Mon_Ouie: They're entirely different programming languages?
[10:14:25] ChristianS: what's nimrod?
[10:17:04] popl: great-grandson of Noah
[10:25:13] Hanmac1: hm does someone have an newer Mac? and if yes what is the system version of GCC ?
[10:25:34] popl: Hanmac1: Do you have a ruby question?
[10:26:09] Hanmac1: popl i am often in this channel, but no that is not an ruby question
[10:29:25] pontiki: one minute, Hanmac1; i need to go dig it out of my satchell
[10:29:51] popl: can you even get gcc apart from xcode with os x?
[10:30:01] Xeago: popl: yes several ways
[10:30:19] Hanmac1: i dont know, but my boss wants to force me to use Mac ..
[10:30:19] popl: my understanding was that apple patched gcc too
[10:30:28] pontiki: Hanmac1: i'm assuming you do mean the xcode version?
[10:30:32] Xeago: either commandline tools, binary packaged
[10:31:05] popl: os x ships with shitty bash
[10:31:11] MrZYX: Hanmac1: he said "a Mac" not "Mac OS X"..? :P
[10:31:28] Xeago: Hanmac1: http://hastebin.com/kukihuwawe os x lion
[10:31:31] Xeago: fairly recent xcode
[10:34:17] Hanmac1: ha i new it ... "recent" is an very strechable word :P OSX recent: "4.2" my recent: "4.7" released: "4.8" ...
[10:36:26] pontiki: Hanmac1: https://gist.github.com/tamouse/5849190
[11:18:35] Hanmac1: Xeago: one of my work colleges is an pure apple fanboy ... his opinion: "if i want an newer GCC on OSX i should make an VM for that" ... oO
[11:27:44] Xeago: and what does he run in that vm?
[11:27:51] Xeago: btw Hanmac1 brew installs newer gcc's just fine
[11:30:42] Hanmac1: Xeago: mayne in that vm another one ... (he is more an php developer so he does not need gcc)
[11:50:24] buzzybron: what does this line > prompt; do ? and why does it have semi colons?
[11:54:08] bnagy: Hanmac1: gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
[11:55:34] bnagy: but I don't know if the versions are like the rhel kernel versions
[12:49:11] Hanmac1: apeiros: china says that usa is the "biggest villian our age" ;P
[12:50:28] ellipse: China said that?
[12:51:27] Hanmac1: ellipse: yeah they did that: http://www.scmp.com/news/china/article/1267204/us-cyber-snooping-makes-it-worlds-biggest-villain-our-age-says-xinhua
[12:55:28] oceanbreeze: Guys hello, i need a script that is checking multiple directories for a file or a folder existense, and then if files/folders exist delete/move them. Can you give me an idea please.
[12:55:59] apeiros: Hanmac1: news at 11?
[12:56:04] bnagy: oceanbreeze: read the docs on Dir and FileUtils
[12:56:44] bnagy: I don't normally leak work life into here, but this current US / HK snowden detente is HIL A RIOUS
[12:57:02] bnagy: scmp being basically a mouthpiece for PRC
[12:59:47] bnagy: don't get out much?
[13:00:27] Dekade: lol can you just answer me maybe
[13:00:35] Treeson: call me maybe
[13:01:03] bnagy: Dekade: People's Republic of China
[13:02:04] Dekade: ahh could of just said that, I can't remember every synonym but I should of known this one lol *facepalm*
[13:02:38] bnagy: ... sorry I seem to have taken my asshole pills tonight
[13:02:47] Zeeo: ACTION having noob questions to submit
[13:02:57] bnagy: Zeeo: don't ask to ask
[13:03:01] Zeeo: so, I have this code https://gist.github.com/anonymous/6ff67c8b478f84cd6898 and everything works fine, but, if I flip the order of the renders I get some extra text from one of the partials
[13:03:19] MrZYX: -> #rubyonrails
[13:03:44] Dekade: it's ok lol
[13:03:46] oceanbreeze: bnagy: Thanks, but how to set variable with multiple directories
[13:04:07] MrZYX: oceanbreeze: use programming
[13:04:57] oceanbreeze: MrZYX: dirx= "/blabla/blabla"
[13:05:16] oceanbreeze: MrZYX: Should i use separated variable for each dir?
[13:05:24] MrZYX: no, an array
[13:05:42] oceanbreeze: MrZYX: Can you give me an example please, im quite new to Ruby scripting
[13:05:45] MrZYX: you should go through some basic tutorial first, like tryruby.org
[13:06:04] Dekade: look up Array's
[13:09:44] oceanbreeze: someting like: dir = ["/home/ocean/asdad/*", "/home/ocean/asdad/*", "/home/ocean/asdad/*"]
[13:12:11] bnagy: >> Dir['/**/**']
[13:12:12] eval-in: bnagy => (https://eval.in/34736)
[13:12:43] bnagy: assuming you're not in a chrooted sandbox :)
[13:14:38] Hanmac1: bnagy: you mean like that? http://pics.nase-bohren.de/sandbox-on-the-beach.jpg
[13:17:11] bnagy: Hanmac1: omg is that a huge list of images that germans find funny?
[13:17:15] bnagy: ACTION runs
[13:25:12] norm: can anyone think of a good way to split a string into strings and numbers? that is, "foo1bar2hello" --> ["foo", 1, "bar", 2, "hello"]
[13:25:18] norm: i can think of plenty of suboptimal ways
[13:25:48] charliesome: >> "foo1bar2hello".scan(/[a-z]+|[0-9]+/)
[13:25:48] eval-in: charliesome => ["foo", "1", "bar", "2", "hello"] (https://eval.in/34737)
[13:27:17] Mon_Ouie: Or split(/(\d+)/) to just split on numbers no matter what the non-number parts look like
[13:28:07] norm: charliesome: that qualifies as a Good Way
[13:28:09] norm: charliesome: thanks
[14:10:47] mcpierce: Working on something and looking for some feedback or advice.
[14:11:14] mcpierce: I have, for Ruby < 2.0, some code to add an attribute to Fixnum to track a specific property for it in our library.
[14:11:32] mcpierce: But I see that, with Ruby 2.0, doing such a thing with Fixnum is forbidden, that there are frozen classes.
[14:11:48] mcpierce: ANy suggestions on another way to carry with an object like that such an attribute?
[14:12:02] MrZYX: just use your own one?
[14:12:27] lupine: class FixnumExtensions ; end or something
[14:12:38] lupine: monkey-patching, eh
[14:12:39] mcpierce: Can a frozen class be extended?
[14:12:44] lupine: I hope not
[14:13:06] mcpierce: lupine: What we did previously was the monkey patch Fixnum, but you can't do that now since it's frozen.
[14:13:20] pontiki: that's an interesting idea..
[14:13:21] MrZYX: why do you need to monkey patch fixnum?
[14:14:05] mcpierce: MrZYX: In our project (Proton, an implementation of AMQP messaging) we have multiple integer types that can be sent in a message (8-bit through 128-bit, signed and unsigned) that, in Ruby, are represented by either Fixnum or Bignum.
[14:14:16] pontiki: can you patch Integer?
[14:14:39] MrZYX: then do a subclass of Fixnum for each one
[14:14:45] mcpierce: MrZYX: What we want to do is, when getting a value out of a message, mark up the Fixnum by adding an attribute that says what type is was when it was retrieved. That way, if we put it into another message we can keep that type value.
[14:15:19] lupine: mcpierce, so the attribute is on an instance of Fixnum?
[14:15:38] lupine: class MarkedupFixnum ; def initialize( fixnum, markup ) ; ...
[14:15:47] lupine: make some of those instead
[14:15:49] mcpierce: lupine: Yes. I have a simple test that does precisely that. But testing it with Ruby 2.0 it fails due to Fixnum being frozen.
[14:15:54] Hanmac1: ... hm for me class Fixnum is not frozen, but the instances are
[14:16:04] lupine: mm, we're talking instance attributes
[14:16:28] lupine: just wrap the instance inside another class. value class pattern or whatever it's called
[14:16:33] mcpierce: The one thing I'm trying to avoid is having to have developers use non-standard primitive types in their app.
[14:17:17] lupine: well, it's perfectly acceptable in this kind of parser situation. look at how yaml does it - you have a parse that generates a tree of nodes, and transform to turn it into native types
[14:17:32] lupine: (maybe, "did". I'm not familiar with the yaml parser for 2.0)
[14:17:50] waxjar: could you pass a tuple/Struct around instead?
[14:18:26] lupine: mcpierce, , monkey-patching Fixnum is exactly the same as having a non-standard primitive type
[14:18:43] mcpierce: waxjar: My end goal would be for whatever gets returned to be indistinguishable from a Fixnum. That's why the meta-programming trick looked so good.
[14:18:47] lupine: it's just more obscure
[14:19:02] mcpierce: lupine: True, but with the benefit of not having to have developers know that they're not using a pure Fixnum.
[14:19:27] waxjar: mcpierce, i see. perhaps 2.0 allows you to refine it, but i wouldn't know
[14:19:36] waxjar: instead of a full monkey patch
[14:20:10] lupine: I was just thinking about an object_id registry of some sort, but all instances of e.g., 42, will have the same object_id anyway
[14:20:30] lupine: mcpierce, will a given fixnum ever have a different markup to other usages of the same fixnum?
[14:20:45] mcpierce: lupine: Also, how would you know when it's safe to dispose of an object if the registry is holding a reference?
[14:21:00] lupine: you're not holding a reference to the object in such a registry
[14:21:04] mcpierce: lupine: Potentially, yes. 17 could, in one case, be a UINT and in another be a LONG.
[14:21:09] lupine: just a fixnum which == the object_id
[14:21:15] mcpierce: lupine: Ah, kk.
[14:23:28] lupine: I really think you're going to need a wrapper
[14:23:49] mcpierce: lupine: I think you're right. I was hoping otherwise, but...
[14:25:12] Hanmac1: lupine on 64bit versions, all 42.0 will also have the same object_id ... same for -42.0 and for 0.0 but not for -0.0 ;D
[14:25:56] mcpierce: Negative zero's? Ruby doesn't use one's compliment internal does it?
[14:41:09] tehKitten: While browsing in a project I found a line of ruby of which I do not understand why the writer of it resorted to this specific solution. I am no developer myself and only know a couple lines of perl, but perhaps someone can explain it to me. The line is:
[14:41:11] tehKitten: RAILS_GEM_VERSION = %x{pkg_info | egrep "^ruby-rails" | awk '{print $1}'}.match(/-([\d\.]+)/)[1]
[14:42:08] tehKitten: to me it would seem it would be easier to get such a version by using Rails::VERSION::STRING or something like that
[14:42:08] lupine: %x{} runs the enclosing command, which aims to extract a version number from a package manager
[14:42:37] lupine: hard to say whether it's sane or not without more context
[14:42:53] waxjar: doesn't look very sane :p
[14:43:03] MrZYX: reminds of some linksys medacenter being hacked because they unnecessary shell'ed out like everything
[14:44:10] lupine: well, there's no interpolation there, so it's not evil from that point of ciew
[14:44:28] lupine: it's not impossible to come up with scenarios where that's the best idea, but they're really not the common case
[14:44:41] tehKitten: I found it here https://github.com/mailserv/mailserv/blob/21d4d83cc9126b4af5facaffd113de1628e98116/install/templates/fs/god/admin.god
[14:46:59] lupine: aye, that's not code that has simple access to that constant
[14:48:07] lupine: they could just delete line 5 completely, of course
[14:50:58] ctooley: I'm getting an error that I'm missing an "end" but can't see any errors in the code with ruby -c.
[14:51:18] ctooley: Is there anything else that could cause that, like imported libraries or such?
[14:51:38] lupine: sure, if there's a syntax error in a file you've required
[14:51:46] lupine: but it should tell you which file it's relevant to
[14:52:22] ctooley: lupine, when I say I can't see the errors, I mean I don't see any errors in the file it's pointing to.
[14:53:53] lupine: all I can suggest is going through it line by line
[14:53:58] MrZYX: or gist it
[14:54:59] ctooley: I found the method that's causing the error, now to find the error.
[14:57:08] ctooley: apparently it was barfing on the method alias
[14:57:57] lupine: maybe it's something deep in an eval somewhere
[15:49:40] kraljev1: Methods starting with uppercase letter.
[15:49:44] kraljev1: Good or bad practice?
[15:50:49] hoelzro: because they look gross an un-rubyish
[15:51:26] kraljev1: what is method is not ment to be called by programmer
[15:51:56] ddv: kraljev1: private method?
[15:52:25] kraljev1: framework method
[15:52:45] kraljev1: def POST_show()
[15:53:05] kraljev1: for /something/show
[15:53:09] kraljev1: HTTP request
[15:53:24] Hanmac1: kraljev1 & hoelzro keep in mind that Array() and String() are methods
[15:53:38] hoelzro: but that's so they loook like fake classes
[16:26:40] ghr: Can someone explain why this is a demeter violation and how you'd do it differently? https://gist.github.com/garethrees/192c565dfb881613508f#file-pelusa-L10
[16:27:37] kpwz: ghr: filedata vs file_data maybe?
[16:28:07] kpwz: the filedata attribute is never referenced
[16:28:28] ghr: oops typo
[16:28:32] ghr: same output
[16:28:48] ghr: gist amended
[16:30:48] MrZYX: I guess the tool thinks you're doing file_data.x.join
[16:32:35] ghr: MrZYX updated https://gist.github.com/garethrees/192c565dfb881613508f
[16:32:48] ghr: even with just `file_data.year` it things its bad
[16:34:22] MrZYX: it also thinks getters are bad, so I guess it's a bit hypercritical
[16:34:33] ghr: aha, I had wondered about that one too
[16:36:23] ghr: fwiw, I was just looking at https://github.com/elm-city-craftworks/jackal and ran pelusa against it, so had a go at removing the violations
[16:37:42] MrZYX: looks like it sees Class.new.something as a violation
[16:38:24] MrZYX: https://github.com/codegram/pelusa/issues/27
[16:42:56] ghr: Hmm interesting. Cheers. hometime now :)
[16:42:57] WhereIsMySpoon: Why am I getting undefined method `empty?' for #<URI::HTTP:0x8281b78> (NoMethodError) that's this line: Net::HTTP.start(uri.host, uri.port) do |http|
[16:45:52] MrZYX: are you sure that's the line?
[16:46:39] fridim_: Hi. I'm in a intensive dev phase (making a lot of small changes). I would like to send my code into my instance of ruby so it's refreshed. I thought maybe something like trap('SIGHUP') { reload_code }. Guys, do you know some ressources about best practices, how would you do ?
[16:47:13] r0bgleeson: WhereIsMySpoon: that's not the line, come back when you know wtf youre doing
[16:47:34] WhereIsMySpoon: r0bgleeson: Oh I see. I guess the cmd line is lying
[16:47:40] MrZYX: or at least post some context
[16:47:52] WhereIsMySpoon: r0bgleeson: or you could not be a douche about it and just ask nicely for more info if you need it
[16:48:11] havenn_: WhereIsMySpoon: Well, that escalated quickly.
[16:48:12] r0bgleeson: look, you're the person asking for free help, if YOU want help YOU provide me with the details
[16:48:24] WhereIsMySpoon: r0bgleeson: sure, I can do that for you
[16:48:24] r0bgleeson: im not going out of my way to help someone who has no idea what theyre doing and hopes someone can fix it for them
[16:48:32] MrZYX: fridim_: don't, it's not fun
[16:49:11] MrZYX: you'd need to track where a constant is defined (all occurences, in the right load order), remove the constants from Object and load the files
[16:49:51] MrZYX: and that doesn't change existing objects
[16:50:33] WhereIsMySpoon: r0bgleeson: MrZYX: http://pastie.org/8075697
[16:50:54] fridim_: MrZYX, ok, it's tricky, but I don't agree, it's fun :)
[16:51:17] fridim_: AFAIK it's a killing feature in the LISP environments
[16:51:20] MrZYX: WhereIsMySpoon: http://rubydoc.info/stdlib/net/Net/HTTPRequest#initialize-instance_method
[16:51:33] MrZYX: (Get is a subclass of that)
[16:51:46] fridim_: I'm sure it's possible in Ruby, just I have to change the way I use it ( a little)
[16:52:12] WhereIsMySpoon: MrZYX: http://ruby-doc.org/stdlib-2.0/libdoc/net/http/rdoc/Net/HTTP.html is out of date then?
[16:53:20] MrZYX: fridim_: it's a total pain in the ass, I tried it already in a very defined environment (known constant/file path mappings, known instances, ability to reinitialize them from that place) and I can't say it's working good
[16:53:28] WhereIsMySpoon: MrZYX: cause that just puts Net::HTTP::Get
[16:54:56] WhereIsMySpoon: MrZYX: also http://ruby-doc.org/stdlib-1.9.3//libdoc/net/http/rdoc/Net/HTTP/Get.html
[16:55:19] MrZYX: hmm, guess the method description is inaccurate
[16:56:12] WhereIsMySpoon: MrZYX: "P request class. This class wraps together the request header and the request path. You cannot use this class directly. Instead, you should use one of its subclasses: Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Head."
[16:56:14] MrZYX: actually your example doesn't reproduce for me
[16:57:16] WhereIsMySpoon: MrZYX: what can I do then?
[16:57:47] ramblex: WhereIsMySpoon: I don't get that error on 2.0.0 but I see it on 1.9.3
[16:57:56] WhereIsMySpoon: im uising 1.9.3
[16:57:57] MrZYX: WhereIsMySpoon: use the docs for the version you're actually using
[16:58:25] MrZYX: or in this case use the version your docs are describing :P
[16:59:00] WhereIsMySpoon: that was stdlib 2.0
[16:59:04] WhereIsMySpoon: guess i want 1.9.3
[16:59:35] fridim_: https://github.com/alexch/rerun
[16:59:44] fridim_: http://rkh.im/code-reloading
[17:00:10] MrZYX: the first one isn't in process reloading
[17:08:32] fridim_: MrZYX, http://rubyworks.github.io/autoreload/
[17:09:34] fridim_: I don't think that gem is magic...
[17:09:44] MrZYX: I didn't say it can't be done, I said it's not fun ;)
[17:11:00] fridim_: MrZYX, yep I know and the more I look at doc/blog posts, the more I think you're right :)
[17:11:27] MrZYX: if I got that right that gem will break if you use super
[17:12:10] fridim_: ACTION is a bit sad and disillusioned
[17:15:45] fridim_: or maybe, simply pry
[17:15:48] fridim_: Pry also aims to be more than an IRB replacement; it is an attempt to bring REPL driven programming to the Ruby language. It is currently not as powerful as tools like SLIME for lisp, but that is the general direction Pry is heading.
[17:34:45] usercheck_: how to compile ruby script to standalone app?
[17:37:37] fridim_: usercheck_, http://lmgtfy.com/?q=how+to+compile+ruby+script+to+standalone+app
[17:37:52] fridim_: ACTION couldn't resist
[17:41:49] popl: fridim_--
[17:44:52] matti: ACTION gives fridim_ teh look
[17:45:19] Eiam: what happened to the title
[17:45:25] Eiam: matz is nice as so are we or something
[17:46:00] Eiam: Rubyists have a saying, or at least, we used to. "Matz is nice so we are nice." This has sort of been lost over the years... some people who have been around Ruby for a long time still say this, but it's something that's gone in and out of popularity.
[17:46:04] popl: Eiam: is that the topic for #ruby-lang
[17:46:14] popl: *in the topic
[17:46:15] Eiam: it was in the topic for here too, because I don't visit #ruby-lang
[17:46:52] Eiam: fridim_: be nice =)
[17:47:16] Eiam: the internet has enough languages with people trying to "teach people to fish" in that manner
[17:47:44] cek: i'm trying to use a proc in 1.9 to issue a "next" for up-level iterator
[17:47:47] cek: and it doens't work
[17:48:57] cek: Proc.new{ next }.call doesn't actually issue any warning
[17:50:04] kenichi: where does rubinius put my gem bins?
[17:50:35] MrZYX: cek: what about returning true/false from it and doing next if proc.call ?
[17:51:59] dp: I see a piece of code in a project I'm looking at like "file = File.join(jekyll_site.source, *%w[_posts], post_file)". Can someone explain to me what the "*%w[_posts]" is?
[17:52:57] MrZYX: %w[_posts] => ["_posts"], * passes the array elements as individual parameters (it's called splat operator)
[17:54:10] dp: is that just something to make sure that there's no string escaping done or something?
[17:54:36] MrZYX: I'm not sure why it's done this way in this case
[17:55:12] MrZYX: it might be handy if you have a ton of string parameters since it allows to omit the " and ,
[17:55:16] dp: so %w is an associative array, with a _posts key. is that correct?
[17:55:55] MrZYX: foo(*%w{first second third fourth fifth}) instead of foo("first", "second", "third", "fourth")
[17:56:17] MrZYX: no, it's just an array of strings
[17:56:38] dp: it's odd that it's done that way here then, since there's only one parameter being passed
[17:59:33] linduxed: if i was to name a gem, should i call it "red_pears" och "redpears"?
[18:05:43] freestyl3r: hi. i have a string "hello\nthere" how do i print it up to newline char? i only want "hello"
[18:08:39] fryguy: freestyl3r: .split("\n")[0] will return just "hello" from that string
[18:08:44] Hanmac1: freestyl3r:
[18:08:49] Hanmac1: >> "hello\nthere"[/.+/]
[18:08:50] eval-in: Hanmac1 => "hello" (https://eval.in/34781)
[18:09:18] freestyl3r: thanks for the answers
[18:09:39] freestyl3r: just for info: which way is considered better?
[18:09:57] MrZYX: take the one you understand
[18:12:18] kenichi: answer to my prev ? - rbx puts gem bins in prefix/gems/1.9/bin
[18:19:43] dp: is there a way for a script running under webrick to print to webricks stderr or something?
[18:20:24] MrZYX: tried just writing to $stderr ?
[18:21:03] dp: yeah, I tried a $stderr.puts "test", and I don't see anything
[18:29:47] Hanmac1: dp did you try STDERR.puts "test" too?
[18:31:10] wgosling: I have a question about CGI.escape(). I have need to generate a URL that has one (of several) ampersands excaped as %26. If I manually replace the & in the url with %26, CGI.escape will escape that again, and provide %2526.
[18:31:30] dp: that also doesn't seem to work. I'm not sure if it matters, but this is all wrapped up in a Sinatra app. I'm fairly unfamiliar with Sinatra, so it may be doing something I don't expect
[18:32:03] wgosling: Anybody know how I can get CGI.espace to produce %26
[18:33:18] fryguy: wgosling: just don't escape it twice
[18:33:42] MrZYX: wgosling: do not replace & by hand, and run it for each value, not on the whole url
[18:34:46] asteve: is it possible to raise an exception and return a string from the same method?
[18:34:56] wgosling: fryguy: I can get it to escape it 0 times or twice.
[18:35:32] MrZYX: >> require 'cgi'; CGI.escape "foo&bar"
[18:35:33] eval-in: MrZYX => "foo%26bar" (https://eval.in/34783)
[18:35:40] asteve: hmm, is it kosher to attempt to extract the a string variable from a raise?
[18:36:07] MrZYX: don't use exceptions for control flow
[18:36:12] fryguy: wgosling: time to rethink that part of your app
[18:41:37] juhoh: Oye! I use rest-client with couchdb. When I try to get a doc with a key, which has to be quoted for it to be valid json, rest-client complains the uri is invalid. How can I get this to pass? My uri looks something like this: uri = 'http://couch:5984/blog/_design/posts/_view/published?key="slug-here"' any thoughts??
[18:42:18] juhoh: this doesn't work with curl either only with my browser :/
[18:42:18] canton7: juhoh, hmm? "slug-here" isn't valid json anyway
[18:42:50] juhoh: well it is for couch when I query it for findOne
[18:43:40] juhoh: it works when I query it with my browser
[18:43:40] juhoh: if I query it without the quotes I get the couch error bad_request, invalid json
[18:44:02] canton7: is the browser escaping the quotes?
[18:44:41] juhoh: canton7: I tried with &quot; around my key but that didn't work
[18:44:47] juhoh: if that's what you mean?
[18:44:57] canton7: not sure what the browser might be doing
[18:44:58] fryguy: juhoh: that's HTML escaping, not URI escaping
[18:45:25] juhoh: ofc... so I have to URLEscape it
[18:45:34] MrZYX: CGI.escape '"slug-here"'
[18:52:22] juhoh: WAT: http://pastie.org/8076069 ??
[18:52:54] MrZYX: >> CGI.escape "http://google.com"
[18:52:55] eval-in: MrZYX => uninitialized constant CGI (NameError) ... (https://eval.in/34784)
[18:53:08] MrZYX: >> require 'cgi'; CGI.escape "http://google.com"
[18:53:08] eval-in: MrZYX => "http%3A%2F%2Fgoogle.com" (https://eval.in/34785)
[18:53:22] MrZYX: CGI.escape is for values, not for URIs
[18:54:15] MrZYX: how should it know whether you meant /?foo&bar or /%2F%3Ffoo%26bar ?
[18:56:52] juhoh: I don't get it :D
[18:57:22] juhoh: GCI.escape returns a String on a given value
[18:57:37] MrZYX: and now that value is escaped
[18:57:38] juhoh: and RestClient.get takes a String as a param
[18:57:43] MrZYX: and can be safely used in a url
[18:57:56] juhoh: what's the difference with a String that's escaped or not?
[18:58:04] juhoh: wtf am I missing here?
[18:58:35] MrZYX: "?foo&bar" not escaped, "%2F%3Ffoo%26bar" escaped
[18:59:23] popl: juhoh: https://en.wikipedia.org/wiki/Percent-encoding
[18:59:26] juhoh: yes, so why does it complain when I feed the escaped value to RestClient.get?
[18:59:27] wgosling: Ok. I figured out my issue. Someone had monkey-patched CGI.escape to be URI.escape which explains my & problems. However, that was done to work around ' ' problems, since one of the rest servers I'm using is terrible and tries to interpret a + in a query as a + and not space...
[19:00:04] MrZYX: juhoh: example.com/?foo=bar&baz vs example.com/?foo=bar%26baz, if you do CGI.escape("example.com/?foo=bar&baz") how should it know which version you meant?
[19:01:16] henk: hi, I want to pass all arrays in an array of arrays as arguments to Array.product. Is there any sane way of doing this?
[19:01:33] MrZYX: juhoh: so you do "example.com/foo=#{CGI.escape("bar&baz")}" to make it clear
[19:01:34] henk: Without knowing how many arrays are in that array, I should mention.
[19:01:35] canton7: that's a lot of arrays...
[19:01:37] juhoh: but I got a NoMethodError from restclient
[19:02:17] henk: canton7: hehe, yeah :)
[19:03:08] MrZYX: juhoh: of course you need to wrap the whole thing into URI.parse again if restclient expects a URI object
[19:04:55] juhoh: ok, thanks guys ;) I got it now
[19:05:01] juhoh: you really had to bend it to me :D
[19:05:08] popl: it expectas a raw url apparently
[19:05:37] popl: *expects
[19:06:22] juhoh: yeah, I couldn't escape the whole uri only the query string
[19:07:06] popl: ugh, the documentation isn't too clear
[19:55:48] foofoobar: Hi. https://gist.github.com/anonymous/45e74d32d2ebba81a527 how can I print all response headers?
[19:57:20] foofoobar: got it. .to_hash
[20:01:50] diegoviola: best way to learn TDD/BDD, etc?
[20:01:59] Xeago: diegoviola: do it
[20:02:27] diegoviola: do i just have to make it an haibt?
[20:02:35] Xeago: lifestyle
[20:02:37] Xeago: codestyle
[20:07:48] juhoh: diegoviola: read on it/watch some videos then _commit_ to a project and take it to the end. every time you encounter a problem you have to solve it. this is how I learned and it almost always pays off...
[20:19:25] cozby: Hi, reading through some ruby code I came across the following and am not sure how to interpret this.. (I'm new to Ruby)
[20:19:26] cozby: !!(resp.code == '200' && resp.body == 'true')
[20:19:35] cozby: the person is returning that
[20:19:45] cozby: what is the point of the double negation?
[20:20:24] MrZYX: there's none
[20:21:16] MrZYX: iirc it's a C ideom to make any positive number/0 to 1/0
[20:22:47] cozby: MrZYX: so there's no point to the double negation
[20:22:51] MrZYX: absolutly
[20:22:59] cozby: thats what I thought
[20:23:00] waxjar: it's a way to turn a truthy value into a Boolean value
[20:23:01] MrZYX: even worse !0 in ruby isn't !0 in C
[20:23:26] waxjar: !"string" will return false, !!"string" will return true
[20:24:44] cozby: MrZYX: the conditional I provided would return a bool regardless...
[20:24:55] cozby: true/false is the same as boolean
[20:25:12] MrZYX: I still think it's a C programmer not thinking
[20:25:19] cozby: interesting
[20:25:29] cozby: this is in the latest gitlab code
[20:27:11] cozby: MrZYX: https://github.com/gitlabhq/gitlab-shell/blob/master/lib/gitlab_net.rb#L19
[20:27:13] MrZYX: you commonly do that in C for example if you want to turn a binary AND or OR to 0/1
[20:27:23] cozby: hmm I see
[20:30:27] cozby: MrZYX: well thank you
[20:35:26] terrellt: I'm curious to see what test failed when they didn't force a boolean.
[20:35:41] MrZYX: I doubt any did
[20:35:58] MrZYX: a == b && c == d is already a boolean
[20:36:03] terrellt: Definitely shouldn't. If == starts returning something besides true/false they've got bigger problems.
[20:36:11] MrZYX: no matter what a, b, c or d are
[20:37:56] r0bgleeson: MrZYX: no its not, not in ruby
[20:38:07] r0bgleeson: >> true && "wee"
[20:38:07] eval-in: r0bgleeson => "wee" (https://eval.in/34788)
[20:38:34] terrellt: r0bgleeson: I think you misread him. It's == that returns true/false.
[20:38:48] r0bgleeson: oh sorry my bad i did
[20:39:58] popl: >> nil || 'foo'
[20:39:59] eval-in: popl => "foo" (https://eval.in/34789)
[21:30:12] terrellt: Damnit rspec expect syntax, why'd you have to take over and ruin my life.
[22:25:42] blitz: what is the => operator used for
[22:26:58] Spooner: blitz, It is used in Hash { key => value }
[22:27:23] Spooner: Also known as the "Hash Rocket".
[22:27:25] blitz: and when you put it into a function, it's for the params hash?
[22:27:43] blitz: in a method call
[22:27:50] Spooner: Yes, there is an implicit hash at the end of the params (which you don't need to wrap in {}).
[22:28:08] blitz: the toughest thing about ruby so far is all the implicitness
[22:28:45] popl: what are you implying?
[22:31:05] sam113101: ACTION gets the joke
[22:31:23] popl: well give it back because I didn't make it for you
[22:31:34] popl: there are starving kids in africa
[22:32:38] sam113101: the things that he's implying were implied, that's why he only said "exactly", get it?
[22:33:14] sam113101: just assuming
[22:33:25] popl: implication not telepathy
[22:33:30] popl: there is a difference sam113101 :)
[22:33:50] popl: implication requires words existing for some possible meaning to be inferred
[22:42:47] Guest91028: can someone explain "state" ?
[22:42:59] Guest91028: ie: behavior versus state
[22:43:51] popl: That's more of a CS topic than a ruby topic, Guest91028
[22:44:09] popl: Wikipedia's probably got some good articles about it.
[22:44:10] Guest91028: poql: im reading a ruby tutorial about modules
[22:44:19] Guest91028: http://rubymonk.com/learning/books/1-ruby-primer/chapters/35-modules/lessons/79-getting-modular
[22:46:03] popl: Guest91028: my nickname is popl. you can type po then hit the tab key to autocomplete my nickname if you are in an IRC client that supports it.
[22:46:26] Guest91028: cool. thanks popl
[22:46:29] popl: that works for any nickname on IRC
[22:46:42] popl: no problem
[22:47:26] popl: Guest91028: https://en.wikipedia.org/wiki/State_(computer_science)
[22:48:00] Guest91028: ah. this makes sense
[23:25:54] kaneda^: hey, is there a rails specific channe?
[23:26:03] kaneda^: is it #rails?
[23:26:09] popl: rubyonrails I think
[23:26:10] popl: ask alis
[23:26:14] popl: /msg alis help
[23:26:23] eval-in: r0bgleeson => "hI" (https://eval.in/34803)
[23:26:41] r0bgleeson: 18>> {:foo => "bar"}.select { |x,k| x == :foo }
[23:26:42] eval-in: r0bgleeson => [[:foo, "bar"]] (https://eval.in/34804)
[23:27:49] kaneda^: i think i broke alis
[23:28:53] popl: go tell #freenode
[23:29:11] kaneda^: nono, she's fine, shhh
[23:29:32] kaneda^: it is in fact #rubyonrails
[23:29:40] kaneda^: but for some reason the language chans come up first
[23:29:51] popl: yes, for some reason