« Back to channel list

#ruby - 28 January 2015

« Back 1 day Forward 1 day »
[00:00:20] Authenticator: I mistyped above though, ... if it's blockeD, reading (.pop), as the last one [producer] dies ...
[00:01:40] Authenticator: I made it work originally by rescuing Exception on the q.pop, which seemed ugly, and only worked once per runtime?!?
[00:02:16] Authenticator: Now I've got the producers set to push a semaphore value onto the queue as they die, which is much less hacky, but still doesn't seem clean.
[00:04:36] splud: sounds more like you???re collecting toe tags from the threads.
[00:05:10] zenspider: I can't make heads or tails out of BS code
[00:06:12] Authenticator: splud: I've heard it called that, in retrospect. I'm currently going out of my way to collect one when they're all dead, but if I collected one each and just counted them that might be easier.
[00:06:45] kl: zenspider: my biggest fear is taking a job on a team of developers that write BS code.
[00:06:58] splud: post-release code reviews at a company I used to work for were called postmortems.
[00:07:00] kl: It would literally ruin my working life.
[00:07:35] splud: My biggest fear is visual-anything.
[00:07:41] splud: or cobol.
[00:09:03] wallerdev: vb.net isnt too bad
[00:09:12] wallerdev: i did it for a couple years, basically the same as c# or java
[00:09:24] wallerdev: with dumb syntax haha
[00:12:17] postmodern: is there something like Hash#values_at, but returns a Hash?
[00:12:31] postmodern: seems like I'm stuck between values_at and using select
[00:19:26] crocket: bb-m.rubygems.org times out frequently, so I can't install gems.
[00:19:32] crocket: Can anyone bring it up?
[00:20:14] crocket: I'm so deperate.
[00:20:17] crocket: I'm so desperate.
[00:20:34] zenspider: I don't even know what that is
[00:20:44] wallerdev: its probably one of the rubygems mirrors
[00:20:53] wallerdev: they give you a different mirror based on what country you try to download from
[00:21:08] crocket: bb-m.rubygems.org is the single reason that I can't install gems.
[00:21:17] crocket: I don't know how to choose a different mirror.
[00:21:24] wallerdev: might be able to overwrite it in your hosts file
[00:21:38] zenspider: gems install for me. go to #rubygems and ask around
[00:22:12] zenspider: I'm hitting: GET https://rubygems.global.ssl.fastly.net/gems/minitest-5.5.1.gem
[00:22:19] crocket: wallerdev, Do you suggest I overwrite bb-m.rubygems.org?
[00:22:23] zenspider: and don't specify what to hit at all
[00:22:38] crocket: Oh my god...
[00:22:47] crocket: bb-m.rubygesm.org can't download mycarpet
[00:22:53] crocket: I mean redcarpet
[00:23:21] wallerdev: can download and install it manually or overwrite the server in your hosts file
[00:23:40] crocket: How do I avoid bb-m.rubygems.org ?
[00:27:26] wallerdev: should be able to get it from the same server zenspider linked
[00:27:32] wallerdev: if you know the version you want
[00:27:39] wallerdev: its the same format just paste it in your browser
[00:58:18] ellisTAA: i???m trying to see if a variable does not equal nil, would i write it like @Variable_name !== nil
[00:59:59] crocket: I finally went through the rubygems timeout hell.
[01:01:16] centrx: ellisTAA, nil itself is falsy, and @variable.nil? will return a true/false if you like
[01:04:29] weaksauce: ellisTAA there are only two things that evaluate to false in ruby. nil and false
[01:04:57] ellisTAA: weaksauce: ty too
[01:05:48] weaksauce: ellisTAA have you tried the codeacademy.com ruby course yet?
[01:06:09] ellisTAA: i dont need to do the course, i need practice, i already learned the concepts
[01:06:41] weaksauce: ellisTAA that provides practice... it's not a book
[01:06:47] weaksauce: it's interactive
[01:07:12] ellisTAA: ill check it out as soon as i get these problems done
[01:09:37] weaksauce: i'd suggest you check it out now. you really don't have a great grasp on the concepts and it would help you immensely. if you do know the language as well as you think you do it shouldn't take much time at all to breeze through it.
[01:16:28] zenspider: nil checks are almost always a code smell
[01:16:53] zenspider: btw... codeschool is apparently free for the next 3 days
[01:17:23] weaksauce: is that better than codeacademy?
[01:17:39] weaksauce: codeacademy is free
[01:18:48] zenspider: dunno. I don't use either of them
[01:20:08] sevenseacat: codeschool is good for the basics and for lots of hand-holding
[01:20:21] sevenseacat: and its ruby course was pretty meh
[01:21:29] pipework: I like learning ruby by using TWGR, then picking up a pickaxe for reference, and then getting metaprogramming ruby and only reading the first half.
[01:21:38] pipework: After that, you're kinda set to go learn anything.
[01:23:03] nii236|irssi: sevenseacat: What do you suggest for a pathway from ruby to rails then?
[01:25:30] ellisTAA: i???m currently using .assoc(obj) on a hash to return a key and value that match my argument, but it is formatting it like this [???key name???, ???value name???]. Anyone know a method that will do the same thing and return it in this format [???key name??? => ???value name???]?
[01:27:23] centrx: ellisTAA, interpolate a string that looks how you want it to look
[01:27:34] ellisTAA: ahh .. ok thanks
[01:29:15] zenspider: ellisTAA: you mean, it is doing exactly what the doco says it'll do
[01:29:28] zenspider: ellisTAA: why are you worried whether the result is an array or a hash?
[01:29:44] ellisTAA: i dont care, it???s the test that i???m working on, i didnt write it
[01:30:14] zenspider: and [???key name??? => ???value name???] is nonsensical. that's an array with a hash syntax
[01:30:49] ellisTAA: well that???s how assoc outputs it...
[01:30:58] zenspider: no it isn't
[01:31:10] zenspider: ["key" => "val"] doesn't exist
[01:31:56] centrx: assoc outputs an array, but he wants this specific format to satisfy a test problem he is doing
[01:32:00] centrx: apparently
[01:32:24] zenspider: that's great. what he's asking for is nonsensical
[01:33:10] ellisTAA: centrx: could u help me out with creating a string for my output? right now i???m not really controlling the format so i???m not sure how to turn it into a string with interpolation. https://gist.github.com/ellisTAA/0a8c4da823b3851e7685 line 66 is the current output
[01:33:34] weaksauce: pipework eloquent ruby is really good.
[01:33:54] pipework: weaksauce: Yeah, it totally is! I don't know how I feel about handing that to a beginner though.
[01:34:09] pipework: I feel like they need to skin their knees a bit on ineloquent ruby for a while.
[01:34:12] weaksauce: oh definitely not!
[01:34:36] weaksauce: that's more of an "ok, I know the syntax and how to do things... how do I make it better"
[01:35:55] pipework: I could see that as a good way to bring up people who do it the right way from the start, but I worry about them being unable to do much more than just parrot his opinions on why being eloquent is better. Sometimes having no previous experience to compare against could shake the foundation that eloquence brought them
[01:36:22] ellisTAA: r u guys talking about advi grimm???s book?
[01:36:32] zenspider: gah that's a mess
[01:37:18] ellisTAA: what???s a mess?
[01:37:21] zenspider: I... I can't even finish reading that
[01:37:40] zenspider: your logic and your code
[01:37:59] ellisTAA: i welcome feedback
[01:38:24] zenspider: 1) use your text editor and reformat your code to be idiomatic and readable
[01:38:35] ellisTAA: zenspider: ok ill do that
[02:14:10] ponga: hey shevy
[02:14:14] ponga: are you there
[02:47:28] Cat_1: Pretty empty in here
[03:36:21] ericwood: non-work hours
[03:36:57] sevenseacat: for some people
[03:37:48] xcesariox: where do i put this "results = Book.collection.map_reduce(map, reduce, out: "vr")" command syntax into? into rails console or mongodb console directly? https://gist.github.com/shaunstanislaus/0f8d87939c0ab01ce5d6
[03:38:57] sevenseacat: xcesariox: don't cross-post.
[03:39:22] sevenseacat: especially if what you're cross-posting is offtopic in one of the channels.
[03:39:50] ericwood: yeah hadoop is strictly forbidden here
[03:43:53] chipotle: helllo ruby
[03:49:03] gr33n7007h: can someone tell my why when I add `unless @queue.pop.nil?` it only pops half of half but when I remove `unless @queue.pop.nil?` it pops all off #=> https://gist.github.com/anonymous/6b0c5c33bf2e32feafa7 (line 79)
[03:50:04] gr33n7007h: my brain ain't working thank you muchly
[03:50:23] sevenseacat: you're welcome
[03:51:19] gr33n7007h: and it's late :(
[03:58:37] epitron: gr33n7007h: dude
[03:58:42] epitron: queue.pop is destructive
[03:58:54] epitron: that's like saying, "puts string if string.erase"
[03:59:18] epitron: it should be: "target = @queue.pop unless @queue.empty?"
[03:59:35] epitron: that loop should be:
[03:59:42] epitron: while target = @queue.pop
[04:00:18] epitron: i think you need some sleep gr33n7007h
[04:01:03] gr33n7007h: yes, fuck it going bed
[04:01:09] gr33n7007h: ACTION YAWN
[04:01:49] gr33n7007h: anyways cheers epitron i'' change it in the morning
[04:04:01] epitron: good ascii art btw
[04:05:41] gr33n7007h: epitron: just changed it to while target = @queue.pop ... end it finished right at the I get a fierce.rb:77:in `join': deadlock detected (fatal)
[04:08:23] gr33n7007h: goodnight god bless
[04:09:45] epitron: deadlock bedtime
[04:20:45] nii236|irssi: Argh crap I'm up to regex topic in koan nooo
[04:26:14] EasyCo: Hey guys, general tool question... what tools, if any, do you guys use for planning out an application. i.e. mapping features, user stories and so on...
[04:28:28] mozzarella: just a regular text editor
[04:29:55] EasyCo: mozzarella: Thanks, we just use whiteboards and word as well. Just wondering if there was a nice tool out there that kind of brought them all together.
[04:56:18] weaksauce: nii236|irssi why aw crap?
[04:56:26] weaksauce: regex is useful
[05:00:56] epitron: EasyCo: mindmapping software is nice
[05:00:57] epitron: as are wikis
[05:01:33] EasyCo: epitron: Any mind mapping software you like?
[05:01:40] epitron: i use XMind because it's free :)
[05:01:42] epitron: oh! workflowy is great
[05:02:02] epitron: it's like a linear mindmap :)
[05:02:30] epitron: https://www.youtube.com/watch?v=CSmbnaPZVHE
[05:03:26] epitron: it's been a lot more useful for me than xmind
[05:03:59] epitron: a) you can search it, b) two people can edit it simultaneously from different browsers, c) it loads fast
[05:04:13] epitron: i really like being able to "zoom into" a node
[05:04:16] EasyCo: Cool, I'll have a look, thanks for your input. Pivotal Tracker also looks pretty nice for agile dev with user stories.
[05:04:19] epitron: mindmaps don't have that
[05:04:50] epitron: i'm not a fan of heavy tools
[05:04:56] epitron: i always stop using them
[05:05:18] epitron: oh yeah, e) you can dump your whole workflowy database to an indented textfile, and reimport it later
[05:05:31] epitron: or wait.. i might be thinking of onetab :)
[05:05:42] EasyCo: Obviously tried a few...
[05:05:49] epitron: http://blog.workflowy.com/2013/06/03/workflowy-now-supports-opml-import-and-export/
[05:06:04] epitron: onetab is "git stash" for chrome tabs :)
[05:06:15] epitron: different, but also nice
[05:07:01] Nilium: "git stash" for tabs is called minimizing the window and opening a new one.
[05:07:08] epitron: so yes, "outliners" is the class of tools that workflowy is a member of
[05:07:08] Nilium: Your mind has been blown.
[05:07:15] epitron: there are other outliners
[05:07:29] epitron: Nilium: sounds good. now i just need 128GB of ram :D
[05:07:40] Nilium: I've got 16gb and it hasn't been an issue yet
[05:07:48] Nilium: But then I don't use Chrome, so I guess my memory usage isn't through the roof yet.
[05:08:08] epitron: if you never close windows, you'll get there pretty fast
[05:08:20] epitron: when i stopped using chrome, my memory usage never broke 2gigs :)
[05:08:25] Nilium: Kind of funny that Chrome is the new Firefox: bloated, slow, and kind of annoying.
[05:08:38] Nilium: Meanwhile, Firefox just crashes if you hit 200 tabs or so.
[05:09:59] EasyCo: 200 tabs! I feel durtay if I have more than 10 open.
[05:10:12] epitron: yeah, that's too many tabs
[05:12:22] epitron: EasyCo: https://en.wikipedia.org/wiki/Outliner
[05:12:27] epitron: these are good :)
[05:13:05] Nilium: I just use a notebook with graph paper.
[05:13:11] Nilium: I'm lazy about this stuff.
[05:13:19] epitron: it has to be something you'll actually use
[05:13:36] epitron: that's the problem with those bit complex atlassian webapps
[05:13:42] Nilium: Trouble with software for it is I can't drag the software with me when I go to call someone an idiot
[05:14:00] TheNet: has anyone here tried opal and if so were you impressed?
[05:14:00] epitron: "hold on!! let me pull it up on my phone!!!"
[05:14:09] epitron: *looks down and pokes at phone for 5 minutes*
[05:14:27] epitron: opal isn't bad
[05:14:28] Nilium: 'Cause I'm very big on just getting up from my desk and walking over to the person who I want to talk to (or is currently on my shit-list)
[05:14:32] epitron: the js it produces is pretty hard to read though
[05:14:41] epitron: i was impressed with how much of ruby was suppored
[05:14:56] Nilium: I think Opal produces source maps, so there's maybe that.
[05:14:58] TheNet: I don't really care about readability, how did you find the performance though?
[05:15:02] Nilium: I'd honestly never use it though.
[05:15:13] epitron: i didn't use it much
[05:15:19] epitron: i just played around with it for a few minutes
[05:15:23] Nilium: Unless a to-javascript language has static typing or reduces the amount of code I have to write drastically, I don't care. It's a pain to debug.
[05:15:26] epitron: it was very fast at 10 line ruby code!
[05:15:50] epitron: pain to debug is more of a browser problem than the language
[05:15:52] TheNet: Nilium: I just perfer the ruby syntax much more than javascript. I'm trying to decide between it and coffee script
[05:15:54] Nilium: It's bad enough that debugging anything in JS is already horrible, I don't like having to also keep a compiler in my head.
[05:15:56] epitron: sourcemaps should make that easy
[05:16:14] epitron: browsers \o/
[05:18:21] mozzarella: I??have the same opinion as Nilium
[05:18:47] epitron: i actually liked using coffeescript
[05:19:01] epitron: do any browsers support ES6 yet?
[05:19:43] mozzarella: coffeescript is easier to transform I think
[05:20:25] epitron: the JS it generates is readable
[05:21:00] epitron: programming is definitely generating a tower of babel kind of situation
[05:21:09] mozzarella: yeah, it's closer to javascript than ruby, it's really just a different syntax for the same thing, with a few addons
[05:21:24] epitron: so many people trying to make programming better by adding yet another language
[05:21:44] Nilium: I use LiveScript for most things, much to the chagrin of every other human being on the planet
[05:21:48] mozzarella: I??don't write enough javascript to bother using something else
[05:21:50] nii236|irssi: weaksauce: regex hurts my brain
[05:21:52] epitron: i think we need to unify our efforts so we can have a cross-language standard library (that's not written in C)
[05:22:04] epitron: then, "yet another language" will be useful from its birth
[05:22:09] Nilium: I'd probably use Dart if I thought I cared, but I don't
[05:22:16] Nilium: Or PureScript
[05:22:27] TheNet: http://xkcd.com/927/
[05:22:28] weaksauce: regex is best ex
[05:22:28] Nilium: PureScript, however, requires haskell to be installed, and so I haven't actually tried it.
[05:22:29] epitron: ES6 is going to win
[05:22:34] epitron: it just needs to be released
[05:22:35] mozzarella: epitron: I??think different browsers support different parts of ES6
[05:22:36] weaksauce: nii236|irssi ^
[05:22:43] mozzarella: parts/features
[05:22:44] Nilium: ES6 will be unused because nobody will write anything for it due to legacy support issues.
[05:22:53] epitron: Nilium: there's polyfills
[05:22:54] mozzarella: I??don't think any of them support it entirely
[05:22:59] Nilium: epitron: You can't polyfill syntax.
[05:23:00] epitron: you can already write ES6 that compiles to JS
[05:23:04] epitron: yes you can :)
[05:23:06] weaksauce: just don't use if for things that you shouldn't be using regex for. nii236|irssi
[05:23:12] Nilium: If you compile to JS then it's not ES6 -_-
[05:23:18] epitron: whatever SEMANTICO
[05:23:30] epitron: you can totally use ES6 and support old browsers
[05:23:37] mozzarella: Nilium: >legacy support issues
[05:23:46] mozzarella: it's seriously not as bad as it was
[05:23:51] mozzarella: the web is moving pretty fast now
[05:24:00] epitron: yeah, now that everyone's stopped trying to resist it
[05:24:06] Nilium: Not fast enough, considering JS is still a thing. ???_???
[05:24:18] epitron: "just go with the web bro"
[05:24:26] epitron: <genius engineer> "fiiiiiiiiine"
[05:24:29] Nilium: You ever noticed how replacing javascript has never been an option on the table? That's legacy support crap.
[05:25:13] epitron: NaCl was the answer to replacing JS
[05:25:22] Nilium: Getting any sort of change or improvement to browsers in is the slowest process on the planet and requires one browser to be self-updating and the only thing in use ever.
[05:25:41] epitron: it used to be the slowest thing ever
[05:25:43] epitron: it's pretty fast now though
[05:25:49] epitron: chrome is zipping along
[05:25:57] epitron: and everyone has to catch up to them to remain relevant
[05:26:02] Nilium: Not really.
[05:26:08] epitron: which part is not real?
[05:26:09] mozzarella: they're trying to improve JS instead of replacing it
[05:26:33] epitron: the real problem with replacing JS is that upgrading human brains is a lot harder
[05:26:44] Nilium: Chrome can't do anything to force any other browser maker's hand.
[05:26:45] epitron: ES6 is just javascripty enough that people will go with it
[05:27:08] epitron: Nilium: right, but there are really only 2 browser makers left: Chrome-based, and Firefox
[05:27:11] Nilium: If Chrome does something, then you have to say "this is only for Chrome" and the people who can't use it will probably just ignore it because it's too much of a pain to install Chrome and then run it.
[05:27:15] Nilium: You forgot Apple.
[05:27:18] epitron: and IE, if your company's IT guy sucks
[05:27:30] epitron: Safari is basically chrome :)
[05:27:32] Nilium: Lest we forget iOS is still relevant, and Safari as a result.
[05:27:38] mozzarella: chrome is trying to push dart and it's not working
[05:27:48] epitron: true, mobile is a different issue
[05:27:53] epitron: most mobile browsers are webkit-based though
[05:28:22] mozzarella: they should make browsers read bytecode, and we could use any language and make it output bytecode instead
[05:28:24] epitron: mozzarella: if you read their original memo, they actually predicted that the web might beat Dart, because it was moving so fast
[05:28:25] Nilium: And who controls Webkit?
[05:28:29] mozzarella: instead of javascript
[05:28:32] Nilium: Right, Apple does! :D
[05:28:37] Nilium: So we're boned.
[05:28:45] epitron: well, chrome forked it
[05:29:01] epitron: chrome is the leader really
[05:29:11] Nilium: Which isn't really important. Webkit isn't what we're talking about.
[05:29:13] mozzarella: it's not like you can't obfuscate javascript, so I??don't see why not
[05:29:25] Nilium: JavascriptCore, V8, etc. are the things we're concerned with
[05:29:48] epitron: mozzarella: heh.. yeah, people were messing with the bytecode idea for a while... ASM.js and NaCl came out of that
[05:29:51] Nilium: The bytecode issue has come up a few times before and the opinion is that having bytecode means you can't optimize JS as well because reasons.
[05:30:07] epitron: mozzarella: eventually they realized that it's good enough to just emit JS
[05:30:20] Nilium: Even though it should be easier to find patterns in bytecode than in JS source.
[05:30:23] epitron: i guess they figured it's not worth the effort standardizing
[05:30:42] mozzarella: if you can optimize java bytecode, why not some other kind of bytecode? lol
[05:30:56] epitron: bytecode would be ideal
[05:31:15] epitron: but everyone just compiles to JS, so they were like, "meh, fuck it"
[05:31:45] mozzarella: meh, it's really just standards, you gotta follow the standards
[05:31:56] mozzarella: you can't do it your way or people will complain
[05:31:57] epitron: we're dancing around the real performance issue though -- THE DOM :)
[05:32:06] epitron: no matter what language you use, the DOM is still terrible
[05:32:16] aagdbl: has anyone started rescue workers inside another process? i.e. without a rake task?
[05:32:32] epitron: aagdbl: is that a rails thing?
[05:33:13] epitron: well, i have no idea what you're talking about :)
[05:33:43] Nilium: I think browsers in general might be the things that have changed the least in terms of capabilities over the last 20 years.
[05:33:53] aagdbl: https://github.com/resque/resque
[05:33:58] splud: we run a watchgog thread from an installer process,
[05:34:09] Nilium: Everyone will go "but they have CSS 3 and HTML5 now" but they're all such small things
[05:34:52] splud: the last _20_ years? Browsers have changed a lot.
[05:34:52] epitron: Nilium: their ability to use all your ram has definitely improved
[05:35:01] Nilium: Is that an improvement?
[05:35:03] epitron: yeah, you should try netscape 4 again :)
[05:35:05] splud: heh, true.
[05:35:08] epitron: no, it was a joke Nilium
[05:35:18] splud: NCSA Mosaic.
[05:35:21] Nilium: They still just display formatted text.
[05:35:24] Nilium: And images.
[05:35:25] Nilium: That's kind of it.
[05:35:35] epitron: i use chrome with js/plugins disabled
[05:35:38] splud: Or for a blast from the past, use the Gopher protocol.
[05:35:39] epitron: s/chrome/opera
[05:35:45] Nilium: Ha, Opera.
[05:35:48] epitron: opera 12 still works on a lot of the web
[05:36:02] epitron: google is really good with degradability
[05:36:16] epitron: uses no ram, it's lightning fast
[05:36:26] epitron: opera 12's caching is great -- not influenced by advertisers :)
[05:36:37] splud: Opera used to be so cool. And firefox too. Then, WTF?
[05:36:37] Nilium: I use Safari because it doesn't crash as much as Chrome and Firefox.
[05:36:38] epitron: and if i want, i have a proxy that can rewrite cache-control headers
[05:37:01] Nilium: I value the ability to survive my idiocy.
[05:37:17] epitron: splud: in the case of opera, the technical/creative genius who made opera what it was left
[05:37:27] epitron: splud: i think that was around 2007
[05:37:37] Nilium: Was Opera ever open source?
[05:37:40] epitron: he's the guy who first introduced tabs and gestures
[05:37:47] Nilium: I mean aside from when they switched to being a fork of Chrome.
[05:37:59] Nilium: Not sure if that's open-source either.
[05:38:04] epitron: they were always closed
[05:38:13] epitron: they had an SDK you could license (see: Wii browser)
[05:38:27] epitron: a lot of people want opera 12 opensourced
[05:38:36] Nilium: Kind of a shame. Seeing the old Opera (pre-Chrome) source would be nice.
[05:38:37] splud: I wish to shoot the chap here who continues to have outdated platforms being built in our kernel build process, and they???re built before the platforms which ARE current.
[05:38:38] epitron: opera claims that it can't because the codebase is too messy or something :)
[05:38:45] splud: Must suffer through so much churn...
[05:38:50] Nilium: Opera was kind of the testing ground for new CSS crap, so it was neat.
[05:38:59] epitron: their HTML renderer is so awesome too
[05:39:03] epitron: it's like greased lightning
[05:39:25] epitron: the Javascript engine was garbage though
[05:39:34] epitron: if they opensourced it, i bet you could just drop V8 in there
[05:39:59] epitron: opera's problem was that they never found a good business model
[05:40:03] splud: and then a bunch of developers would start cramming all sorts of useless crap in there...
[05:40:09] epitron: they couldn't charge people for the browser, so they started selling out to advertisers
[05:40:26] epitron: i think that's what drove away the original innovative dude
[05:40:27] Nilium: Opera's business model was (rightly) accusing Microsoft of having a monopoly and hoping that would work.
[05:40:30] Nilium: It didn't work.
[05:40:45] splud: I???d pay for a browser that didn???t consume all my memory, and wasn;t coming out with an urgent update several times a week.
[05:41:12] epitron: splud: at this point, definitely :)
[05:41:18] epitron: 7 years ago i wouldn't have though
[05:41:29] splud: I applies, what 35.0 from Firefox after waiting a couple of days, and I kid you not, no sooner had I restarted the effin thing, than there was a dialog telling me I need to upgrade to 35,1...
[05:41:50] epitron: it only checks for updates on startup ;)
[05:42:02] splud: epitron: finances different, or your perceived value of a good tool?
[05:42:19] epitron: well, opera in 2008 was awesome
[05:42:26] epitron: and it was free
[05:42:29] epitron: so, i didn't care :)
[05:42:43] epitron: and i guess my finances have improved as well
[05:42:57] epitron: i wonder if people would pay $2/month for a browser
[05:43:14] epitron: ugh, there's so much friction to getting people to pay
[05:43:35] epitron: create account, validate email, input credit card info, check that money went through...
[05:43:44] splud: I pay for a TiVo subscription - allows me and my kids to skip commercials, and watch what we want when we???re interested.
[05:43:45] epitron: there needs to be a magic button that just sends someone $1 when you click it
[05:43:52] splud: Time has value.
[05:44:06] splud: I see a button which will be exploited.
[05:44:18] epitron: ok, a coin slot on your computer
[05:44:26] epitron: and you can just put coins in it, and they get sent over the internet
[05:44:33] splud: in fact it???s probably already been exploited in MSIE.
[05:44:35] epitron: and a dirty guy comes into your house once a week to empty the coin box
[05:45:15] splud: smokin a stogie, hasn???t showered in weeks, coarse beard, coarse attitude, filthy clothes.
[05:45:29] epitron: covered in grease
[05:45:39] epitron: he shoves a crowbar into your computer
[05:45:47] epitron: pops open the coin drawer
[05:46:02] epitron: coughs phlegmily
[05:46:11] Nilium: ACTION looks at heroku to figure out why anyone in their right mind pays for this.
[05:46:15] epitron: (phlegmatically?)
[05:46:19] splud: and hacks a bit onto your desk and monitor...
[05:46:29] sevenseacat: Nilium: because its easy
[05:46:38] splud: oooh, he;s a trained phlegmatist.
[05:46:41] Nilium: Easy is scp'ing a binary to my server and restarting it
[05:46:44] Nilium: This looks complicated
[05:46:49] sevenseacat: people like me absolutely hate doing anything devopsy
[05:47:01] Nilium: I use Go precisely because I'm lazy as hell
[05:47:03] sevenseacat: deployment is just a git push
[05:47:16] epitron: splud: Coinpal sounds like it might make an amusing youtube video :)
[05:47:19] Nilium: I don't want deployment tied to my SCM. That sounds bad.
[05:47:21] splud: I???m rather irritated with Go actually.
[05:47:32] sevenseacat: Nilium: it does?
[05:47:35] epitron: splud: it's got a tim & eric feel
[05:47:41] splud: Had to do a LOT of work to work around it???s seeing inability to handle branches.
[05:47:53] Nilium: Go and branches?
[05:48:08] epitron: splud: are there syntactic sugar languages on top of go yet?
[05:48:14] Nilium: There was one.
[05:48:20] Nilium: It got shouted down into oblivion for being a stupid idea.
[05:48:24] epitron: GoingGoingGone
[05:48:29] splud: Go is a continuous build environment. Just because it builds something doesn???t mean it is deployed to the field.
[05:48:36] epitron: Nilium: weird
[05:48:45] Nilium: I feel like splud is referring to a very different Go.
[05:49:02] epitron: Go is definitely fast at building :)
[05:49:06] splud: We use it to verify code commits and push code to devices for daily regression.
[05:49:17] Nilium: splud: Ok, seriously, what go are you referring to?
[05:49:21] Nilium: The programming language?
[05:49:23] epitron: continuous build environment: "while true; do go build; sleep 1; done"
[05:49:35] Nilium: epitron: I use it with entr, but similar otherwise.
[05:49:59] Nilium: http://entrproject.org ??? This thing.
[05:50:21] splud: Woot, at least it finally churned the new kernel and drivers.
[05:50:28] epitron: http://www.andrewturnbull.net/mozilla/ns50.png
[05:50:33] Nilium: Handy tool for rebuilding stuff only when the file has been changed rather than just doing it every second (though Go certainly makes that doable)
[05:51:28] splud: go fires off our make scripts when the monitored repositories have changed.
[05:51:35] epitron: Nilium: neat
[05:51:41] Nilium: splud: Go, the programming language?
[05:51:57] Nilium: Anyway, the only complaints I hear about Go are from people who want generics, usually. Admittedly not on my radar because I don't have much of a use for them.
[05:51:57] splud: go, the continuous integration tool.
[05:52:06] epitron: Nilium: sooo.. "ls *.blah | entr" means.. if you add a new .blah file, it won't see it?
[05:52:07] Nilium: splud: Not the go we're referring to.
[05:52:50] Nilium: epitron: It won't, so you do while sleep 1 ; do find . -iname '*.go' | entr -d go build root/... ; done
[05:53:02] Nilium: -d tells entr to die when the directory structure changes
[05:53:20] Nilium: So then it loops back, finds all new files, and monitors those for changes
[05:53:29] epitron: this is pretty ghetto
[05:53:36] epitron: i like the concept
[05:53:59] epitron: maybe if it took "find" arguments i'd like it more
[05:54:12] epitron: entr -iname '*.blah' <command>
[05:54:17] Nilium: Makes more sense to just pipe the results of find to entr.
[05:54:26] Nilium: That way it keeps entr's use focused.
[05:54:28] epitron: but the while loop!
[05:54:34] epitron: -iname is just a single option
[05:54:56] Nilium: It is, but it's also an additional thing in the code that needs to be maintained, tested, etc.
[05:55:02] epitron: wrapping things in while loops makes visually parsing your command annoying
[05:55:03] Nilium: Why add it if something already does it?
[05:55:06] epitron: and typing is annoying
[05:55:20] Nilium: You're going to be running it once when you start, who cares?
[05:55:43] epitron: i can see that the maintainer experience is more important to you than the user experience :)
[05:55:44] Nilium: You sound like the sort of person who writes a 20,000 line function that does everything..
[05:55:55] epitron: i like simple things too
[05:56:00] epitron: but usability is important
[05:56:12] Nilium: Usability does not mean cramming all tools into one tool
[05:56:18] epitron: it's one command
[05:56:33] epitron: if you pipe in filenames, entr is already maintaining a list of files to watch
[05:56:48] Nilium: Yes, a list of files you explicitly specified.
[05:56:49] epitron: being able to get them from STDIN or a GLOB function is hardly a big complexity increase
[05:56:58] Nilium: No, that's a pretty big complexity increase.
[05:57:21] epitron: i guess you do have to add a "watch for all added files" and match the glob against them
[05:57:22] Nilium: You should appreciate exactly how much of a hellhole dealing with the filesystem is
[05:57:36] epitron: inotify is more annoying than the FS
[05:59:53] Nilium: I don't envy anyone who has to deal with directories in C.
[06:00:23] epitron: lol, entr is 500 lines of code
[06:00:53] epitron: * Determine if the user is specifying FIFO mode by supplying a pathname
[06:00:56] epitron: * prefixed with '+' and set the global mode flag accordingly
[06:01:07] epitron: i wonder if that's how you're supposed to do live updates
[06:01:46] epitron: iterating lists of things in C is pretty ugly
[06:01:53] epitron: that's a big source of complexity
[06:02:38] Nilium: If you could get a list. Directory streams are unpleasant.
[06:03:01] Nilium: Not awful, but unpleasant.
[06:03:40] epitron: i'd probably write this in C++, so i can get lots of wrappers around this stuff
[06:04:11] epitron: you're right -- this is some ugly code
[06:04:20] Nilium: Well, the C++ stdlib has nothing for working with directories, so that's not much use.
[06:04:29] epitron: i'm sure there's some C++ lib for it
[06:04:36] Nilium: Boost. Probably other things.
[06:04:56] Nilium: Boost is basically my nightmare, so I just stay away for as long as possible.
[06:05:06] epitron: is there a leet version of boost? :)
[06:05:28] Nilium: Does leet mean something?
[06:05:37] epitron: https://en.wikipedia.org/wiki/Leet
[06:06:00] Nilium: Never heard anyone use it as leet, and I kind of assume that all died a long time ago.
[06:06:11] epitron: "Leet originated within bulletin board systems (BBS) in the 1980s"
[06:06:21] Nilium: Besides that, not sure how it applies to a library.
[06:06:31] epitron: if you like, replace "leet" with your favorite adjective
[06:06:34] epitron: "ninja" for example
[06:06:44] Nilium: Well now you're just asking for people to kick you square in the genitals
[06:07:10] epitron: think of a good, efficient, clean, useful library written by someone with deep knowledge
[06:07:20] epitron: now imagine if that covered some of the usecases of boost
[06:07:23] epitron: does that exist?
[06:07:30] Nilium: Probably somewhere.
[06:07:38] Nilium: The word for that is "lightweight."
[06:08:03] epitron: lightweight isn't the only attribute :)
[06:08:04] Nilium: "Ninja" is for HR people and "leet" is for people who are 13 and somehow stuck in the '90s.
[06:08:46] splud: NERD, I???m claiming that one
[06:09:13] splud: up for grabs are GEEK and DORK
[06:09:22] Nilium: I grant that you may be in the '90s and possess a window to the future
[06:09:43] Nilium: And somehow have a cat 5 going through said window.
[06:10:05] splud: I cat ethernet back in the early 90???s at home.
[06:10:16] splud: effin 3Com cards cost a small fortune.
[06:11:10] splud: I have 6 runs of 5e in an underground conduit between my house and barn, plus a couple RG6U coax.
[06:11:35] Nilium: My dad always had a bunch of ethernet controller cards around from Intel, oddly enough.
[06:13:26] splud: I had some intel ones too. And some other brands. Still have a binload of them out in the barn in fact, not that I???m in a big rush to use 100mbit (tossed the 10bT ones long ago).
[06:13:39] splud: I run gigabit everywhere now.
[06:20:31] splud: g???nite folks. 13 hours at work yesterday and 20 hours today.
[06:20:58] splud: (not the norm, but I???ve got stuff that needs resolvin???)
[06:37:06] concertino: If I do .each on some array, inside a method, and one of them returns something
[06:37:16] concertino: will each continue to operate on the remaining elements?
[06:54:17] concertino: sorry i'm just learning but, how can I use .select on an array and pass the block the index of each item as well as the item?
[07:00:05] mozzarella: concertino: use with_index
[07:01:50] concertino: mozzarella: looking into that now
[07:02:14] mozzarella: >> ['A', 'b', 'c'].select.with_index { |item, index| index % 2 == 0 && item == item.upcase }
[07:02:15] eval-in_: mozzarella => ["A"] (https://eval.in/265673)
[07:06:58] concertino: hmm... how can I return an array that's missing the element at a specific index? Keep if, and select seem like a waste
[07:08:11] concertino: is there a without method? I'd like to do ['A', 'b', 'c'].without(1) => ['A', 'b']
[07:08:20] concertino: is there a without method? I'd like to do ['A', 'b', 'c'].without(1) => ['A', 'c']
[07:08:22] concertino: sorry, correction
[07:10:12] mozzarella: >> t = ['a', 'b', 'c']; t.delete_at(1); t
[07:10:13] eval-in_: mozzarella => ["a", "c"] (https://eval.in/265677)
[07:10:28] mozzarella: concertino: ^
[07:10:44] concertino: ah. simple enough
[07:10:49] concertino: thanks again
[07:19:18] concertino: >> arr = [1, 2, 3, 4, 5]
[07:19:19] eval-in_: concertino => [1, 2, 3, 4, 5] (https://eval.in/265709)
[07:19:26] eval-in_: concertino => undefined local variable or method `arr' for main:Object (NameError) ... (https://eval.in/265710)
[07:20:26] astrobun_: >> [1,2,3,4,5][0]
[07:20:27] eval-in_: astrobun_ => 1 (https://eval.in/265711)
[07:21:01] eval-in_: astrobun_ => 5 (https://eval.in/265712)
[07:21:18] astrobun_: >> [[5]][0][0]
[07:21:19] eval-in_: astrobun_ => 5 (https://eval.in/265714)
[07:21:31] astrobun_: BELIEVE IN SYNTAX
[07:21:49] concertino: is there an equivalent to delete_at, that returns a new array missing the specified element?
[07:24:43] sevenseacat: check the docs for delete_at ?
[07:30:15] concertino: sevenseacat: unfortunately that returns the deleted object
[07:31:00] concertino: I'm hoping for something like: ['a', 'b', 'c', 'd', 'e', 'f'].without(2) => ['a', 'b', 'd', 'e', 'f']
[07:31:19] apeiros__: concertino: there's no single method. use tap + delete_at
[07:31:27] apeiros__: or use more than one statement
[07:31:38] apeiros__: (I think I actually prefer the latter)
[07:32:01] concertino: eh... that makes this a bit difficult
[07:32:08] concertino: if I must i must
[07:32:22] apeiros__: I don't see how that can possibly make anything more difficult
[07:32:27] concertino: I'm trying to find it
[07:32:55] concertino: given an array and number i'm trying to return a NEW array containing all numbers that sum with another number in the original array to make n
[07:33:03] sevenseacat: i'd use more than one - not a huge fan of tap
[07:33:12] sevenseacat: people tend to use it for silly things
[07:33:27] concertino: I was going to do this: nums.select.with_index {|item, index| nums.without(index).include?(n - item)}
[07:33:43] apeiros__: so sick of clever code.
[07:33:50] havenwood: apeiros__: rotate(2).drop(1).rotate(-2)
[07:34:08] concertino: I'm not typically prone to that but it seems easy if the without method existed
[07:34:23] Cope: concertino: what are you actually trying to do? what would a test case look like?
[07:34:28] apeiros__: >> "havenwood".chars.rotate(2).drop(1).rotate(-2).join
[07:34:28] eval-in_: apeiros__ => "haenwood" (https://eval.in/265745)
[07:34:32] apeiros__: looks good.
[07:34:40] havenwood: checks out. ship it
[07:34:48] mozzarella: >> ['a', 'b', 'c'].tap { |a| a.delete_at(1) }
[07:34:48] eval-in_: mozzarella => ["a", "c"] (https://eval.in/265746)
[07:35:00] apeiros__: concertino: what precisely is more difficult there with more than one statement?
[07:35:44] concertino: Cope: if nums = [0, 2, 3, 4, 5, 6] and n = 6, then the returned array would look like [0, 2, 4, 6]
[07:36:16] concertino: 0 is passed through since it can be summed with 6 to make n, 2 can be summed with 4, etc etc
[07:37:06] Cope: I've been doing this sort of thing in racket :)
[07:37:08] concertino: apeiros__: Sorry i misspoke, the program isn't more difficult just felt that the line using "without" is mroe difficult
[07:37:36] apeiros__: yeah, I don't see that being more difficult either :)
[07:38:36] mozzarella: just use tap
[07:39:20] mozzarella: also, you know that you don't need an index to delete an item from an array? you can delete something by value, which might remove more than one item
[07:39:54] concertino: exactly why I chose not to use that, since I don't want to delete more than one item
[07:46:57] concertino: is it possible to exclude an element using keep_if?
[07:48:23] apeiros__: concertino: gtg, but I'm somewhat certain this could be done in O(n) instead of O(n^2) as yours does
[07:49:08] concertino: apeiros__: I'll consider that, ty
[07:49:30] mozzarella: concertino: it would exclude all of them
[07:49:45] mozzarella: not only the first one
[07:49:56] concertino: keep_if where the condition is index != index_to_exclude
[07:50:00] concertino: is along the lines I was thinking
[07:50:28] mozzarella: why would you do that, though? that's just retarded
[07:50:38] mozzarella: just use tap and be done with it
[07:51:04] concertino: Not certain how to use tap. Let me read up then
[07:51:16] mozzarella: I gave you an example above
[07:51:25] mozzarella: >> ['a', 'b', 'c'].tap { |a| a.delete_at(1) }
[07:51:25] eval-in_: mozzarella => ["a", "c"] (https://eval.in/265778)
[07:51:51] concertino: oh that's perfect
[07:51:59] concertino: let me see if i'm understanding what's going on here
[07:52:09] sevenseacat: lol thats what you were told before
[07:52:21] concertino: Victim of tab switching I guess
[07:52:45] concertino: so tap is just a way to make sure at the end of a block's execution, the tapped value is re-yielded?
[07:53:50] concertino: ah not quite what i'm after since i need a new array. can I use dupe first?
[07:55:39] mozzarella: no, it just returns the item, and you can do whatever you want with it inside the block
[08:07:03] apeiros__: sevenseacat: happens all the time. I love it when people ask questions and don't bother to pay attention to answers.
[08:07:32] sevenseacat: ACTION gives apeiros__ a hug.
[08:07:43] mozzarella: but asking questions is all the fun
[08:09:32] apeiros__: sevenseacat: thanks :)
[08:12:47] apeiros_: damn, why does my tail grow?
[08:19:36] shellox: I need some help guys. I want to check if string "Product (123C) (+6,000 NT)" matches a regex and if so get the "6000" in a variable
[08:19:40] shellox: how would i do that?
[08:20:48] apeiros_: shellox: str = "6000". if you want it more dynamically, you should say something about the rules of your string format.
[08:21:47] apeiros_: you can extract values from regex matches using capturing groups. e.g.:
[08:22:16] shellox: which syntax to use? =~ ?
[08:22:19] apeiros_: >> "hello".match(/h(a|e|i|o|u)/).captures
[08:22:20] eval-in_: apeiros_ => ["e"] (https://eval.in/265846)
[08:22:28] apeiros_: I'd use .match.
[08:22:33] shellox: okay thanks
[08:22:46] apeiros_: with =~??you have to resort to $1-$N (pseudo-)globals
[08:23:00] shellox: ok, i'll have a look on the docs for it
[09:58:42] knut: hello, I'm having trouble with a serial connection. I send a command to a microcontroller, which answers within 30ms, and with an oscilloscope I can confirm that, but on the serial port i can read the data just about 0.5s later. when I send, wait a bit, and read my methods work fast, but when i send and directly read my methods block 0.5s until the data can be read. I'm using the serialport gem on an Odroid U3. Maybe I could have for
[09:58:42] knut: gotten to set a flag, or where can I start searching?
[10:46:03] arup_r: Anybody read this book http://www.informit.com/store/effective-ruby-48-specific-ways-to-write-better-ruby-9780133846973 ?
[11:32:22] sogard: Book looks interesting.
[11:32:46] sogard: I took a look over it and I'm thinking about getting one.
[11:33:19] sogard: It's a tad expensive, though, especially since it doesn't offer so much for the people who are actually used to writing Ruby.
[11:34:02] sogard: A plus to it is the fact that it's up to date.
[11:38:18] sogard: I can't believe the Ruby IRC is so bored today.
[11:38:38] certainty: believe it :)
[11:46:05] YamakasY: hi guys, is there a way in the following example when group1 is like group.1 and group2 like group.2 that I replace the dot with a underscore in the same sort_by line ? http://pastie.org/9847304#14
[11:47:54] YamakasY: I try to avoid to do an extra gsub
[11:56:00] sogard: Why not use gsub?
[11:56:19] sogard: Told you everyone is really bored today.
[11:56:19] YamakasY: sogard: in the same line ?
[11:56:30] YamakasY: sogard: oh I se now indeed
[11:56:41] sogard: Maybe you can map it?
[11:56:54] YamakasY: yes I looked into that, but I'm not sure
[11:57:38] sogard: You know how the map method works?
[11:58:30] sogard: Are you using irb?
[11:59:24] YamakasY: not that I know of
[11:59:41] sogard: What OS are you on?
[12:01:24] YamakasY: sogard: just linux, I use it in puppet
[12:01:31] YamakasY: puppet templates
[12:02:10] sogard: irb is an interactive Ruby interpreter.
[12:02:19] sogard: You can run it from your terminal.
[12:02:33] sogard: It can help you a lot with these small issues.
[12:02:48] sogard: Run irb in a terminal ans then input: ["group.1", "group.2"].map {|g| g.gsub /\./, "_"}
[12:03:07] YamakasY: yes ok, but what I wonder is how to do it in the same line
[12:04:01] YamakasY: now I would generate such map line under the sort_by, but I think it can be combined
[12:04:15] waxjar: you shouldn't, because your sort will be wacky
[12:04:41] YamakasY: waxjar: ok, that is what I needed to know, so no performance issue either ?
[12:05:40] waxjar: you're sorting < 10 elements arrays. don't worry about performance :P
[12:08:36] sogard: You cannot combine the sorting with a map.
[12:12:36] sogard: YamakasY: You can first do the map and then the sort: array.map {}.sort_by {}
[12:18:17] YamakasY: sogard: yap
[13:12:33] avril14th: How can one do a string.gsub{ |match, index| } where index represents the offset in the string where the match occured?
[13:16:28] avril14th: or actually, get the post_match
[13:17:44] avril14th: got it, thx :)
[13:31:11] Raven20: When working with an API, I'm getting data passed to me as JSON and I'd like to actually get the object instead. I don't think parsing the object id from the json and doing ```Object.find json[:object_id]``` makes sense, right? Am I missing something obvious?
[13:32:00] ddv: Raven20: to_json?
[13:32:23] apeiros_: errr, an API will never contain a ruby object_id
[13:32:28] workmad3: Raven20: if you're getting JSON, you need to parse it... if you want to load an object up from the db based on an ID in that json, that's what you want to do...
[13:32:31] apeiros_: as that makes absolutely no sense whatsoever
[13:32:53] workmad3: apeiros_: I assumed he meant something more like 'post_id' and badly generalized the term ;)
[13:33:00] Raven20: aperos: i have two rails app, one acting as the API and the other client side
[13:33:00] apeiros_: lets hope so
[13:33:13] apeiros_: I'm not aperos. use tab completion if you can't spell.
[13:33:26] workmad3: or even if you can, as it's still faster generally :)
[13:34:15] workmad3: Raven20: but yeah... I think the obvious bit you're missing is that you have a string of json and you need to parse that and load data based on its contents, and you for some reason don't think that makes sense
[13:34:25] workmad3: Raven20: so I'm personally curious about what would make sense... ;)
[13:34:45] waxjar: Raven20: what does "get the object" mean, what do you expect to happen?
[13:35:27] apeiros_: ok, I guess 3 ppl are enough, gladly leaving this one to you folks :)
[13:35:56] Raven20: a previous version of the API wasn't passing json... instead, it was passing objects. I could do something like: @person = get "persons/index" and then just pass the persons around. Now I'm getting json, so I have to go through each one and do a Person.find #
[13:36:16] kiddoboy: In methods we can do: def foo(bar=nil); return unless bar; "bar is: #{bar}"; end
[13:36:17] workmad3: Raven20: how was it passing objects?
[13:36:30] apeiros_: ACTION suspects a confusion of internal & external API
[13:36:59] kiddoboy: How can we do the same thing with map?
[13:39:13] kiddoboy: (1..3).map { |e| return e if e < 2; 'bigger then 1' }
[13:39:36] kiddoboy: What is the command I should replace return with?
[13:39:37] workmad3: kiddoboy: sounds like you want select, not map
[13:39:59] workmad3: kiddoboy: so you want it to be either 'e' or 'bigger than 1' for all items?
[13:40:13] workmad3: kiddoboy: ok... then 'e < 2 ? e : 'bigger than 1'
[13:40:15] kiddoboy: It's just an example
[13:40:19] workmad3: kiddoboy: no return
[13:40:29] kiddoboy: But imagine that I have 7 lines of code there
[13:40:40] workmad3: kiddoboy: return in that block will not do what you want
[13:40:41] kiddoboy: How can I return from the second line for instance?
[13:40:51] waxjar: with next
[13:40:53] kiddoboy: How can I return the value to map
[13:41:04] apeiros_: still with next :)
[13:41:10] workmad3: waxjar: does 'next' have a return value for map?
[13:41:16] apeiros_: >> [1,2,3].map { |x| next 20 }
[13:41:16] eval-in_: apeiros_ => [20, 20, 20] (https://eval.in/266549)
[13:41:40] kiddoboy: Thanks that was it
[13:41:42] apeiros_: next, break & return all take a value. without one given, they default to nil.
[13:41:43] workmad3: ACTION didn't know about that use-case for next
[13:42:00] certainty: so go on with the next use-case
[13:42:04] apeiros_: kiddoboy: note that next is considered spaghetti
[13:42:24] workmad3: I have stew tonight, not pasta
[13:42:29] waxjar: probably better to get the code in the block to be smaller
[13:43:30] kiddoboy: In this situation it is ok to use next
[13:48:20] kiddoboy: It is the situation where you drop the ternary operator and just do: next a if condition; b instead of condition ? a : b when condition, a and b are bigger espressions
[13:49:22] kiddoboy: A best practice to drop if statements
[13:51:24] waxjar: returning early and if-else expressions are really the same thing though.
[13:51:37] waxjar: there's still two paths your code can take
[13:52:43] certainty: still if-else is explicitly to do branching
[13:53:40] certainty: i'm unsure about their equivalence, though they achieve the same effect
[13:57:00] workmad3: kiddoboy: also, you've not removed the if statement there... you're just using a suffix version
[13:57:27] certainty: which i only ever use if the expression before is short
[13:57:56] certainty: but that's a different thing
[13:59:19] apeiros_: refactor big expressions to methods. use ternary with those.
[14:01:55] certainty: the ternary appears to be problematic to me as well. even with short branches and condition. Very often the condition is a predicate ending an a ? which seems to clash with the ? from the ternary
[14:02:19] certainty: may only be a matter of taste though
[14:04:42] workmad3: certainty: yeah, I'm not too fond of that either... but I prefer that to a multi-line conditional in a block to replace it, or an inline 'if <condition> then <method1> else <method2> end'
[14:06:09] apeiros_: I have no issue with `condition? ? foo : bar`
[14:06:43] apeiros_: but as workmad3 said - if your company styleguide says that this is a no-no, just replace it with `if condition? then foo else bar end`
[14:06:56] workmad3: apeiros_: the double-? is a slight ugliness, IMO... but not enough to really warrent more than a minor bitch here when certainty brings it up :)
[14:08:52] certainty: ACTION nods
[14:09:29] ddv: the ugliness is in your head, workmad3
[14:09:38] certainty: and in mine
[14:10:15] workmad3: ddv: that can be said of any ugliness or beauty
[14:10:26] workmad3: ddv: but I'm not in the mood for that sort of philosophical discussion today :P
[14:10:50] ddv: everything is in your head
[14:11:16] workmad3: must... resist... being... drawn... into... discussion
[14:11:17] mwlang: I usually use Array(some_variable) to guarantee I have an array. For example => Array(???hello???) => [???hello???]; Array([???hello???, ???world???]) => [???hello???, ???world???]. However, to my surprise (and first time I???m doing this with hashes => Array({:hello => :world}) => [[:hello, :world]] instead of [{:hello => :world}]
[14:11:37] mwlang: So, what???s the easiest way to ensure an array of hashes?
[14:12:43] apeiros_: Array(var) IMO means you failed to normalize in the right place
[14:13:00] mwlang: I???m feeding into a #map block and the usage pattern I typically use is Array(some_variable).map{|m| do_something(m)}
[14:13:16] apeiros_: yes. why is it possible that some_variable is not an Enumerable?
[14:13:55] mwlang: apeiros: in this case, I???m parsing an XML document. Sometimes I get just one section, in which case its just a hash???other times, the section is repeated and I get an Array.
[14:14:47] apeiros_: and why does your parser not translate those cases to the same structure? (that's what normalization means)
[14:15:48] apeiros_: it makes even less sense. parser has to branch on whether to return array or not, all consumers of the parsers have to branch again depending on whether they got an array or not
[14:15:55] apeiros_: just remove both branchings.
[14:16:21] mwlang: apeiros_ no idea why the author did it that way. Its actually the nori gem, FWIW, which parses XML docs into hashes.
[14:16:36] mwlang: (inherited this project, too)
[14:16:56] apeiros_: ok. so you're working around the mess others created. well then.
[14:17:01] apeiros_: good luck :)
[14:17:09] mwlang: apeiros_: aren???t we all? :-o
[14:17:13] Nilium: It's always the mess others created (??????????????????? ?????????
[14:17:27] Nilium: Especially the node.js users, who have done nothing but messes (????????????)???????????????
[14:17:29] apeiros_: Nilium: IME often "others" means "my old self" :-p
[14:17:35] mwlang: I???m basically attempting to normalize efficiently within my scope of work.
[14:18:12] Nilium: apeiros_: I have that too, but at work, I haven't been there long enough for it to be my old self
[14:18:13] apeiros_: and I've seen shitty unnecessary array normalization all over the place in all kinds of code.
[14:19:09] apeiros_: most common case: `def foo(arg); Array(arg).whatever???`. proper solution: `def foo(*args); args.whatever`. let the caller normalize.
[14:21:20] mwlang: I prefer Array(items).map{|item| do_something(item)} to this: items.is_a?(Array) ? items.map{|item do_something(item)} : do_something(items)
[14:21:58] workmad3: mwlang: apeiros_'s point is that it should just be 'items.map{|item| do_something(item)}' and the caller is responsible for making sure it passes an array
[14:22:19] mwlang: workmad3: Ah, yes, I totally agree there.
[14:23:21] mwlang: mostly, I was just surprised by the behavior of Array() on a Hash object.
[14:24:34] workmad3: mwlang: it's the result of Hash#to_a
[14:25:36] workmad3: mwlang: it seems weirdly reasonable for Array(arg) to call arg.to_a if it's present :)
[14:28:35] metrix: I would like to run a block for every element in two hashes. Hash.merge only runs a block on the hashes that are duplicates... Any suggestions?
[14:29:00] metrix: err.. Hash.merge only runs a block on the KEYS that are duplicates
[14:29:08] apeiros_: we still don't have Enumerator#+, aight?
[14:29:30] apeiros_: metrix: "errr" again? because I think you mean: runs the block only *once* on duplicate keys
[14:29:36] apeiros_: (it does run on all keys)
[14:30:00] apeiros_: ah, or did you pass the block directly to merge, not to a chained .each?
[14:30:51] metrix: Directly to merge
[14:32:37] metrix: h1 = {:a=>'1',:c=>'1'}
[14:32:47] metrix: h2 = {:c=>'1'}
[14:33:11] metrix: irb(main):004:0> h1.merge(h2) {|key,a,b| a.to_i * b.to_i}
[14:33:12] metrix: => {:a=>"1", :c=>1}
[14:34:52] metrix: notice key :a is a string, even though I converted everything to integer
[14:35:07] apeiros_: metrix: then you're using the wrong tool
[14:35:18] apeiros_: the merge block is *specifically* to resolve merge conflicts.
[14:35:28] metrix: Then what is the right tool
[14:35:30] apeiros_: a.merge(b).each { ???your block??? }
[14:35:32] jlebrech: is there a gem to get the structure of a valid ruby file?
[14:35:42] apeiros_: but that will run the block only once for duplicate keys
[14:35:59] apeiros_: jlebrech: "structure"?
[14:36:31] jlebrech: apeiros_: say turn it into a hash
[14:36:47] jlebrech: to read the code programaticaly
[14:36:48] apeiros_: jlebrech: that still does not make sense on its own.
[14:36:53] apeiros_: you want a parser?
[14:37:00] jlebrech: yeah, i meant that
[14:37:04] d10n-work: Which is more idiomatic? https://dpaste.de/Agcc
[14:37:04] apeiros_: there's plenty. see Ripper, Parser, ruby_parser
[14:37:12] apeiros_: metrix: alterantively: (a.to_a+b.to_a).each
[14:37:22] apeiros_: metrix: that will run it for every key
[14:39:10] jlebrech: apeiros_: i was just wondering why there weren't more visual code editors that let you select a method to edit rather than whole files. say for a touch screen
[14:39:31] jlebrech: apeiros_: that would need to parse
[14:40:28] jlebrech: apeiros_: something like this: https://github.com/oggy/cast (not a rubygem)
[14:44:17] apeiros_: jlebrech: for an editor, a parser won't work
[14:44:27] apeiros_: a parser expects valid syntax and will abort on invalid syntax
[14:44:38] apeiros_: but editing a file, you *by definition* will have invalid syntax
[14:48:27] GreatSUN: I have a problem with modules and classes integration
[14:48:33] GreatSUN: can someone please assist?
[14:48:34] GreatSUN: https://gist.github.com/GreatSUN/78aa5cfa399c13476e3d
[14:48:45] jlebrech: apeiros_: yeah it would be a different approach
[14:48:57] GreatSUN: somehow I need to find a way to access the class variable
[14:49:14] shevy: it's time again
[14:49:16] jlebrech: apeiros_: you wouldn't be able to save a method till it's valid
[14:49:25] shevy: who wants to be spanked
[14:49:57] apeiros_: jlebrech: that's very user friendly :)
[14:50:34] apeiros_: jlebrech: it also means you can't open any incomplete/invalid file from another source.
[14:50:36] jlebrech: apeiros_: sarcasm? :D
[14:50:44] apeiros_: jlebrech: of course
[14:50:52] apeiros_: jlebrech: "god damit I have to take the train, save it already!!!"
[14:51:17] jlebrech: apeiros_: well if the file is invalid it would be in a simple mode
[14:51:18] GreatSUN: jlebrech: the problem would be at most that you can not save a file at the end of your day when you have not been able to fix the error
[14:51:34] GreatSUN: or the other way round, you might not be able to identify the error properly
[14:51:53] GreatSUN: which might be easier when you are able to save the current status
[14:52:09] GreatSUN: also you would not be able to begin the work and transfer it to another developer
[14:52:36] GreatSUN: I think it would at least need some kind of question: "Do you really want to save a broken file?"
[14:52:51] jlebrech: yeah, force save
[14:53:30] jlebrech: and you wouldn't be able to reopen in "smart" mode till you fix the syntax error
[14:54:21] jlebrech: or it could just parse in order to insert collapsible text
[14:54:43] GreatSUN: jlebrech: right, not open would be horrible, too afterwards
[14:54:58] GreatSUN: anyhow, can someone please have a look at my gist?
[14:59:27] GreatSUN: noone of you guys experienced with metaprogramming in ruby?
[15:00:08] jlebrech: never used const_get
[15:00:26] GreatSUN: jlebrech: just gets the object of the Module
[15:00:48] GreatSUN: could be replaced for non dynamic use with -> include Module1 / include Module2
[15:01:10] jlebrech: do you still get your issue with non-dynamic?
[15:01:24] GreatSUN: as it is just the same in this case, yes
[15:01:53] GreatSUN: the problem is that the class variable is set only on Module base
[15:01:59] GreatSUN: not on class base
[15:02:23] GreatSUN: therefore accessing it from outside of the module is not working
[15:02:55] GreatSUN: the question is how to get the class to have the class variable shared with the module
[15:03:30] JDiPierro: GreatSUN: I think you might want your "extend ClassMethods" to be "include ClassMethods"
[15:03:51] JDiPierro: nope, I'm wrong
[15:04:05] GreatSUN: already wanted to say something like that
[15:04:14] GreatSUN: cause then classmethods would be instancemethods
[15:04:43] JDiPierro: hmmm.. this is a stumper
[15:06:49] jlebrech: apeiros_: the upshot of relying on validity is that you can tie the undo/vcs system into it
[15:06:52] GreatSUN: JDiPierro: you are very welcome if you have an idea
[15:07:10] JDiPierro: GreatSUN: What about class_variable_get?
[15:08:26] GreatSUN: JDiPierro: no. class_variable_get is not available in an instance method
[15:12:33] GreatSUN: JDiPierro: self.class.class_variable_get <--- solution
[15:12:49] JDiPierro: GreatSUN: Noice!
[15:15:06] Hanmac1: ACTION does hide classes as constants in singleton classes of objects ;P
[15:15:36] workmad3: GreatSUN: hmm... your code there actually seems to work fine for me without jumping through hoops
[15:15:57] workmad3: GreatSUN: with one modification... 'include Module1' inside Module2
[15:17:36] GreatSUN: workmad3: also good solution
[15:17:40] GreatSUN: thanks a lot :-)
[15:18:40] workmad3: GreatSUN: not that I know what use-case you're really dealing with there, tbh
[15:18:47] GreatSUN: workmad3: updated gist right away with the second solution
[15:19:33] GreatSUN: workmad3: just trying to figure out what would be the best solution to get this working hence we want to have smaller modules and though want to divide modules into multiple ones
[15:19:59] workmad3: GreatSUN: yeah... just trying to figure out why you're splitting up actions around a class variable across multiple modules
[15:20:29] workmad3: GreatSUN: and why Module1 doesn't provide class and instance level readers for the var... and why you're using a class variable rather than a module-ivar... etc :)
[15:20:51] GreatSUN: workmad3: if you have modules counting more than 900 lines of code, you should start splitting
[15:21:06] workmad3: GreatSUN: agreed... but where you split is an important consideration ;)
[15:21:31] workmad3: GreatSUN: and I'm not sure I'd agree that splitting the management of a class-variable is good
[15:21:32] GreatSUN: workmad3: the point is that they are all just connected to one topic, so we have basic things that nearly all methods share with each other
[15:21:38] GreatSUN: and other things that are not shared
[15:21:58] workmad3: GreatSUN: ok... so why not have a basic interface to access defined in that one module and then rely on the interface, rather than accessing the storage directly?
[15:22:12] workmad3: GreatSUN: i.e. create class and instance level readers for the class-var ;)
[15:22:41] banister: workmad3 where do you put modules that you mix into your models/controllers?
[15:23:02] workmad3: banister: frequently in lib/
[15:23:25] GreatSUN: workmad3: yeah, I was thinking about that already and just wanted to see the other ways how things might work out to be able to decide for the best way
[15:23:37] banister: workmad3 isn't lib/ just a junk drawer for putting things where you don't know where to put them...? :) I thought the new standard was models/concerns/ or controllers/concerns/ depending on if it's for models or controllers
[15:23:46] GreatSUN: but in general I think, you are right
[15:24:01] GreatSUN: the base module would be the best solution
[15:24:02] workmad3: banister: depends on if you bring structure to lib/ or not :P
[15:24:15] banister: workmad3 you don't like models/concerns/ ?
[15:24:28] workmad3: banister: not particularly
[15:25:27] waxjar: anything "reusable" goes into /lib :p
[15:28:23] banister: waxjar aren't all objects reusable?
[15:29:00] workmad3: banister: some are more re-usable than others :P
[15:29:04] workmad3: you should know that ;)
[15:29:32] banister: workmad3 seems like a pretty vague test for what should go in lib/ :)
[15:29:34] avril14th: I don't understand MatchData#begin, is that the offset in the original string?
[15:31:14] workmad3: banister: yeah... but it's about as vague as what should go under a concerns/ folder... and what about stuff like extensions to AR::Base that add in new class-macros... or something that spans controllers and models with utility methods... or a whole host of other things that are useful but don't fit under the term 'concern'? ;)
[15:34:31] waxjar: "potentially" reusable in two or more apps? idk, really :p
[15:46:50] avril14th: is there a method to delete part of a string given two indexes (start and end indexes)
[15:47:15] canton7: avril14th, #slice! iirc
[15:48:25] ddv: avril14th, "blaat"[begin, end]
[15:48:53] avril14th: thx canton7
[15:48:57] avril14th: ddv: that won't remove it
[15:50:09] workmad3: avril14th: str[begin..end] = "" will though
[15:50:27] avril14th: that is true :)
[15:50:56] workmad3: ddv: str[x, y] is 'get y characters starting at x' btw ;)
[15:51:05] workmad3: ddv: rather than start, end
[15:51:29] ddv: workmad3: true
[16:03:27] chinmay_dd: How do you capture CTRL + D in Ruby? Suppose my program is waiting for input and on CTRL + D I want it to exit smoothly without giving any traces. I am able to capture CTRL + C using 'rescue Interrupt' but can't seem to do the same for CTRL + D. Thanks!
[16:06:59] DefV_: chinmay_dd: ctrl-d is end-of-file
[16:07:33] DefV_: or SIGQUIT
[16:08:08] DefV_: you can capture that whit Signal.trap
[16:08:23] chinmay_dd: Oh okay. Thanks. WIll try it out
[16:08:26] DefV_: Signal.trap("SIGQUIT") { what_to_do }
[16:11:43] zipkid: Hello, is it possible to use GetoptLong on a string instead of the script's command line?
[16:56:49] oddover: Hi all. I need some help converting an array to a nested hash. Here's an example: http://pastebin.com/EA7ys7Lj
[16:57:03] oddover: the first line has the array, the second line has the hash I'd like to end up with
[16:57:35] oddover: so, each element of the array becomes a key point to a hash with the next element as a key, and so on
[16:58:35] oddover: http://pastebin.com/Ry3jU5GV
[16:58:49] oddover: actually, I would accept the other version in that new one as well
[16:59:46] odigity: Is the stdlib compiled directly into the ruby binary in the debian/ubuntu package? I just did dpkg -L ruby1.9.1, and the list of files is less than a page long. Just docs and binaries.
[17:28:33] knut: hello, I'm having trouble with a serial connection. I send a command to a microcontroller, which answers within 30ms, and with an oscilloscope I can confirm that, but on the serial port i can read the data just about 0.5s later. when I send, wait a bit, and read my methods work fast, but when i send and directly read my methods block 0.5s until the data can be read. I'm using the serialport gem on an Odroid U3. Maybe I could have for
[17:28:34] knut: gotten to set a flag, or where can I start searching?
[17:29:35] knut: After SerialPort#write SerialPort#readpartial blocks for about 0.5s until data arrives.
[17:34:06] mwlang: knut you may need to user a profiler to track that one down.
[17:34:11] havenwood: knut: How about IO::select to monitor until data's ready?: http://www.ruby-doc.org/core-2.2.0/IO.html#method-c-select
[17:38:50] havenwood: knut: What version of Ruby? Can you reproduce it on 2.2.0/
[17:39:08] havenwood: (meant trailing slash to be a question mark)
[17:39:39] eval-in_: havenwood => "\"" (https://eval.in/266980)
[17:56:25] Godd2: Would you consider fixing a bug refactoring?
[17:57:09] ddv: only if you also made improvements to existing code
[17:57:27] ddv: which a bugfix actually is
[17:58:08] Godd2: I guess that could boil down more into what an "improvement" is
[17:59:18] Godd2: Is it possible to simultaneously refactor code and result in worse code?
[17:59:37] Godd2: if I havent changed the "external behavior"
[17:59:39] adnauseaum: when people come in here to ask for a good ruby tutorial, what do you guys recommend
[17:59:48] ddv: adnauseaum, using Google
[17:59:54] ddv: usually*
[17:59:59] Godd2: adnauseaum are you into reading or watching vids?
[18:00:24] Godd2: what level of ruby are you at? just starting? know a little? intermediate?
[18:00:30] adnauseaum: zero knowledge
[18:00:58] Godd2: THen I would recommend Programming Ruby
[18:01:07] Godd2: also known as the Pickaxe book
[18:01:52] ddv: godd2, sometimes you have to write 1000 lines of code to know how to throw 900 lines away
[18:02:25] Godd2: ddv that's fair, and I'd agree.
[18:02:47] Godd2: sort of like learning an art. You have to go too far to know where the sweet spot is
[18:03:53] Godd2: adnauseaum also, not a book, but great for learning Ruby: http://www.codecademy.com/tracks/ruby
[18:04:18] adnauseaum: i like codecademy
[18:04:25] adnauseaum: i forgot they had a ruby lesson
[18:04:27] adnauseaum: i did python on there
[18:04:52] Godd2: Python and Ruby are similar
[18:07:37] havenwood: godd2: It's not just a refactor if you fix a bug. Sometimes code relies on bugs to work. You can refactor your bugs but fixing them is a bug-fix.
[18:08:39] adnauseaum: is rails easier to use than django? because i couldn't figure out django to save my life
[18:08:46] Godd2: havenwood so would you say that a bug is part of "external behavior" and that fixing a bug is disqualified from being a refactoring for that reason?
[18:09:08] ddv: adnauseaum, django is always trying to be like rails but fails horribly
[18:09:40] Godd2: adnauseaum a framework is usually easy if you're familiar with the underlying language. That said, Rails is probably easier to learn
[18:10:21] havenwood: godd2: Yeah, assuming the bug is behavior, changing it means it's not just a refactor since refactoring preserves behavior.
[18:10:54] ddv: havenwood, refactoring preserves behaviour?
[18:11:12] Godd2: ddv in every definition I've seen, yes
[18:11:12] ddv: havenwood, No
[18:11:49] havenwood: ddv: "behavior preserving transformations"
[18:12:14] Godd2: ddv but "behavior" is defined in a way to mean external to the code you're modifying
[18:12:29] ddv: ah okay
[18:12:57] Godd2: so like if you have a square root function, then "behavior" would be the mapping of any input to some output, and if you change the internals without changing what the function spits out, you've refactored
[18:12:59] havenwood: behavior in the Behavior Driven Development sense
[18:13:18] adnauseaum: ruby would be recommended more for web applications that something like python right?
[18:13:32] havenwood: adnauseaum: In #ruby, yes.
[18:13:40] adnauseaum: well in general
[18:13:49] Godd2: adnauseaum Ruby is used for lots of things, not just web apps
[18:14:00] adnauseaum: web apps are my goal
[18:14:06] Godd2: as for choosing ruby over python, that's not a decision someone can make for you
[18:14:13] adnauseaum: and i can't figure out django to save my life
[18:14:34] havenwood: adnauseaum: What are you trying to make?
[18:14:43] Godd2: Twitter 7.0
[18:15:08] ddv: adnauseaum, django has good docs..
[18:15:20] adnauseaum: i'm a web designer with html/css knowledge and i want to expand into web development
[18:15:57] ddv: adnauseaum, first learn to program...
[18:16:02] havenwood: adnauseaum: Check out Roda (http://roda.jeremyevans.net) for a nice way to make APIs and Volt (http://voltframework.com) for a nifty reactive web framework.
[18:16:09] ddv: adnauseaum, learn a language
[18:16:15] ddv: adnauseaum, then a framework
[18:16:15] Godd2: adnauseaum I have a feeling that your trouble learning Django will be similar to trouble you have learning Rails, and that your intuition is correct that you should step back and become reasonably familiar with a language before learning a framework in it
[18:16:23] havenwood: adnauseaum: But yeah, Ruby has a bunch of great stuff for the web. Learn Ruby, it's lovely.
[18:16:33] Godd2: (even a year or two's worth of study)
[18:16:35] ddv: adnauseaum, you're doing it all backwards
[18:17:33] havenwood: adnauseaum: Learn Ruby then make beautiful apps with Volt. Go forth and code!
[18:18:10] knut: havenwood: i've tried to use IO#read_nonblock with IO#select instead of IO#readpartial, but turns out to be the same
[18:18:11] Godd2: adnauseaum make learning Ruby a priority, and Rails will come with it
[18:18:36] adnauseaum: i did that with python and django doesnt make any sense
[18:18:41] havenwood: godd2: Or you'll learn that what you're doing isn't similar enough to Basecamp for Rails to make sense. Spare yourself the rails!
[18:18:55] havenwood: Or it's perfect, either way.
[18:19:04] havenwood: Depends on what you're doing I think.
[18:19:25] workmad3: havenwood: sames true with any framework... if what you're doing hits its sweet-spot, it's awesome
[18:19:35] workmad3: if it doesn't, you'll feel like you're pulling teeth
[18:19:54] workmad3: if you're really good with a framework, you can make pretty much any problem seem to fit it though...
[18:19:59] Godd2: adnauseaum learn ruby until you feel like rails isn't doing black magic. then you will be ready
[18:20:09] havenwood: workmad3: The moment of "Oh gosh, someone's already solved ALL THE PROBLEMS! \o/" is nice.
[18:20:09] workmad3: especially if you're only good with the framework and nothing outside of it...
[18:20:49] workmad3: ACTION still gets people looking askance at him when they say "I want to make a real-time chat app" in #rubyonrails and I say 'Use meteor'
[18:21:44] knut: btw, thats my code: https://gist.github.com/knutmithut/f2cd99854e4864476a9d
[18:21:50] havenwood: Right too for the job.???
[18:22:08] workmad3: havenwood: yes you are... ;)
[18:22:25] Godd2: havenwood but I like using a gun to make a tuna sandwich. stop restricting me!
[18:22:30] havenwood: ACTION looks askance.
[18:23:04] workmad3: godd2: pfft, guns are tame... you can join the big-kid table when you start using high explosives ;)
[18:25:26] havenwood: knut: hem, how odd..
[18:26:09] knut: the problem is not writing or reading from buffer, because when there is data it is super fast.. but for the data to reach the buffer it takes quiet some time
[18:26:27] knut: even so on the oscilloscope all the communication is done within 50ms
[18:36:21] arup_r: workmad3: I found you out :) http://stackoverflow.com/users/16035/workmad3
[18:36:39] workmad3: arup_r: it's not like I hide that :P
[18:37:37] arup_r: got you first here http://stackoverflow.com/questions/28199598/not-setting-arguments-properly-in-rails-tasks
[18:37:55] workmad3: arup_r: heh :) I just answered that one from a link in #rubyonrails ;)
[18:38:20] arup_r: I am also on the same page
[18:39:16] workmad3: hmm... not gotten as much rep as normal over the last week
[18:41:19] workmad3: arup_r: where's your profile link then? :P
[18:41:34] arup_r: http://stackoverflow.com/users/2767755/arup-rakshit :p
[18:41:59] workmad3: heh :) you spend too much time on SO ;)
[18:42:02] wallerdev: do you get anything for rep
[18:42:15] wallerdev: like turn in rep for a t shirt or something
[18:42:18] workmad3: wallerdev: a feeling of pride?
[18:42:25] workmad3: wallerdev: also, moderator abilities
[18:42:36] arup_r: lol... nothing
[18:43:11] workmad3: arup_r: am I allowed to feel smug that my best answer has over 200 upvotes? ;)
[18:44:42] arup_r: I know you are best! :) Congo for that,.....
[18:45:09] workmad3: arup_r: I'm just trying to make myself feel better after seeing your 50k+ rep :P
[18:46:18] arup_r: workmad3: Those are only Ruby.. no varieties ..
[18:46:35] workmad3: arup_r: most of mine are C or C++
[18:46:52] workmad3: arup_r: at least you're still using the stuff you've got answers about :P
[18:47:23] workmad3: arup_r: I don't do any C or C++ anymore
[18:54:41] arup_r: workmad3: Too bad I'm in Rails
[18:55:13] workmad3: arup_r: why's that bad?
[18:55:16] wallerdev: i have 171 rep
[18:55:22] wallerdev: i am amazing
[18:55:50] wallerdev: http://stackoverflow.com/users/732675/wallerdev
[18:57:42] arup_r: wallerdev: Didn't get a chance to work on it much Soooo :(
[18:57:54] arup_r: Really I am poor
[18:58:51] arup_r: I never got such log file :) http://stackoverflow.com/questions/28200143/my-application-is-in-ruby-on-rails-i-see-some-logs-traces-for-ali-hack-can-so workmad3: or wallerdev: may give it a try.. I'v less experience
[19:00:12] avril14th: what would be the regex to match the last two words of a string?
[19:00:22] wallerdev: looks like it's just one of those scripts that crawls the net and tries to submit common exploits
[19:00:30] wallerdev: doesnt look like an issue with your site at all
[19:01:16] wallerdev: /(\w+)\s+(\w+)$/
[19:01:48] wallerdev: depends on the kind of strings you have though
[19:02:02] wallerdev: like if you're using foreign letters or punctuation things get a bit more complicated
[19:02:12] avril14th: thx wallerdev
[19:02:23] arup_r: wallerdev: Can I pm you ?
[19:02:36] wallerdev: if you want
[19:23:39] rsavage: quick question
[19:23:58] rsavage: can you have multiple elsif 's? in an if statement?
[19:35:53] ellisTAA: i have to search a hash for a non-identical given value( e.g. i???m given ???fi??? and if something like ???fight??? is in the hash i should return the key and value), so in order to do this i???m trying to convert hash to a string so that i can search it for a regex. this is the best way that i can think of. any thoughts on this? am i wrong, right?
[19:36:32] apeiros_: ellisTAA: use Enumerable#find
[19:36:45] ellisTAA: so hash.find?
[19:37:31] apeiros_: >> {key: "fight"}.find { |k,v| v =~ /\Afi/ }
[19:37:32] eval-in_: apeiros_ => [:key, "fight"] (https://eval.in/267227)
[19:38:14] ellisTAA: sweet ??? let me try that
[19:47:54] ellisTAA: apeiros_: thanks, that worked
[19:49:32] ddv: apeiros_: what editor do you use?
[19:51:38] electrical: Hi all. the to_yaml function seems to have changed between ruby 2.0 and 2.1 causing a weird issue.. where it initially generated ":datadir: /var/lib/hiera\n" it does now ":datadir: \"/var/lib/hiera\"\n" for a part of the yaml string. Any idea's how i can solve / change it?
[19:54:00] apeiros_: electrical: way. too. vague.
[19:54:43] ellisTAA: i have a method find that takes an argument (something) and i have some code that searches a hash for the argument (something) using a regex ??? but for some reason the regex doesn???t regard the argument (something) an argument but a string ???. why?
[19:54:54] apeiros_: electrical: I mean I can give an equally unspecific answer, but I doubt that'll make you happy.
[19:55:05] electrical: apeiros_: sorry. let me try to be more specific :-) creating a gist now
[19:55:48] apeiros_: ellisTAA: gist, along with example in-/output + expected output (output probably == return value in this case)
[19:56:38] ellisTAA: k. how do i highlight lines in a gist?
[19:56:51] electrical: apeiros_: https://gist.github.com/electrical/0d8b3b0edd797a197669 <-- function and different output depending on the ruby version
[19:57:36] electrical: the issue here is that the value of the datadir key gets quotes around it and escaped. this is something i didn't expect
[19:58:33] apeiros_: ellisTAA: if it's that much code, then you should reduce it before gisting
[19:59:42] apeiros_: electrical: looks equivalent to me
[19:59:54] apeiros_: there are multiple ways to represent strings in yaml
[20:00:14] apeiros_: electrical: or do they deserialize to different values for you?
[20:00:30] electrical: apeiros_: yeah.. my issue is that it broke testing as i evaluate the generated yaml vs expected yaml string
[20:00:41] electrical: and i didn't expected the quoting and escaping
[20:01:17] apeiros_: electrical: ah well, I doubt there's a way to use the old way of quoting
[20:01:31] apeiros_: and since it's technically correct, there's not much reason to either
[20:01:57] electrical: i understand. wonder how to solve it testing wise.
[20:02:26] electrical: especially since we test against different ruby versions
[20:03:04] ellisTAA: apeiros_: https://gist.github.com/ellisTAA/0a8c4da823b3851e7685 how can i get the regex to look for the method argument (something)?
[20:03:27] apeiros_: electrical: generate files for both versions and check whether it's equal to either
[20:03:38] apeiros_: or serialize/deserialize and test against deserialized
[20:03:46] electrical: hmm good one. thanks!
[20:04:13] apeiros_: or the first one, but with the file being chosen based on RUBY_VERSION
[20:06:14] ellisTAA: do i have to use interpolation?
[20:06:47] ellisTAA: yes! it kinda works
[20:07:34] apeiros_: yes, /something/ searches for litterally something. it does not know or care for a variable called `something`
[20:08:15] graft: hey, what the heck is __FILE__? like, how does it work?
[20:08:16] apeiros_: it'd be rather unpleasant otherwise
[20:08:29] graft: it's not a constant
[20:08:30] apeiros_: graft: the same way keywords work, or string literals.
[20:08:41] ellisTAA: so i used interpolation. but now i need to turn the array into a hash. i thought i could use .named_captures but that doesn???t work on arrays i think ???http://www.ruby-doc.org/core-1.9.3/Regexp.html#method-i-named_captures
[20:09:41] apeiros_: ellisTAA: eh, I think you completely misunderstand .named_captures
[20:09:41] graft: apeiros_: well where does it live? is it a keyword?
[20:09:49] eam: graft: it's a variable
[20:09:52] apeiros_: graft: it lives in the interpreter
[20:09:58] apeiros_: it's not really a variable
[20:10:03] apeiros_: you can't assign to it
[20:10:20] ellisTAA: apeiros_: it only applies to regex searches right?
[20:10:22] graft: and it has file-level scope, which is unlike any other variable i've heard of
[20:10:49] apeiros_: graft: consider it a magical string literal. like __LINE__ is a magical integer literal.
[20:11:02] eam: oh, is it special cased in the parser?
[20:11:16] apeiros_: I'd expect that to be the implementation, yes
[20:11:20] eam: apeiros_: arguably is a variable that one can't assign to :)
[20:11:36] apeiros_: arguably is a string literal which looks a bit odd because it doesn't have quotes :-p
[20:12:17] eam: well, it's runtime-settable
[20:12:22] eam: just not via assignment
[20:12:42] graft: it's not run-time settable, since it differs for every file you require
[20:12:42] apeiros_: it's not a method either, as you can't shadow it
[20:12:47] apeiros_: >> defined? __FILE__
[20:12:48] eval-in_: apeiros_ => "expression" (https://eval.in/267259)
[20:12:54] apeiros_: >> defined? "hellau"
[20:12:54] eval-in_: apeiros_ => "expression" (https://eval.in/267260)
[20:13:02] apeiros_: >> defined? require
[20:13:03] eval-in_: apeiros_ => "method" (https://eval.in/267261)
[20:13:08] apeiros_: >> x = 1; defined? x
[20:13:09] eval-in_: apeiros_ => "local-variable" (https://eval.in/267262)
[20:13:21] apeiros_: and leading _ would be local variable
[20:28:54] d10n-work: Is there a nice way to do something like Net::HTTP[method.to_sym].new where if method is 'GET' it would evaluate to Net::HTTP::Get.new
[20:30:33] crome: Object.const_get("Net::HTTP::#{method}")
[20:30:37] crome: is it what you are looking for?
[20:31:26] apeiros_: crome: const_get + public_send
[20:31:40] apeiros_: oh, well, actually ^ @ d10n-work
[20:32:12] apeiros_: plerp, should have read all before responding
[21:04:30] d10n-work: thanks crome
[21:06:28] lucasSantAnna: has someone here that is using microservice concepts?
[21:06:33] lucasSantAnna: ow are you guys doing to orchestrate the services ?
[21:24:57] mwlang: ugh???subversion???does anyone remember how to restore a locally modified file to last commit???s version? I???ve been doing git for too long!
[21:25:29] tobiasvl: mwlang: svn revert ?
[21:25:31] crome: isn't it revert
[21:25:44] crome: (it's been ages, though)
[21:25:53] mwlang: that???s what I thought, but I got an error???looking it up in the docs now.
[21:28:13] adnauseaum: wow, ruby is a really easy language
[21:29:10] ddv: adnauseaum: easy to learn, hard to master
[21:29:12] mwlang: weird, svn revert worked 2nd time I tried it???must???ve typo???d.
[21:29:49] adnauseaum: as is anything in life
[21:30:03] ddv: well it especially holds true for ruby
[22:00:55] Curs0r: Hello all. I have pretty much no ruby experience, I'm just relaying a question for a friend. Is there a simple way to convert a Latin1 character to octal in a string? Such as: replacing ? with \351?
[22:02:47] apeiros_: Curs0r: .chr.to_s(8)
[22:03:07] Curs0r: thank you :)
[22:03:21] wallerdev: why would someone want octal
[22:03:33] apeiros_: wallerdev: never understood that either
[22:04:45] GaryOak_: unicode man, to the rescue
[22:04:52] Curs0r: because postscript is being a pain about Latin1 special characters in a bash script apparently, and seems to work if they're octal escaped
[22:07:05] da3m0n22: hey guys, something strange, gem list rake shows "rake (10.4.2, 10.1.0,", however bundle exec rake install show "Could not find rake- in any of the sources"
[22:07:32] da3m0n22: any ideas? it's install of gitlab https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md#install-gitlab-shell
[22:08:41] Rayford: different manager?
[22:08:45] Rayford: rvm vs something else?
[22:09:06] da3m0n22: not using rvm, rbenv or chruby
[22:09:56] Rayford: have you tried to uninstall?
[22:10:52] da3m0n22: will try, second please
[22:13:50] da3m0n22: not working, 'bundle install' complains about drapper, which is in repositories too
[22:14:26] da3m0n22: i've tried putting .gem file of drapper (correct version) into ruby gem cache, but it's not looking into the directory probably
[23:05:57] ellisTAA: can someone help me pass this test. i???m trying to convert a hash into a string with a specific format. the method i???m working on is called printable & the problems i???m having can bee seen in the failed_tests.rb section https://gist.github.com/ellisTAA/0a8c4da823b3851e7685
[23:08:14] centrx: >> ['a', 'b', 'c'].join(' ')
[23:08:15] eval-in_: centrx => "a b c" (https://eval.in/267526)
[23:09:09] centrx: >> { a: 1, b: 2, c: 3 }.map { |k,v| "aa#{k} - bb#{v}" }
[23:09:10] eval-in_: centrx => ["aaa - bb1", "aab - bb2", "aac - bb3"] (https://eval.in/267527)
[23:09:14] centrx: ellisTAA, ^
[23:10:46] havenwood: >> [["apple", "fruit"], ["fish", "aquatic animal"]].map { |k, v| "[#{k}] \"#{v}\"" }.join("\n")
[23:10:46] eval-in_: havenwood => "[apple] \"fruit\"\n[fish] \"aquatic animal\"" (https://eval.in/267530)
[23:10:49] ellisTAA: centrx: what does the ???aa bb mean?
[23:10:58] centrx: just an example
[23:11:03] havenwood: ellisTAA: That's an odd format, where'd that test come from?
[23:11:04] centrx: randomtext
[23:11:58] ellisTAA: havenwood: what???s an odd format? my code or the test
[23:12:09] ellisTAA: havenwood: thanks for the help
[23:12:18] havenwood: ellisTAA: Drop the `print_result = ` variable, it's unused. It implicitly returns.
[23:12:22] havenwood: ellisTAA: Yeah, the test.
[23:12:32] havenwood: ellisTAA: Just curious.
[23:12:52] zenspider: again... unreadable overly complex code... a day later.
[23:13:10] ellisTAA: havenwood: i was told not to say where. sorry about that :\
[23:13:21] havenwood: ellisTAA: That's fine, no worries.
[23:13:28] ellisTAA: i appreciate tht help thoug
[23:13:44] ellisTAA: zenspider: i???m a noooob!
[23:14:05] centrx: that's a paddlin'
[23:14:29] havenwood: ellisTAA: you can drop the whole if/else rigmarole here, it's already true or false: Rigmarole
[23:14:33] havenwood: https://gist.github.com/ellisTAA/0a8c4da823b3851e7685#file-dictionary-rb-L45-L49
[23:14:35] zenspider: told not to say where?? it's totally googleable
[23:14:50] centrx: https://www.youtube.com/watch?v=ZXQR-cPXlmY
[23:14:51] havenwood: sekret, shhhhh
[23:15:17] zenspider: ellisTAA: a noob that yesterday was arguing that you didn't need to read/learn anything, you just needed practice.
[23:15:36] zenspider: always my first Big Red Flag???
[23:15:58] zenspider: https://www.google.com/search?q=%22African+land+animal+with+stripes%22
[23:16:02] havenwood: ellisTAA: looks like you're needlessly assigning local variables to your return value in a few places. don't do that.
[23:16:43] ellisTAA: havewood: ty, what is Rigmarole
[23:16:56] havenwood: ellisTAA: a word i had to google to spell correctly
[23:17:05] havenwood: then pasted instead of the gist link i meant to
[23:17:15] havenwood: so... nvm >.>
[23:17:32] zenspider: I thought it was "riga..."
[23:23:53] electrical: Hi all. still having this issue. https://gist.github.com/electrical/0d8b3b0edd797a197669 a certain string gets quoted and escaped with ruby 2.1 and up. but not with ruby 2.0 and lower.. is there a way that i can achieve the same what ruby 2.1 does but then with lower ruby versions?
[23:24:20] electrical: I've tried to stringify the variable by "#{var}" but had no luck either.
[23:24:36] electrical: adding quotes doesn't seem to work either
[23:25:36] Godd2: electrical one obvious solution is to only use one version of ruby in production
[23:25:45] electrical: godd2: hehe true :-)
[23:25:59] Godd2: but that doesn't help much
[23:26:05] electrical: we test against multiple versions and that's why i ran into this
[23:26:48] Godd2: ah I see. where are you getting .to_yaml from?
[23:27:04] Godd2: since it may be version sensitive
[23:27:04] electrical: stdlib from ruby
[23:27:30] electrical: just doing a require 'yaml'
[23:29:18] Godd2: I don't know enough about the yaml spec to know if having quotes around directories is a no-no
[23:29:39] Godd2: because that's the only difference between the strings, no?
[23:29:58] electrical: apeiros: said earlier that its fine.
[23:30:07] electrical: yeah. indeed.
[23:30:22] Godd2: so what's the issue then?
[23:31:51] Godd2: you just don't like how it looks?
[23:32:06] Godd2: I mean, that's a valid reason
[23:32:56] electrical: well i do validation if i get back what i expect. ( rspec tests ) and we test against different ruby versions
[23:33:30] electrical: so depending on which ruby version i'm testing it may pass or fail
[23:33:34] electrical: slightly annoying
[23:33:39] Godd2: electrical if the output is valid yaml, then my suggestion is to change your spec to account for the validity
[23:34:04] Godd2: that is, make your test a little more general
[23:37:59] Godd2: electrical you can also try doing hiera_config.inspect.to_yaml
[23:38:24] Godd2: it may force the quotes you're looking for
[23:39:22] electrical: godd2: "--- ! '{:backends=>\"yaml\", :yaml=>{:datadir=>\"/some/path/to/hiera\"}}'\n"
[23:39:37] Godd2: did that work?
[23:39:57] electrical: nope. it dumped the ruby hash directly
[23:40:13] electrical: as a single string
[23:40:24] Godd2: oh then yea, my only recommendation is to change the test to allow for quotes being there or not being there
[23:42:34] electrical: Looks like it yeah
[23:43:48] Godd2: or you can change the CI matrix to not test against older versions of ruby if you aren't using them, but that's a different branch of thought
[23:44:56] troynt: is there a shorter way to write some_arr.map!({|x| x['string'] }) ??
[23:44:56] havenwood: Seems it doesn't matter what it serializes to as long as it deserializes as expected.
[23:45:09] havenwood: Like Marshal can serialize differently on different system.
[23:45:10] jhass: troynt: not in ruby ;)
[23:45:20] troynt: jhass, thx
[23:45:45] Godd2: jhass well he can make it one character shorter by removing the parens
[23:45:48] havenwood: jhass: though i've yearned for it from time to time
[23:46:18] jhass: havenwood: .map &.["string"] <3
[23:46:42] centrx: What is this, a Skype replacement made by Mozilla?
[23:46:51] havenwood: jhass: is that a Crystalism?
[23:47:01] havenwood: jhass: oh, wow!
[23:47:06] jhass: can even go on and chain stuff
[23:47:14] jhass: .map &.["string"].upcase
[23:47:40] jhass: it's because &. is actually just a parse time rewrite
[23:50:14] troynt: jhass, what is &. called ? and what is it rewritten to?
[23:50:25] jhass: troynt: that's not ruby
[23:50:25] troynt: can't seem to get it working
[23:50:29] troynt: that's why
[23:51:25] Godd2: best reason
[23:51:31] havenwood: troynt: http://crystal-lang.org/
[23:52:52] troynt: havenwood: cool, I'll just run rails on that. thx
[23:52:59] troynt: (kidding)
[23:54:02] jhass: the almost-sinatra poc is called frank ;D