« Back to channel list

#ruby - 02 August 2014

« Back 1 day Forward 1 day »
[00:15:38] benzrf: w09x: you could sort it and then take part
[00:15:41] benzrf: sounds inefficient tho
[00:22:39] w09x: benzrf: thanks, i went with finding the percentile then just taking anything above that
[00:22:40] w09x: seemed to work
[00:23:35] benzrf: w09x: sounds good
[01:30:03] whomp: what's the function to split a 2d array into boxes?
[01:30:44] whomp: i need to win a code golf thing with my co workers
[01:31:07] whomp: and the challenge is to validate a 2d array as a valid sudoku board
[01:37:54] gizmore: So the best IM lib in ruby is https://github.com/yong/purple_ruby/blob/master/ext/purple_ruby.c ?
[03:54:07] Hanmac: xDDDD apeiros & shevy https://github.com/ruby/ruby/commit/0a0160d6b659f6131a525fe1579e7c463d4c197e <<< Object#itself xD
[04:08:13] eam: in what cases is #itself useful?
[04:20:29] gizmore: i need help in compiling a C extension wrapper for libpurple
[04:20:54] gizmore: i managed to succed in "make clean && make install" it builds an .so
[04:22:00] gizmore: but there is ERROR: rubycode require "" file_not_found: rubypurple_ext
[04:22:12] iliketurtles: if I mix in a module with N number of private methods into another class, is it possible to programatically invoke all of these mixed-in private methods in that class in some sort of enumerator?
[04:22:20] gizmore: i have built rubypurple_ext.so but require does not find it?
[04:22:41] gizmore: iliketurtles: no
[04:22:58] iliketurtles: gizmore: any idea how to accomplish something similar
[04:23:08] gizmore: iliketurtles: maybe you would like to use some subscribe/publish method
[04:24:42] gizmore: can i load gizmore.so binarylib with require "gizmore" ? Oo
[04:24:52] Hanmac: eam for group_by for sample
[04:25:33] gizmore: Class.relation.each do |item|
[04:25:39] eam: Hanmac: I'm dense, how is it used there?
[04:25:58] gizmore: item.publish('myproject/ohnoigotouched')
[04:26:11] Hanmac: gizmore: so did you make the libpurple wrapper yourself? require does not search in current path
[04:26:41] gizmore: Hanmac: i have forked code from 2009, patched a .c file and try to compile it (i have 400kb .so \o/)
[04:26:57] Hanmac: eam enum.group_by(&:itself) might be better than group_by {|n| n}
[04:27:31] Hanmac: gizmore: hm for testing did you try require "./rubypurple_ext"
[04:27:34] gizmore: Hanmac: he also wants to execute a method / event on all then, i think
[04:27:41] eam: Hanmac: ooooh
[04:28:01] gizmore: eam: you can call parent methods with "super" in your methods
[04:28:29] fly2web: numbers.inject(0) { |sum, number | sum + number } <?????? what is ???0????
[04:28:34] gizmore: if you really need to chain something, you probably need something like publish/subscribe or a simple array or something
[04:28:55] gizmore: * this should have went to iliketurtles -.-
[04:29:19] iliketurtles: gizmore: not really chain, just i want to ensure all methods in a module can be invoked in a single call :\
[04:29:20] gizmore: btw i made the best irc bot ever in ruby since january :)
[04:29:21] eam: fly2web: the starting sum
[04:29:37] fly2web: oh thanks eam
[04:29:55] gizmore: iliketurtles: yeah, i think you need to push the methods on an array, and call them all for an object
[04:30:05] gizmore: iliketurtles: if you like i can tutor you a bit in query
[04:30:12] gizmore: or in #ruby101
[04:30:54] mallu: hi, I have two days.. 2014-08-01T04:05:12.000Z and 2014-08-02T04:21:52.000Z How do I check to see if one is older than the other?
[04:31:44] fly2web: i m reading rubymonk twice times.
[04:32:02] mallu: I want to check to see if the first days is older than 2 days
[04:32:19] mallu: is it possible without splitting?
[04:32:43] gizmore: Hanmac: i did this: make install and it copied the .so :P
[04:32:55] gizmore: as root.... i hope it??s not malware!
[04:32:57] mallu: the dates were created via Time.now.utc.strftime("%Y-%m-%dT%I:%M:%S.000Z")
[04:33:19] mallu: can someone please help
[04:33:40] gizmore: mallu: first+2.days <= second
[04:34:01] mallu: ok let me try that
[04:34:04] gizmore: mallu: imagine it as two "timelines" / "lineals"
[04:34:44] gizmore: you surely wanna check if something happens with A when patched with 2.days :)
[04:35:26] gizmore: and you wanna check if its something with B (can be a point) ,,, then in your head move the lineal + 2 over point B
[04:36:51] Hanmac: gizmore: beware, #days is a rails method and does not work everywhere
[04:37:32] gizmore: class Number; def days(d); d*14440; end
[04:38:09] gizmore: no need to change good code for the kernel slim
[04:39:09] mallu: [143] pry(main)> start_time = "2014-08-01T04:05:12.000Z" => "2014-08-01T04:05:12.000Z" [144] pry(main)> date_now = Time.now.utc.strftime("%Y-%m-%dT%I:%M:%S.000Z") => "2014-08-02T04:36:57.000Z" [145] pry(main)> start_time+2.days <= date_now NoMethodError: undefined method `days' for 2:Fixnum from (pry):173:in `__pry__
[04:39:30] gizmore: >> 2*60*60*24
[04:39:31] eval-in: gizmore => 172800 (https://eval.in/174731)
[04:39:47] gizmore: mallu: instead of 2.days use 172800
[04:39:50] mallu: gizmore: please take a look at http://pastie.org/9438377
[04:40:51] jeaye: Anyone know if http://tryruby.org/levels/1/challenges/0 is written entirely in ruby?
[04:40:52] gizmore: or write class Number; def days(d); d*60*60*24; end; end somewhere above to monkeypath
[04:41:39] Hanmac: mallu: you do it wrong, you need to convert both your time into Time objects not both into strings
[04:41:47] mallu: gizmore: my start_date is a string correct
[04:42:04] gizmore: your dates should be Time or DateTime objects
[04:42:07] mallu: ok.. so start_date.time?
[04:42:30] gizmore: hmm, i am on rails, but i think it uses normal Time and Datetime too
[04:43:02] gizmore: >> (Time.now + 20 ) > (Time.now + 10)
[04:43:02] eval-in: gizmore => true (https://eval.in/174732)
[04:44:56] Hanmac: >> require "date"; start_time = DateTime.parse "2014-08-01T04:05:12.000Z"; start_time + 2 <= DateTime.now
[04:44:56] eval-in: Hanmac => false (https://eval.in/174734)
[04:45:23] gizmore: Hanmac: yep, except replace time.now with B
[04:46:06] Hanmac: mallu look how i would do that
[04:46:34] mallu: geat.. exactly what I needed
[04:46:42] gizmore: Hanmac: please take a look at my ruby monkeypatches (some rubycore, some activerecord) .... https://github.com/gizmore/ricer2/tree/master/config/initializers/ricer - i would love some general coding style feedback
[04:47:07] mallu: one quick question.. how to you convert DateTime to UTC?
[04:48:01] gizmore: UTC is the timezone at 0 all the time, no?
[04:48:20] gizmore: >> TimeZone.set('UTC')
[04:48:20] eval-in: gizmore => uninitialized constant TimeZone (NameError) ... (https://eval.in/174735)
[04:48:45] gizmore: mallu: probably setting the timezone to utc before using methods that have localization
[04:49:32] mallu: got it.. DateTime.now.new_offset(0)
[04:49:45] gizmore: what does that do? Oo
[04:49:55] gizmore: does it shift time?
[04:50:05] mallu: convert current time to utc
[04:50:32] iliketurtles: gizmore: went ahead and just added a constant to the module containing the method names I want to call, since there are only a few for now
[04:50:52] iliketurtles: then I can call them programatically via METHODS.each { |m| self.send(m, token) }
[04:50:53] gizmore: mallu: i would expect if i do Time.now("sometz") == Time.now("othertz") it is the same value ... just the "display" is different
[04:51:07] iliketurtles: wish there was a way to generate a list of method names programatically in a method :P
[04:51:18] gizmore: mallu: maybe you can also make it remember which timezone entered it? (no idea)
[04:51:42] mallu: i think DateTime.now.new_offset(0) will work for me
[04:51:45] gizmore: mallu: but the "values" should be the same... like 4:00GMT+1 is the same as 3:00GMT+2
[04:52:02] gizmore: maybe it now show 3:00UTC
[04:52:24] gizmore: because the time/date knows "aha we want utc representation" (just guessing)
[04:53:12] gizmore: btw, rfc giz003: PlanckSeconds since last_big_bang (the new unix timestamp)
[04:54:10] gizmore: iliketurtles: self.class.instance_methods.sort
[04:55:13] iliketurtles: gizmore: that doesn't seem to work for a module...
[04:56:09] iliketurtles: i dont see any of my mixed in methods if i look at the class that mixes in the module that defines the methods im interested in either
[04:58:14] gizmore: iliketurtles: try self.instance_methods inside a module
[04:59:00] iliketurtles: i get an empty array gizmore
[04:59:16] iliketurtles: oh, i should mention they're private methods
[04:59:26] gizmore: should not matter
[04:59:42] gizmore: the maybe your module does not define any methods
[05:00:07] iliketurtles: it does. two.
[05:00:26] iliketurtles: even if i invoke self.private_instance_methods i get an empty array
[05:07:20] fly2web: modudle can???t initiated? but class can intiated?
[05:07:53] iliketurtles: i think you mean instantiated
[05:08:25] iliketurtles: but in fact, if you require a module in a class, you can call module.private_instance_methods and you get an array. you can't call it in the self context of the module though. weird
[05:08:32] iliketurtles: or maybe pry is being janky
[05:09:07] fly2web: oh yes instantiated.
[05:09:37] fly2web: iliketurtles:
[05:10:17] fly2web: iliketurtles: are you skilled for programming?
[05:10:54] iliketurtles: lol, i suppose? fly2web
[05:12:19] iliketurtles: i'm not the best w/ ruby
[05:12:51] fly2web: then i want see content of my aiside man???s internet. then i can see it by wireless?
[05:14:21] iliketurtles: http://www.fugly.com/media/IMAGES/Random/65_wat.jpg
[05:14:43] fly2web: what is it?
[05:17:45] fly2web: now i feel ruby as normal level instead of difficulty
[05:23:54] crazydev: Hi, I'm ruby developer, one of my friend invited me into his startup as dev, but they are using php with laravel, But i didnt like to work on php project, is it bad for a programmer to reject a project because of their language choise ?
[05:25:17] Hanmac: depends ... do you have or gain enough money already that you can say no?
[05:27:55] crazydev: money ? of course, but as a friend, i have to help him, but working with those php code doesnt make comfortable
[05:47:20] mallu: is it possible to put an if statement with this? creation_time = DateTime.parse "#{creation_date}"; creation_time + 1 >= DateTime.now.new_offset(0)
[05:47:40] mallu: if creation_time = DateTime.parse "#{creation_date}"; creation_time + 1 >= DateTime.now.new_offset(0) SyntaxError: unexpected tSTRING_BEG, expecting keyword_then or ';' or '\n' ...reation_time = DateTime.parse "#{creation_date}"; creation_t.
[05:47:58] mallu: i want this to be conditional
[05:48:12] mallu: so that if true do something else do something else
[05:49:10] mallu: gizmore: any idea?
[05:50:21] fredlinhares: mallu, do know about ternary operators?
[05:52:05] fredlinhares: a = b > 10 ? result_if_true : result_if_false
[05:52:20] mallu: something like the this creation_time = DateTime.parse "#{creation_date}"; creation_time + 1 >= DateTime.now.new_offset(0)?
[05:54:44] mallu: fredlinhares: can you tell me how I can modify mine?
[05:55:51] gizmore: mallu: try:
[05:55:57] gizmore: creation_time = DateTime.parse "#{creation_date}";
[05:56:06] gizmore: (creation_time + 1) >= DateTime.now.new_offset(0)?
[05:56:11] gizmore: not the () in the left
[05:56:18] gizmore: note the () in the left*
[05:59:45] gizmore: i MaDE IT \O/
[06:01:17] gizmore: fixed ruby libpurple wrappers "ruburple" to compile with newer stuff, made a local gem with it and my rails uses it and hopefully i can start playing now
[06:01:48] mallu: gizmore: forgive my ignorance.. so how do I do something is it is true?
[06:02:55] gizmore: mallu: def a_older_than_b_for_time_n(a, b, n)
[06:04:21] gizmore: mallu: make sure you call that function with time/datetime objects
[06:04:38] gizmore: 'n' can be a number
[06:10:16] mallu: gizmore: can you please take a look at this and tell me how I can execute delete-snapshot if the above condition is true? http://pastie.org/9438436
[06:13:00] gizmore: mallu: http://cxg.de/_7b350f.htm
[06:18:15] mallu: gizmore: I'm getting Age in seconds: 0
[06:21:59] mallu: gizmore: creation_date: 2014-08-02T06:16:37.000Z creation_time: 2014-08-02T06:16:37+00:00 Age in seconds: 0
[06:26:25] mallu: its not calculating the age correctly creation_date: 2014-08-02T06:16:37.000Z creation_time: 2014-08-02T06:16:37+00:00 DateTime: 2014-08-02T06:25:35+00:00 Age in seconds: 0
[06:27:12] gizmore: you seem to compare the same date maybe?
[06:28:09] mallu: comparing this creation_time: 2014-08-02T06:16:37+00:00 DateTime: 2014-08-02T06:25:35+00:00
[06:28:31] gizmore: >> a = Time.now.utc.strftime("1970-01-01T01:01:01.000Z"); a.to_i
[06:28:31] eval-in: gizmore => 1970 (https://eval.in/174762)
[06:29:02] gizmore: >> a = Time(1970, 1, 1, 1, 1, 10); a.to_i
[06:29:02] eval-in: gizmore => undefined method `Time' for main:Object (NoMethodError) ... (https://eval.in/174763)
[06:29:11] gizmore: >> a = Time.new(1970, 1, 1, 1, 1, 10); a.to_i
[06:29:11] eval-in: gizmore => 3670 (https://eval.in/174764)
[06:29:28] gizmore: >> a = Time.now.utc.strftime("1970-01-01T01:01:10.000Z"); a.to_i
[06:29:28] eval-in: gizmore => 1970 (https://eval.in/174765)
[06:29:42] gizmore: it seems that the strftime does not like the format?
[06:29:47] gizmore: >> a = Time.now.utc.strftime("1971-01-01T01:01:10.000Z"); a.to_i
[06:29:48] eval-in: gizmore => 1971 (https://eval.in/174766)
[06:29:55] gizmore: >> a = Time.new(1971, 1, 1, 1, 1, 10); a.to_i
[06:29:55] eval-in: gizmore => 31539670 (https://eval.in/174767)
[06:30:08] gizmore: >> a = Time.new(1971, 1, 1, 1, 1, 20); a.to_i
[06:30:08] eval-in: gizmore => 31539680 (https://eval.in/174768)
[06:30:34] gizmore: mallu: maybe your strftime is just wrong
[06:37:10] mallu: what does this number mean? age = (DateTime.now - creation_time) => (23867126930369/21600000000000)
[06:38:33] mallu: gizmore: do you know what this number means? age = (DateTime.now - creation_time) => (23867126930369/21600000000000)
[06:38:35] mozzarella: time elapsed
[06:38:46] mallu: in seconds?
[06:39:56] mozzarella: elapsed time in seconds, yes
[06:41:33] mallu: why there is a /?
[06:42:40] mallu: [237] pry(main)> DateTime.now => #<DateTime: 2014-08-01T23:41:55-07:00 ((2456872j,24115s,678489932n),-25200s,2299161j)> [238] pry(main)> creation_time => #<DateTime: 2014-08-01T04:05:12+00:00 ((2456871j,14712s,0n),+0s,2299161j)> [239] pry(main)> (DateTime.now - creation_time).to_i => 1
[06:42:51] mallu: why only 1 second?
[06:43:44] mallu: take a look at this http://pastie.org/9438497
[06:44:39] mallu: shouldn't DateTime.now - creation_time more than 7 hours?
[06:45:37] mozzarella: I think it's substracting the two underlying dates
[06:46:02] mallu: two underlying dates?
[06:55:30] mallu: can you please explain that if you don't mind
[06:55:30] mozzarella: I date only cares about the current day, not the current time
[06:55:30] mozzarella: so it gives you the number of days
[06:55:31] mozzarella: >> (DateTime.now - DateTime.now.prev_month).to_i
[06:55:31] mozzarella: the bot is dead
[06:55:31] mallu: oh I see.. that makes sense
[06:55:31] mozzarella: (????;____;)
[06:55:31] mallu: mozzarella: thanks
[06:55:31] mozzarella: why are you working with datetimes?
[06:55:31] mallu: trying to compare two dates and if creationg_time is older than certain days I want to do something
[06:55:31] mallu: if creation_date > 7 then delete some old backups
[06:55:31] mallu: an arbitrary #
[06:55:31] mallu: actually... we only want to keep backup for 7 days in aws
[06:55:31] mozzarella: I??see, then you can use that, it gives you the number of days instead of seconds
[06:55:31] mozzarella: if you want seconds you can call .to_time on the datetimes
[06:55:31] mallu: ok.. cool thanks
[06:55:31] mallu: days is fine
[06:55:32] eval-in: mozzarella => uninitialized constant DateTime (NameError) ... (https://eval.in/174778)
[06:56:16] mozzarella: ( ?????????)
[06:56:43] mozzarella: it's too late eval-in??? just go home
[07:09:59] Mon_Ouie: You need require 'date'
[07:10:13] Mon_Ouie: >> require 'date'; DateTime
[07:10:13] eval-in: Mon_Ouie => DateTime (https://eval.in/174782)
[07:20:45] mozzarella: Mon_Ouie: it took 8 goddamn minutes to answer???
[07:22:39] Mon_Ouie: Oh, he's probably just tired
[09:26:02] crazydiamond: Hi. In RSpec, is should syntax deprecated?
[09:26:18] Nilium: Should syntax?
[09:28:07] Nilium: http://rubydoc.info/gems/rspec-core/RSpec/Core/MemoizedHelpers#should-instance_method ??? The documentation for the should method (not syntax) suggests it may be a poor choice, but doesn't appear to be deprecated.
[09:31:23] crazydiamond: Nilium, I've got this: http://dpaste.com/2TKMHNX
[09:32:05] crazydiamond: ok, seems that I should enable it
[09:32:15] crazydiamond: or, in other words: it expects me to enable it
[09:43:15] Nilium: crazydiamond: In that case, rspec's docs probably need updating.
[09:43:56] crazydiamond: Nilium, mine ones?
[09:44:18] Nilium: No, I mean rspec's documentation's obviously insufficient if you're getting an error the docs don't reflect
[09:44:38] Nilium: Which I guess is kind of the norm for Ruby stuff anyway
[09:50:36] yottanami: Is anyway to write this condition smaller http://dpaste.com/1ZWP2XJ ?
[09:55:12] atmosx: yottanami: flight.airline ? "#{flight.airline}-#{flight_number}" : "-#{flight_number}"
[09:56:06] mozzarella: you know that nil.to_s == '', right?
[09:56:32] toretore: >> false.to_s
[09:56:33] eval-in: toretore => "false" (https://eval.in/174827)
[09:56:37] ari-_-e: "#{flight.airline or ''}-#{flight_number}"
[09:57:39] ari-_-e: or yes, omit the or '' if flight.airline will be nil when falsy
[09:57:44] mozzarella: airline looks like it could be either nil or an object
[09:58:22] mozzarella: and in that case he could make use of the fact that nil.to_s == ''
[09:59:04] ari-_-e: could also be false
[10:00:41] toretore: `flight.airline || ''` is the best answer
[10:12:07] shevy: what is module_function really doing?
[10:12:21] shevy: is it the same as doing extend self (if we have only one method in that module)?
[10:15:57] Nilium: Probably?
[10:16:14] Nilium: Looks like it's just adding the method to the singleton class's list of instance methods.
[10:16:36] Nilium: I mean, it's literally a loop where it searches for each named method and then sets that method as an entry in the singleton class.
[10:17:37] Nilium: I need to find a bunch of git and hg users so I can pester them with a conceptual question
[10:17:49] robscormack: git user here
[10:18:03] Nilium: Most people are, I'm a little more curious about the hg users though
[10:18:11] Nilium: At any rate, how do you feel about git's index?
[10:18:40] Nilium: Would you miss having it?
[10:18:54] Nilium: hg users don't have one.
[10:19:04] robscormack: that's why I stopped using hg
[10:19:19] Nilium: Hence why I need to find a bunch of hg users to pester about it and see if they find the index confusing or don't like it or if they want one or what
[10:19:43] Nilium: 'Cause obviously it's got users, there are people who prefer it to git, but git's index alone would keep me from using hg
[10:20:12] arup_r: Can anyone guide me by saying, how can I install only this http://api.rubyonrails.org/classes/ActiveModel/Dirty.html#method-i-changed_attributes to use with plain Ruby ? I am learning some Rails concept.. I don't want to test this in a Rails end
[10:20:16] Nilium: Though hg has mq, which is kind of like a sort-of index
[10:22:02] robscormack: Nilium: for me personally it all depends on how many times you care about what's on git.
[10:22:57] robscormack: for people with OCD like me, it's much easier to see what's on staging and what needs to be on staging before committing
[10:23:45] Nilium: Well, for me, it's partly that and partly that I do a lot of hunk adds
[10:24:05] Nilium: And hg record sort of kind of does that but it's an all-or-nothing thing
[10:24:22] Nilium: You don't get to, say, indicate you want one thing then go back and read off the diff
[10:24:40] Nilium: You get to say you want X and that's your commit right now, even though that might not be the full commit
[10:24:40] robscormack: and that's exactly a feature I love when I'm drunk.
[10:25:10] Nilium: Never had to try using git when I'm drunk, but I make heavy use of it because I tend to make tons of changes then go back and add --patch them in.
[10:25:31] Nilium: E.g., add --patch, stash, test build, stash pop, continue committing
[10:25:38] Nilium: If the commit didn't build, amend it
[10:25:48] Nilium: I could probably automate that
[10:26:12] robscormack: that's what I did at one of my startups.
[10:26:28] robscormack: I used to work from the university, from home or from my friends' offices.
[10:27:09] Nilium: Should just require a post-commit hook and maybe something to quickly clone it to ensure it has a clean working tree (since there might be extra files in there) and then build, but overall the idea seems like it should be simple
[10:27:32] Nilium: Since, ideally, a local clone would just be hardlinks anyway, so fairly inexpensive
[10:27:34] robscormack: then I created a workflow to let me know what the heck was I doing and retrieve the greatest and latest thing, see if I finished it and then finally commit to dev.
[10:30:00] Nilium: At any rate, I need to sleep.
[10:30:17] robscormack: but my OCD is killing me today :c
[10:30:21] Nilium: Going to have to start waking up before 8am for a job, so being up at 3am is.. not a good thing.
[10:30:36] shevy: you are getting old
[10:31:13] robscormack: it's saturday today!
[10:31:26] robscormack: (or sunday, idk)
[10:33:39] Nilium: Saturday here, but I start a job on Monday, so I'm going to basically be shifting sleep schedules cold turkey
[10:33:47] Nilium: Going to be interesting to see how close I get to dying
[10:34:04] robscormack: well, luck is for cowards so be successful!
[10:36:11] shevy: I am a lucky hero
[10:51:27] arup_r: shevy: I am glad to hear.. I want to work with you.. that's why!
[11:05:18] atmosx: hey shevy
[11:05:25] atmosx: anyone experience with oauth2 gem?
[11:12:06] robscormack: painful one, yes
[11:17:06] arup_r1: What is quickest way to collect all cdata in an XML using Nokogiri ?
[11:22:52] shevy: only painful ways
[11:24:33] crazydiamond: how to calculate difference between two DateTime's in (hours minutes, seconds)? reference says that - method for Date (which's parent of DateTime) returns date or rational http://ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html#method-i-2D
[11:25:21] shevy: can't you use - there ?
[11:27:13] crazydiamond: shevy, ok, it will return me days. so, how I convert these to hours, minutes and seconds?
[11:27:31] shevy: does it really return a class called days?
[11:27:33] atmosx: robscormack: is there any test the endpoint? I mean, curl should work.. but although I get the token, I can't fetch any info. I get 404's even when copying requests from the documentation
[11:27:38] atmosx: any *way*
[11:27:57] crazydiamond: shevy, it returns Rational, that expresses days
[11:28:05] shevy: (DateTime.new - DateTime.new).class # => Fixnum
[11:28:23] shevy: >> require 'time'; require 'date'; (DateTime.new - DateTime.new).class
[11:28:23] eval-in: shevy => Rational (https://eval.in/174832)
[11:28:34] shevy: irb tells me Fixnum haha
[11:28:36] crazydiamond: irb(main):031:0> (DateTime.new(2014, 8, 2, 12, 30, 0) - DateTime.new(2014, 8, 1, 0, 0, 0)).class
[11:28:40] robscormack: atmosx I had a small sinatra app to test it
[11:28:45] robscormack: it was provided with doorkeper
[11:29:00] shevy: crazydiamond, what if you do this in irb: (DateTime.new - DateTime.new).class
[11:29:10] shevy: probably is 0
[11:29:16] crazydiamond: shevy, Rational
[11:29:23] shevy: that can not be
[11:29:25] shevy: what is your ruby version?
[11:29:31] crazydiamond: shevy, ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
[11:29:32] shevy: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
[11:29:45] atmosx: robscormack: you used oauth to get authentication credentials? I just need access to products... I don't really need a callback and all that.
[11:30:07] robscormack: atmosx I used it both ways
[11:30:22] arup_r1: The one I am using is very slow :p
[11:30:34] crazydiamond: so, If I'm just learning ruby, must I start with 2?
[11:30:37] shevy: not sure what to do with a Rational
[11:30:47] robscormack: crazydiamond yes sir
[11:30:53] robscormack: 2.1, to be precise.
[11:30:54] shevy: I have ruby 2.1.2
[11:31:06] crazydiamond: shevy, I can multiply it * 60 * 60 * 24 and this will give me seconds
[11:31:23] crazydiamond: to be more precise
[11:31:39] crazydiamond: (diff * 60 * 60 * 24).to_i
[11:31:41] arup_r1: doc = Nokogiri::XML(open("/path/to/file") ; doc.css("*") { |node| puts node node.cdata? }
[11:31:49] arup_r1: This is SLOW
[11:32:00] arup_r1: No one is helping me :-(
[11:32:14] shevy: nobody uses XML either
[11:33:07] arup_r1: Is XML dead ?
[11:34:28] atmosx: arup_r1: you either start reading some documentation or hire a ruby developer.
[11:34:38] atmosx: err wtf. you *should*
[11:34:59] arup_r1: atmosx: Why ? What's wrong ?
[11:35:18] atmosx: Because you ask questions like a shoot-gun :-)
[11:35:35] atmosx: browse the web, read some doc, find a way to make it faster.
[11:35:41] atmosx: pay sheve to do it.
[11:36:03] arup_r1: shevy: is my friend like you
[11:36:23] shevy: I have no time
[11:36:35] arup_r1: I don't want you to code.. want you give some tips
[11:36:38] shevy: atmosx arup_r1 has like 50.000 karma on stackoverflow
[11:36:43] shevy: arup_r1 ok. stop using XML
[11:37:11] shevy: I did so like 10 years ago and never regretted it
[11:38:55] atmosx: shevy: that doesn't compute.
[11:39:31] shevy: it is a perfect compute
[11:43:30] arup_r1: shevy: Thanks .. I'm Insulted by someone.. I will try to solve it by myself..
[11:44:03] arup_r1: I have some XML right now on my plate.. I need to eat those any how.. :-(
[11:44:18] shevy: believe me, once XML is no longer part of your life, you'll be a happier person
[11:44:40] crazydiamond: does ruby have more powerful shell than irb, which has all the autocomplete features etc?
[11:44:55] arup_r1: atmosx: Thanks for your awesome help! It makes my code more faster than earlier..
[11:46:15] arup_r1: shevy: You are true.
[11:47:09] shevy: you can have some autocomplete in irb or?
[11:47:22] shevy: require 'irb/completion'
[11:48:12] atmosx: arup_r1: Sorry if you felt insulted.
[11:49:49] arup_r1: atmosx: Before you, I had been by others too.. I am now habituated with it. :-)
[11:49:51] crazydiamond: shevy, thanks!
[11:53:07] zeroXten: is there a way to make global options across subcommands using Thor?
[11:53:45] robscormack: crazydiamond I use pry. Try it.
[11:55:46] atmosx: crazydiamond: there's 'pry'
[11:56:26] crazydiamond: robscormack, atmosx thanks. hacking it now
[12:00:07] fly2web: i can scrape some program like wireshark with ruby?
[12:08:10] shevy: you are an evil hacker
[12:13:37] arup_r1: fly2web: Welcome!
[12:13:49] fly2web: thanks arup_r1 :)
[12:14:03] fly2web: i can scrape some program like wireshark with ruby? is possible arup_r1
[12:14:33] arup_r1: I don't know Ruby... I do know BASIC
[12:14:48] fly2web: this is ruby channel.
[12:15:14] fly2web: perhaps you are ciucripi ???s friend?
[12:16:49] arup_r1: Who is She ;) ?
[12:17:27] shevy: fly2web get out of Korea and learn english man
[12:17:56] fly2web: shevy: i live in US.
[12:18:08] fly2web: shevy: you know about wireshark?
[12:19:00] shevy: you sure enough don't live in the USA with that level of english
[12:19:45] shevy: asians in canada https://www.youtube.com/watch?v=pKv_QPfYB1M
[12:22:29] fly2web: shevy: you are actor of that movie?
[12:22:45] shevy: man, I don't live in canada
[12:23:44] fly2web: oh you live beggar cave. haha
[12:24:59] shevy: and you live in taekwondo cave
[12:26:03] fly2web: i have no time to joking to you. i must study ha*k.
[12:30:00] fly2web: shevy: what is your IQ? i think that your iq is 2 letter.
[12:31:35] shevy: fly2web my IQ beats your IQ
[12:32:09] fly2web: my IQ is 154, i m mensa member.
[12:32:30] shevy: fly2web you lie
[12:32:33] shevy: your IQ is 56
[12:32:50] shevy: you should study hard
[12:33:50] shevy: to raise your IQ
[12:34:03] fly2web: my iq is 156
[12:34:14] fly2web: i m too sleepy.
[12:34:19] fly2web: so i have mistake.
[12:34:26] shevy: you said 154 before now you say 156
[12:34:41] fly2web: because of sleepy
[12:34:56] shevy: you should read books
[12:35:05] shevy: the big books
[12:35:08] shevy: not the small ones
[12:35:14] ChanServ: +o Mon_Ouie
[12:35:15] Mon_Ouie: +b *!~lee@*
[12:35:17] Mon_Ouie: Mon_Ouie kicked fly2web: has gone way too far???
[12:35:22] wasamasa: shevy: judging by your replies, you're talking with fly2web again
[12:35:27] wasamasa: shevy: let me turn off my filter
[12:35:32] Mon_Ouie: -o Mon_Ouie
[12:35:40] shevy: wasamasa awww he just got kicked :(
[12:35:52] ChanServ: +o Mon_Ouie
[12:36:11] Mon_Ouie: -b+b *!~lee@* fly2web!*@*
[12:36:31] Mon_Ouie: -o Mon_Ouie
[12:36:43] shevy: wasamasa guess you won't need that filter anymore
[12:36:58] wasamasa: well, he isn't the only one here
[12:37:53] wasamasa: I've decided to add people who clearly aren't (maliciously) trolling and rather just exhausting to deal with
[12:37:58] wasamasa: <fly2web> my IQ is 154, i m mensa member.
[12:38:17] wasamasa: I have no words
[12:38:33] wasamasa: first he couldn't use github or a search engine, now he knows what mensa is
[12:38:38] shevy: so he isn't on your black list completely
[12:38:47] wasamasa: I have a "Fool list"
[12:38:52] wasamasa: it hides people so I can toggle
[12:39:33] shevy: your definition above sounds like a description for a 'help vampire'
[12:39:41] wasamasa: help vampires
[12:48:25] pontiki: 'sup shevy
[12:49:40] shevy: it's too hot to cheer
[13:02:47] mechanicalduck_: So I tried JRuby to walkaround an issue with Ruby (Installer) on Windows.
[13:03:00] mechanicalduck_: Guess what - JRuby does not support building gem native extensions.
[13:03:23] mechanicalduck_: mkmf.rb can't find header files for ruby at C:/jruby-1.7.13/lib/native/include/ruby/ruby.h
[13:03:32] mechanicalduck_: So where can I get those header files?
[13:03:40] mechanicalduck_: I need them for JRuby on Windows.
[13:12:57] wasamasa: I doubt this is possible with jruby
[13:13:04] wasamasa: since the idea is not needing C at all
[13:13:39] wasamasa: let's verify this hypothesis by looking up how well nokogiri plays with it
[13:14:52] wasamasa: https://github.com/sparklemotion/nokogiri/wiki/Pure-Java-Nokogiri-for-JRuby
[13:15:14] gogohome: wasamasa: hello
[13:15:33] wasamasa: apparently it is possible, but since you're on windows, they recommend you to go for the pure java version for minimum pain involved
[13:16:06] arup_r: wasamasa: You are Ruby Pro
[13:16:16] wasamasa: I'm a google pro
[13:16:30] wasamasa: started learning ruby like two months ago
[13:16:46] arup_r: shame on me!
[13:17:01] wasamasa: wrote one actually useful script so far
[13:17:24] arup_r: Is this your first Programming language ?
[13:17:31] arup_r: I don't think so
[13:17:47] gogohome: unban fly2web plz wasamasa
[13:17:55] gogohome: fly2web is my friend.
[13:17:57] wasamasa: it's not, no
[13:18:08] wasamasa: I've learned python before for years
[13:18:17] wasamasa: so it's a lot simpler
[13:18:25] wasamasa: however I've got to get used to the magic in rails
[13:18:42] arup_r: Humm.. You beat me then! I am the only cheap programmer out there..
[13:19:11] wasamasa: gogohome: why do you think I have the choice over that
[13:19:39] gogohome: i don???t know that, but fly2web will regret of it.
[13:19:54] wasamasa: well, I don't
[13:20:01] wasamasa: I'm no op in here
[13:20:14] gogohome: unban fly2web.
[13:20:18] wasamasa: if flyzweb is that stupid, then he deserved it
[13:21:01] wasamasa: also, why do I feel like gogohome is him under a different ip address...
[13:21:16] arup_r: wasamasa: They are same
[13:21:32] arup_r: ban gogohome too :-)
[13:21:33] gogohome: oh, fly2web is my frined
[13:21:54] gogohome: i m not fly2web.
[13:21:58] gogohome: just friend.
[13:22:09] wasamasa: of course not, you just share the same user name
[13:22:15] arup_r: gogohome he is evil.. why are you begging for him
[13:22:28] gogohome: for frined.
[13:22:47] gogohome: fly2web i s best friend
[13:22:58] arup_r: If you request once more ... we will ban you
[13:23:26] arup_r: gogohome you fly to home with fly2web
[13:23:41] arup_r: don't kill us here
[13:23:49] gogohome: i m kind just
[13:23:51] arup_r: shevy don't like these
[13:30:40] mechanicalduck_: wasamasa: Is there a pure java version for the gem wdm?
[13:30:59] wasamasa: mechanicalduck_: no idea
[13:33:20] mechanicalduck_: wasamasa: It is cursed, this linux-windows fs monitoring thing. I tried so many combinations, none of them work, some little piece is always missing.
[13:36:28] lukeholder: looking for a gem that lays sql over csv files
[13:36:33] lukeholder: with the ability to do joins
[13:36:58] lukeholder: like sequel gem's in memory sqlite but populated by the csv files
[13:37:59] wasamasa: funny, I've joked about that at work
[13:38:11] wasamasa: "We must write CSV-ORM.rb some day!"
[13:43:37] mechanicalduck_: So I got the damn header files in place.
[13:43:44] mechanicalduck_: make: Nothing to be done for `install'.
[13:44:04] mechanicalduck_: wdm gem is listed as installed but is still not detected by gem listen.
[13:58:54] shevy: what is gem listen
[13:58:59] shevy: oh he is gone
[14:05:48] xxmicloxx: Hello, does anyone know something like DataInputStream in java for ruby?
[14:07:24] shevy: what is that
[14:07:28] shevy: perhaps class IO
[14:07:37] shevy: http://www.ruby-doc.org/core-2.1.2/IO.html
[14:07:46] shevy: pipework, I find the ruby docu so ugly :(
[14:08:05] xxmicloxx: DataInputStream is a helper class where you can call readByte or readShort etc...
[14:14:37] Mon_Ouie: Read data to a string and use String#unpack to convert them
[14:17:32] eam: sysread() is what you want for that, right?
[14:18:50] Mon_Ouie: I'm not sure why you'd want sysread over read
[14:21:21] eam: if it's like perl (and I'm not sure it is) read() would go through an i/o layer that might not 1:1 map to the underlying syscall
[14:22:46] Mon_Ouie: Well that is the case, but why would you want the behavior of read(2) for that?
[14:23:49] eam: well now that you mention it, perhaps you don't
[14:24:55] toretore: xxmicloxx: https://github.com/justfalter/bindata
[14:53:03] anildigital: For Ruby people http://ruby-operators.herokuapp.com/
[14:53:29] anildigital: Contribute https://github.com/anildigital/ruby-operators
[14:59:22] benzrf: >twiddlewalka
[15:08:43] pontiki: <3 anildigital
[15:15:02] shevy: pontiki likes everyone
[15:15:40] anildigital: shevy: pontiki <3
[15:18:10] anildigital: Do tell, if you know some new names for Ruby operators
[15:19:55] anildigital: and do tweet about it :D thanks
[15:20:21] shevy: I remember
[15:20:25] shevy: havenwood said one
[15:20:30] shevy: shark operator or something
[15:20:35] shevy: walrus operator?
[15:20:41] shevy: where is he :(
[15:29:44] Mon_Ouie: I've heard people call ||= a hammer
[15:30:12] shevy: where would you guys put a todo file of your gem project?
[15:30:27] pontiki: in the gem root
[15:30:31] shevy: ok but I mean... at the base... aha ok
[15:51:47] shevy: I wanna dance
[15:53:54] heyimwill: TODO.md is an actual website
[15:56:15] Petru: probably belongs to a guy named Todo
[15:57:01] pipework: shevy: I find that it often has the information I need, even if it's not all pretty and shiny.
[15:57:33] shevy: I like pretty and shiny
[15:58:04] pontiki: or a guy with nothing to do...
[15:58:45] pontiki: i like useful and substantial
[16:03:12] eam: I keep meaning to put a todo in my projects
[16:15:15] shevy: why have I tried rewriting this project...
[16:51:52] anildigital: Mon_Ouie: is it that popular?
[16:52:16] anildigital: Btw.. here is updated site http://ruby-operators.herokuapp.com/
[16:53:02] anildigital: If you want to contribute, please edit https://github.com/anildigital/ruby-operators/blob/master/public/config/operators.json
[16:56:10] Mon_Ouie: anildigital: Well??? can't be much less than octothrope
[17:38:24] shevy: when I subclass from a class
[17:38:28] shevy: but all is packed into modules
[17:38:31] shevy: for instance:
[17:38:36] shevy: module Foo; class Bar
[17:38:39] shevy: and then another project
[17:38:44] shevy: module Ble; class Yo
[17:38:50] shevy: hmm no, that is a bad example...
[17:39:02] shevy: I wanted to give an example like:
[17:39:07] shevy: class Yo < Foo::bar
[17:39:13] shevy: class Yo < Foo::Bar
[17:39:17] shevy: class Yo < Bar
[17:40:53] eam: down with module
[17:40:59] jhass: I don't think your question is clear
[17:41:54] shevy: give an answer man
[17:42:12] jhass: I have no idea what the question is, actually
[17:43:30] eam: shevy: try it on a newer ruby
[17:43:43] shevy: I only work with the latest and greatest
[17:43:56] shevy: but I am going with the ::
[17:43:57] eam: I don't know what the question is either, but that's a pretty decent generic answer huh
[17:44:02] shevy: other projects seem to do so too
[17:44:12] pipework: shevy: I don't think anyone follows.
[17:44:31] shevy: class MyApp < Sinatra::Base
[17:45:25] Mon_Ouie: I don't think you even stated a question yet
[17:49:54] eam: awesome_print knows where methods come from and the names of args, like: irb_require(*opts, &b) Object (IRB::ExtendCommandBundle)
[17:49:59] eam: how does it get that information?
[17:50:34] jhass: should be the Method object obtained by the method method
[17:52:20] Hanmac: eam dark magic
[17:52:43] shevy: hey Hanmac
[17:52:52] shevy: you have become very quiet ever since you got your new job
[17:53:26] Hanmac: >> def meth(a,b=1,*c,d:, e: 4, **f,&g);end; method(:meth).parameters
[17:53:27] eval-in: Hanmac => [[:req, :a], [:opt, :b], [:rest, :c], [:keyreq, :d], [:key, :e], [:keyrest, :f], [:block, :g]] (https://eval.in/174880)
[17:53:46] eam: wow awesome
[17:53:57] Hanmac: shevy hm that has other reasons ... i and my sister doing driving lessons ...
[17:54:46] shevy: I just found the coolest comment I ever wrote
[17:54:49] shevy: reset # This method will also invoke reset().
[17:55:13] pontiki: that's not cool
[17:55:17] pontiki: no rhyming couplets
[18:03:55] mattalexx: When I run "asdf = true and false" asdf is false (though I expect it to be true. I have to put brackets around it to get what I want: "asdf = (true and false)". Why?
[18:04:24] jhass: >> asdf = (true and false); asdf
[18:04:24] eval-in: jhass => false (https://eval.in/174881)
[18:04:45] jhass: >> asdf = true and false; asdf
[18:04:45] eval-in: jhass => true (https://eval.in/174882)
[18:05:01] jhass: >> asdf = true && false; asdf
[18:05:01] eval-in: jhass => false (https://eval.in/174883)
[18:05:11] eam: mattalexx: precedence of = is higher than "and"
[18:05:23] mattalexx: eam: Wonder why..
[18:05:29] jhass: so the other way around you described it, but precedence, as said
[18:05:37] eam: because it was copied from perl, where the rules are the same
[18:06:01] jhass: one of the reasons most people prefer && over and, the precedence rules are more what you're used to from other languages
[18:06:07] mattalexx: ACTION does a search for " and " across entire codebase
[18:06:20] eam: and/or/not are also pretty screwed up for other reasons
[18:06:28] eam: >> [true and false]
[18:06:28] eval-in: eam => /tmp/execpad-17d6e11bded0/source-17d6e11bded0:2: syntax error, unexpected keyword_and, expecting ']' ... (https://eval.in/174885)
[18:06:39] eam: >> [ true && false]
[18:06:39] eval-in: eam => [false] (https://eval.in/174886)
[18:06:59] eam: though that problem is unique to ruby
[18:08:08] pontiki: i don't think and/or/not are methods. i thought they were syntactic elements
[18:08:20] eam: they're keywords
[18:08:37] pontiki: &&/||/! are methods
[18:08:51] jhass: uhm no, only !
[18:09:06] eam: and some things in ruby are only methods sometimes and other times aren't
[18:09:35] jhass: >> class Foo; def self.!; :not_foo; end; end; !Foo
[18:09:35] eval-in: jhass => :not_foo (https://eval.in/174887)
[18:10:01] shevy: why is it on the left hand side
[18:10:01] jhass: pontiki: how do I override && if it's a method?
[18:10:24] eam: >> class Fixnum; def -@; 7 end; end; [ -1, --1, -(1), - 1 ]
[18:10:24] eval-in: eam => [-1, 7, 7, 7] (https://eval.in/174888)
[18:10:29] pontiki: idk, i'm wrong, i thought you already said that...
[18:11:43] eam: seems like ruby's parser for numeric literals shouldn't include "-" for this reason
[18:12:30] eam: I guess it gets more complex with minus embedded in complex expressions like
[18:12:39] eam: >> [1e1, 1e-1]
[18:12:40] eval-in: eam => [10.0, 0.1] (https://eval.in/174891)
[18:14:03] eam: maybe 1e-1 should actually call -@() and **()
[18:14:33] eval-in: godd2 => 1.0 (https://eval.in/174892)
[18:15:16] eam: >> class Fixnum; def **(x); 88; end; end; [1e1, 1**10]
[18:15:16] eval-in: eam => [10.0, 88] (https://eval.in/174893)
[18:15:20] jhass: that's academic anyway, overriding Fixnum#-@ is pretty insane IMO
[18:15:37] eam: then it shouldn't be a method at all :)
[18:16:04] eam: anyway there are legit reasons to override it, such as causing it to throw an error
[18:16:15] jhass: I said Fixnum#-@, not MyClass#-@
[18:16:25] eam: yeah I know
[18:16:26] godd2: I dunno jhass I can imagine creating a child class of Fixnum in which negation takes on a slightly different meaning, but I dunno.
[18:16:42] jhass: godd2: thing is, I can't
[18:16:54] eam: you can't really create children classes of Fixnum, I tried yesterday
[18:16:55] Hanmac: godd2: you cant make a childclass of Fixnum ... okay you can but it does not work
[18:17:00] jhass: and if it comes to a subclass, you won't have a literal for it anyway
[18:17:13] eam: I wanted to create a byte class for that dude with the brainfuck interpreter
[18:17:28] jhass: so the behavior in literal parsing is irrelevant for the subclass case
[18:18:28] eam: well what if you want to change floating point behavior, that's a legit use case
[18:18:33] eval-in: yourmother__ => 2 (https://eval.in/174894)
[18:18:42] Hanmac: list of classes you cant make instances from:
[18:18:42] Hanmac: >> ObjectSpace.each_object(Class).reject {|o| o.respond_to?(:new) }
[18:18:42] eval-in: Hanmac => [Bignum, Float, Fixnum, Integer, Symbol, Encoding, FalseClass, TrueClass, NilClass, Complex, Rational, Thread::Backtrace::Location, Thread::Backtrace, RubyVM::Env, RubyVM, Binding, UnboundMethod, Metho ... (https://eval.in/174895)
[18:18:46] eam: say you want java float semantics instead of ieee
[18:19:37] Hanmac: eam ... ups you did say the j-word inside this channel ... now we all will hate you ...
[18:19:50] eam: well let's say its for jruby compat reasons
[18:19:57] eam: ACTION ducks
[18:20:21] godd2: Well I'll at least say this, even if theres some method that has never been changed or touched or overridden yet, that doesn't mean there's not a use case for it at some point. Maybe Matz figured that he didn't have all the answers, and is letting us figure this out.
[18:20:24] eam: Hanmac: if it makes you feel better I think java is hella stupid for not implementing ieee floats
[18:20:48] Hanmac: hey! i am not even sure if php does full implment them ;P
[18:21:22] eam: now I'm wondering how to add .new to a class
[18:21:29] eam: has to be possible
[18:21:49] godd2: eam what do they do different? use 7 bits for the exponent instead of 8 ?
[18:22:14] eam: http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf
[18:22:28] eam: pretty esoteric stuff
[18:37:04] arup_r: Guys any idea? How can I do this outside of Rails ? http://api.rubyonrails.org/classes/ActiveModel/Dirty.html#method-i-changed_attributes
[18:38:11] pontiki: you can use active model outside of rails...
[18:38:56] godd2: or you can implement ActiveSupport::HasWithIndifferentAccess
[18:40:52] pontiki: HWIA doesn't return previous values
[18:42:30] arup_r1: pontiki: Are you telling me ?
[18:42:55] pontiki: that you can use active mode outised of rails? yes
[18:43:07] arup_r1: Please tell me how
[18:43:18] pontiki: what do you mean?
[18:43:36] arup_r1: I mean which Gem I need to install it
[18:43:42] pontiki: active_model
[18:43:43] arup_r1: for doing this?
[18:44:16] arup_r1: https://github.com/ntalbott/active_model ?
[18:44:45] centrx: That's pretty ancient
[18:45:26] centrx: arup_r1, https://rubygems.org/gems/activemodel
[18:45:30] godd2: gem install activemodel
[18:46:17] arup_r1: godd2: That I know hehehehe.. Only not able to find out the correct one
[18:46:38] godd2: https://github.com/rails/rails/tree/master/activemodel
[18:47:18] arup_r1: centrx: Thank you very much
[18:52:51] gogohome: very hot. so i can???t sleep
[19:00:11] anildigital: Those who missed http://ruby-operators.herokuapp.com/ Do contribute if I missed any awesome Ruby operator name. Thanks. Good night folks!
[19:05:42] graft: hey folks, i've got this class Dummy that I'm extending with Enumerable - the problem is whenever I do select on it, i end up with an Array - how can i make it so that select returns a new Dummy instead?
[19:05:53] graft: while still using all of the Enumerable goodness...
[19:06:36] graft: seems like I should be able to overwrite enum_for and return some Enumerator subclass or some such
[19:08:12] centrx: graft, Yeah I think the Enumerable select is always designed to return Array, as it does with Hash too
[19:08:29] centrx: graft, returning an Enumerator is different from returning a new Dummy
[19:09:19] centrx: graft, You can override #select to do: super.to_dummy :or: Dummy.new(super)
[19:09:34] graft: centrx: yeah, but i don't want to rewrite Enumerable
[19:11:05] centrx: graft, You can do some metaprogramming for it
[19:12:08] centrx: graft, and/or instead of including Enumerable in Dummy, have Dummy contain some object that acts like an array, and Dummy mediates between the array and the Dummy type
[19:14:08] godd2: graft perhaps you want to use #find instead?
[19:15:36] graft: i basically want to have all of the Enumerable methods, select, reject, sort, etc., but instead of them returning an Array they return my collection class instead... i guess i just have to write my own select/reject/sort/etc.
[19:16:20] graft: centrx: yeah, the Dummy class already uses an array internally
[19:17:09] centrx: graft, So just use define_method or method_missing to define these methods, which send the corresponding method in the internal array, and then transforms the output into a Dummy
[19:17:34] godd2: method_missing won't work if he includes Enumerable
[19:17:44] centrx: define_method is cleaner anyway
[19:18:20] centrx: graft, So you only need to write one method definition, which calls the corresponding method in the internal array. You don't need to write your own select and sort methods
[19:18:22] graft: yeah.... just trying to avoid duplication dammit
[19:18:35] centrx: graft, You only need one loop with one define_method in it
[19:20:03] graft: centrx: not sure i follow...
[19:20:23] centrx: graft, https://gist.github.com/anonymous/25ee4a2568f12ca5e8ca
[19:21:34] centrx: graft, fixed: https://gist.github.com/anonymous/fec4f600eb70567f3c70
[19:21:38] graft: centrx: aha, cool, very nice
[19:22:00] jhass: you can replace the array with Enumerable.instance_methods
[19:22:31] graft: i don't want all of Enumerable's instance_methods, however, just the ones that would return an Array
[19:22:52] graft: like i don't want find
[19:23:00] jhass: I'd rather check inside if an array was returned
[19:23:20] graft: hmm, that's a good idea
[19:23:42] graft: unless find returns an array, but i guess i know what i'm collecting
[19:24:13] graft: probably safer to list them out though
[19:27:23] godd2: graft: here you go: https://gist.github.com/nicklink483/a039ff62dcaa60ff52e9
[19:27:52] godd2: That way you get all the functionality of enumerable, but overridden methods will return a new custom collection
[19:28:36] jhass: godd2: why not pass the block to @elements.each ?
[19:29:02] jhass: and why yield if there's no block?
[19:29:28] godd2: I'm sure there are better ways to write what I wrote.
[19:29:49] jhass: simply delegate, @elements.each(&block)
[20:00:34] godd2: This just shows I need to learn how delegation works
[20:09:58] shevy: why don't we have accessors for "foo?" methods?
[20:10:00] shevy: def foo?; @foo
[20:10:36] centrx: You mean !!@foo ?
[20:10:58] centrx: As you see, it is the same as attr_reader
[20:11:09] shevy: well they don't have the trailing ?
[20:11:12] centrx: Actual foo? methods usually have special logic, not accessors
[20:11:44] jhass: I've seen quite a few that map to a (boolean) instance variable
[20:11:54] godd2: shev i think cent means it should have been def foo?; !!@foo
[20:14:12] Mon_Ouie: I usually do attr_accessor and alias the reader it creates
[20:15:53] godd2: I still think we should have an anternary operator.
[20:16:10] godd2: some_condition !? when_false : when_true
[20:16:31] centrx: just move the ! to the front
[20:16:41] godd2: yea but its way funner to write !?
[20:16:58] jhass: or swap the bodies
[20:18:23] eam: >> def ???(cond, a, b); cond ? b : a end; ??? true, 1, 2
[20:18:24] eval-in: eam => 2 (https://eval.in/174908)
[20:19:26] godd2: ah, the interrobangary
[20:20:13] godd2: we could call it the wtf operator
[20:22:12] Mon_Ouie: We still need to get alias ?? lambda in core
[20:22:54] Mon_Ouie: Also the new ??? syntax for hashes
[20:24:48] godd2: and ??? for case equality?
[20:27:24] Mon_Ouie: Sure, why not???I mean, if Haskellers can get a UnicodeSyntax language extension in their compilers, why couldn't we?
[20:31:42] TieSoul: is there a faster/better way to do "for i in 0..arr.length; arr[i] += arr2[i]; end"?
[20:33:31] jhass: arr.each_with_index do |e, i| arr2[i] += e; end
[20:33:58] godd2: that wouldn't be the same. his changes arr, while yours changes arr2
[20:34:11] jhass: meh, just exchange the names
[20:34:59] jhass: there may be a way to avoid it altogether, but we know nothing about the real problem
[20:36:17] TieSoul: I'm making a simulation of an object moving through two-dimensional space with the coordinates and delta represented as arrays as a part of an interpreter for an esoteric language.
[20:37:47] TieSoul: not so much a simulation
[20:37:54] TieSoul: I just wanted to sound fance
[20:38:07] TieSoul: it's more of a "thing that moves with constant speed"
[20:38:11] TieSoul: not very complicated.
[20:38:12] jhass: so there are only ever two items in the array?
[20:39:04] jhass: I'd consider just coords[0] += delta[0] ; coords[1] += delta[1] (as two lines) then
[20:40:30] shevy: Mon_Ouie, how would that look when you wrote: "<Mon_Ouie> I usually do attr_accessor and alias the reader it creates" ? class Foo; attr_accessor :bar; alias bar? bar; end <--- like so?
[20:41:08] threesixes: im already 25% at codecademy's ruby progress after 3 days of strolling through, pretty neat language
[20:41:45] jhass: TieSoul: or using matrix stdlib
[20:41:54] Mon_Ouie: shevy: yeah
[20:43:11] TieSoul: Matrix stdlib? I'll look at that, thanks.
[20:44:25] Mon_Ouie: TieSoul: Befunge?
[20:45:08] TieSoul: Yup, Befunge.
[20:45:13] TieSoul: -98, to be exact.
[20:46:37] Mon_Ouie: I never couldn't commit to the task of implementing an esoteric language enough to respect the 98 spec :p
[20:47:32] TieSoul: I've already done it in Python (not fully compliant though, there's an infinite loop when Mycology does some part, and I can't reproduce it, which is frustrating).
[20:47:41] Mon_Ouie: I'm not sure I even understand how wrapping around works in Befunge98
[20:47:43] TieSoul: Now I'm redoing it in Ruby, and concurrent.
[20:48:55] TieSoul: Wrapping in b-98 works like this: If it reaches an edge, it reverses the delta and moves until it hits another edge, then it reverses the delta and continues.
[20:50:49] shevy: threesixes 3 days of trolling???
[20:50:53] Mon_Ouie: Ah, I think the explanation on http://quadium.net/funge/spec98.html must have scared me
[20:53:06] shevy: when I have a string like "Fooooo bar.", is there a simple and elegant way to turn this into "Fooooo Bar."?
[20:54:37] shevy: .split(' ').map(&:capitalize).join(' ') shall do
[20:56:40] TieSoul: erm, so how do I get the matrix library? I'm kind of a Ruby noob.
[20:56:50] jhass: require 'matrix'
[20:57:01] TieSoul: oh you need to use 'quotation marks'
[20:59:02] Mon_Ouie: It works fine with "quotation marks" too, but it does need to be a string
[21:01:35] TieSoul: so how do I import another file in the same directory? I have a file named "ip.rb", but when I use "require 'ip'" it throws an error.
[21:02:10] TieSoul: Do I need to do something inside the other file to make it work?
[21:02:27] robscormack: require_relative './ip' doesn't work?
[21:02:47] TieSoul: lemme try that
[21:02:52] Mon_Ouie: If you're going to use require_relative it should be require_relative 'ip'
[21:03:05] TieSoul: yeah, that works
[21:03:15] godd2: >> "Fooooo bar.".gsub!(/ (\b\w)/) {|m| " " + $1.upcase}
[21:03:15] eval-in: godd2 => "Fooooo Bar." (https://eval.in/174914)
[21:03:46] robscormack: Mon_Ouie yup, my bad.
[21:03:51] godd2: there you go shevy, but be wary, it will capitalize any word following a space
[21:03:58] threesixes: sorry shevy i didn't write that down thats like leson 2 + 3 on codecademy its like .capitalize or something like that
[21:04:06] yoshie902a: anyone know any good tutorials for XACML in ruby
[21:07:49] threesixes: shevy, .capitalize!
[21:08:23] wasamasa: yoshie902a: what's that even
[21:09:54] Mon_Ouie: threesixes: his problem was that he wanted to capitalize every word individually
[21:10:44] robscormack: wasamasa: it's like OAuth2, only harder to handle and not scalable.
[21:11:03] wasamasa: robscormack: hmm, why would there only be no decent tutorials on it...
[21:11:18] robscormack: I don't have any good tutorials on it and for one, wouldn't recommend anything to connect with that.
[21:11:20] wasamasa: ah, I know why, it reeks of java and is xml
[21:11:57] wasamasa: therefore, throw the appropriate tools at it
[21:12:43] yoshie902a: wasamasa: o qoute from stackoverflow: ??? With XACML, you can implement context-aware authorization that is policy-based. For instance you can write rules such as: managers can edit documents they own; doctors can view the medical record of patients they are assigned to???
[21:13:08] wasamasa: sounds yucky
[21:13:14] yoshie902a: wasamasa: this is a good slide that explains it http://www.slideshare.net/DavidBrossard/authorization-its-not-just-about-who-you-are
[21:13:20] robscormack: it's like cancan on steroids.
[21:13:22] jhass: sounds like too much authorization in your authentication protocol
[21:13:24] wasamasa: wouldn't one solve that with relational databases
[21:13:32] wasamasa: or whatever else in the appropriate parts
[21:13:45] wasamasa: just giving the user the information he's supposed to see
[21:14:03] yoshie902a: wasamasa: I???m looking for best practices and good coding patterns
[21:14:13] wasamasa: yoshie902a: this is not #java
[21:14:19] yoshie902a: it can get yucky
[21:14:42] yoshie902a: wasamasa: don???t get the java comment, explain
[21:15:09] wasamasa: the more lower-level a programming language is, the more there's a need for programming patterns
[21:15:32] wasamasa: java is pretty bad at this while ruby is quite good
[21:16:07] yoshie902a: wasamasa: or if you are dealing with many variables and need a clean organized way to manage them.
[21:16:48] wasamasa: use whatever abstractions your language provides, not what some hyped book thinks is good
[21:16:55] jhass: yoshie902a: like a hash?
[21:17:04] wasamasa: and since java intentionally limits you, you're fucked anyways
[21:17:10] wasamasa: heck, people prefer configuring java with xml
[21:17:19] wasamasa: instead of using something a bit more dynamic
[21:17:28] wasamasa: while the ruby world uses yaml for serialization
[21:17:53] jhass: hm, there's much json these days
[21:18:41] robscormack: yaml 1.2 includes json as part of its standard.
[21:18:50] jhass: while Marshal uses a binary format
[21:19:32] yoshie902a: It???s a bit more complex
[21:19:40] robscormack: the problem with XML is that it is new era's Cobol: it's implemented everywhere and it takes a world to get rid of it.
[21:19:56] yoshie902a: check out the slide share I posted, might give you a better idea of what I???m looking for
[21:21:34] eam: http://harmful.cat-v.org/software/xml/
[21:27:46] robscormack: I MUST write a rant about JavaScript.
[21:27:53] robscormack: please? please? please?
[21:28:54] pontiki: reddit awaits, robscormack
[21:30:06] shevy: godd2 ewwwwww now that is ugly
[21:30:18] robscormack: I must make a confession, pontiki: I don't get reddit.
[21:30:25] eam: if you don't like javascript just disable it in your browser
[21:30:36] shevy: on reddit there are too many uneducated people
[21:30:42] shevy: educating them takes really a long, long time
[21:30:52] eam: shevy: it's the only way they'll improve though
[21:31:09] eam: you used to be like that too, we all did
[21:31:14] eam: (and all still are)
[21:31:17] shevy: I was always great
[21:31:26] shevy: except when I used php
[21:31:39] shevy: I wrote functions that way:
[21:31:43] shevy: function FOO_BAR()
[21:32:23] threesixes: i dont like javascript because its not server side, and requires you to have it enabled
[21:33:11] robscormack: why on earth people don't have a standard way to write JavaScript or even a standard way to organise their code?
[21:33:43] shevy: it's more fun when people write free style
[21:33:52] threesixes: idk i like hierarchy, not schizophrenic messes
[21:34:10] eam: I don't know if you noticed but you're in #ruby
[21:34:51] robscormack: then, can we create rubyscript? :X
[21:35:16] shevy: RUbY for the browser
[21:35:24] shevy: alert 'hello world!'
[21:36:10] threesixes: chomp chomp chomp, i dont get it lol
[21:36:58] robscormack: jquery(document).get_element_by_id :carousel
[21:40:20] lisa__: is there someone who is good in rails
[21:40:26] lisa__: i have a small question
[21:40:37] jhass: I'm pretty sure in #rubyonrails are some ;)
[21:40:50] lisa__: ohh thanks :)
[21:42:23] lisa__: can't join :/
[21:42:39] jhass: check /msg NickServ help
[21:46:21] lisa__: not very helpful
[21:46:36] jhass: you need to register with that and then identify
[21:48:42] pontiki: robscormack: if not reddit, tumblr; if not tumblr, facebook; if not fb, g+; if not g+, twitter; if not twitter, livejournal :)
[21:50:10] pontiki: just use the ruby transpiler to get your ruby in the browser
[21:50:39] pontiki: http://opalrb.org
[21:51:12] shevy: we need opalrb
[21:51:14] shevy: to become part of firefox
[22:08:41] mistergibson: I wish ruby would take code examples from OpenJDK, a fine working example, and implement true threads. It would kick ass then.
[22:29:52] pontiki: have at it, mistergibson
[23:06:27] shevy: I am going to quiz you people
[23:06:29] shevy: what does Array#pop do
[23:06:36] centrx: It poops out an element
[23:10:01] pontiki: same as Array#scat ?
[23:16:16] shevy: NoMethodError: undefined method `scat' for ["a", "b", "c", "d", "e", "f", "g", "b", "h", "i"]:Array
[23:16:49] pontiki: i see the joke eludes you
[23:17:37] eam: method_pissing
[23:24:43] mistergibson: [0, 1, 2, 3].pop => 0
[23:25:50] Nowaker: mistergibson: somebody overwrote .pop method on Array?
[23:30:06] shevy: method_pissing
[23:30:19] shevy: it's used when it is toilet time
[23:33:46] mistergibson: err.. => 3 - I'm smoking dope
[23:34:26] shevy: that is good mistergibson
[23:44:44] shevy: is .slice() giving me any advantage over [] ?
[23:44:58] shevy: docu says synonym
[23:45:22] drizz: you probably save ??1s on the name lookup though!
[23:45:48] drizz: 1??s even
[23:51:25] shevy: a micro second