« Back to channel list

#ruby - 26 January 2015

« Back 1 day Forward 1 day »
[00:00:01] crocket: 'gem install bundler' installs bundler in a user directory.
[00:14:53] skinux: Isn't require 'gtk' correct for using GTK toolkit?
[00:37:28] gr33n7007h: >> "string".encoding
[00:37:29] eval-in_: gr33n7007h => #<Encoding:UTF-8> (https://eval.in/258987)
[00:44:01] gr33n7007h: 19>> __ENCODING__
[00:44:02] eval-in_: gr33n7007h => #<Encoding:US-ASCII> (https://eval.in/258988)
[00:44:13] gr33n7007h: 2.0>> __ENCODING__
[00:44:20] gr33n7007h: 20>> __ENCODING__
[00:44:21] eval-in_: gr33n7007h => #<Encoding:UTF-8> (https://eval.in/258989)
[01:27:53] Sendo: Is ruby with ror fast for creating websites?
[01:51:20] patrick99e99: hey ruby friends... I just made my own Matrix class and put it within a module, and for whatever weird reason, when I run rake, when rspec / spec_helper gets included and the default rake task for spec gets loaded, MyModule::Matrix explodes and says it's undefined
[01:51:51] patrick99e99: if I rename my class to Matricks then it works fine
[01:52:16] patrick99e99: but I thought this was the whole reason for modules, and that it is supposed to make it possible to do this sort of thing?
[01:54:47] crocket: It seems backward compatibility is not important in ruby world.
[01:55:26] crocket: waxjar, why?
[01:55:57] waxjar: just curious why you say that
[02:13:38] insaneinside: SO! Why does Object#extend(mod) not invoke mod.included, while Object#singleton_class#include (which I've seen used much less often) does? Am I... Doing It Wrong(TM)?
[02:15:40] wallerdev: extend and include dont do the same thing
[02:15:44] centrx: insaneinside, There is a Module#extended
[02:15:55] centrx: Module.extended
[02:16:03] centrx: whatever it's called
[02:18:26] insaneinside: ack! so much for consistency in (in)transitivity!
[02:19:21] centrx: Usually class methods are included in an included module through a ClassMethods submodule called from the included method
[02:21:59] insaneinside: >> module M; [:included,:extended].each { |x| class_eval("def self.#{x.to_s}(by); puts \"\#{by} #{x.to_s} \#{self}!\"; end") }; end; Object.new.extend(M)
[02:21:59] eval-in_: insaneinside => #<Object:0x424734d8> extended M! ... (https://eval.in/259196)
[02:22:13] insaneinside: >> module M; [:included,:extended].each { |x| class_eval("def self.#{x.to_s}(by); puts \"\#{by} #{x.to_s} \#{self}!\"; end") }; end; Object.new.include(M)
[02:22:13] eval-in_: insaneinside => undefined method `include' for #<Object:0x4173b504> (NoMethodError) ... (https://eval.in/259197)
[02:22:31] insaneinside: >> module M; [:included,:extended].each { |x| class_eval("def self.#{x.to_s}(by); puts \"\#{by} #{x.to_s} \#{self}!\"; end") }; end; Object.singleton_class.include(M)
[02:22:31] eval-in_: insaneinside => #<Class:Object> included M! ... (https://eval.in/259198)
[02:22:58] insaneinside: see, in the extend case it's actually that *M* extended the object, and not the other way around.
[02:23:24] insaneinside: (and derp, that was supposed to be Object.new.singleton_class.include(M), but w/e)
[02:24:41] insaneinside: but i've complained enough. Thanks for the reference to Module#extended, centrx :)
[02:26:34] aaas: newbie question: tryign to understand blocks on youtube etc....in particular how do i Understand this code: https://gist.github.com/anonymous/6a2932396335212017a2 is 'movies' an argument to create_tables? then what is create_tables
[02:29:05] insaneinside: aaas: someone else knows the proper channel for Ruby on Rails questions, but it isn't this channel...
[02:29:43] aaas: insaneinside well my question is not really about rails per se...i can probably dig up a different non-rails example
[02:29:46] waxjar: #rubyonrails :)
[02:30:39] insaneinside: aaas: it looks like you're asking about the API. Syntax? Yeah, `create_tables` is a method, called with argument 'movies'.
[02:31:41] aaas: insaneinside so as i understand it the do...end is a block, and this is ALSO an argument to create_table, as well as 'movies'?
[02:32:27] insaneinside: think of it like a lambda function (or a functor, if you've donce C++...) that gets passed to the method definition
[02:33:15] insaneinside: explicitly -or- implicitly, i.e. `def x(y,&z); z.call(y); end` is equivalent to `def x(y); yield y; end`.
[02:33:34] insaneinside: (but i hear the latter is more efficient)
[02:34:43] aaas: ok looks like i have a bit more reading up to do to understand this stuff, thanks
[02:35:08] insaneinside: np, always happy to run my mount :S
[02:38:46] waxjar: if you're familiar with javascript, it's very similar to passing in callbacks like so: onSomething(function() { "this would be the block" });
[02:40:31] aaas: yes i understand labmdas, java anonymous functions, closures, etc, but in this case I dont exactly see how it's working ...maybe i have to understand the rails specific design to do so
[02:40:38] multi_io_: do you install rbenv on OSX via homebrew?
[02:42:41] insaneinside: multi_io_: maybe RTFM? => https://github.com/sstephenson/rbenv#installation
[02:43:00] multi_io_: insaneinside: yeltzooo
[02:43:19] multi_io_: insaneinside: yeah, I read that, and now I'm unsure :)
[02:43:35] waxjar: the biggest difference is that the block is outside the parenthesis (method(method, args) do |block, args| .. end)
[02:44:07] insaneinside: multi_io_: my (very quick) reading of the OS X-related parts tells me either git- or homebrew-based would work
[02:44:35] multi_io_: exactly, that's what I'm unsure about -- which of the two would be preferable.
[02:44:54] multi_io_: I guess I'll use brew
[02:57:07] insaneinside: uh-oh. It's that time when... that "fun little project" has become complex enough that I need to disambiguate some issues on paper.
[03:58:01] d10n-work: What is a nice way to make docopt work with the command-line arguments used by require 'sinatra'? I want to add flags for a different sinatra-based program but I can only think of duplicating some of the code in sinatra/main for docopt's output
[04:10:20] pontiki: d10n-work: what is docopt?
[04:11:10] d10n-work: pontiki: it parses command-line options from standard documentation
[04:11:24] pontiki: d10n-work: also, i'm not sure what command-line arguments have to do with require 'sinatra'...
[04:11:28] d10n-work: hhttp://docopt.org/
[04:12:28] d10n-work: require 'sinatra' does require 'sinatra/base' which does require 'optparse' and makes a new OptionParser
[04:12:56] insaneinside: er: we're worried about duplicating `require` statements?
[04:13:49] d10n-work: no. It would be nice not to have to duplicate sinatra/base's handling of arguments
[04:19:37] pontiki: d10n-work: it seems that OptionParser is required in Sinatra::Application, which isn't in sinatra/base
[04:19:51] pontiki: so just require 'sinatra/base' and you won't have an options parser
[04:20:02] pontiki: you'll have to use a module-style sinatra app
[04:20:35] d10n-work: ah I typed base and meant main :) I will use a module-style sinatra app
[05:15:23] jidar: is there a easy way to upgrade your ruby version with rbenv? I did a install 2.1.5 but now I've got to go manually get all the gems and such
[05:16:00] jidar: so I usually just do a gem list and copy that into a notepad/fixup then paste a gem install with a hundred items
[05:33:39] sevenseacat: just bundle in your apps?
[05:59:50] Lingos: I have a question about organizing data. I have a Message object, and I need to keep analytical data about it. For example, wasOpened, didSendPushNotification, wasDeleted, timeOpened, wasForwarded, lots of booleans, counters, etc. Is it better to keep these as columns in the Message model, or is it better practice to create some model, Analytics, and have that associated to a
[05:59:50] Lingos: Message instance?
[07:29:00] samfisher: anyone knows what a Prague Attention Test is?
[07:48:49] lxsameer: does using instance_eval is bad idea in general ?
[07:54:03] certainty: lxsameer: my rule is to think again whenever i think i need some form of eval. But sometimes it is the right choice
[07:54:36] lxsameer: certainty: cool
[08:21:01] pontiki: he's really uncertain
[08:21:28] pontiki: (*sigh* 2:21am)
[08:58:11] Manouel: Hey guys ! One of you already used hdf5 gem ?
[09:04:00] Nameo0: Hello! =) How would you extract a value based on key from a hash that is nested inside an array?
[09:04:40] certainty: find the hash in the array then access the wanted element by key
[09:05:27] Nameo0: I meant what is the syntax b/c I cannot figure that out.
[09:05:42] Nameo0: Is it: array[0]hash[:key]
[09:05:53] certainty: array[indexd][key]
[09:07:45] Nameo0: Okay, cool it works! Thnak you certainty! =)
[09:07:59] Nameo0: avril14th, Hello! =)
[09:38:12] atmosx: good morning
[09:39:32] atmosx: I'm trying to figure out what happens in the second part of the array in this line: https://gist.github.com/atmosx/5164717f9659424552a5#file-test-rb-L13 . I understand that hte first part is called and then called again and again... until we have 2 elements. But what about the '2nd' end of the array?
[09:40:23] avril14th: atmosx: what you want to do?
[09:40:52] certainty: atmosx: it returns the smaller element of the two
[09:41:24] atmosx: avril14th: I'm trying to understand how recursion works. In this example, the code creates a 2-size array and then compares a to b
[09:41:27] ariejan: I have a module, which gets included into a class. But calling the method just returns ???nil???, method not executed, so it seems. https://gist.github.com/ariejan/809659c42fdbda2e8eac
[09:42:07] certainty: to understand recursion you, of course, have to first understand recursion
[09:42:11] atmosx: avril14th: whre a is array[0] and b [1] ... what I don't underand is where is compared the 2nd part of the array, or maybe it's not compared at all?
[09:42:24] atmosx: certainty: yeah, that's the problem.
[09:42:38] atmosx: certainty: seems like the topic is kinda hard for me to grasp, unfortunately.
[09:43:12] ariejan: atmosx: think of it like this: you have a method calling itself, calling itself, etc.
[09:43:20] atmosx: ariejan: Yeah I get that.
[09:43:41] ariejan: atmosx: to process a list, your method takes a list, processes the first argument, and calls itself with the rest of the list, until there is no ???rest??? left, just one element to process.
[09:43:54] certainty: atmosx: do you understand simpler examples of recursion?
[09:44:06] atmosx: certainty: are there any simpler examples?
[09:44:22] ariejan: atmosx: that was a simple example. :-)
[09:44:25] certainty: atmosx: sure, just traversing a list for example as ariejan currently tells you
[09:44:40] atmosx: okay let me try to implement that
[09:44:44] certainty: or counting down
[09:44:48] atmosx: a list, which deletes each element?
[09:44:57] atmosx: err 1 element at each iteration
[09:48:56] certainty: ariejan: i can not confirm that.
[09:49:31] certainty: i mean, the code you gisted works here
[09:49:32] ariejan: atmosx: check this example: https://gist.github.com/ariejan/537680134081dbe3c468
[09:50:23] ariejan: the print_list method takes an array of integers. It uses Array#shift to take an delete the first element of the array and print out the result. It then calls itself again to process the rest of the list. The kicker is that there is a guard in the method to just do nothing (return) if the provided list is empty.
[09:52:14] atmosx: ariejan: made this but pop doesn't work for some reason https://gist.github.com/atmosx/4b8ccacca719bf9fb192
[09:52:46] atmosx: ariejan: looking at your code now
[09:52:59] certainty: atmosx: Array#pop returns the pop'ed element not the rest of the array
[09:53:17] atmosx: certainty: oh.
[09:53:20] certainty: generally your recursive step should bring you closer to the basecase
[09:53:20] atmosx: my bad...
[09:53:43] certainty: (recursive steps actually as there might be multiple)
[09:55:02] certainty: atmosx: also to stay in your example. while that should generally work. you can think about the algorithm differently. removing an element can be seens as copying the array but leaving out the element you want to be removed
[09:55:45] atmosx: certainty: array.delete(array.pop) ?
[09:56:07] atmosx: certainty: like new_array = array.delete(array.pop) ...but then I'mnot using the exact same call
[09:56:09] waxjar: array.pop already modifies the array
[09:56:15] atmosx: I'm creating a new list, I don't know can I do that?
[09:56:29] atmosx: waxjar: hm
[09:56:41] atmosx: oh true, let me modify the code
[10:00:15] atmosx: https://gist.github.com/atmosx/671910a7cf7cae74936a works! Thanks guys I made my first successful recursion, but any idea how can I count the steps? The valie of 'step' is always because essentially it's like if it is always called for the first time.
[10:00:42] tobiasvl: define step outside the recursive method
[10:00:42] atmosx: I guess I could do that if I ceated a class, then a method and 'step' was a class variable.
[10:00:56] atmosx: oh stupid me, I think so much in terms of classes
[10:01:25] certainty: atmosx: generally if you need to carry state around during recursion you have to pass it into the methods. Creating helpers to make the interface cleaner
[10:01:33] certainty: accumulators commonly
[10:02:06] atmosx: certainty: pass it you mean like an argument?
[10:02:55] certainty: also notice that using accumulators and a special form of recursion you actually generate and iterative process
[10:03:31] certainty: some languages can optimize this and in fact create code that is as efficent iteration constructs in other languages
[10:03:37] certainty: atmosx: yes like arguments
[10:04:13] tobiasvl: note that what certainty talks about is called tail call optimization, and in ruby it depends on the implementation
[10:04:47] atmosx: "tail call" optimization
[10:05:30] atmosx: A tail recursive function is one where the final statement is a call to the same method.
[10:05:36] atmosx: from here http://nithinbekal.com/posts/ruby-tco/
[10:05:42] certainty: yeah though the iterative part doesn't depend on tail calls. You can think about this way. if you pass the state in explicetly, you could in general, stop the computation with the state it currently knows about. Then resume it some time later. because all information to make the computation is in the arguments and not somewhere in the stack frames
[10:05:54] certainty: also sorry if that confuses you more than it helps
[10:06:16] atmosx: but literally speaking any recursion is a 'tail call' since at the moment the menthod/function is called inside herself execution stops until the inner call returns a result, isn't so?
[10:07:00] atmosx: certainty: Yes I think I'm a little bit over my head now.
[10:07:15] atmosx: by the end of the course I might be able to discuss the topic again having more insight.
[10:07:16] certainty: atmosx: generally it's only considered a tail call if no work is done after that recursive call
[10:07:31] atmosx: certainty: i see.
[10:07:37] atmosx: so not my case. since I'm comparing in the end
[10:07:44] certainty: this means that you for example don't depend on the result of the recursive step
[10:08:06] atmosx: oh I see.
[10:08:17] atmosx: what is the use of a having a call upon which result you don't depend?!
[10:09:18] certainty: there are basically two ways to arrive at a result in a recursive implementation. 1) compute while you go down the recursion and return the result once you hit the base case 2) go down and down building up temporary results on the stack frames and compute the final result after you hit the base case when you walk the stack up again
[10:09:41] certainty: atmosx: usuall when you can apply strategy 1
[10:10:17] certainty: in version one you can throw away all the stack frames and just return the result
[10:11:01] atmosx: the second is a good case for debugging?
[10:11:44] atmosx: I need to see an implementation of the 2nd case to really undertand it but I think that I see your point
[10:16:14] atmosx: certainty: nevermind, I have some homework to do on what we've discussed :-) . I'll see if I can figure it out, it's a merge-sort algorithm implementation with many limitations though.
[10:22:05] certainty: atmosx: https://gist.github.com/anonymous/3c0f5694ca059d7609c6
[10:22:49] atmosx: certainty: what does this code mean _,*r = ary
[10:23:18] certainty: it destructures the array, binding the first element to _ and all the rest to *r
[10:23:23] certainty: then returning r
[10:23:37] certainty: this just means that it returns the array minus the first element
[10:24:06] certainty: dunno, it may even be buggy. but it works as a quick way to implement that
[10:25:01] atmosx: certainty: thanks mate, I'll work on it again later on.
[10:27:18] workmad3: certainty: would probably have been easier to just do 'def tail(ary); ary[1..-1]; end' ;)
[10:28:11] certainty: workmad3: yep, though that is somewhat uncommon to approach lists from the right no?
[10:28:42] workmad3: certainty: ary[1..-1] is fairly common in ruby to get a tail
[10:29:03] workmad3: certainty: dunno about lists in general, especially in functional languages
[10:29:07] certainty: ok i didn't know that. My first instinct is to alway remove elements from the head
[10:29:45] workmad3: certainty: well, ary[1..-1] does remove the head
[10:29:46] certainty: workmad3: they generally do the head,*rest thing.
[10:30:09] certainty: workmad3: woops
[10:30:31] certainty: forget what i've just said
[10:30:38] workmad3: certainty: but I could see, especially with the possibility for infinite lazy lists, that ary[1..-1] could be... interesting... to support :)
[10:31:41] workmad3: certainty: heh :) I was almost tempted to do 'def car(ary); ary[1..-1]; end'
[10:31:54] workmad3: certainty: but then I got worried about which one was which with car and cdr :)
[10:31:57] certainty: would be cdr
[10:32:06] workmad3: so I was right to worry :)
[10:32:35] certainty: but generally lispers nowadays tend to use first and rest
[10:32:42] workmad3: certainty: btw, if you need both the head and the tail, then 'head, *tail = ary' would be great
[10:32:56] certainty: hard to find computers with address and decrement registers these days
[10:33:07] workmad3: it's just if you throw away the head that ary[1..-1] is more rubyish :)
[10:33:17] certainty: workmad3: that's basically how languages with pattern matching do this
[10:33:32] certainty: workmad3: true
[10:34:25] certainty: to be honest, i tend to forget the different possible usecases for Array#[] and i almost never get them right from the start (except the simple case where the argument is just the index)
[10:34:42] certainty: if i know those better i'd probably chosen your (better) solution
[10:38:25] workmad3: certainty: the only ones I tend to remember are index access, and range-slicing :)
[10:38:48] certainty: hehe, seems as if i should at least get the latter under my belt as well
[10:39:12] workmad3: certainty: I tend to have to try it out before I remember if 'ary[1,2]' does a slice from ary[1] to ary[2], or 2 elements starting at ary[1]
[10:40:17] certainty: i'd say the letter again, but i don't know
[10:40:23] certainty: i would test out as well
[10:43:25] timgauthier: since your on the topic of arrays
[10:43:47] certainty: we're on the topic of age since we both can't seem to remember things so well anymore :p
[10:44:19] timgauthier: lets say i have 2 arrays one is a list of courses and they have a "product id" so like courses[(1, Course name, 15), (2, Second Course name, 12)]
[10:44:33] timgauthier: that is a multidimension array right, an array of arrays
[10:45:35] timgauthier: okay, now lets say i have another array that is just a list of product ID's, this one is from the "user" so user has access to these products
[10:45:48] timgauthier: userarray[12,16,18]
[10:46:48] timgauthier: what is the logic to compare them. I want to compare the userarray to the product arrays to find only the courses that match keys that are in the userarray
[10:47:07] timgauthier: so i only want to show courses that have a product id that matches at least one found in the userarray
[10:47:59] certainty: courses.select{|id,name,*| userarray.include?(id) }
[10:48:37] timgauthier: whats that actually doing though, is it taking the one array, exploading it into a for each and comparing each one? thats just a whole logic chunk i'm not grasping
[10:49:16] timgauthier: ohhhh, your doing a select then comparing the third key to an if statement from the second array?
[10:49:42] certainty: the third element is the id?
[10:49:42] timgauthier: oh yeah, then i need to make an array of the courses that inclu... fuck why is this such convoluted logic :(
[10:49:46] certainty: well then i got it wrong
[10:49:53] certainty: yeah but you get the idea
[10:50:03] timgauthier: yeah you had ID as the 'key' or whatever
[10:50:11] certainty: .select{|_,_,id| userarray.include?(id) }
[10:50:32] timgauthier: now to make this logic work in php :P lol but honestly i just wasn't grasping the logic enough to even look for answers or figure out what i was trying to do
[10:50:35] certainty: not exactly the most efficent way to do it maybe
[10:50:58] timgauthier: yeah, sadly i can't really change how the course-list is presented, its from a third party api so i'd have to deal with it the way it is
[10:51:17] certainty: then i'd probably change the userarry to a set
[10:51:23] certainty: the lookup should be faster then
[10:51:36] scientist1642: When we say x = "1"; x = "2" the second assignment doesn't actually overwrite the value at current object location right? it creates a new object and stores it's location in x. then how come - x = "1"; l = lambda {x}; x = "2" l.call still returns 2, as x maps to previous location of object in closure
[10:51:39] certainty: workmad3: is that right or am i telling nonsense?
[10:52:40] Xeago_: scientist1642: the implementation differs per type
[10:53:11] zwer: Xeago_ it does? when would the behavior be different
[10:53:24] workmad3: certainty: seems right
[10:53:32] Xeago_: hmm, I amw rong indeed, thought it was integers
[10:53:35] Xeago_: but he uses strings???
[10:53:51] Xeago_: some strings are stored inline, others are pointers to structs
[10:53:53] scientist1642: Xeago_: it's the same for fixnums
[10:54:28] Xeago_: and some fixnums are stored in the value to the pointer
[10:54:52] workmad3: Timgauthier: no idea what you'd use in PHP... .select is a ruby enumerable method... in PHP, what you'd probably do is something like '$founditems = []; foreach(item in $userarray) {$founditems.push(item) if $idarray.contains($userarray[2])}
[10:54:59] workmad3: Timgauthier: something along those lines anayway
[10:55:03] Xeago_: I can't really explain it in english: x->pointer->struct, or x->pointer,which-has-a-value
[10:55:28] timgauthier: workmad3 that actually helps a ton, my problem was not even understanding it on a conceptual level
[10:56:00] workmad3: scientist1642: closures store a reference to the local binding, not a copy of it at the instant the closure was created
[10:56:23] workmad3: scientist1642: i.e. if you update a local variable before the closure is called, the closure reflects that change
[10:56:39] ddv: this is why its called a closure...
[10:56:54] scientist1642: workmad3: that's my point - that means that value at the location is overwritten right?
[10:57:28] workmad3: scientist1642: no... 'x' is updated to point to a new object
[10:58:19] workmad3: scientist1642: but in another sense, yes... because the 'value' of 'x' in the local variable bindings is overwritten with a new location
[11:00:19] scientist1642: workmad3: but in closure we have x pointed to the old location
[11:00:25] workmad3: scientist1642: no
[11:00:33] avril14th: is there a way to run a shell script from ruby without ruby waiting for the script to finish?
[11:00:54] avril14th: like asynchronously, returning immediately even though the script keeps running
[11:02:26] workmad3: avril14th: http://www.ruby-doc.org/core-2.2.0/Kernel.html#method-i-spawn
[11:03:06] avril14th: workmad3: wonderful, thx
[11:05:37] scientist1642: workmad3: hmm, why not closure includes current lexical scope bindings doesn't it?
[11:06:15] workmad3: scientist1642: it stores a reference to the scope, it doesn't copy it... if something updates the scope, those changes are reflected inside the closure
[11:06:40] workmad3: scientist1642: e.g. the same as if you did 'a = []; b = a; a.push("foobar")' then b would show an array with "foobar" in it
[11:06:50] workmad3: scientist1642: because they both reference the same object
[11:07:37] workmad3: scientist1642: similarly, you can think of the lexical scope as an object (sort of), and the closure simply points to the same scope as the outside, so any updates to the scope are reflected in both places
[11:08:27] workmad3: (that's a bit simplistic... but it demonstrates the idea at least... it's no doubt inaccurate in many ways that others could pick up on though :) )
[11:10:19] scientist1642: workmad3: wow I see, that's very dangerous. then sometimes lexical scope actually will turn out to be a "dynamic scope" which takes a fun from using closures, but I also see that otherwise a lot of memory will be used as garbage collection won't be able to free up space
[11:11:38] timgauthier: i don't... really understand how it is important in what most people are doing for programminging
[11:12:10] workmad3: scientist1642: dunno about calling them 'dangerous'... any tool can be dangerous in many circumstances... it's the way closures work in ruby though, and it's pretty useful for them to have those characteristics, otherwise a lot of things in ruby would break
[11:13:37] workmad3: scientist1642: according to the wiki page on closures, ruby closures are 'lexical closures that capture variables by reference' rather than something like ML, which captures variables by value
[11:15:30] scientist1642: workmad3: I actually had ML closures in mind when learning about blocks in ruby
[11:15:53] workmad3: scientist1642: heh :)
[11:18:21] scientist1642: workmad3: thank you I will continue exploring ;)
[11:18:26] workmad3: Timgauthier: it can be useful to figure these things out, as it lets you determine differences between languages in a more comparable way than 'X has closures, Y has closures, therefore if I know how to use closures in X then I know how to use closures in Y'
[11:19:10] timgauthier: i love this, i can't use http at all right now because my wifi is too slow, but irc is fine
[11:19:24] workmad3: Timgauthier: also, there would be a big difference in how you use blocks/lambdas/procs etc. in ruby if closures worked differently :)
[11:19:53] klip: Did someone just say Ruby's variables are lexical w/ closures?
[11:20:00] klip: Pretty sure they're not, otherwise I wouldn't have been bitten by them before
[11:20:14] timgauthier: kl__ no they said
[11:20:15] klip: All I know is, from some traumatic experience, I try and avoid closures in Ruby
[11:20:18] timgauthier: that they are closures with pointers
[11:20:40] klip: what's the difference (in Ruby)?
[11:20:46] workmad3: well, I said they are lexical closures with capture-by-reference semantics rather than capture-by-value
[11:21:05] workmad3: no reference to pointers :P
[11:21:42] timgauthier: yeah sorry, i don't know what i'm talking about
[11:22:12] ddv: obviously
[11:22:25] timgauthier: its why i'm here
[11:22:45] workmad3: kl__: probably the bit that bit you and surprised scientist1642 is the difference :) that if you do 'x = "1"; f = lambda{x}; x = "2"; f.call' then you will get "2" out of the lambda, not 1
[11:22:46] timgauthier: thats nice code you got there, wouldn't it be a shame if i broke it...
[11:23:19] felltir: >> x = "1"; f = lambda{x}; x = "2"; f.call
[11:23:19] eval-in_: felltir => "2" (https://eval.in/260252)
[11:23:45] workmad3: kl__: in capture-by-value, the lambda would have returned "1", not "2"
[11:23:46] timgauthier: see and i expect that to be 2 looking at it
[11:24:06] timgauthier: but i can also see how it could be 1... so yeah
[11:24:21] workmad3: Timgauthier: in ML, reassigning x would have been strictly prohibited anyway :)
[11:24:35] timgauthier: ML being matlab?
[11:25:02] workmad3: https://en.wikipedia.org/wiki/ML_(programming_language)
[11:25:09] timgauthier: yeah, i could click that
[11:25:11] timgauthier: but it won't load anything
[11:25:40] klip: workmad3: i see. that *is* confusing!
[11:25:59] klip: workmad3: everything else in Ruby is pass-by-value: why the difference?
[11:28:21] certainty: >> def lets_see(x); x.object_id end; a = []; [a.object_id, lets_see(a)]
[11:28:21] eval-in_: certainty => [542677360, 542677360] (https://eval.in/260253)
[11:28:29] certainty: doesn't look like pass-by-value
[11:30:29] workmad3: kl__: err... pretty much everything in ruby is pass-by-reference
[11:32:44] workmad3: >> def not_by_value(ary); ary.push("hello!"); end; a = []; not_by_value(a); puts a
[11:32:44] eval-in_: workmad3 => hello! ... (https://eval.in/260284)
[11:33:30] klip: workmad3: duh. Let's pretend I didn't just say that
[11:33:43] certainty: ACTION saves the log
[11:34:02] workmad3: kl__: I guess you were thinking of the behaviour of reassigning parameters not reflecting outside the method?
[11:35:10] certainty: actually i used to think some years back that strings were passed by value. I had a bad bug in a mailer that would gsub! on a string and the calling code used that string later. Customers got truncated E-Mails
[11:35:14] certainty: that was bad
[11:35:30] felltir: in some cases things are pass-by-value
[11:35:32] workmad3: certainty: oops :)
[11:35:56] workmad3: felltir: tbh, the most accurate description would be the C description of 'pass by pointer-value'
[11:36:11] certainty: workmad3: yeah that was a bad day for me. I took a week and some shots to get over it
[11:36:23] felltir: >> a = "foo"; h = {a => "bar"}; puts [a.object_id, h.keys.first.object_id]
[11:36:24] eval-in_: felltir => 543096260 ... (https://eval.in/260285)
[11:36:29] felltir: >> a = "foo"; h = {a => "bar"}; puts [a.object_id, h.keys.first.object_id].inspect
[11:36:30] eval-in_: felltir => [553803580, 554999760] ... (https://eval.in/260286)
[11:36:39] felltir: like that, I mean
[11:37:18] klip: workmad3: i was thinking that - yes: how comes reassigning parameters doesn't mess up the outside?
[11:37:31] workmad3: kl__: as said, it's more 'pass-by-pointer-value' in C terms
[11:38:01] workmad3: kl__: so you have pointers to the same objects, but the pointers themselves are passed by value, so re-assigning them doesn't cause external changes
[11:38:36] workmad3: kl__: in that respect, closures do work slightly differently... but it's close enough that you can see the logic at least :)
[11:39:11] felltir: well it makes sense in that case, because the internal variable is a different object, in ruby terms
[11:39:40] felltir: whereas the inside of a closure references the external variables directly
[11:40:38] felltir: because it contains the entirety of it's binding
[11:40:46] workmad3: felltir: I'd guess that the internals of hash .clone or .dup the key so that it's protected from updates that would change the hash code
[11:40:58] workmad3: felltir: so it's not quite a 'pass-by-value', but it looks kinda similar :)
[11:42:07] felltir: workmad3: I think it doesn't matter if it's clone or dup, given that it's special behaviour for strings and gets frozen anyway :p
[11:42:20] klip: workmad3: gotcha. ta :)
[11:43:07] workmad3: felltir: yeah, but it's still not the case that there's a special-case of arguments being passed to a method there, which is important to note, IMO ;)
[11:43:21] felltir: definitely :)
[11:53:18] ShadySQL: guys could anyone please help me out
[11:53:19] timgauthier: DATABASES ARE BAD MKAY
[11:53:20] timgauthier: DONT DO DRUGZ
[11:53:26] ShadySQL: I am having a strange err??r
[11:53:28] timgauthier: workmad3 would likely help you ShadySQL
[11:53:28] ShadySQL: http://pastebin.com/mtzCp79a
[11:53:41] certainty: Timgauthier: you mean with drugs?
[11:53:46] timgauthier: no thats your dept
[11:53:47] ShadySQL: drugs are good
[11:53:52] ShadySQL: do them please
[11:53:52] certainty: i was going to say
[11:53:56] ShadySQL: with a couple of women
[11:54:09] workmad3: I have high-quality caffeine available in a variety of brews...
[11:54:12] ShadySQL: seems like I have a ruby version error
[11:54:18] ShadySQL: can anyone square me away?
[11:54:19] ShadySQL: http://pastebin.com/mtzCp79a
[11:54:26] ShadySQL: some recommendation?
[11:54:27] certainty: ShadySQL: gem install daemons. Add them to your Gemfile or whatever you use to manage your gems
[11:54:59] certainty: anyway. bbl
[11:55:39] ddv: I drink tea nowadays
[11:55:58] timgauthier: shevy does lines of php
[11:56:06] ddv: shevy: :-)
[11:56:13] workmad3: Timgauthier: whereas you seem to mainline it :P
[11:56:59] timgauthier: i wrote this one line, its amazing, i made an array from a comma seperated string!
[11:57:10] timgauthier: next up i'm going to put CSV's in!
[11:58:11] shevy: Timgauthier yeah I can't deny it, I think I wrote 10k or 20k lines of PHP in my life
[11:58:16] shevy: but I have repented my sins and became a better man
[11:58:35] timgauthier: i'm likely near that, but thats because i keep <? ?> <?= ?> things
[11:59:03] shevy: embedded php!
[11:59:06] ddv: I only wrote PHP in college, which is like 8 years ago or something
[11:59:07] shevy: mix html and php!!!
[11:59:14] shevy: ddv were you not the diesel engine guy?
[11:59:20] shevy: or was that ddd
[11:59:29] shevy: I can't keep your nicks apart
[11:59:39] ddv: that is YOUR problem
[11:59:49] ddw: my brother ddv and ddd!
[11:59:52] workmad3: ddv: well, one of his problems anyway...
[11:59:55] ShadySQL: doesn't work
[12:00:08] ShadySQL: I am trying to install
[12:00:19] ShadySQL: the new relic aws plugin
[12:00:22] ShadySQL: doesn't work
[12:00:36] ShadySQL: their service doest even start
[12:00:45] ShadySQL: it won't even demonize
[12:00:49] ShadySQL: it just sucks
[12:02:10] sevenseacat: you're doing it wrong?
[12:10:39] ShadySQL: now I have another strange error
[12:10:40] ShadySQL: http://pastebin.com/jVsedjGP
[12:10:50] ShadySQL: words of wisdom?
[12:12:25] sevenseacat: what does your config file look like?
[12:12:41] sevenseacat: looks like it has asyntax error
[12:14:56] ShadySQL: http://pastebin.com/kWpuf15g
[12:24:26] timgauthier: workmad3 this is what i'm comparing for my two arrays lol :'( https://gist.github.com/timgauthier/89fbaf1a6514e1ab8768/edit
[12:26:09] timgauthier: derp https://gist.github.com/timgauthier/89fbaf1a6514e1ab8768
[12:27:42] _lazarevsky: I have the following string -> "asddfsdbollocks(ineedthis)therestshouldgo"
[12:27:53] _lazarevsky: I wanna return only the stuff inbetween the ()
[12:27:59] _lazarevsky: what's the most elegant way of doing that?
[12:28:01] _lazarevsky: thanks so much
[12:28:07] sevenseacat: youre welcome
[12:28:41] DefV_: _lazarevsky: regexp matchh
[12:29:15] _lazarevsky: DefV_: would you happen to know the regex for that ? :)
[12:29:23] DefV_: >> "adzaijdazi(stuff)alzdlalzd"[/\((.+)\)/,1]
[12:29:23] eval-in_: DefV_ => "stuff" (https://eval.in/260400)
[12:30:02] _lazarevsky: DefV_: you beauty
[12:30:04] _lazarevsky: thanks so much
[12:31:04] Hijiri: >> runParser (char '(' *> many (noneOf ")") <* char ')') "fiejslfiejlsfij(aaaa)fefe"
[12:31:05] eval-in_: Hijiri => /tmp/execpad-e8922734a82c/source-e8922734a82c:2: syntax error, unexpected '>' ... (https://eval.in/260427)
[12:31:37] dotix: can you monkey patch a class but without opening it (normal way) : class String; def to_s; ... ; end; end; ?
[12:31:52] dotix: I'm looking for something similar with: [String, ....].each { ... }
[12:33:40] scientist1642: dotix: how about using mixins?
[12:34:56] dotix: you still have to open the class .. module MyMixin; def to_s; end; end; .. class String; include MyMixin; end;
[12:35:17] apeiros_: String.include Mixin
[12:35:36] apeiros_: String.__send__ :include, Mixin # for older rubies where Module#include is private
[12:35:55] apeiros_: also: monkey patching is bad. don't do it.
[12:36:37] dotix: maybe you have to do it
[12:36:51] apeiros_: you almost certainly don't.
[12:37:26] dotix: :D maybe depends on the experience.. I can't see other way of doing some tasks without using mixins
[12:37:45] apeiros_: dotix: "using mixins" is *not* the same as "monkey patching"
[12:38:01] apeiros_: monkey patching is specifically about modifying classes you don't own.
[12:40:26] apeiros_: alternatives to monkey patching:
[12:40:38] apeiros_: 1) create a subclass and instantiate that
[12:40:47] dotix: I see your point. Thanks for explanation. What if you want to add few functionalities to XML::Element
[12:41:00] apeiros_: 2) decorator pattern (wrap the object, delegate all original methods, implement your own ones in the wrapper)
[12:41:34] apeiros_: dotix: do you own the XML::Element class? I assume not -> monkey patching. rules as said apply.
[12:43:16] dotix: I will try to understand the second method
[12:43:42] dotix: I have a method and I want to add them to XML::Attr and XML::Element
[12:43:44] arup_r: Did anyone ever work with Ruby to work with openoffice doc ?
[12:43:48] dotix: and probably to more classes in the future
[12:43:53] arup_r: Need some pointer..
[12:44:48] apeiros_: dotix: oh, third and often used variant: use a function (pass in the object instead of using self)
[12:47:32] dotix: I like the last one. Thank you apeiros_
[12:48:13] dotix: I still have to read what are you trying to say at 2) decorator pattern. Do you happen to have a link?
[12:49:06] dotix: http://nithinbekal.com/posts/ruby-decorators/
[12:58:34] avril14th: how would you write a regex to match 14 digits with any number of spaces in between?
[12:59:39] pontiki: i wouldn't use a regexp
[13:00:15] tobiasvl: well you can do something like /(\d\s){14}/
[13:00:26] avril14th: tobiasvl: that's 14 where spaces count 1
[13:00:57] tobiasvl: oh yeah hehe
[13:01:02] jefus: how about strip the spaces first?
[13:01:05] tobiasvl: that doesn't work at all lol
[13:01:14] tobiasvl: yeah strip spaces while I get a coffee
[13:01:36] jefus: if the spaces are not significant, that should be easier
[13:05:41] workmad3: avril14th: as jefus said... '.gsub(/\s/, '').match(/(\d{14})/)
[13:07:13] avril14th: indeed, working. but less efficient, and I also need to remove the matches from the string (gsub!) so I can't work on a copy
[13:07:33] arup_r: Any body worked with Ruby and OpenOffice document ?
[13:07:36] workmad3: avril14th: or, if you only wanted to strip out spaces between digits... .gsub(/(?<=\d)\s(?=\d)/, '')
[13:08:45] workmad3: avril14th: sorry, that should be \s+ in the middle there :)
[13:08:56] avril14th: arup_r: reading with roo
[13:08:59] workmad3: >> "foo 1 2 bar 2 4 5\t6".gsub(/(?<=\d)\s+(?=\d)/, '')
[13:09:00] eval-in_: workmad3 => "foo 12 bar 2456" (https://eval.in/260506)
[13:09:48] arup_r: No.. It wouldn't work.. I have to work with word doc file.. not excel doc
[13:10:01] workmad3: avril14th: so, with your needs, you could do a pre-process to remove spaces between digits with that, and then gsub out your 14-digit long matches ;)
[13:10:48] workmad3: avril14th: or are the spaces significant if they're in digit runs of less than 14 digits?
[13:11:06] avril14th: workmad3: can't, I need to keep the string as it is and just remove what I match from it because what's left needs to go to some other processing
[13:11:49] workmad3: avril14th: ok... then I think you're out of the realm of regexp
[13:12:01] avril14th: ok, just needed a confirmation
[13:12:14] avril14th: thx workmad3 jefus
[13:13:06] avril14th: ~ 1000 lines of text processing here, if I meet Regexp in the street I'll slap it
[13:14:11] pontiki: oh, it's australia day
[13:16:41] maasha: hi, what is a great way using ruby to find out how much memory is available on a system?
[13:16:59] maasha: There is a gem with a strange name, but I cant remember ...
[13:17:14] maasha: Or is there a builtin method?
[13:27:02] nerium: Is it a bad idea to asserts (like you do in C) inline in the code?
[13:27:47] Hanmac1: nerium: hm an example of what you mean?
[13:29:30] nerium: hanmac1: https://gist.github.com/oleander/ee6abead0beffe749166
[13:33:44] nerium: hanmac1: Any idea?
[13:33:56] Hanmac1: hm currently i dont know
[13:42:31] kstuart: nerium: what would assert do if the expression was false?
[13:42:45] nerium: kstuart: it would raise an error
[13:44:22] Kn|t3_: noob ruby question - i have a = [1,2,3,4,5,6,7,8,9]. puts a[i].map(&:to_s).join.to_i works as expected (in a loop) but num = a[i].map(&:to_s).join.to_i fails with undefined method `map' for nil:NilClass
[13:45:08] Kn|t3_: ok i missed something, i also do a = a.permutation.to_a.reverse
[13:45:11] kstuart: if assert is just an abstraction over 'raise "assertion failed" unless largest >= n' then I don't see it as bad.
[13:45:25] Kn|t3_: i would appreciate any pointers
[13:45:26] avril14th: Kn|t3_: a[i] is nil
[13:45:40] kstuart: nerium: just a convenience method?
[13:45:56] kstuart: more terse
[13:46:29] kstuart: nerium: ps, where are you getting assert method from?
[13:46:45] Kn|t3_: umm ok avril14th , any idea why any value would be nil ?
[13:46:51] Kn|t3_: here is the gist - https://gist.github.com/anonymous/5401b3faf1c438ada7d7
[13:48:16] gr33n7007h: Kn|t3_, a.length-1
[13:48:34] Kn|t3_: oops - thanks gr33n7007h
[13:49:00] Kn|t3_: that was an embarassing mistake
[13:49:39] avril14th: Kn|t3_: yeah, length - 1
[13:49:53] Kn|t3_: sure - thanks avril14th :)
[13:50:21] gr33n7007h: or 0...a.length
[13:50:55] avril14th: Kn|t3_: syntax tips: https://gist.github.com/muichkine/c67df2d54085aeb14839
[13:52:23] Kn|t3_: woah -that looks amazing, awesome!
[13:54:44] pontiki: i don't think you need the final res in that inject
[13:58:33] matgee: kicked for flooding
[13:58:34] matgee: kicked for flooding
[13:58:35] matgee: kicked for floodingkicked for flooding
[13:58:37] matgee: kicked for flooding
[13:58:39] matgee: kicked for flooding
[13:58:41] matgee: kicked for flooding
[13:58:43] matgee: kicked for flooding
[13:58:45] matgee: kicked for flooding
[13:58:51] ChanServ: +o apeiros_
[13:58:52] ChanServ: +o apeiros_
[13:58:57] apeiros_: wow, slow chanserv
[13:58:59] wasamasa: apeiros: slam the brakes
[14:08:20] kstuart: oops, wrong screen!
[14:17:28] bergelmir: i have a rspec-related question. is there a way to check if a method was called with an array that contains 10 items? i need to check the array size
[14:26:54] avril14th: bergelmir: yes
[14:33:33] jhass: avril14th: no patience and crossposter
[14:33:35] jhass: spare your time
[14:38:20] emilkarl: Hi, having problem with compass 1.0.3. I have config.rb in a project, but then I run compass compile it tris to load a rails config file which is strange???and there is no app/config/application.rb so it just run this loop over and over again.
[14:41:21] emilkarl: http://pastie.org/9862427
[14:46:25] RedNifre: Hi there! :)
[14:47:14] RedNifre: What is the most elegant way to increment the last number in a string? E.g. turning "1.0.99" into "1.0.100" or "release 3 beta" into "release 4 beta"?
[14:48:58] workmad3: RedNifre: "1.0.99".gsub(/\d+[^\d]*$/){|m| m.succ} is the best I can come up with
[14:50:18] workmad3: bah, one sec, needs reworking for numbers in the middle of strings
[14:51:16] tobiasvl: http://ruby-doc.org/stdlib-2.0/libdoc/rubygems/rdoc/Gem/Version.html might help
[14:51:22] tobiasvl: or some comparable gem
[14:51:26] tobiasvl: sure there's a gem for this
[14:52:33] workmad3: .gsub(/\d+(?=[^0-9]*$)/){|m| m.succ}
[14:53:02] gr33n7007h: workmad3, bravo!
[14:53:39] RedNifre: Thanks, that's great!
[14:53:45] workmad3: today is a regexp lookahead day, obviously :)
[14:54:36] RedNifre: I played around with succ, it's funny how it already does something similar, e.g. "9".succ -> "10" or "9a".succ -> "9b" or "9z".succ -> "10a"
[14:55:17] workmad3: RedNifre: yeah, it's almost but not quite enough :)
[14:55:30] RedNifre: I'll use workmad3's solution for now, but I'll bookmark the gem for future reference. Thank you two very much :)
[14:55:44] workmad3: RedNifre: "1.0.99".succ gives "1.1.00" for example
[14:57:32] gr33n7007h: RedNifre, .pred gives you the opposite :)
[14:58:14] RedNifre: Does this channel have a bot that connects to irb?
[14:58:25] gr33n7007h: yep, eval-in_
[14:58:59] RedNifre: how to use it?
[14:59:24] gr33n7007h: that's g14 classified
[14:59:38] RedNifre: > "aaa".pred
[14:59:50] gr33n7007h: only on ints
[14:59:55] havenwood: a slight modification for consideration: sub(/\d+(?=[^\d]*\z)/, &:succ)
[15:00:17] gr33n7007h: >> "abc".succ
[15:00:17] eval-in_: gr33n7007h => "abd" (https://eval.in/260723)
[15:00:40] RedNifre: havenwood, what does your version do differently?
[15:01:10] gr33n7007h: using /z end of a string
[15:01:15] havenwood: RedNifre: just #sub instead of #gsub, since you're doing it once
[15:01:29] havenwood: RedNifre: and shorthand :succ block
[15:02:05] havenwood: and some random meddling for no good reason
[15:02:19] gr33n7007h: >> "abc".next
[15:02:19] eval-in_: gr33n7007h => "abd" (https://eval.in/260747)
[15:03:58] epitron: >> "abc".prev
[15:03:58] eval-in_: epitron => undefined method `prev' for "abc":String (NoMethodError) ... (https://eval.in/260748)
[15:04:13] jhass: >> "abc".pred
[15:04:13] eval-in_: jhass => undefined method `pred' for "abc":String (NoMethodError) ... (https://eval.in/260749)
[15:04:20] gr33n7007h: I know there should be
[15:04:29] jhass: wasn't there something?
[15:04:54] gr33n7007h: idk of anything
[15:05:00] epitron: >> entropy.reverse
[15:05:00] eval-in_: epitron => undefined local variable or method `entropy' for main:Object (NameError) ... (https://eval.in/260750)
[15:05:06] eval-in_: RedNifre => 4 (https://eval.in/260751)
[15:07:45] epitron: >> SpaceSpace.each_qbit.map { |q| q.information }.sum
[15:07:46] eval-in_: epitron => uninitialized constant SpaceSpace (NameError) ... (https://eval.in/260754)
[15:07:57] matti: epitron: Hahaha
[15:08:04] matti: epitron: <3 each_qbit
[15:08:08] havenwood: >> "abc".tap { |s| last = s.bytes.last.pred.chr; s.chop! << last }
[15:08:08] eval-in_: havenwood => "abb" (https://eval.in/260758)
[15:08:41] epitron: havenwood: can it be done for qbits? :D
[15:09:22] arup_r: Ahh.. Dunno how to work with OpenOffice word using Ruby... :( I'm in trouble.. Nothing I found on internet too...
[15:09:38] epitron: Lol @ chop
[15:09:53] matti: arup_r: It has API in Python, not sure if anyone did anything with Ruby :(
[15:10:08] arup_r: link please..
[15:10:30] havenwood: epitron: not a lot of chances to chop!, have to manufacture use cases :P
[15:10:39] arup_r: no body did in Ruby,,, even if they do.. didn't share
[15:11:14] epitron: Ruby needs more cooking metaphors
[15:11:26] epitron: String#dice
[15:11:36] epitron: String#julienne
[15:11:58] oddmunds: Array#sample
[15:12:09] epitron: String#puree (alias for sha1)
[15:12:16] jefus: Hash#scramble
[15:12:25] havenwood: >> %w[cookies cake pie].sample
[15:12:26] eval-in_: havenwood => "cake" (https://eval.in/260773)
[15:12:30] havenwood: why i think i will...
[15:12:40] epitron: Good choice, ruby!
[15:12:46] havenwood: mm, scrambled hash
[15:13:19] jefus: hungry. :/
[15:13:25] matti: epitron: No! Cake is a lie.
[15:13:36] havenwood: Pie. Ala. Mode.
[15:14:56] epitron: Mmm... Mode
[15:16:20] havenwood: "?? la mode" made up in the States. no relation to ice cream. weird.
[15:18:03] arup_r: no Ruby -- http://www.openoffice.org/api/ :p
[15:18:27] DefV_: get cracking!
[15:21:15] epitron: Mmm... Made up words
[15:21:22] havenwood: https://github.com/dvandersluis/rubyuno#readme
[15:22:07] epitron: :rockstar:
[15:22:56] DefV_: I was hoping for UNO the game
[15:22:59] DefV_: #disapointed
[15:23:49] havenwood: DefV_: https://github.com/kidrane/UNO-game/blob/master/lib/uno.rb
[15:27:10] epitron: Deck is a good enumerable
[15:28:38] epitron: 3 deck shoe: ([deck]*3).shuffle
[15:28:52] epitron: + .flatten
[15:29:17] havenwood: is it april yet? we should propose a #flat_shuffle
[15:29:52] epitron: And shuffled_cycle
[15:30:24] havenwood: #bicycle to do two cycles
[15:30:45] oddmunds: deck.riffle(other_deck)
[15:31:16] epitron: This is a fun idea to teach my ruby class
[15:32:54] epitron: Deck.52_pickup: creates 52 new global variables with a card in each
[15:33:16] oddmunds: deck.deal(3) #=> [[0,3,6], [1,4,7], [2,5,8]] #(assuming a sorted deck)
[15:33:31] kalleth: rofl, epitron
[15:33:35] kalleth: 52 card pickup in ruby, nice
[15:33:39] epitron: Card class would be good too
[15:33:46] kalleth: can you fudge the GC to spray them over the memory space? ;)
[15:34:12] oddmunds: Card#+(other_card) #=> new_deck
[15:34:26] epitron: 52 random objects are turned into cards
[15:35:01] epitron: That would require a patch
[15:35:12] epitron: But it would totally be worth it
[15:38:08] epitron: I like the idea of cards with succ methods
[15:38:33] epitron: That's a deck!
[15:38:51] gr33n7007h: >> suits = %w[2660 2663 2665 2666].map(&:hex).map{|s|[s].pack('U')}; cards = %w[A 2 3 4 5 6 7 8 9 T J Q K]; cards.product(suits).shuffle.sample(2)
[15:38:53] ak: Hi, I'm trying to deploy casino - http://casino.rbcas.com/ I am running centos 7 with mariadb, ruby 2.0.0 and apache 2.4. When I go to the webpage for the app I see http://i60.tinypic.com/wldhqh.png
[15:38:56] ak: any ideas?
[15:39:30] epitron: gr33n7007h: what happened to the result :(
[15:40:39] havenwood: ak: gem install bundler
[15:40:54] epitron: hand-crafted in Switzerland
[15:41:16] ak: cheers, I thought I had, will check :)
[15:42:33] ak: havenwood: yes, still the same error
[15:43:19] epitron: Good old 3521b9a4
[15:43:48] epitron: If you look in that memory address, there's buried treasure
[15:44:41] ak: actually, error ID is now 18c197f7 although the part above that is still the same
[15:45:24] epitron: Quite a different error
[15:46:10] ak: http://ur1.ca/jjoiz
[15:46:50] jhass: ak: try #passenger
[15:46:58] ak: cheers :)
[15:47:22] epitron: Thanks for stopping by!
[16:08:25] P-NuT: Hi all, does anyone know what the fastest ORM for reading results is for ruby on ARM?
[16:08:45] P-NuT: ...I guess also what is the fastest DB to use with it?
[16:10:58] centrx: P-NuT, Probably Sequel with SQLite
[16:12:18] workmad3: P-NuT: on ARM? bleh, no idea... embedded sqlite is probably the way to go as centrx suggested though
[16:22:31] dstarh: when I do case "foo", "bar" is there some way to know which one matched?
[16:22:55] workmad3: dstarh: if you care, they should probably be different cases :P
[16:23:40] dstarh: workmad3 yea was trying to do soemthing like myobj.send("#{matched}=", val)
[16:24:32] dstarh: for like 5 or 6 cases I just need to call a setter which matches the accessor method
[16:24:58] dstarh: call an accessor method which matches the matched that is
[16:25:07] centrx: dstarh, just use the same variable used in the case statement, set it beforehand if appropriate
[16:25:36] dstarh: centrx doh
[16:37:32] ericwood: I'm writing some tests and I need to stub out a class constant...any suggestions?
[16:37:40] ericwood: apparently Mocha doesn't really work with constants
[16:41:21] ericwood: damn. It's impossible. I knew it.
[16:45:35] felltir: ericwood: in which framework? Rspec has stub_const
[16:45:51] ericwood: heh a coworker jsut informed me we have a custom test helper that does it
[16:54:02] epitron: https://github.com/epitron/cards/blob/master/cards.rb
[16:56:04] oddmunds: epitron: ...but that is a Deck
[16:56:14] epitron: Card.all is a deck
[16:57:15] epitron: hah, i could use divmod to get the card's value!
[16:57:41] epitron: value, suit = pos.divmod(4)
[16:58:35] oddmunds: i want to make a Card and Deck project now
[16:58:39] ericwood: http://docs.spring.io/spring/docs/2.5.x/api/org/springframework/aop/config/SimpleBeanFactoryAwareAspectInstanceFactory.html
[16:58:43] oddmunds: implementing it MY WAY
[16:59:03] ericwood: sometimes I wonder if java is a parody of itself
[16:59:10] epitron: oddmunds: GO GO GO
[16:59:27] centrx: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
[16:59:30] workmad3: ericwood: each java version is a parody of the previous version
[16:59:49] ericwood: it's literally just gibberish
[17:00:04] epitron: centrx: lolol
[17:00:08] epitron: centrx: i love the video too
[17:00:18] centrx: there's a video!?
[17:00:22] epitron: where he's using Eclipse to create all those implementations and stuff
[17:00:37] epitron: he starts with normal fizzbuzz, then refactors it into oblivion
[17:01:11] skj3gg: gotta bookmark that, wow!
[17:01:30] workmad3: ericwood: http://neverworkintheory.org/2014/01/29/stefik-siebert-syntax.html specifically the point 'C-style syntax, as used in Java and Perl, is just as hard for novices to learn as a randomly-designed syntax'
[17:01:31] epitron: damn, can't find it
[17:01:45] epitron: the guy was great too -- he had this cockney accent that made him sound like Bricktop from Snatch
[17:01:55] ericwood: workmad3: omg yes I remember that
[17:02:35] workmad3: ericwood: so you can sort of say that Java is empirically demonstrated to be no better than gibberish, and be on fairly firm footing :)
[17:03:20] workmad3: criticism also applies to C, Perl, C++, and probably a bunch of others :)
[17:03:46] ericwood: everything sucks
[17:03:47] epitron: lol, randomly designed syntax
[17:03:57] ericwood: iirc perl performed the worst
[17:04:34] max96at: the fact that to take a lambda as a function argument you need a interface with a single function first is kinda weird too
[17:04:53] GaryOak_: epitron: a language that changes syntax at compile time
[17:05:02] epitron: Syntax.succ
[17:05:08] epitron: Syntax.sample
[17:05:17] epitron: Syntax.all.shuffle
[17:11:43] shevy: now that is better
[17:11:45] shevy: let's huge one another!
[17:12:00] GaryOak_: I'm hugeing you right now
[17:13:54] shevy: I wanted to type hug
[17:14:20] workmad3: ACTION is worried as to what a 'huge' may be
[17:15:04] kiddo__: Hi. How can I get the number of objects created under a namespace currently in memory?
[17:15:06] ericwood: plz don't huge me
[17:15:14] centrx: kiddo__, Check out ObjectSpace
[17:23:27] epitron: ACTION huges shevy
[17:23:35] shevy: you guys just riding on the typo...
[17:24:13] shevy: kiddo__ you probably have to select the objects in the namespace too
[17:24:26] epitron: verbing huge is the best thing that's happened today
[17:24:31] epitron: you totally huged that word
[17:24:40] epitron: big huges for that
[17:24:44] shevy: you can have things like ObjectSpace.memsize_of() ObjectSpace.count_objects and ObjectSpace.each_object
[17:24:55] shevy: you are still on it, it was a TYPO :(
[17:25:26] epitron: the guy who discovered penicillin made a typo too
[17:25:36] epitron: HE HUGED IT AS WELL
[17:26:14] shevy: he made a typo?
[17:26:32] workmad3: epitron: I assume you're referring to the glory-hound flemming, not the people who made it useful, chains and florey?
[17:27:08] epitron: some of my history is from TV ^_^
[17:27:20] epitron: 10 GREATEST HUGES IN HISTORY
[17:27:38] epitron: or maybe it was from an email forward
[17:28:48] workmad3: epitron: fleming 'discovered' penicillin, made a note of it in a lab book as a vaguely interesting observation and basically wrote it off as pretty much useless... chains and florey did all the hard work of identifying the anti-biotic aspects of the mold, extracting it, concentrating it and turning it into something that could be used in medicine in the middle of WW2
[17:29:00] workmad3: epitron: and fleming gets all the credit as the 'discoverer of penicillin'
[17:29:13] centrx: what a huge douche
[17:29:22] workmad3: centrx: yeah, almost as bad as edison :)
[17:29:24] GaryOak_: what a hug douche
[17:29:34] shevy: don't huge this douche
[17:29:57] epitron: total douche hugger
[17:30:04] GaryOak_: ian fleming also wrote the james bond books, little known fact
[17:30:34] workmad3: GaryOak_: different fleming :P
[17:32:17] workmad3: GaryOak_: alex fleming is the 'discoverer of penicillin'
[17:32:33] GaryOak_: oh ian's brother
[17:34:47] oddmunds: Barbara Broccoli, american filmmaker involved in the James Bond series, is the 'discoverer of Brocolli'
[17:34:57] oddmunds: lil' known fact
[17:36:58] GreatSUN: Searching for some trainer to provide ruby course for beginner and expert in baden W??rttemberg, Germany
[17:37:40] epitron: oddmunds: Albert R. Broccoli married into the Broccoli fortune
[17:38:06] epitron: it's a little known fact: if a poor guy marries a rich woman, he has to take HER last name
[17:38:13] GreatSUN: Best of he is known in the community and wrote some article(s)
[17:39:40] workmad3: it's a little known fact: most little known facts are BS
[17:40:23] bricker: workmad3: YOU are a little known fact.
[17:40:43] bricker: wait we're talking about Barbara Broccolo?
[17:40:45] epitron: it's a little known fact: your mom is not a whore
[17:41:20] shevy: pics from his mom
[17:42:07] GaryOak_: This kind of great conversation would never happen on #python, I <3 ruby
[17:43:08] epitron: "strings /dev/mem" is fun
[17:46:42] b-dean: does anyone know how long drb servers will run? do they have some sort of timeout where they the tcp connections die or something? I'm getting some "connection reset by peer" stuff with drb and am unsure where to look to figure out what's going on
[17:46:55] pipework: As long as the process is up, I believe.
[17:47:10] pipework: Unless you're doing something interesting that might prevent that.
[17:47:16] b-dean: that's what I thought too. but I can't figure out why the connection would get reset then
[17:47:51] epitron: b-dean: that's probably a network issue
[17:48:04] pipework: Got code you can share?
[17:48:09] workmad3: b-dean: are you going through some form of proxy to reach the drb server?
[17:48:14] epitron: routers sometimes drop idle TCP connections
[17:48:22] epitron: especially NAT routers
[17:48:36] epitron: (they have to track all the connections in a big table, and often that table fills up)
[17:48:43] workmad3: ^^ that's the sort of thing I was thinking of, but was thinking more proxies rather than routers
[17:48:50] epitron: proxies too
[17:48:57] pipework: Let the sockets hit the floor, let the sockets hit the floor, let the sockets hit the floooooooor.
[17:49:13] ericwood: 1) nothing wrong with me
[17:49:17] ericwood: 2) nothing wrong with me
[17:49:20] b-dean: well the client and server are on different networks
[17:49:22] ericwood: I'll spare you the rest
[17:49:51] epitron: 3) jk i am 100% made of wrong lolol
[17:50:06] b-dean: like 10.x vs some 172.x, but I've never noticed any problem before. Maybe the IT department changed something :\
[17:50:15] pipework: 1) Something's got to ACCEPT
[17:50:18] pipework: 2) Something's got to ACCEPT
[17:50:22] pipework: 31) Something's got to ACCEPT
[17:50:32] ericwood: you skipped a few numbers there
[17:50:45] pipework: Nope, see [09:49:17] <ericwood> 1) nothing wrong with me
[17:51:20] pipework: I can confirm, in fact, there is nothing wrong with me. So it's obviously, you, not me. I hope we can still be friends though?
[17:52:20] epitron: pipework: did you run a level 1 diagnostic?
[17:53:35] pipework: epitron: No, level 31.
[18:13:39] dgarstang: Does ruby have a simple way to search a hash for a given key?
[18:14:08] workmad3: dgarstang: you mean like 'hsh.has_key?(some_key)'
[18:14:23] dgarstang: workmad3: yes but I don't know where in the hash the key is
[18:14:35] dgarstang: workmad3: i just want to return true/false if it's anywhere in the hash
[18:14:37] centrx: sounds like it's not hash
[18:14:47] dgarstang: centrx: que?
[18:15:03] centrx: dgarstang, Hashes are organized by key, the address of the key is the key
[18:15:06] workmad3: dgarstang: err... 'hsh.has_key?(some_key)' returns true/false depending on if the hash has that value...
[18:15:20] dgarstang: sigh. hashes can be nested, no?
[18:16:07] centrx: so is it a hash of hashes, a tree of hashes, an array of hashes, a hash of arrays of hashes...?
[18:16:18] dgarstang: centrx: yes, isn't that still a hash?
[18:16:32] workmad3: dgarstang: it's lots of hashes
[18:16:36] workmad3: dgarstang: not a single hash
[18:16:42] dgarstang: workmad3: does it matter?
[18:17:19] dgarstang: let me rephase. is there a ruby function to deep search a hash of unknown depth and return if a key exists or not?
[18:17:38] papercode: do other languages support that?
[18:17:41] dgarstang: seems like a pretty obvious piece of functionality
[18:17:58] whatasunnyday: Do people generally check in the coverage folder (generated by simplecov into version control)?
[18:18:02] papercode: you would have to check at every layer if the value for a key was a hash and recurse
[18:18:20] dgarstang: papercode: the structure is indeterminate
[18:18:34] pipework: dgarstang: Ruby doesn't provide a method in core or stdlib, but deep fetching is perfectly possible.
[18:19:04] papercode: like i said, at every value you'd need to check if the value was a hash, then dive into that layer and repeat
[18:19:05] workmad3: heh, sorry, my 'no' was 'not in stdlib, feel free to write it yourself'
[18:19:07] centrx: it's pretty straightforward with recursion
[18:19:21] dgarstang: centrx: ruby makes my eyes bleed. was hoping for a one liner
[18:19:22] pipework: centrx: You don't even need to use recursion.
[18:19:29] pipework: Just a loop and fetch.
[18:19:47] pipework: Well, #key? too
[18:19:50] centrx: it could be any depth
[18:20:00] dgarstang: pipework: I haven't learned to read squiggle, so my ruby isn't so good
[18:20:01] papercode: .to_json.match(/..../)
[18:20:16] pipework: centrx: You still don't need recursion, just a loop.
[18:20:16] havenwood: dgarstang: maybe you're thinking Perl
[18:20:24] dgarstang: havenwood: ruby, perl, same thing
[18:20:29] pipework: dgarstang: I don't know what that means.
[18:20:43] centrx: dgarstang, Hashie has "DeepFetch" and "DeepFind", might want to use that
[18:20:45] dgarstang: pipework: every time I read ruby code, I have to translate | and {} in my head.
[18:20:50] pipework: Do you just want to check anywhere in the hash if a key exists?
[18:20:55] dgarstang: pipework: yes
[18:20:58] centrx: dgarstang, https://github.com/intridea/hashie
[18:20:59] pipework: Or do you have a 'path' to the key?
[18:21:19] dgarstang: pipework: i have a partial path. at a certain point below that, the structure may change
[18:21:55] dgarstang: centrx: thanks, i'll take a look at that'
[18:22:27] pipework: dgarstang: Then you need deep_fetch, a gem, and the other part is taking the remaining hash and looping over it, detecting if there's a key you're looking for, and if not then you check if the #values are hashes, if they are, then you can loop again.
[18:23:12] pipework: If you use recursion, mind that ruby isn't optimized for tail recursion by default, and I believe it's not that good at any recursion optimization, at least with cruby.
[18:24:37] dgarstang: ugh. "undefined method `deep_find'"
[18:24:44] pipework: dgarstang: Gems bruh
[18:24:55] dgarstang: pipework: i installed it, and I have 'require hashie'
[18:25:15] pipework: dgarstang: You might want to use a gem that implements that method then.
[18:25:51] dgarstang: pipework: sorry? i installed the gem, i have "require 'hashie'". i have a hash, and I'm running h.deep_find('key')
[18:26:20] pipework: Sorry, meeting.
[18:26:31] workmad3: https://github.com/intridea/hashie#deepfetch
[18:26:37] workmad3: (reading docs helps)
[18:27:02] dgarstang: workmad3: i did
[18:27:27] workmad3: dgarstang: did you do that bit where you extend the hash with DeepFetch?
[18:27:41] workmad3: dgarstang: or DeepFind?
[18:27:53] dgarstang: workmad3: does that mean the hash gets modified?
[18:28:53] workmad3: dgarstang: hashie doesn't monkey-patch the core Hash class... you need to pull the bits you need into the hashes you want features on... such as extending a specific hash with deep_find, or subclassing Hash with coercion features
[18:29:01] workmad3: as the docs show
[18:29:20] dgarstang: workmad3: does that mean the hash gets modified?
[18:29:30] workmad3: dgarstang: depends what you mean by 'gets modified'
[18:29:45] dgarstang: workmad3: this is ohai in chef. not sure if that's kosher
[18:36:16] workmad3: dgarstang: hmm... not sure on that front, I'm afraid
[18:36:27] workmad3: dgarstang: never needed to play with deep-searching hashes in chef
[18:37:15] dgarstang: workmad3: just trying to work out if instance is in a vpc. if it is, ohai has a vpc_id key nested in there
[19:21:15] wasamasa: what the hell was that
[19:23:04] centrx: This bar is pretty dirty
[19:23:30] havenwood: savon le chat
[19:23:43] havenwood: http://ekladata.com/1dN3wpfiQtD-u2Ze2DIBRqNGZYo.jpg
[19:57:23] AlHafoudh: which project skeleton generator do you use?
[19:58:50] astroduck: Hi! gem on my Mac is working really slowly, its lookup time for gems is like 10mins
[19:59:22] astroduck: Also, it wont install dependencies by itself, any fix for that?
[19:59:54] astroduck: Gem version is 2.0.14
[20:03:40] havenwood: astroduck: For starters update to the latest RubyGems: gem update --system
[20:04:13] havenwood: astroduck: Are you using system Ruby?
[20:04:36] astroduck: havenwood: yes, ruby --version gives me 2.0.0p481
[20:06:22] atmosx: astroduck: that's an awful choice
[20:06:28] atmosx: astroduck use rvm
[20:06:35] atmosx: astroduck: or rbenv or anything\
[20:07:43] astroduck: atmosx: The ruby version? Umm, ok so how do I install rvm? sorry this is my first time with ruby, I've only played around with jekyll
[20:08:01] weaksauce: gist your gemfile
[20:08:07] havenwood: astroduck: Are you using Homebrew? You could use the brew Ruby.
[20:08:30] havenwood: astroduck: Or RVM or ruby-install/chruby are alternative options.
[20:08:42] atmosx: astroduck: you have xcode and llvm-gcc in yoru system already?
[20:09:05] havenwood: astroduck: 2.2.0 for the win!
[20:09:31] weaksauce: astroduck ruby-install + chruby is better than rvm imo
[20:09:57] havenwood: ruby-install and chruby! \o/
[20:09:58] astroduck: atmosx: Yes I have both of those. ... You guys are confusing me now
[20:10:11] atmosx: havenwood: and rvm and rbenv
[20:10:13] havenwood: You can use chruby with the brew ruby too.
[20:10:14] atmosx: all together!
[20:10:27] havenwood: atmosx: and RVM ships with MRVM so you can use chruby.
[20:10:41] havenwood: in case you didn't feel like you had enough options
[20:10:54] atmosx: nah I'm fine with rvm I don't bother with other alts
[20:11:07] atmosx: I took this coursera course on algorithms
[20:11:36] atmosx: I understood the theory after spending several hours studying back and forth, but I'm unable to produce a valid ruby merge-sort algorithm as of today. Recursive that is.
[20:11:45] havenwood: https://github.com/wayneeseguin/rvm/blob/master/docs/alt.md
[20:12:09] astroduck: so, `brew install rvm`?
[20:12:32] atmosx: astroduck: no, you have brew installed in your system?
[20:12:39] astroduck: atmosx: yes
[20:12:43] havenwood: astroduck: No, you could `brew install ruby` or `brew install ruby-install chruby` but RVM has its own installer.
[20:12:48] atmosx: astroduck: \curl -sSL https://get.rvm.io | bash -s stable
[20:12:58] havenwood: astroduck: If you don't need more than one Ruby, just: brew install ruby
[20:13:24] astroduck: havenwood: it'll give me latest gem as well?
[20:13:53] havenwood: astroduck: A pretty new one. But to update RubyGems on whatever Ruby, just: gem update --system
[20:15:01] astroduck: havenwood: ok cool, I'll install rvm later.
[20:15:08] astroduck: Thansk guys :)
[20:15:40] havenwood: astroduck: You can go back and forth between brew and system Ruby by linking and unlinking the brew one. E.g.: brew link ruby
[20:15:47] havenwood: brew unlink ruby
[20:16:17] havenwood: astroduck: If you want to use gem executables (you probably do) then just add this to your dotfiles: export PATH=$(brew --prefix ruby)/bin:$PATH
[20:17:29] havenwood: Now that they've bottled the Ruby package you can pour it without compiling. (They've really run wild with the metaphors.)
[20:18:05] havenwood: Makes the brew Ruby quick to install. :)
[20:25:50] mwlang: is it possible to generate a Gemfile from a Gemfile.lock file? basically reverse the usual generation?
[20:27:45] ericwood: oof sounds like you got yourself into some trouble
[20:28:29] apeiros: mwlang: to a degree. you won't know what versions were specified.
[20:29:03] apeiros: also anything code is lost. not sure about stuff like git: and path:
[20:29:15] mwlang: apeiros: that???s ok, I???ve just about got it recreated by inspecting the lock file.
[20:29:18] ericwood: also namespaces for different environments most likely
[20:29:24] astroduck: havenwood: I did `brew install ruby` but `ruby --version` still gives me 2.0.0, relinking doesn't work either
[20:29:28] mwlang: it was a slip of the finger selecting files to include in first git commit.
[20:30:00] havenwood: astroduck: Sounds like your PATH isn't setup correctly for Homebrew. It'll probably complain if you check: brew doctor
[20:30:09] apeiros: "I accidentally the world! Is that bad?"
[20:30:49] havenwood: astroduck: It'll tell you the PATH order is wrong. You can fix it by editing your `/etc/paths` file.
[20:31:24] havenwood: astroduck: Putting `/usr/local/bin` above `/usr/bin` will fix this issue.
[20:31:41] havenwood: (In `/etc/paths`.)
[20:32:10] mwlang: ???loofah??? ?? what the heck is ???loofah???? (encountered reading Gemfile.lock)
[20:32:18] mwlang: ACTION goes looking for loofah
[20:32:52] Hijiri: shower sponge?
[20:33:31] astroduck: havenwood: /usr/local/bin is above /usr/bin in my zshrc
[20:33:52] havenwood: astroduck: printenv PATH
[20:34:05] havenwood: astroduck: ^ what does that say?
[20:34:09] mwlang: well, I???ll have to say it???s aptly named???its an HTML/XML/XHTML scrubber/sanitizer built on top of Nokogiri
[20:34:49] astroduck: havenwood: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin ... also brew doctor only says that brew is outdated, and some unexpected header files
[20:35:09] havenwood: astroduck: brew update
[20:35:20] havenwood: astroduck: then: brew upgrade
[20:35:42] havenwood: astroduck: then: ruby -v
[20:36:52] astroduck: havenwood: ok, it might take some time, slow internet :/
[20:37:51] astroduck: havenwood: I have to update brew once every 24 hours? That's really weird
[20:38:09] havenwood: astroduck: Live in the "now", man...
[20:39:38] perturbation: you have to update brew every 24 hours or what? the bus will explode? ;)
[20:39:55] astroduck: perturbation: ruby will, I suppose
[20:40:06] mwlang: ???.we need ???brew drink???
[20:41:42] pontiki: first you brew, then you drink
[20:42:44] shevy: then you get rid of your clothes
[20:42:56] shevy: go out at moonlight
[20:43:00] shevy: and DANCE and PARTY more!
[20:43:31] astroduck: havenwood: I'll be damned, it worked! Brew update did it. I am most confused now
[20:43:53] astroduck: The world of brew is very complex and rather tasty
[20:44:04] mwlang: pontiki: good point???.we need ???drink brew???
[20:44:42] havenwood: mwlang: require 'bundler'; puts "source 'https://rubygems.org'\n\n#{Bundler::LockfileParser.new(Bundler.read_file('Gemfile.lock')).dependencies.map(&:name).map { |gem| "gem '#{gem}'" }.join("\n")}"
[20:45:11] mwlang: and to ensure it keeps the glass full??????brew drink brew???
[20:45:46] mwlang: havenwood: ah. nice. I???m saving that. Not the first time I accidentally lost the Gemfile.
[20:46:12] havenwood: mwlang: ^ This is just a standard source and the Gemfile gem names. You could piece together the other parts if you wanted, I suppose.
[20:46:33] havenwood: mwlang: Stop "losing" Gemfiles! :P
[20:48:35] mwlang: havenwood: I???ll have to stop doing ???rm Gemfile; git checkout .??? before first commit. ;-)
[20:49:25] astroduck: mwlang: whats wrong with your ? key, its like it has a mind of its own
[20:50:50] mwlang: astroduck: no idea.
[21:05:13] afex: hi all. is it possible for one ruby process to host 2 rack applications on separate ports? for example, an application server on one port, and a metrics server on another.
[21:09:23] ddv: afex, sure why not
[21:12:59] afex: ddv: do i need to use a specific web server to accomplish this? (puma, unicorn, etc) or is this something handled by my application?
[21:13:26] afex: i'm not sure exactly how to declare the port bindings for my separate apps
[21:13:45] c355E3B: afex, you may want to look at passenger
[21:13:53] c355E3B: if your trying to run a bunch of apps on one server
[21:13:55] ddv: afex, works out the box with passenger
[21:14:28] ddv: afex, if you want to keep using puma/unicorn, you need to proxy those requests, with nginx, varnish etc
[21:14:29] c355E3B: they ship a nice PPA for nginx and apache
[21:15:15] ddv: afex, (if you want to use the same port)
[21:15:23] scottstamp: Hmm, am I misunderstanding something with routes? This is one of the lines in my initializer, get 'explore(/:sort(/:tags))' => 'explore#index', I'd expect /explore/popular to map to explore#index{params[:sort]=>"popular"}, but for some reason it's setting :tag instead.
[21:15:29] deepy: If you've not decided between nginx or apache, pick nginx. it's much much nicer to work with
[21:15:51] scottstamp: nginx w/ passenger <3 my dream stack
[21:16:13] wallerdev: scottstamp: probably want #rubyonrails
[21:16:14] afex: ddv, c355E3B: in my case it is a primary app, where each request is producing in-memory metrics. i'd like another app to listen on a different port and expose those metrics for my monitoring tolos
[21:16:35] ddv: afex, ok
[21:16:39] scottstamp: Oh, thanks wallerdev, I was trying #rails and thought it was odd nobody was there.
[21:16:43] mwlang: my only complaint with nginx w/ passenger is having to manually install the system startup script into /etc/init.d
[21:17:02] ddv: mwlang, depends on distro
[21:17:12] mwlang: so different Linux systems means finding the right init script.
[21:17:12] wallerdev: its empty cuz rails is dead
[21:17:14] ddv: mwlang, systemd is very easy
[21:17:15] wallerdev: nodejs is the future
[21:17:38] c355E3B: afex, have you concidered using something like mtqq or amqp to publish this data
[21:17:46] c355E3B: then read it that way
[21:18:02] c355E3B: Or if both apps are rack apps
[21:18:16] c355E3B: you can mount both of them inside of one config.ru file
[21:18:51] c355E3B: then have the app publishing the metrics gain direct access to them
[21:19:11] afex: so config.ru settings can bind different rack apps to different ports?
[21:19:54] mwlang: so I have a deeply nested hash structure???occassionally the whole nested structure isn???t there. Rather than an error, what???s a simple way to return nil?
[21:20:22] mwlang: this seems a little hacky: my_hash[:a][:b][:c] rescue nil
[21:21:09] c355E3B: afex, yes in some cases
[21:21:19] c355E3B: I was sugesting using `Rack::Cascade` to do this
[21:21:20] waxjar: mwlang: my_hash.fetch(:a).fetch(:b).fetch(:c), throws a KeyError when a key isn't there
[21:22:14] mwlang: hmmm???I think wrapping that in a begin rescue block would be smart.
[21:22:25] wallerdev: .fetch(:a, {}) would work
[21:23:37] afex: c355E3B: ok so it seems that as long as i write the metrics server to the rack spec, users could choose to host it as they'd like. (same port with cascade, separate port with passenger). does that sound accurate?
[21:24:21] mwlang: wallerdev: actualy, I think that might be the cleanest, then no rescue block needed???although rescue block gives me opportunity to write to logs.
[21:25:10] wallerdev: kinda ugly still haha
[21:25:20] wallerdev: id change the structure if i could but no idea on your data
[21:26:04] waxjar: you can also set a default_proc which returns a hash with a default_proc that returns a hash with a... etc
[21:27:06] waxjar: >> Hash.new { |h,k| h[k] = h.dup.clear }[:a][:b][:c]
[21:27:07] eval-in_: waxjar => {} (https://eval.in/261555)
[21:29:01] apeiros_: why h.dup.clear instead of Hash.new(&h.default_proc)?
[21:30:40] waxjar: no particular reason, that's better actually
[21:32:56] checkit: Hey guys... I'm looking for a good vagrant box for rails development.
[21:36:11] skinux: Since I've finished CodeAcademy's Ruby course, are there any other free courses or tutorials for learning more advanced programming?
[21:37:25] ericwood: just start writing some stuff
[21:37:29] ericwood: the pickaxe book is really good
[21:42:28] GaryOak_: checkit: https://atlas.hashicorp.com/boxes/search?utf8=%E2%9C%93&sort=&provider=&q=rails
[21:42:36] GaryOak_: checkit: not sure if this will help
[21:43:51] checkit: GaryOak_: Thanks bud
[22:09:21] odigity: The docs for Kernel#load says if the filename isn't an absolute path, it checks the paths in $:. However, you can load a file in the same dir with load('foo.rb') or load('./foo.rb'). So, it implicitly also checks the CWD, even though it doesn't show up in $: or in the docs?
[22:17:44] eam: odigity: looks that way, my guess is docs are wrong
[22:17:56] odigity: that's so weird, for such an old and fundamental method
[22:18:07] eam: load/require should behave as they do
[22:18:44] eam: I suspect it's just incomplete, it should be: "if it's an absolute path, that's that. Else $:, else relative path"
[22:19:25] odigity: is it easy to open an issue on ruby docs? :)
[22:19:33] eam: should be yeah
[22:19:48] eam: we just fixed a sorta related bug around rb loading last week
[22:20:32] eam: there's a heuristic ruby uses to find itself and it'll incorrectly find a directory if the name is "ruby"
[22:22:30] odigity: I didn't know ruby was so spiritual.
[22:22:51] c355E3B: well a rose by any other name
[22:27:00] GaryOak_: odigity: lololol
[22:28:21] eam: I also noticed the default path for the ruby loader, if PATH is unset, includes "."
[22:28:35] odigity: got some annoying warnings from rails about some changes bundler made to the binstubs -- and I'm not even sure what those are for or if I should be using them -- which has prompted me to take a deep tour through ruby code loading, rubygems, bundler, up to the rails binstubs, so I can really understand what it's all about
[22:28:38] eam: haven't fully reasoned out whether that's a potential attack vector, kinda suspicious
[22:29:54] odigity: I don't assume anything on my system represents default ruby because of distro packaging. I'd have to build from source to get a value I trust to represent ruby's built-in default load path
[22:33:23] eam: odigity: well, as I mentioned it may calculate those values on the fly based on the interpreter path
[22:33:31] eam: relocatable