« Back to channel list

#ruby - 02 June 2017

« Back 1 day Forward 1 day »
[00:03:36] chaugiang: has joined #ruby
[00:04:37] ecuanaso: has joined #ruby
[00:10:56] xco: has joined #ruby
[00:12:23] xco: hash = {“hi” => “hello} i’d like to do something like hash[/hi/i] where /hi/.i as provided key would be a string. how do i do that? :)
[00:12:44] xco: where /hi/i **
[00:14:04] xco: so i’m looking to do something like hash[/hi/i.to_s] so i can get “hello” but obviously this won’t work. any ideas
[00:16:34] dc2: has joined #ruby
[00:19:53] ecuanaso: has joined #ruby
[00:20:42] kegster: has joined #ruby
[00:21:23] chaugiang: has left #ruby: ()
[00:23:38] havenwood: >> module CaseInsensitiveHash; refine Hash do; def [] key; super key.downcase end end end; module Example; using CaseInsensitiveHash; def self.example; life = {}; life['Meaning'] = 42; life['meaning'] end end; Example.example # xco
[00:23:39] ruby[bot]: havenwood: # => nil (https://eval.in/809862)
[00:24:29] havenwood: well, in 2.4.1 it's: #=> 42
[00:24:54] al2o3-cr: >> RUBY_VERSION
[00:24:55] ruby[bot]: al2o3-cr: # => "2.3.0" (https://eval.in/809863)
[00:25:02] havenwood: xco: I don't think that's a good idea. Tell us more about what you're doing and I think we'll come up with something better.
[00:25:28] al2o3-cr: yeah, everything about that sounds wrong
[00:25:37] havenwood: actually, no, my code was wrong
[00:26:49] havenwood: I mean this abomination:
[00:26:51] havenwood: >> module CaseInsensitiveHash; refine Hash do; def []= key, value; super key.downcase, value; end; def [] key; super key.downcase end end end; module Example; using CaseInsensitiveHash; def self.example; life = {}; life['Meaning'] = 42; life['meaning'] end end; Example.example
[00:26:57] ruby[bot]: havenwood: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
[00:27:26] al2o3-cr: third time lucky?
[00:27:44] havenwood: bot wins this round
[00:29:57] nadir: has joined #ruby
[00:29:57] al2o3-cr: xco: you could make the key a regex?
[00:30:02] nadir: has joined #ruby
[00:30:28] GinoMan2440: has joined #ruby
[00:31:08] ecuanaso: has joined #ruby
[00:31:24] aurelien`: has joined #ruby
[00:35:48] al2o3-cr: i've only just noticed `I'm terribly sorry ...` lol
[00:36:46] foobar007: has joined #ruby
[00:37:25] foobar007: How can I make my object respond to the hash interface? i.e., m = MyObj.new; puts m[:attr] ??
[00:37:45] zenspider: foobar007: implement methods
[00:38:02] zenspider: in the above case: class MyObj; def [] key; ...; end; end
[00:38:18] foobar007: ah ruby. always so simple :)
[00:38:40] xco: has joined #ruby
[00:38:49] xco: sorry got disconnected just in case someone answered this
[00:38:49] foobar007: []= to set the value as well, i guess?
[00:38:57] xco: well i have a hash that looks like this hash = {“one” => [“two”, “three”]} what i want is to take any key value (that matches “one” case insensitive) to return [“two”, “three”]
[00:39:47] zenspider: xco: seems like a bad idea... why?
[00:39:55] al2o3-cr: have you got these quotes out of a novel
[00:40:02] foobar007: zenspider: thank you, kind stranger.
[00:40:05] xco: zenspider: why what? :)
[00:40:09] zenspider: foobar007: no prob
[00:40:22] zenspider: xco: why do you want to do that? what are you *actually* trying to do?
[00:40:28] xco: zenspider: cause i’m accepting parameters from a search box
[00:40:56] xco: so a user can enter anything. and i want to match that, disregarding case sensitivity
[00:40:57] zenspider: parameters you don't control? that also sounds like a bad idea
[00:41:10] xco: too many bad ideas :D
[00:41:17] zenspider: you want to match what? the parameters or the values?
[00:41:26] ecuanaso: has joined #ruby
[00:42:00] xco: the parameters
[00:42:44] zenspider: this sounds dangerous and/or ill-conceived.
[00:43:45] xco: zenspider: any advice?
[00:43:57] xco: maybe what to do instead?
[00:51:48] quazimodo: has joined #ruby
[00:53:34] haylon: has joined #ruby
[00:54:30] ecuanaso: has joined #ruby
[00:55:26] apparition: has joined #ruby
[00:57:21] mostlybadfly: has joined #ruby
[00:58:51] charliesome: has joined #ruby
[00:59:31] bmurt: has joined #ruby
[01:01:48] mikeiniowa: has joined #ruby
[01:05:11] juggler: has joined #ruby
[01:11:41] GodFather_: has joined #ruby
[01:13:46] SilentNinja1: has joined #ruby
[01:14:27] SilentNinja1: Hi, Is there a liner to conver local time to UTC? Maybe DateTime.current.utc ?
[01:15:07] gusrub: has joined #ruby
[01:16:51] SilentNinja1: a liner to convert I mean. Thanks
[01:17:13] SilentNinja1: one liner, doh!
[01:17:18] dc2: has joined #ruby
[01:20:06] havenwood: >> require 'date'; Time.now.utc.to_datetime.zone # SilentNinja1
[01:20:07] ruby[bot]: havenwood: # => "+00:00" (https://eval.in/809880)
[01:20:22] havenwood: SilentNinja1: Or if you're using #current, you're in Rails or at least have ActiveSupport?
[01:21:25] havenwood: SilentNinja1: In which case you can: DateTime.current.utc
[01:21:31] cyphase: has joined #ruby
[01:21:43] havenwood: SilentNinja1: Use the Rails console to test it: rails c
[01:21:47] havenwood: ?rails SilentNinja1
[01:21:47] ruby[bot]: SilentNinja1: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[01:22:45] xco: is there another way to write this [] << “hello” ?
[01:22:54] havenwood: xco: ["hello"]
[01:23:13] xco: any other way?
[01:23:33] havenwood: xco: Many, why do you ask?
[01:24:10] hosttor: has joined #ruby
[01:24:13] xco: not important, tired of writing [] << “hello” and [“hello”] just curious if there are more i don’t know
[01:24:42] havenwood: xco: %w[hello]
[01:24:58] havenwood: >> %w[hello]
[01:24:59] ruby[bot]: havenwood: # => ["hello"] (https://eval.in/809881)
[01:25:00] charliesome: has joined #ruby
[01:25:09] Cohedrin: has joined #ruby
[01:25:18] xco: thanks :)
[01:25:42] havenwood: xco: you're welcome
[01:26:37] havenwood: xco: You might find this quickref handy: https://zenspider.com/ruby/quickref.html#arrays
[01:27:14] xco: will come in handy
[01:30:18] bruce_lee: has joined #ruby
[01:30:19] bruce_lee: has joined #ruby
[01:37:56] mmasaki: has joined #ruby
[01:38:09] ecuanaso: has joined #ruby
[01:38:52] d^sh: has joined #ruby
[01:41:30] bokayio: has joined #ruby
[01:41:48] wingbibbit: has joined #ruby
[01:42:41] wingbibbit: Question: I have an array of hashes. Each hash has the elements "first_name", "last_name", and "email". I'm attempting to identify duplicates in the array.
[01:43:17] wingbibbit: I was planning on iterating through the array, searching the reset of the array to see if first_name last_name and email of the current index match any other indexes and if so, how many
[01:44:46] wingbibbit: I should also state that each hash also has the element "id", which will be different every time, so I need to go through each array index and A) find any duplicates, where first_name last_name and email of the current index matches any others, and if so print off the ids of each matching element.
[01:45:01] wingbibbit: Does anyone have any thoughts on the best way to approach such an issue?
[01:45:38] wingbibbit: reset == rest*
[01:55:07] gizmore|2: has joined #ruby
[02:02:48] kegster: has joined #ruby
[02:16:56] PaulCapestany: has joined #ruby
[02:18:20] dc2: has joined #ruby
[02:20:25] genpaku: has joined #ruby
[02:21:02] Jameser: has joined #ruby
[02:23:16] bmurt: has joined #ruby
[02:24:26] bkulbida: has joined #ruby
[02:26:29] __Yiota: has joined #ruby
[02:26:47] uZiel: has joined #ruby
[02:28:08] bkulbida: has joined #ruby
[02:30:17] mim1k: has joined #ruby
[02:34:56] chaugiang: has joined #ruby
[02:36:29] chaugiang: has left #ruby: ()
[02:38:23] __Yiota: has joined #ruby
[02:42:19] N0ATN: has joined #ruby
[02:44:50] nickjj_: has joined #ruby
[02:46:17] luckyruby: has joined #ruby
[02:47:39] workmad3: has joined #ruby
[02:48:25] luckyruby: has joined #ruby
[02:58:39] Cohedrin: has joined #ruby
[03:02:40] iamayam: has joined #ruby
[03:03:39] Cohedrin: has joined #ruby
[03:11:22] uZiel: has joined #ruby
[03:15:44] xall: has joined #ruby
[03:17:57] JoshS: has joined #ruby
[03:21:45] chaugiang: has joined #ruby
[03:32:26] gix: has joined #ruby
[03:32:51] mim1k: has joined #ruby
[03:33:07] P1ro: has joined #ruby
[03:39:26] cajone: has joined #ruby
[03:41:45] uZiel: has joined #ruby
[03:48:46] mim1k: has joined #ruby
[03:50:31] luckyruby: has joined #ruby
[03:57:49] nicesignal: has joined #ruby
[03:58:05] Kneecaps: has joined #ruby
[04:01:10] username: has joined #ruby
[04:06:24] gnufied: has joined #ruby
[04:06:51] taurgal: has joined #ruby
[04:08:13] raul782: has joined #ruby
[04:08:42] kies: has joined #ruby
[04:09:47] mim1k: has joined #ruby
[04:18:13] _whitelogger: has joined #ruby
[04:18:18] bambanx: has joined #ruby
[04:18:29] tvw: has joined #ruby
[04:20:16] dc4: has joined #ruby
[04:22:06] chaugiang: has joined #ruby
[04:22:10] ascarter: has joined #ruby
[04:27:33] pankaj: has joined #ruby
[04:29:01] horst: has joined #ruby
[04:29:13] Jameser: has joined #ruby
[04:32:16] ascarter: has joined #ruby
[04:37:10] renchan: has joined #ruby
[04:39:41] patarr: has joined #ruby
[04:47:32] cschneid_: has joined #ruby
[04:49:21] MasterAsia: has joined #ruby
[04:49:31] MasterAsia: How is Array#dig implemented?
[04:53:59] haylon: has joined #ruby
[04:55:07] Mortomes|Train: has joined #ruby
[04:59:52] Cohedrin: has joined #ruby
[05:00:12] johnzorn: has joined #ruby
[05:05:57] burgestrand: has joined #ruby
[05:12:32] raul7821: has joined #ruby
[05:15:17] rohitpaulk: has joined #ruby
[05:16:41] Bock: has joined #ruby
[05:16:56] nofxxxx: has joined #ruby
[05:17:51] chaugiang: has left #ruby: ()
[05:18:30] rgr: has joined #ruby
[05:20:04] Kneecaps: has left #ruby: ()
[05:21:00] dc4: has joined #ruby
[05:21:56] nofxxxx: masterasia, hover your mouse over a method on rdoc, "expand something" will appear, click to show source
[05:23:05] anisha: has joined #ruby
[05:24:39] username: has joined #ruby
[05:30:21] kmhn: has joined #ruby
[05:31:04] devyn: has joined #ruby
[05:31:52] aupadhye: has joined #ruby
[05:34:06] Cohedrin: has joined #ruby
[05:38:57] rohitpaulk: has joined #ruby
[05:39:45] segmond: has joined #ruby
[05:42:44] Jameser: has joined #ruby
[05:45:42] spectra: has joined #ruby
[05:49:51] aupadhye: has joined #ruby
[05:50:54] mtkd: has joined #ruby
[05:51:58] luckyruby: has joined #ruby
[05:54:46] aufi: has joined #ruby
[05:56:12] agent_white: has joined #ruby
[05:58:50] burgestrand: has joined #ruby
[06:01:29] nanoz: has joined #ruby
[06:03:12] Silthias: has joined #ruby
[06:04:46] opencw: has joined #ruby
[06:04:52] dc4: has joined #ruby
[06:07:26] mtkd: has joined #ruby
[06:10:42] spectra: has joined #ruby
[06:12:25] rohitpaulk: has joined #ruby
[06:12:29] quazimodo: has joined #ruby
[06:14:11] ^mtkd: has joined #ruby
[06:18:03] KeyJoo: has joined #ruby
[06:20:01] roshanavand: has joined #ruby
[06:22:22] Mortomes|Work: has joined #ruby
[06:26:23] aurelien: has joined #ruby
[06:38:17] andikr: has joined #ruby
[06:40:41] patarr: has joined #ruby
[06:41:12] argonostrum: has joined #ruby
[06:41:36] argonostrum: has left #ruby: ()
[06:43:53] roshanavand: has left #ruby: ()
[06:45:52] conta: has joined #ruby
[06:46:20] kies: has joined #ruby
[06:46:31] cfec0b8d: has joined #ruby
[06:56:56] SesMan: has joined #ruby
[06:58:27] ascarter: has joined #ruby
[06:59:51] ltem: has joined #ruby
[07:04:29] vali: has joined #ruby
[07:06:20] workmad3_: has joined #ruby
[07:08:21] normie1: has joined #ruby
[07:08:28] jenrzzz: has joined #ruby
[07:08:29] jenrzzz: has joined #ruby
[07:10:36] jgnagy: has joined #ruby
[07:12:34] jgt2: has joined #ruby
[07:12:55] xall: has joined #ruby
[07:13:39] TomyWork: has joined #ruby
[07:13:45] Rich_Morin_: has joined #ruby
[07:15:20] burgestrand: has joined #ruby
[07:16:33] jaruga________: has joined #ruby
[07:17:24] im0nde: has joined #ruby
[07:20:52] bkxd: has joined #ruby
[07:29:39] flying: has joined #ruby
[07:38:51] Silthias: has joined #ruby
[07:43:41] charliesome: has joined #ruby
[07:44:50] burgestrand: has joined #ruby
[07:45:33] vondruch: has joined #ruby
[07:46:46] roshanavand1: has joined #ruby
[07:49:48] oskurot: has joined #ruby
[07:53:29] luckyruby: has joined #ruby
[07:56:36] charliesome: has joined #ruby
[07:59:08] jenrzzz: has joined #ruby
[08:02:18] bkxd: has joined #ruby
[08:06:53] Ryzokuken: has joined #ruby
[08:08:18] yottanami: has joined #ruby
[08:08:49] mikecmpbll: has joined #ruby
[08:11:25] jusa: has joined #ruby
[08:12:05] bkxd_: has joined #ruby
[08:14:00] yottanami: I am using Minitest here is my test https://gist.github.com/yottanami/dee6c21512350b8aba5b4b76ab9c2cf0
[08:14:42] yottanami: But I have problem with `before do` and I get this error ``<class:CheckoutTest>': undefined method `before' for CheckoutTest:Class (NoMethodError)`
[08:16:57] elomatreb: Does Minitest even offer that? IIRC you define a `setup` method instead
[08:18:33] latemus: has left #ruby: ()
[08:22:23] zenspider: yottanami: looking...
[08:22:26] Mia: has joined #ruby
[08:22:27] Mia: has joined #ruby
[08:22:36] zenspider: yottanami: correct. before is either for minitest/spec or (probably?) for rails extended minitest
[08:22:43] zenspider: def setup instead
[08:23:26] zenspider: or switch from class CheckoutTest to describe Checkout do
[08:23:43] zenspider: (you can keep the test methods and assertions ... mix and match)
[08:24:24] Cohedrin: has joined #ruby
[08:24:51] yottanami: zenspider, elomatreb tnx, anyway what do you thing about my tests? Are they wrote in a good way? https://gist.github.com/yottanami/dee6c21512350b8aba5b4b76ab9c2cf0
[08:26:05] zenspider: your assert_equal lines are backwards. expected first
[08:26:28] zenspider: and don't use assert_equal for floats
[08:26:45] zenspider: (never use any equality with floats, except zero)
[08:28:01] zenspider: you shouldn't use floats for money anyhow. use integers (hundreds of cents) or BigDecimal
[08:31:26] rohitpaulk: has joined #ruby
[08:32:05] brent__: has joined #ruby
[08:32:29] elomatreb: yottanami: You're repeating that product setup/adding to basket a little, maybe move that to a method
[08:35:08] elomatreb: And I doubt line 31 will do what you want
[08:37:01] dionysus69: has joined #ruby
[08:40:50] MarkBilk: has joined #ruby
[08:41:10] tvw: has joined #ruby
[08:41:31] patarr: has joined #ruby
[08:42:25] yogg-saron: has joined #ruby
[08:43:31] bkxd: has joined #ruby
[08:43:44] roshanavand: has joined #ruby
[08:48:29] Silthias: has joined #ruby
[08:49:36] jane_booty_doe: has joined #ruby
[08:50:34] milardovich: has joined #ruby
[08:50:42] Beams: has joined #ruby
[08:51:14] zenspider: elomatreb: it will if yottanami implements it that way, no?
[08:53:43] elomatreb: Oh, right, I didn't read the test name. I just never saw anyone override >> so I assumed it was a typo
[08:53:55] tomphp: has joined #ruby
[08:54:26] haylon: has joined #ruby
[08:55:09] luckyruby: has joined #ruby
[08:56:29] herwin: then it still looks like you have to add the product before removing it
[08:56:56] herwin: "def >>; end" would pass this test too
[08:59:07] zenspider: herwin: good catch. true. it needs to be set up right. unfortunately... I think we're speaking to ourselves.
[08:59:11] zenspider: yottanami: ??
[08:59:16] mim1k: has joined #ruby
[09:01:04] herwin: so we're rubberducking someone else's problems? :)
[09:01:24] elomatreb: #ruby consulting, we'll mail the invoice
[09:04:14] zenspider: pretty much... I love it when people ask something and don't bother with the answer...
[09:05:44] lxsameer: has joined #ruby
[09:06:12] ltp: has joined #ruby
[09:06:45] Axy: has joined #ruby
[09:06:45] Axy: has joined #ruby
[09:08:32] rgr: has joined #ruby
[09:08:55] romank: has joined #ruby
[09:16:33] pandaant: has joined #ruby
[09:17:17] Fernando-Basso: has joined #ruby
[09:18:52] Polysics: has joined #ruby
[09:19:01] marr: has joined #ruby
[09:19:47] Polysics_: has joined #ruby
[09:21:14] conta: guys, so I had some classes (in many files, using each other) in Rails app, and all was loaded by Rails magic. Now I am moving it out and running it inside sinatra. Do I have to require files in classes that use them, or is there another way?
[09:23:53] oded: has joined #ruby
[09:24:32] bkxd: has joined #ruby
[09:26:30] zenspider: conta: yes, you need to require them. load them one at a time and fix the problems that come up
[09:26:48] mim1k: has joined #ruby
[09:27:04] zenspider: each file should require everything it needs to do its job, so walk the dependency chain down and fix from the bottom up
[09:27:34] conta: zenspider: ok, many thanks
[09:27:36] biberu: has joined #ruby
[09:27:40] zenspider: also, please don't assume everyone in here is a guy.
[09:28:30] conta: guys is gender neutral, or not? at least that's what people used in US, when I was there
[09:29:08] zenspider: we're on the internet... the whole world, not just in the US
[09:29:16] ytti: it is generaly considered gender neutral, but some peeps really want to be offended
[09:29:27] zenspider: but no, guys isn't necessarily gender neutral
[09:29:27] ytti: so depending on company, you may need to be more conservative with communication
[09:29:29] burgestrand: has joined #ruby
[09:29:33] zenspider: ytti: shut it
[09:31:30] yottanami: zenspider, What do you mean by `assert_equal lines are backwards`?
[09:31:53] yottanami: zenspider, and what should I use for floats checking?
[09:31:59] zenspider: yottanami: you were writing assert_equal(actual, expected) and need to write assert_equal(expected, actual)
[09:32:15] zenspider: doesn't matter if they pass, obviously... but the error message will be backwards if it fails
[09:32:27] zenspider: for floats: assert_in_delta or assert_in_epsilon
[09:32:50] zenspider: the latter is nice because it auto-scales
[09:33:11] zenspider: http://docs.seattlerb.org/minitest/Minitest/Assertions.html
[09:35:13] Truenigma_Work: has joined #ruby
[09:36:39] yottanami: zenspider, and how should I force it use BigDecimal?
[09:37:42] mikecmpbll: ACTION always thought that assert_equal is backwards :d
[09:40:05] zenspider: mikecmpbll: luckily, nobody asked you
[09:40:31] zenspider: yottanami: Depends on your code... you can convert them as the numbers come in
[09:40:32] mikecmpbll: i think that's a great shame!
[09:40:45] ljarvis: i never remember the order
[09:41:00] zenspider: mikecmpbll: yeah. if only Ward Cunningham and Kent Beck asked your opinion back in the 90s
[09:41:16] gil_: has joined #ruby
[09:41:16] gil_: has joined #ruby
[09:41:20] mikecmpbll: exactly, minitest would be greater, and life would be more marvellous.
[09:41:28] zenspider: ljarvis: must be hard to do your job
[09:41:38] nanoz]: has joined #ruby
[09:41:45] ljarvis: zenspider: are you having a nice evening?
[09:42:51] zenspider: A fine evening... and I just love it when the peanut gallery offer up their gracious opinions
[09:43:05] ljarvis: what's a peanut gallery?
[09:43:10] zenspider: mikecmpbll: obviously. much more marvellous
[09:43:34] nofxxxx: has joined #ruby
[09:43:55] herwin: I got really confused by a failing test in perl yesterday, because I used the ruby ordering of expected and actual
[09:44:24] herwin: and perl used is(actual, expected
[09:44:34] herwin: (more precisely: the test module I used)
[09:44:51] mim1k: has joined #ruby
[09:45:06] zenspider: hopefully they closed the parens. :P
[09:45:07] herwin: if only everything was always in sync
[09:45:24] elomatreb: expect(a).to eq b
[09:45:25] elomatreb: ACTION hides
[09:46:22] zenspider: elomatreb: my favorite is that they had to add the expect(x) form to quell warnings and for some reason they didn't call it assert.
[09:47:23] ljarvis: still, better than should. I always hated that, "should" is an awful way to describe behaviour
[09:47:33] elomatreb: I like the expectation terminology, but I'm biased because I first got into testing with RSpec
[09:47:41] ljarvis: may has well just used maybe
[09:47:50] zenspider: totally agree. I write rfc_spec as a joke and the `should` form always passed
[09:48:25] mikecmpbll: herwin : they know what they're doing those perl folks
[09:49:50] yottanami: elomatreb, How can I improve line 31?
[09:49:50] roshanavand: has joined #ruby
[09:50:05] elomatreb: Nevermind that, I was just confused
[09:50:29] elomatreb: Using >> is fairly uncommon, but if it makes sense it's perfectly fine
[09:52:01] rohitpaulk: has joined #ruby
[09:52:10] ddffg: has joined #ruby
[09:58:08] zenspider: yottanami: you improve that test by first ensuring that there is something to take out... otherwise you verified the absense of nothing
[09:59:40] tomphp: has joined #ruby
[10:01:29] belmoussaoui: has joined #ruby
[10:02:58] ferr1: has joined #ruby
[10:03:36] tvw: has joined #ruby
[10:05:35] qba73: has joined #ruby
[10:06:50] nowhere_man: has joined #ruby
[10:09:42] chaugiang: has joined #ruby
[10:09:56] chaugiang: has left #ruby: ()
[10:10:25] bkxd: has joined #ruby
[10:11:43] zenspider: man... you want to talk backwards... Module methods... that's backwards. so fucked up.
[10:14:02] yottanami: has joined #ruby
[10:17:05] Drakevr: has joined #ruby
[10:20:57] Mortomes|Train: has joined #ruby
[10:21:36] DrCode: has joined #ruby
[10:22:15] jinie: has joined #ruby
[10:24:38] jinie: has joined #ruby
[10:25:10] uZiel: has joined #ruby
[10:26:32] FedorEmelianenko: has joined #ruby
[10:27:31] Mon_Ouie: has joined #ruby
[10:30:38] Mon_Ouie: Please use the channel to ask questions instead of using private messages
[10:31:09] Mon_Ouie: I'm not particularly familiar with RSpec, but you can ask a more specific question here, maybe someone will be able to answer then
[10:31:36] FedorEmelianenko: My question is more broad
[10:31:52] FedorEmelianenko: has left #ruby: ()
[10:33:42] luckyruby: has joined #ruby
[10:35:24] pwnd_nsfw`: has joined #ruby
[10:42:24] patarr: has joined #ruby
[10:42:42] silverdust: has joined #ruby
[10:46:26] xall: has joined #ruby
[10:50:12] burgestrand: has joined #ruby
[10:52:23] bkxd: has joined #ruby
[11:00:52] brent__: has joined #ruby
[11:02:00] KnownSyntax: has joined #ruby
[11:03:05] patarr: has joined #ruby
[11:03:59] chaugiang: has joined #ruby
[11:11:33] yogg-saron: has joined #ruby
[11:12:18] jgnagy: has joined #ruby
[11:13:09] chaugiang: has left #ruby: ()
[11:14:23] bambanx: has joined #ruby
[11:14:39] GodFather_: has joined #ruby
[11:15:13] mim1k: has joined #ruby
[11:21:27] Burgestr_: has joined #ruby
[11:22:43] ij: has joined #ruby
[11:22:50] ij: "#{ foobar }" or "#{foobar}"?
[11:22:54] quazimodo: has joined #ruby
[11:23:18] elomatreb: The former is the style advocated by most popular styleguides
[11:23:43] ij: former is the left, right?
[11:24:39] ij: Thing is: I don't write ruby for work for two years and I remember doing "#{ foobar }". I started an argument about this with a fresh rubyist and airbnb/ruby guide suggests "#{foobar}".
[11:24:41] ij: I feel very had.
[11:26:25] elomatreb: lol, I'm tired
[11:26:35] elomatreb: The *latter* (the right one) is the one I meant
[11:27:37] elomatreb: E.g. https://github.com/bbatsov/ruby-style-guide#spaces-braces
[11:27:43] chouhoulis: has joined #ruby
[11:27:57] elomatreb: But if you prefer to have the spaces you're certainly free to do so
[11:29:59] minimalism: has joined #ruby
[11:31:44] bkxd_: has joined #ruby
[11:38:06] minimalism: has joined #ruby
[11:50:35] vince`: has joined #ruby
[11:53:10] bmurt: has joined #ruby
[11:56:32] chouhoulis: has joined #ruby
[11:56:58] ldnunes: has joined #ruby
[11:59:43] mradmacher: has joined #ruby
[12:00:21] zapata: has joined #ruby
[12:05:54] HoierM: has joined #ruby
[12:07:38] synthroid: has joined #ruby
[12:11:46] bkxd: has joined #ruby
[12:13:03] milardovich: has joined #ruby
[12:16:21] synthroid: has joined #ruby
[12:19:43] synthroid: has joined #ruby
[12:19:59] bruce_lee: has joined #ruby
[12:23:35] xall: has joined #ruby
[12:23:37] dminuoso: ij: airbnb has quite sensible conventions I find.
[12:26:15] dionysus69: has joined #ruby
[12:28:10] im0nde: has joined #ruby
[12:29:08] dminuoso: Except the "avoid return" -> Ive started using it everywhere.
[12:29:18] dminuoso: But I find that Im fairly alone with that one.
[12:36:04] mtkd: has joined #ruby
[12:36:56] newcoder: has joined #ruby
[12:37:15] newcoder: Hi, where is ruby mostly used?
[12:38:18] Burgestr_: Knee jerk reaction: web, security research, devops/systems scripting
[12:38:54] newcoder: Which gui tool should we use with ruby to make desktop app?
[12:40:06] edgr: has joined #ruby
[12:40:32] im0nde: has joined #ruby
[12:41:48] Jameser: has joined #ruby
[12:43:51] mim1k: has joined #ruby
[12:44:25] centrx: has joined #ruby
[12:44:25] centrx: has joined #ruby
[12:46:35] gnufied: has joined #ruby
[12:51:07] dminuoso: newcoder: none.
[12:51:15] mim1k_: has joined #ruby
[12:51:39] dminuoso: newcoder: The ecosystem has barely any usable parts for graphical interfaces
[12:54:03] Alina-malina: has joined #ruby
[12:55:48] bweston92: has joined #ruby
[12:56:20] Alina-malina: has joined #ruby
[12:56:49] chouhoulis: has joined #ruby
[13:01:01] chichou: has joined #ruby
[13:02:03] Jameser: has joined #ruby
[13:02:11] valentin: has joined #ruby
[13:02:40] newcoder: Why isn't ruby good for graphical interface?
[13:04:27] dminuoso: newcoder: Because the ecosystem has barely any usable parts for graphical interfaces.
[13:04:40] dminuoso: It has nothing to do with the language, there just isn't much tooling or libraries around for it.
[13:04:54] dminuoso: Those libraries that are around, are kind of outdated or very rudimentary.
[13:05:04] newcoder: Why can't ruby use external gui library like qt?
[13:05:18] mikecmpb_: has joined #ruby
[13:06:37] konsolebox: newcoder: someone has to develop and maintain the bindings to any gui tool/library.
[13:08:09] elomatreb: You can if you really want, it's just not very much fun
[13:09:19] dminuoso: newcoder: It's a devils circle. Because there's no tooling nobody uses it. Because nobody uses it, few people help maintain the qt bindings (they exist but are fairly outdated)
[13:09:30] dminuoso: Because they are badly maintained, nobody uses it.
[13:09:56] dminuoso: Leaving projects to die, bringing us back to the beginning.
[13:10:29] dminuoso: It's too complex of a topic to just "do it by yourself" like with most ruby gems. It needs a team of people.
[13:14:27] haylon: has joined #ruby
[13:15:09] elomatreb: The only scripting languages I can think of that have a reputation for GUI are Python because they do have working bindings and people use them and Javascript through the mess that is Electron
[13:15:44] newcoder: elomatreb: Javascript has gui bindings too?
[13:15:53] uZiel: has joined #ruby
[13:15:59] sonOfRa: newcoder: it does if you bundle a web browser with every application you write!
[13:16:12] elomatreb: "the mess that is Electron" ;)
[13:18:20] mim1k: has joined #ruby
[13:19:55] pupsicle: has joined #ruby
[13:20:05] oleo: has joined #ruby
[13:22:47] rippa: has joined #ruby
[13:23:39] dminuoso: Electron is great.
[13:23:51] dminuoso: I have enough CPUs to take the 17% CPU hit when my cursor is blinking.
[13:24:01] ljarvis: electron keeps my office warm
[13:24:50] mikecmpbll: has joined #ruby
[13:28:30] dminuoso: newcoder: When we did our GUI we developed it natively in Qt with C++, and connected it with CORBA back then.
[13:29:21] dminuoso: (More modern options are using miniruby or something like 0mq)
[13:29:22] newcoder: What is CORBA?
[13:29:31] dminuoso: Something you dont want to use in this day and age.
[13:29:43] gnufied: has joined #ruby
[13:30:05] belmoussaoui__: has joined #ruby
[13:30:17] dminuoso: newcoder: 0mq is a far more elegant approach, if we did it again we'd be using that.
[13:30:56] newcoder: dminuoso: Then why CORBA?
[13:31:06] dminuoso: newcoder: Because CORBA was cool stuff 10 years ago.
[13:31:20] dminuoso: Well. 20 actually.
[13:31:41] mikecmpbll: has joined #ruby
[13:34:13] yogg-saron: has joined #ruby
[13:36:12] milardovich: has joined #ruby
[13:37:33] dminuoso: Also because its a really fat standard established in old industries that get all the gray beards excited.
[13:44:25] yottanami: I am trying to use `assert_includes` to check an array contains a item but I get this error: `Expected #<Checkout::Product:0x0055c440123748 @code="004", @name="Glasses", @price=0.11109999999999999431565811391919851303e2> (Checkout::Product) to respond to #include?.`
[13:44:32] yottanami: Here is my Test https://gist.github.com/yottanami/becc2f38fb5b0eaf342e7d0dabb7e993
[13:44:50] ljarvis: yottanami: you have the args the wrong way around
[13:44:55] newcoder: dminuoso: Why do we need CORBA with qt?
[13:48:10] mikecmpbll: has joined #ruby
[13:50:57] __Yiota: has joined #ruby
[13:51:07] Frem: has joined #ruby
[13:52:44] arup_r: has joined #ruby
[13:52:57] burgestrand: has joined #ruby
[13:54:22] dminuoso: newcoder: You dont _need_ it, but that's how we handled having a GUI done properly together with Ruby components
[13:54:51] dminuoso: As well as connecting it with a 3d scenegraph
[13:55:08] arup_r: Getting error while parsing an YAML "did not find expected key while parsing a block mapping at line 23 column 9" can you help what is wrong https://gist.github.com/aruprakshit/ff3bb4591e8a4836a51aa604bea5ab42 ?
[13:55:53] MarkBilk: Does QtRuby work at all? In MSWindows?
[13:56:03] rickumali: has joined #ruby
[13:56:38] __Yiota: has joined #ruby
[13:57:22] dminuoso: arup_r: Your lines 25/26/27 are messed up
[13:57:33] newcoder: has left #ruby: ()
[13:57:35] dminuoso: arup_r: I think this is still a bug because the diagnostic shows the wrong line.
[13:58:07] arup_r: dminuoso: thank you mate
[13:58:13] dminuoso: Or Im not sure whether it is.
[13:58:21] dminuoso: arup_r: Next time do a simple binary search.
[13:58:26] dminuoso: Its what I did.
[13:58:26] arup_r: yes I was looking at the line number in error message, and didn't see anything wrong
[13:58:37] dminuoso: Make a testcase next time
[13:58:42] vondruch: has joined #ruby
[13:58:47] arup_r: dminuoso: binary search? Can u teach me the trick?
[13:59:07] dminuoso: arup_r: in this case I just deleted half the file, see if the problem remained
[13:59:39] dminuoso: arup_r: It's literally the application of this: https://en.wikipedia.org/wiki/Binary_search_algorithm
[13:59:51] dminuoso: Lets you debug code in O(log n)
[14:00:08] arup_r: I know BST. I didn't get how u applied it on yml file so fast..
[14:00:16] dminuoso: arup_r: Im a speedy bastard.
[14:00:22] arup_r: seems so!
[14:00:25] arup_r: again thanks
[14:00:43] arup_r: i was stuck in the error message line.. haha..
[14:01:02] dminuoso: arup_r: Well I first analyzed the code points of that line of code
[14:01:09] dminuoso: Since they were all ASCII compatible, it must have been unrelated
[14:01:24] dminuoso: arup_r: Though I know now that it means, that the problem is in the subtree of that line of code.
[14:01:29] jshjsh: has joined #ruby
[14:01:48] dminuoso: All of that in 2 minutes. :S
[14:01:51] haylon: has joined #ruby
[14:02:02] dminuoso: That and copy + pasting, saving and writing ruby code to do this.
[14:03:13] vondruch: has joined #ruby
[14:03:23] arup_r: You are Pro in programming!! The way you are analyzing I am far behind of you! 😂
[14:05:46] ljarvis: dminuoso is the best
[14:05:58] cadillac_: has joined #ruby
[14:06:04] mikecmpbll: has joined #ruby
[14:06:57] dminuoso: I work in short burts. 10 commits in one hour, then 3 hours of playing pinball, then another 10 commits in an hour. Except I usually skip the pinball part.
[14:07:14] dminuoso: That may or may not be an exaggeration.
[14:07:51] kKzs: has joined #ruby
[14:10:04] chouhoulis: has joined #ruby
[14:10:06] yogg-saron: has joined #ruby
[14:11:26] brent__: has joined #ruby
[14:12:15] romank: has joined #ruby
[14:14:53] __Yiota: has joined #ruby
[14:15:33] hutch34: has joined #ruby
[14:15:36] somerandomteen: has joined #ruby
[14:15:41] luckyruby: has joined #ruby
[14:16:16] GinoMan: has joined #ruby
[14:17:13] mikecmpbll: has joined #ruby
[14:22:52] LastWhisper____: has joined #ruby
[14:23:27] cschneid_: has joined #ruby
[14:26:43] mim1k: has joined #ruby
[14:27:01] Cohedrin: has joined #ruby
[14:27:14] LyndsySimon: I keep having issues with RVM. Is there a comparable tool out there I could use?
[14:29:22] rickumali: LyndsySimon: rbenv
[14:29:32] LyndsySimon: rickumali: Would you recommend it?
[14:29:35] havenwood: LyndsySimon: Or chruby
[14:29:39] ljarvis: chruby > *
[14:30:00] rickumali: LyndsySimon: I recommend it, yes
[14:30:10] rickumali: i've not heard of chruby, but it's good to know
[14:30:17] rickumali: there are alternatives
[14:30:17] LyndsySimon: Reading their doc looks very promisign.
[14:30:23] sepp2k: has joined #ruby
[14:30:29] LyndsySimon: I had no idea that RVM was overriding cd. That's insane.
[14:32:17] phreakocious: I would like to use this gem that normally writes to stdout, but have the output go into a variable. It offers the ability to swap out the file descriptor, but that seems sloppy (if it's even possible). Any thoughts? https://github.com/arches/table_print
[14:34:17] ljarvis: phreakocious: what do you mean "it has the ability" and then "if it's even possible" -- does it have the ability to swap out the file descriptor?
[14:34:22] fmcgeough: has joined #ruby
[14:34:40] phreakocious: if it's even possible to collect the output of a swapped out file descriptor into a variable, is what I meant.
[14:34:56] havenwood: phreakocious: consider using StringIO
[14:35:18] phreakocious: beautiful, I'll look into it. thanks :)
[14:35:24] havenwood: phreakocious: https://ruby-doc.org/stdlib/libdoc/stringio/rdoc/StringIO.html
[14:36:02] ljarvis: >> require "stringio"; str = StringIO.new; $stdout = str; puts "omg"; $stdout = STDOUT; puts "cheese"; puts str.value
[14:36:09] ruby[bot]: ljarvis: I'm terribly sorry, I could not evaluate your code because of an error: OpenURI::HTTPError:500 Internal Server Error
[14:36:21] jamesaxl: has joined #ruby
[14:36:34] phreakocious: thanks again, havenwood and ljarvis
[14:36:51] c0defist2000: has joined #ruby
[14:38:01] c0defist2000: my #<ActionDispatch::Cookies::CookieJar:0x00000004312960> does not contain the cookies from my "session that initiated the websocket"
[14:38:16] ResidentBiscuit: has joined #ruby
[14:38:28] c0defist2000: anyone have any idea why my cookies in my actioncable connection are empty
[14:38:36] c0defist2000: (only in production)
[14:38:47] u0_a190: has joined #ruby
[14:39:21] c0defist2000: seems many people have had the same problem with missing cookies from the actioncable connection, but no real answer..
[14:39:44] Jameser: has joined #ruby
[14:39:50] u0_a190: a do anyone know whats the msfconsole irc channel name
[14:39:56] t-recx: has joined #ruby
[14:40:04] phreakocious: worked like a champ, despite being a little hard on the eyes :D
[14:40:11] shinnya: has joined #ruby
[14:40:20] havenwood: ?rails c0defist2000
[14:40:21] ruby[bot]: c0defist2000: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[14:40:26] havenwood: ?metasploit u0_a190
[14:40:27] ruby[bot]: u0_a190: Please join #metasploit for help with it.
[14:40:41] c0defist2000: havenwood, rails/actioncable yes, sorry
[14:40:57] c0defist2000: ill try #rails, derp
[14:41:07] mtkd: has joined #ruby
[14:41:36] havenwood: c0defist2000: I've not run into that particular issue with ActionCable. Yeah, #rubyonrails is a good bet. The channel should get active here soon.
[14:44:11] mikecmpbll: has joined #ruby
[14:44:38] mwlang: has joined #ruby
[14:46:31] bkxd: has joined #ruby
[14:49:09] LyndsySimon: rickumali: I hate to be a pain, but I'm setting up rbenv and am not seeing what I need in their docs.
[14:49:11] SeepingN: has joined #ruby
[14:49:29] LyndsySimon: rickumali: In particular, I'm not seeing an analogue to rvm's gemsets.
[14:49:47] rickumali: that's beyond what I know, LyndsySimon
[14:49:48] ljarvis: rvm gemsets are unique
[14:50:01] ljarvis: you wont get them from chruby or rbenv (and you don't need them)
[14:50:06] Jameser: has joined #ruby
[14:50:15] rickumali: ljarvis: bundle?
[14:50:15] ljarvis: i think rbenv and chruby has extra plugins for adding this functionality fwiw
[14:50:24] ljarvis: yeah, they're not the same thing though
[14:50:51] rickumali: ljarvis: i don't know rvm, but saw gemsets and thought: bundle
[14:50:59] ljarvis: imo most systems just install all of the gems in the same place per ruby version, so gemsets are a bit moot
[14:51:13] havenwood: rickumali: Some folk use gem_home with chruby but most just use Bundler: https://github.com/postmodern/gem_home#readme
[14:51:21] LyndsySimon: ljarvis: This is slightly beyond my knowledge at the moment. My background is in Python and I fully understand how virtualenvs work there. Does Ruby have a *need* for gemsets?
[14:51:41] ljarvis: LyndsySimon: nope, they're an rvm feature, not a ruby feature
[14:51:58] elomatreb: As soon as you're working with more than one project with different gem versions
[14:52:02] LyndsySimon: I'm working on projects that have Gemfiles created by bundler. I've just never used them outside of rvm
[14:52:04] havenwood: LyndsySimon: No. Now that Bundler is standard and RubyGems supports Gemfiles, they're not neccessary.
[14:52:32] LyndsySimon: havenwood: How does that reconcile with what elomatreb said? Can I have multiple versions of the same gem installed concurrently?
[14:52:47] elomatreb: Yes, bundler will make sure you require the correct one at runtime
[14:52:50] havenwood: LyndsySimon: You can have every version of every gem installed.
[14:53:18] havenwood: LyndsySimon: Your Gemfile.lock will contain the exact version of the gems your app uses.
[14:54:02] LyndsySimon: How does Bundler do that? If I call `rails console`, for instance, is the ruby interpreter that it's calling aware of the gemfiles and able to specific the gem versions that way?
[14:54:27] LyndsySimon: havenwood: Yep, I'm familiar with the file structure :) I just need to understand what it's doing so I can troubleshoot things.
[14:54:28] elomatreb: If you just call `rails console` bundler is not involved, you usually do `bundle exec rails console`
[14:54:31] havenwood: LyndsySimon: You prefix `bundle exec` to the command to limit gems to the exact versions.
[14:54:31] ljarvis: you'd use `bundle exec rails console` so it runs inside the bundler environment
[14:55:48] Jameser: has joined #ruby
[14:56:08] LyndsySimon: Ahh, OK. So with rvm, I don't have to prefix commands because it's shimming the shell commands. With rbenv, I have to use bundle's explicit management to do things in the "environment" (which in actuality is just Bundler loading and passing the specs from the gemfiles to Ruby before executing the commands I pass in)
[14:56:38] havenwood: LyndsySimon: With rbenv you have to rehash to create shims every time you install gems.
[14:56:43] havenwood: ?rbenv LyndsySimon
[14:56:43] ruby[bot]: LyndsySimon: Missing command under rbenv? Did you try `rbenv rehash`?
[14:56:57] Jameser: has joined #ruby
[14:57:12] ljarvis: one of the reasons chruby wins for me
[14:57:14] havenwood: LyndsySimon: rbenv creates shims to switch Rubies. chruby sets env vars correctly to switch Rubies
[14:57:19] LyndsySimon: Hmm. OK. I think I'm still missing a critical piece of information or two.
[14:57:49] elomatreb: I don't even have chruby on my machines anymore, and on the Arch-based ones not even ruby-install. Bundler just works
[14:58:04] mwlang: hmmm…did we lose ruby-toolbox.com or is it just me?
[14:58:16] havenwood: You don't need a Ruby version switcher if you're not switching between Ruby versions.
[14:58:25] jamesaxl: has joined #ruby
[14:58:29] havenwood: mwlang: seems down
[14:58:40] LyndsySimon: My system ruby is 2.4.1 (Installed via homebrew). My project's ruby is 2.3.1. I've installed it via rbenv. How do I use bundler now to install the gems from the gemfiles?
[14:58:46] havenwood: mwlang: In the meanwhile this is up: http://awesome-ruby.com/
[14:59:00] elomatreb: `bundle install` in the directory of the project
[14:59:06] mwlang: oh, I didn’t know about that one. thanks!
[14:59:07] havenwood: LyndsySimon: gem install bundler && bundle
[14:59:21] LyndsySimon: elomatreb: bundler replies that my ruby version is 2.4.1
[14:59:41] elomatreb: Does your Gemfile require a Ruby version?
[14:59:43] havenwood: LyndsySimon: then you're using Ruby 2.4.1 not Ruby 2.3.1
[14:59:43] LyndsySimon: Do I need to somehow "activate" the rbenv version?
[14:59:58] havenwood: LyndsySimon: I'd suggest chruby since it's much simpler. Did you rehash?
[15:00:03] havenwood: ?rbenv LyndsySimon
[15:00:03] ruby[bot]: LyndsySimon: Missing command under rbenv? Did you try `rbenv rehash`?
[15:00:04] LyndsySimon: Yes, my system ruby is 2.4.1. I've specified 2.3.1 in .ruby-version. rbenv installed it fine.
[15:00:15] LyndsySimon: I did rehash, but I'll do it again.
[15:00:19] pawandubey: has joined #ruby
[15:00:34] chalkmonster: has joined #ruby
[15:00:41] Jameser: has joined #ruby
[15:00:54] pawandubey: Hey guys, is there a good way to skip the minitest setup for just a single test case?
[15:02:29] LyndsySimon: Maybe this will help: I'm sharing my screen at this link: https://appear.in/how-to-ruby
[15:03:02] snockerton: has joined #ruby
[15:03:11] blackwind_123: has joined #ruby
[15:03:16] LyndsySimon: Oh! I think I figured it out.
[15:03:49] LyndsySimon: `ruby --version` is 2.3.1. Bundler says I'm using 2.4.1. That's because I have Bundler installed in my system ruby but not in the rbenv-controlled 2.3.1.
[15:03:54] mim1k_: has joined #ruby
[15:04:05] havenwood: LyndsySimon: gem install bundler && bundle
[15:04:06] LyndsySimon: There's a `bundle` command in my system ruby, but not one in my 2.3.1 environment, therefore it isn't shimmed.
[15:04:28] LyndsySimon: havenwood: Yeah, I'm in the process of doing just that.
[15:04:30] havenwood: LyndsySimon: or >.>: gem install bundler && rbenv rehash && bundle
[15:04:42] havenwood: Do you still have to do that?
[15:05:07] elomatreb: Throw some npm install in there for good measure
[15:05:37] LyndsySimon: havenwood: I see that, and now I understand exactly what `rbenv rehash` does.
[15:06:09] pupsicle: has joined #ruby
[15:06:13] LyndsySimon: You have to rehash not whenever a gem is installed, but whenever a gem is installed that includes executables you want to access from the shell.
[15:06:42] havenwood: LyndsySimon: If you ever get tired of rehashing chruby wil be waiting! ;-)
[15:06:53] rickumali: ACTION claps "Good stuff!"
[15:07:20] havenwood: LyndsySimon: If you can, bump your Gemfile to Ruby 2.3.4 (the latest stable release of 2.3).
[15:07:39] havenwood: LyndsySimon: It's just bug and security fixes since 2.3.1.
[15:08:19] LyndsySimon: havenwood: That's a good idea, but there are other changes happening concurrently (upgrading rails). Instead, I plan to lead a project to migrate the whole team from rvm.
[15:09:16] LyndsySimon: Somewhat annoyingly, rvm requires the ruby version right now to be 'ruby-2.3.1', while rbenv wants it to be '2.3.1'. That means there's going to have to be a point where we all move over at once :(
[15:09:38] havenwood: LyndsySimon: Switch to chruby.
[15:09:44] havenwood: LyndsySimon: It supports fuzzy matching.
[15:09:50] LyndsySimon: I'll look into chruby before making a recommendation.
[15:09:59] havenwood: LyndsySimon: Then they can both be: ruby-2.3.1
[15:10:22] im0nde: has joined #ruby
[15:10:34] LyndsySimon: I'm comfortable doing that now. I already more fully understand rbenv than I ever did rvm. I hate magic.
[15:10:52] valerauko: has joined #ruby
[15:10:57] havenwood: LyndsySimon: Here's an Ubuntu guide for example: http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you
[15:11:06] havenwood: LyndsySimon: Then you'll love chruby.
[15:11:06] somerandomteen: has joined #ruby
[15:11:12] LyndsySimon: havenwood: Cool, thanks :)
[15:11:37] havenwood: LyndsySimon: Or macOS: http://ryanbigg.com/2015/06/mac-os-x-ruby-ruby-install-chruby-and-you
[15:12:12] haylon: for the aws-sdk-ruby v2 Gem, is there any way to make the describe_stack_events() method show latest events at the bottom instead of at the top? Or shoudl I ask that in ##aws?
[15:12:23] LyndsySimon: Heh. While I'm on macOS, I'll read the linux version first. I'm a Linux user using macOS, so it's easier for me to grok that way.
[15:12:36] LyndsySimon: This has all been super helpful so far.
[15:13:42] jgnagy: has joined #ruby
[15:13:53] valerauko: Hey, i saw a bug on the ruby tracker that i think i could fix. Is there a contributor's 101 "guide" past the Patch Writer's Guide?
[15:16:27] valerauko: Should I just fix it as I see fit and then ask for feedback on the patch?
[15:17:55] LyndsySimon: valerauko: I can't speak for Ruby, but that's the approach I've taken in the past for other projects. Just be prepared for the PR to be rejected initially, and for the people who do so to be at least a bit gruff about it :)
[15:17:59] [Butch]: has joined #ruby
[15:18:56] valerauko: guess it's time to try my luck!
[15:19:28] LyndsySimon: Feel free to shoot me a message if you want a quick code review before submitting your PR, I'd be happy to.
[15:20:20] valerauko: Thanks, I might just do that!
[15:21:25] vali: has joined #ruby
[15:21:49] cdg: has joined #ruby
[15:22:19] jusa: has joined #ruby
[15:22:32] yottanami: How can change this code to use inject? `@products.each_with_object(Hash.new(0)) { |p, count| count[p.code] += 1 }
[15:22:32] yottanami: .keep_if { |_k, v| v >= 2 `
[15:23:19] elomatreb: You don't, each_with_object is exactly what you need there
[15:24:29] havenwood: yottanami: I'd just suggest `product` rather than `p` since it's more descriptive and there's already a Kernel#p taking `p`.
[15:25:03] Jameser: has joined #ruby
[15:25:38] cdg: has joined #ruby
[15:27:03] elomatreb: I like group_by, I'd probably do it like `@products.group_by(&:code).transform_values(&:length)`
[15:27:40] cardboard64: has joined #ruby
[15:28:17] havenwood: elomatreb: That's a nice solution.
[15:29:06] mwlang: I like the spirit! LyndsySimon and valerauko — I don’t think we do enough to encourage new contributors to existing projects.
[15:29:11] yottanami: elomatreb, Cool, Kind of magical solution
[15:29:59] elomatreb: #group_by is a really nice method, surprisngly often useful
[15:31:33] jamesaxl: has joined #ruby
[15:32:13] jgt2: has joined #ruby
[15:32:14] yottanami: elomatreb, I am not familiar with transform_values. should I set a condition for length >1 ?
[15:32:38] sagax: has joined #ruby
[15:32:52] elomatreb: Oh, you'd still need your keep_if block. That just builds a Hash with the codes as keys and the counts as values
[15:34:00] elomatreb: Remember that the &:something syntax is equivalent to a block like `{|argument| argument.something }`
[15:34:17] sagax: what i can read about "finance" and "transactions" with ruby?
[15:34:45] havenwood: sagax: Don't use Floats. ;-P
[15:35:30] sagax: and also about "atomic operations"
[15:36:20] havenwood: sagax: Integer, Rational and BigDecimal can all represent money. There are gems like money, monetize, etc.
[15:37:02] elomatreb: "atomic operations" as in file IO?
[15:37:45] apeiros: sagax: ruby doesn't have transactions, or a concept of atomic operations. only in regard to concurrency. and there you can assume nothing is atomic unless explicitly documented otherwise.
[15:37:47] havenwood: sagax: You might even consider a database like Datomic: http://www.datomic.com/
[15:38:04] apeiros: database drivers for ruby of course support the database's transactions
[15:38:31] elomatreb: I've seen building a file in e.g. /tmp and moving it once you're done being called atomic, since you're in very little danger to end up with an incomplete file
[15:38:45] somerandomteen: Hi all! How can I access an instance of a class from within the class?
[15:38:51] apeiros: "little danger" != "atomic"
[15:39:04] stormbytes: has joined #ruby
[15:39:09] apeiros: atomic is a strong/strict assertion and there isn't much satisfying it
[15:39:09] havenwood: sagax: Datomic is handy for stuff like retaining all transactions in an audit-able way.
[15:39:17] adaedra: somerandomteen: you meed from a class method?
[15:39:24] havenwood: sagax: Financial institutions love that stuff.
[15:39:37] sagax: oh, thanks, it's great information for me
[15:39:43] sagax: i read more about this, thanks
[15:39:54] adaedra: s/meed/mean/
[15:40:08] havenwood: somerandomteen: Have any example code to Gist? It might help us understand what you're asking to see what you have so far.
[15:40:16] MarkBilk: Does Tk work well for programming GUIs in Ruby?
[15:40:26] somerandomteen: adaedra: no, like this: validates_presence_of :whatever if instance.stupid == true
[15:40:47] adaedra: I think you want to call it with a lambda
[15:40:53] apeiros: somerandomteen: to access an instance, it has to actually exist
[15:40:58] somerandomteen: ahh yep, you may well be right adaedra
[15:40:59] havenwood: MarkBilk: TK's not in the stdlib anymore but it was gemified and is still maintained. Or there are other options.
[15:41:03] apeiros: somerandomteen: during class definition time, it won't exist
[15:41:12] apeiros: and yes, hence lambda as adaedra suggests
[15:41:15] adaedra: validates_presence_of :whatever, if: -> { stupid? } # or something like that
[15:41:27] LyndsySimon: sagax, havenwood: I'll also say that when I was playing with writing a cryptocurrency exchange, my model was to use an append-only log for all transactions. That helped me maintain an audit trail and know where I could divide work between workers concurrently and when it needed to be executed in series.
[15:41:32] synthroid: has joined #ruby
[15:41:33] apeiros: iirc AR supports if: :stupid?
[15:41:43] adaedra: ah yes maybe
[15:41:47] somerandomteen: or after_initialise :whatever_validator and create that as a function adaedra apeiros?
[15:41:47] havenwood: :stupid.to_proc
[15:41:48] havenwood: or: if: :stupid.to_proc
[15:42:08] havenwood: forgot the predicate
[15:42:08] apeiros: somerandomteen: yes. though you'd do good and ask in #rubyonrails for how to properly handle your case.
[15:42:19] apeiros: validations usually don't go into after_initialize (z, not s)
[15:42:34] jgnagy: has joined #ruby
[15:42:47] somerandomteen: ah yep haha, I'm a Brit, I'd screw up so many of the spellings without my IDE ^.^
[15:42:59] somerandomteen: I'll go pop over and ask in ror, thanks :)
[15:43:23] apeiros: somerandomteen: the guides are usually quite helpful with basic questions like these.
[15:43:38] apeiros: guides.rubyonrails.org
[15:43:39] patarr: has joined #ruby
[15:43:58] apeiros: http://guides.rubyonrails.org/active_record_validations.html being the one you're looking for probably.
[15:44:35] LyndsySimon: havenwood: I've got chruby+ruby-install working now. So far so good - except that I need an equivalent to rehash :)
[15:45:11] LyndsySimon: havenwood: For instance, which I `gem install bundler`, I had to reload my shell session for `bundle` to point to the one I just installed. Same thing for rails.
[15:45:16] somerandomteen: apeiros: trouble is, it's a bit more complicated than just validations
[15:45:24] havenwood: LyndsySimon: Hmm, that shouldn't be the case...
[15:45:37] apeiros: somerandomteen: then you'd have to do better than your current description anyway.
[15:45:44] kaiks: has joined #ruby
[15:45:45] apeiros: so far it was basics covered by the guides
[15:46:21] MarkBilk: havenwood: I can require 'tk' in irb, so I seem to have it, but not as a gem. In Ruby 2.3.3 .
[15:46:54] LyndsySimon: havenwood: It might be a problem with my .zshrc.
[15:47:10] mim1k: has joined #ruby
[15:48:06] brent__: has joined #ruby
[15:48:44] etehtsea: has joined #ruby
[15:49:15] kaiks: hi, in rails, why can't i access a non-persisted model's association? i.e. model = Model.new(association_id: 123); model.association #=> nil
[15:49:27] havenwood: LyndsySimon: You should have to source chruby or restart after installing a new Ruby. But newly installed gems will already be in your PATH and should *just work*.
[15:49:30] LyndsySimon: Doesn't seem to be. When I install bundler, it doesn't show up on my path under I reload.
[15:49:38] apeiros: ?rails kaiks
[15:49:38] ruby[bot]: kaiks: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[15:49:46] brent__: has joined #ruby
[15:49:52] havenwood: LyndsySimon: Check?: chruby
[15:49:58] havenwood: LyndsySimon: Is the right Ruby selected?
[15:50:06] LyndsySimon: Whoa. Something's weird. I don't think it's a ruby issue.
[15:50:48] gil_: has joined #ruby
[15:50:48] gil_: has joined #ruby
[15:51:07] username1: has joined #ruby
[15:51:27] valerauko: oh well. looking at the core source, it seems == and eql? are usually defined in C. time to copy their patterns!
[15:51:39] LyndsySimon: https://usercontent.irccloud-cdn.com/file/F8bGwD9C/Magic.%20%3A(
[15:51:57] elomatreb: that prompt though
[15:52:05] LyndsySimon: What part? :)
[15:53:26] libfud1: has joined #ruby
[15:54:15] havenwood: LyndsySimon: gem install bundler
[15:54:26] amclain: has joined #ruby
[15:54:28] havenwood: LyndsySimon: Then sanity check: gem which bundler
[15:54:33] havenwood: LyndsySimon: And: which bundle
[15:55:10] havenwood: LyndsySimon: You can also remove your Brew Ruby from the mix to simplify: brew unlink ruby
[15:55:19] havenwood: LyndsySimon: Add it back wth: brew link ruby
[15:55:45] adaedra: woah, monofur, long time no see
[15:55:46] centrx: has joined #ruby
[15:55:47] havenwood: LyndsySimon: Switch to brew with: chruby system
[15:56:00] centrx: has joined #ruby
[15:56:47] LyndsySimon: havenwood: I don't understand.
[15:57:06] havenwood: LyndsySimon: Which part?
[15:57:10] LyndsySimon: It does pick up the new stuff when I cd out and back in:
[15:57:14] LyndsySimon: https://usercontent.irccloud-cdn.com/file/lWJkxXXL/image.png
[15:57:25] LyndsySimon: "switch to brew with: chruby system"
[15:57:48] myk267: has joined #ruby
[15:58:29] LyndsySimon: adaedra: I like monofur because the "e" is easy to read. I wish it was easier to distinguish multiple underscores, though.
[15:58:30] Jameser: has joined #ruby
[15:58:49] havenwood: LyndsySimon: So chruby does nothing if you don't source it. In that case you're either using brew or system Ruby.
[15:59:23] havenwood: LyndsySimon: If you `brew unlink ruby` then you'll see `ruby -v` is system Ruby.
[15:59:46] havenwood: LyndsySimon: If you then `brew link ruby` you'll see `ruby -v` is brew Ruby.
[15:59:59] LyndsySimon: https://usercontent.irccloud-cdn.com/file/nrgLrcKc/image.png
[16:00:15] havenwood: LyndsySimon: If you source chruby.sh (about a hundred lines), you can then use the `chruby` command. (But it won't change anything till you run it.)
[16:00:34] havenwood: LyndsySimon: The auto.sh is a few more lines and will auto-switch when it detects a .ruby-version file.
[16:00:34] LyndsySimon: It's sourced in my .zshrc.
[16:00:39] havenwood: Sec, phone.
[16:00:45] LyndsySimon: ACTION nods.
[16:04:14] LyndsySimon: Yeah - it's gotta be something in my shell. It appears that chruby is doing the right thing, because it got added to the directory that's first in my path, it just doesn't resolve to that. I wonder if zsh is caching the location of the executable from the previous call or something.
[16:04:17] LyndsySimon: https://usercontent.irccloud-cdn.com/file/fDIPKe3l/image.png
[16:05:44] apeiros: ⌥ for branch, nice :D
[16:06:01] LyndsySimon: Yeah, it's totally the shell. hash isn't getting updated:
[16:06:05] LyndsySimon: https://usercontent.irccloud-cdn.com/file/hqfbTvC6/image.png
[16:06:29] tomphp: has joined #ruby
[16:06:36] elomatreb: Is that an actual branch symbol or some repurposed character from some alphabet?
[16:07:15] elomatreb: Oh, nevermind. Non-apple user
[16:07:17] apeiros: elomatreb: option-key on apple
[16:07:44] apeiros: though I just notice the 2016 mbp no longer uses that symbol, wth?
[16:08:22] Jameser: has joined #ruby
[16:08:45] apeiros: it's a very nice icon IMO, a bifurcation provides you with an option…
[16:09:13] MarkBilk_: has joined #ruby
[16:09:43] LyndsySimon: It's not an Apple symbol, it's just unicode.
[16:10:04] nitric: has joined #ruby
[16:10:24] apeiros: yeah, now guess who asked for its inclusion :)
[16:10:38] LyndsySimon: Just like the command key - it's symbol is "PLACE OF INTEREST SIGN": ⌘
[16:10:50] apeiros: http://www.fileformat.info/info/unicode/char/2325/index.htm
[16:10:58] apeiros: it's *literally* called "OPTION KEY"
[16:11:03] LyndsySimon: Well, of course. I just mean that it's like the symbol isn't available on Linux.
[16:11:48] apeiros: sure, I didn't say it wasn't available on *nix either. just what the symbol is (which happens to also be its origin)
[16:12:22] apeiros: and yes, I'm aware apple used the "place of interest" sign (from some nordic country iirc? sweden?) for the command key :)
[16:12:29] LyndsySimon: There's also ⎇, "ALTERNATIVE KEY SYMBOL". They're handy together.
[16:13:32] Jameser: has joined #ruby
[16:14:32] LyndsySimon: AFK. I've been working from a diner, and my battery is low enough I should walk back to work. :(
[16:15:55] gusrub: has joined #ruby
[16:17:27] cardboard64: has left #ruby: ()
[16:18:13] djuls: has joined #ruby
[16:25:49] ascarter: has joined #ruby
[16:25:54] pupsicle: has joined #ruby
[16:31:37] cibs: has joined #ruby
[16:34:48] im0nde: has joined #ruby
[16:36:18] rippa: has joined #ruby
[16:36:33] pupsicle: Can anyone explain or point me to some documentation explaining why the output of this snippet is true instead of false? https://gist.github.com/anonymous/9c3973e0ffe1660ace4423056b2941d1
[16:37:41] elomatreb: initialize is run after the methods are defined, so it overrides the existing one
[16:38:03] elomatreb: Oh, you asked for documentation. nvm, sorry
[16:38:16] pupsicle: No that's perfect. Thanks very much
[16:38:47] gizmore: has joined #ruby
[16:42:02] elomatreb: pupsicle: https://eval.in/810647 demonstration :)
[16:43:27] pupsicle: Very cool. It makes sense too, not sure why it didn't occur to me. Thanks.
[16:44:08] troys: has joined #ruby
[16:44:14] TomyLobo: has joined #ruby
[16:45:34] ozcanesen: has joined #ruby
[16:46:44] apeiros: to be a bit more precise: initialize is run every time you call Foo.new (which you call after defining bar)
[16:47:45] jamesaxl: has joined #ruby
[16:47:51] micahjam97: has joined #ruby
[16:48:27] cdg: has joined #ruby
[16:51:52] arup_r: has joined #ruby
[16:52:20] bmurt: has joined #ruby
[16:52:43] pawandubey: has joined #ruby
[16:53:23] valerauko: has joined #ruby
[16:54:01] LyndsySimon: pupsicle: I would actually explain that differently. Foo.bar is calling "bar", a method of "Foo". Foo.new.bar is calling "bar", a method of "Foo.new", which of course is an instance of "Foo". It's not so much a matter of the order things are happening as it is becuase of the fact that an instance of a class is a discrete object, and doesn't share methods with the class from which it is derived.
[16:55:06] LyndsySimon: You know what, scratch that. I'm overcomplicating, and thought you had defined self.bar.
[16:55:29] pupsicle: LyndsySimon: bar was instance method as well, yeah.
[16:55:32] pupsicle: Thanks though
[16:56:01] LyndsySimon: Yeah, I should have stopped and verified my reading of it.
[16:58:10] cdg_: has joined #ruby
[17:00:44] nowhere_man: has joined #ruby
[17:02:57] hays_: has joined #ruby
[17:02:57] hays_: has joined #ruby
[17:04:33] woodruffw: has joined #ruby
[17:04:33] woodruffw: has joined #ruby
[17:06:19] perniciouscaffei: has joined #ruby
[17:10:39] cerulean: has joined #ruby
[17:11:36] crankharder: has joined #ruby
[17:13:52] balazs: has joined #ruby
[17:14:27] jenrzzz: has joined #ruby
[17:14:28] jenrzzz: has joined #ruby
[17:21:58] stormbytes: has joined #ruby
[17:22:52] cschneid_: has joined #ruby
[17:23:21] davidalejandro: has joined #ruby
[17:29:14] ecuanaso: has joined #ruby
[17:29:48] arup_r: has joined #ruby
[17:33:03] jgt2: has joined #ruby
[17:33:08] djbkd: has joined #ruby
[17:36:17] chouhoul_: has joined #ruby
[17:36:30] xall: has joined #ruby
[17:38:53] mathys: has joined #ruby
[17:39:19] duderonomy: has joined #ruby
[17:41:13] dcluna: has joined #ruby
[17:41:28] nadir: has joined #ruby
[17:50:16] cschneid_: has joined #ruby
[17:50:24] johnzorn: has joined #ruby
[17:54:07] hutch34: has joined #ruby
[17:54:48] gusrub: has joined #ruby
[17:57:03] akkad: has joined #ruby
[18:00:01] ZacNoMore: has joined #ruby
[18:00:23] enterprisey: has joined #ruby
[18:00:43] cschneid_: has joined #ruby
[18:02:35] Axy: has joined #ruby
[18:02:35] pawandubey: has joined #ruby
[18:03:15] KeyJoo: has joined #ruby
[18:04:02] mim1k: has joined #ruby
[18:05:17] quobo: has joined #ruby
[18:06:00] ZacNoMore: has joined #ruby
[18:08:56] Cohedrin_: has joined #ruby
[18:10:17] chouhoulis: has joined #ruby
[18:11:44] mim1k: has joined #ruby
[18:12:13] opencw: has joined #ruby
[18:12:38] pupsicle: has joined #ruby
[18:15:53] roshanavand: has joined #ruby
[18:18:27] AlHafoudh: has joined #ruby
[18:22:31] pb122-two: has joined #ruby
[18:29:24] blackwind_123: has joined #ruby
[18:30:25] cout: is there any [preferably but not necessarily non-hacky] way to guarantee ordering of finalizer calls at shutdown?
[18:30:36] Rich_Morin_: has joined #ruby
[18:31:02] cout: I have an application that uses ffi-rzmq, and if the zmq socket isn't closed before the context is destroyed, the process hangs
[18:31:25] cout: (IMO zmq is being stupid here, but that's another story)
[18:32:20] mim1k: has joined #ruby
[18:36:00] KrzaQ: Are questions about windows rubyinstaller in scope of this channel?
[18:41:52] KrzaQ: I have an offline (I can only remote desktop to the server, there's no internet access) installation of ruby 2.4 by rubyinstaller2. How can I install gems?
[18:43:09] KrzaQ: I googled it, but I'm not sure if [1] is still a correct way to do this.
[18:43:11] KrzaQ: [1]: http://help.rubygems.org/kb/rubygems/installing-gems-with-no-network
[18:43:18] mahlon: has joined #ruby
[18:43:54] elomatreb: The general strategy of downloading a packaged gem and installing it is still correct
[18:44:01] LastWhisper____: has joined #ruby
[18:44:15] KrzaQ: Ok, thank you :)
[18:44:46] Rich_Morin_: has joined #ruby
[18:45:15] jenrzzz: has joined #ruby
[18:45:15] jenrzzz: has joined #ruby
[18:47:01] LastWhisper____: has joined #ruby
[18:48:03] __Yiota: has joined #ruby
[18:48:15] djbkd: has joined #ruby
[18:51:16] GodFather_: has joined #ruby
[18:52:46] mim1k: has joined #ruby
[18:53:32] Rich_Morin: has joined #ruby
[18:53:32] GodFather_: has joined #ruby
[18:54:42] DLSteve: has joined #ruby
[18:56:43] xall: has joined #ruby
[18:57:13] dionysus69: has joined #ruby
[18:58:35] djbkd: has joined #ruby
[18:59:44] foxxx0: has joined #ruby
[19:01:14] jenrzzz_: has joined #ruby
[19:01:46] cerulean_: has joined #ruby
[19:02:01] Rich_Morin_: has joined #ruby
[19:03:44] jgt2: has joined #ruby
[19:05:53] djbkd: has joined #ruby
[19:09:30] mochiyoda_: has joined #ruby
[19:09:41] yogg-saron: has joined #ruby
[19:13:11] Rich_Morin_: has joined #ruby
[19:17:07] cerulean_: can anyone help me solve this one https://gist.github.com/anonymous/349cf63ea7e3bafdca6b392638fb1884
[19:19:14] Cohedrin: has joined #ruby
[19:19:56] cerulean_: found the issue, but i have no idea what to do
[19:19:57] cerulean_: https://github.com/nov/json-jwt/issues/45
[19:20:06] Axy: has joined #ruby
[19:20:06] Axy: has joined #ruby
[19:20:51] PaulCapestany: has joined #ruby
[19:21:13] apeiros: you should use set_key(n, e, d) instead of .e=, .n=, .d=
[19:21:28] cerulean_: thx apeiros
[19:21:37] elomatreb: Low-level crypto interfaces D:
[19:21:57] Rich_Morin_: has joined #ruby
[19:22:02] apeiros: elomatreb: more like blow-up level crypto interfaces, amirite?
[19:22:08] plujon: has joined #ruby
[19:22:16] hutch34: has joined #ruby
[19:22:39] elomatreb: "RSA is just numbers, what could be so difficult"
[19:22:52] apeiros: recommended by lord failalot and sir securitygaped
[19:22:57] cerulean_: it's in the netssh gem
[19:22:58] bkxd: has joined #ruby
[19:23:01] cerulean_: do i neeed to fork and fix?
[19:23:34] apeiros: did you try updating first?
[19:24:05] djbkd: has joined #ruby
[19:24:36] cerulean_: git-deploy is throwing the error, let me try updating git-deploy
[19:25:37] cerulean_: it looks like it's using a very old version of net-ssh
[19:25:53] apeiros: that on its own might be a reason not to use git-deploy
[19:26:03] cerulean_: it was working as of very recently
[19:26:04] apeiros: security related stuff should not be old
[19:26:21] cerulean_: what should i switch to then? it was working really well
[19:26:30] apeiros: all computers which got owned by any of the various viruses, trojans and other toolkits worked fine too
[19:28:25] elomatreb: What does git deploy do? If it's just what I think it is, can't you use the actual git executable which will use your system ssh?
[19:28:32] bkxd: has joined #ruby
[19:29:23] cerulean_: yes you can, git-deploy integrates with it
[19:29:27] cerulean_: i might ditch it soon tho
[19:29:28] jenrzzz: has joined #ruby
[19:29:32] cerulean_: hasnt been updated since 2015
[19:29:51] apeiros: ACTION still uses git + 20 lines of shell for private deploys
[19:30:07] apeiros: and I think now with `git worktree` I could probably axe 5 lines.
[19:31:14] oleo: has joined #ruby
[19:32:39] ur5us: has joined #ruby
[19:35:33] eightlimbs: has joined #ruby
[19:36:16] nowhere_man: has joined #ruby
[19:38:35] Rich_Morin_: has joined #ruby
[19:38:42] cerulean_: well i fixed it
[19:38:49] cerulean_: it was because i nuked my git history
[19:38:56] cerulean_: i rolled back to an older history (oh well)
[19:38:59] giantwaffeldonke: has joined #ruby
[19:40:46] jusa: has joined #ruby
[19:40:59] eightlimbs: https://gist.github.com/eightlimbed/45641835a30fdf825b55cf20025f26c0
[19:41:21] eightlimbs: I wrote a question as a comment in the gist
[19:41:59] zacts: has joined #ruby
[19:42:08] eightlimbs: I don't understand why (arr.length-1).times produces different results than arr.length-1.times
[19:43:03] djbkd: has joined #ruby
[19:43:35] elomatreb: precedence. You're doing arr.length - (1.times ...)
[19:44:06] djbkd: has joined #ruby
[19:44:18] shinnya: has joined #ruby
[19:45:39] cpruitt: has joined #ruby
[19:46:58] apeiros: and 1.times returns 1 and runs the block once.
[19:47:34] __Yiota: has joined #ruby
[19:48:07] mim1k: has joined #ruby
[19:48:16] ircmaxell: I'm running into a really weird problem: https://github.com/plataformatec/devise/blob/master/lib/devise/parameter_filter.rb#L17-L24 that block of code is adding a key to conditions that doesn't exist before hand.
[19:48:18] apeiros: oh, "sorted" means "performed a sort during this iteration"
[19:48:31] apeiros: ?rails ircmaxell
[19:48:31] ruby[bot]: ircmaxell: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[19:48:43] ircmaxell: calling with `({}, :downcase, [:email]`) returns {:email : nil} at runtime, but not in console
[19:48:48] ircmaxell: apeiros: not a rails question
[19:49:11] ta: has joined #ruby
[19:49:12] ircmaxell: basically, `conditions[k] = value.send(method) if value.respond_to?(method)` is assigning even though value is `nil`
[19:49:36] mtkd: has joined #ruby
[19:49:54] apeiros: if I had a penny for every time people claim "it's not a rails question" when it really is. but this time, you're actually right :D
[19:50:27] djbkd: has joined #ruby
[19:50:29] ircmaxell: this isn't my first rodeo (though an early forey into Ruby/Rails)
[19:50:53] apeiros: what does it return in console?
[19:51:03] ircmaxell: console runs as expected, and produces {}
[19:51:51] apeiros: check your return value's .default_proc
[19:52:11] apeiros: the one at runtime
[19:52:18] ircmaxell: ok, booting debugger
[19:52:38] LastWhisper____: has joined #ruby
[19:52:46] apeiros: maybe it's not really a plain empty hash, but one like: Hash.new { |h,k| h[k] = nil } (though, seems unreasonable, but it would exhibit the observed behavior)
[19:52:59] apeiros: >> Hash.new { |h,k| h[k] = nil }
[19:53:01] ruby[bot]: apeiros: # => {} (https://eval.in/810953)
[19:53:06] apeiros: looks empty at first
[19:53:12] apeiros: >> Hash.new { |h,k| h[k] = nil }; h[:email]; h
[19:53:19] ruby[bot]: apeiros: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
[19:53:34] apeiros: gawd, eval.in hasn't been very reliable lately :(
[19:53:36] apeiros: >> Hash.new { |h,k| h[k] = nil }; h[:email]; h
[19:53:39] ruby[bot]: apeiros: # => undefined local variable or method `h' for main:Object (NameError) ...check link for more (https://eval.in/810954)
[19:53:56] havenwood: #=> {:email=>nil}
[19:53:59] apeiros: >> h = Hash.new { |h,k| h[k] = nil }; h[:email]; h
[19:54:02] ruby[bot]: apeiros: # => {:email=>nil} (https://eval.in/810961)
[19:54:20] apeiros: >> h = Hash.new { |h,k| h[k] = nil }; h[:email]; h.default_proc
[19:54:22] ruby[bot]: apeiros: # => #<Proc:0x41fa9a10@/tmp/execpad-595c17bf445f/source-595c17bf445f:2> (https://eval.in/810962)
[19:55:18] apeiros: if default_proc is nil, then I have no idea what's happening and would suggest to set a binding.pry in the relevant piece of code to see what's going on.
[19:55:45] eightlimbs: elmatreb: thank you
[19:55:46] zacts: has joined #ruby
[19:55:50] eightlimbs: apeiros: thank you
[19:56:01] ircmaxell: yeah, proc is nil
[19:56:17] apeiros: ircmaxell: ok, binding.pry before line 18, 19, 20 and 21 :)
[19:56:25] apeiros: investigate that bugger
[19:56:42] apeiros: though, without me, I gotta shower and stretch
[19:57:03] ircmaxell: yeah, I tried attaching GDB, but man this runtime is too complex to simply understand
[19:57:35] apeiros: I'd use binding.pry. there are a couple of helpful scripts around to get gdb to work, though.
[19:57:51] blackwind_123: has joined #ruby
[19:57:52] cschneid_: has joined #ruby
[20:05:18] jamesaxl: has joined #ruby
[20:06:36] rohitpaulk: has joined #ruby
[20:07:57] eightlimbs: I have an array like this: [[1, 2], [3, 4], [8, 9], [4, 3], [2, 1]] - I want to remove the arrays that have the same digits as previous elements in the array ([4, 3], [2, 1])
[20:08:18] username: has joined #ruby
[20:08:43] eightlimbs: I tried .map{|x| x.sort } , but then I lose the order of the original array
[20:09:49] eightlimbs: .map{|x| x.sort }.uniq
[20:10:06] SpydarOO7: has joined #ruby
[20:10:24] elomatreb: I feel like you could do something with a set difference (-)
[20:10:45] elomatreb: >> [1, 2] - [2, 1]
[20:10:48] ruby[bot]: elomatreb: # => [] (https://eval.in/811070)
[20:14:08] eightlimbs: has joined #ruby
[20:14:38] ircmaxell: apeiros: found it. Thanks. Someone defined nil.downcase...
[20:14:42] ircmaxell: ACTION head-desks
[20:18:14] Cohedrin: has joined #ruby
[20:18:17] ta: has joined #ruby
[20:19:04] im0nde: has joined #ruby
[20:20:52] apeiros: ircmaxell: oh dear
[20:20:59] centrx: has joined #ruby
[20:21:19] apeiros: please send a bug report to the author of whichever gem committed this atrocity.
[20:23:10] Cohedrin: has joined #ruby
[20:24:54] apeiros: ircmaxell: in case you need help to figure that out: nil.method(:downcase).source_location
[20:25:09] kies: has joined #ruby
[20:26:37] elomatreb: https://eval.in/811076
[20:26:40] elomatreb: ACTION hides
[20:27:22] apeiros: ACTION knows somebody who put this into a relatively popular gem
[20:29:59] lxsameer: has joined #ruby
[20:34:27] ecuanaso: has joined #ruby
[20:40:15] Cohedrin: has joined #ruby
[20:41:21] guymanndude: has joined #ruby
[20:42:39] guymanndude: hi, I've noticed a bug in my code where converting a DateTime UNIX epoch time to a formatted string sets the date to 1970-01-01
[20:42:45] benlieb: has joined #ruby
[20:42:46] guymanndude: any guidance on what I'm doing wrong?
[20:42:54] guymanndude: DateTime.strptime(epoch_date.to_s, '%s').strftime("%Y-%m-%d")
[20:43:32] ^mtkd: has joined #ruby
[20:43:36] benlieb: Are array lookups in ruby constant time? Just curious after reading this comment, probably meaning to refer to Java or C: Array is collection of similar types of data. So all the elements will take same amount of memory.Therefore if you know the base address of array and type of data it holds you can easily get element Array[i] in constant time:
[20:43:37] cadillac__: has joined #ruby
[20:44:20] guymanndude: where epoch_date is Time.now.utc.to_i basically
[20:45:23] chouhoul_: has joined #ruby
[20:47:04] mim1k: has joined #ruby
[20:47:49] im0nde: has joined #ruby
[20:48:13] jenrzzz: has joined #ruby
[20:50:14] gusrub: has joined #ruby
[20:57:46] jordila: has joined #ruby
[20:58:02] pupsicle: benlieb: If you view the source, you can see that it is: https://github.com/ruby/ruby/blob/d0015e4ac6b812ea1681b1f5fa86fbab52a58960/array.c#L1210
[20:59:37] chouhoulis: has joined #ruby
[21:00:02] pupsicle: benlieb: the function fb_ary_entry is called by Array #[] as seen here: https://ruby-doc.org/core-1.9.3/Array.html#method-i-5B-5D
[21:00:31] pupsicle: rb_ary_entry*
[21:00:44] apeiros: benlieb: yes, arraylookup is O(1)
[21:01:13] ircmaxell: apeiros: yeah, that's how I found it actually. And it was in one of our applications code libraries (not a gem)
[21:02:40] jordila: has left #ruby: ()
[21:02:40] cerulean: do you guys recommend any light weight searching (rails) solutions?
[21:03:02] pupsicle: >> DateTime.strptime(Time.now.utc.to_i.to_s, '%s').strftime('%Y-%m-%d')
[21:03:04] ruby[bot]: pupsicle: # => uninitialized constant DateTime (NameError) ...check link for more (https://eval.in/811107)
[21:03:19] cerulean: is there an easy Model.search like method? (rails channel is dead)
[21:03:19] patarr: has joined #ruby
[21:03:42] pupsicle: >> require 'date'; DateTime.strptime(Time.now.utc.to_i.to_s, '%s').strftime('%Y-%m-%d')
[21:03:44] ruby[bot]: pupsicle: # => "2017-06-02" (https://eval.in/811108)
[21:04:02] pupsicle: guymanndude: seems to work for me
[21:04:15] havenwood: cerulean: See #where and #find_by, etc.
[21:05:50] jgt2: has joined #ruby
[21:06:03] akkad: has joined #ruby
[21:07:09] guymanndude: pupsicle: here's how I'm using for ref https://0bin.net/paste/iU2tMR-9C9-GkWAK#tst4Pm2vJ8Wk7usGJv1nDlu4dUHVG+sBgynVTwiHfDu
[21:07:48] guymanndude: pupsicle: how I end up calling it is: Time.epoch_to_date(epoch_date: Time.now)
[21:07:54] GinoMan2440: has joined #ruby
[21:07:56] guymanndude: this always gives me the 1970 date
[21:08:39] brent__: has joined #ruby
[21:09:50] pupsicle: guymanndude: add a 'to_i' on the end of that Time.now
[21:09:58] al2o3-cr: guymanndude: you have to call tv_sec or to_i first
[21:10:10] djuls: has joined #ruby
[21:10:58] GodFather_: has joined #ruby
[21:17:55] rickumali: has left #ruby: (""Peace!"")
[21:18:24] taurgal: has joined #ruby
[21:20:05] al2o3-cr: guymanndude: any reason you're using DateTime and not just Time?
[21:20:34] guymanndude: al2o3-cr: I believe Time is only localtime and I need utc
[21:20:40] djbkd: has joined #ruby
[21:20:46] guymanndude: I guess I could do Time.utc.strptime...
[21:21:49] guymanndude: actually that wouldn't work
[21:22:02] al2o3-cr: i'd do something the long the lines of
[21:22:08] manveru: Time.strptime('2007 UTC', '%Y %z')
[21:22:09] al2o3-cr: >> class Time def epoch_to_date(epoch_date:) Time.at(epoch_date).utc.strftime('%F') end end; Time.epoch_to_date epoch_date: 342344
[21:22:11] ruby[bot]: al2o3-cr: # => undefined method `epoch_to_date' for Time:Class (NoMethodError) ...check link for more (https://eval.in/811111)
[21:23:08] manveru: you can always append the timezone for strptime :)
[21:23:22] mim1k: has joined #ruby
[21:23:32] eightlimbs: has joined #ruby
[21:24:03] akkad: has joined #ruby
[21:25:02] fmcgeough: has joined #ruby
[21:27:24] __Yiota: has joined #ruby
[21:29:23] mahlon: has joined #ruby
[21:38:10] stee_3_: has joined #ruby
[21:38:46] costa: has joined #ruby
[21:41:47] jamesaxl: has joined #ruby
[21:46:47] guymanndude: hmm, so I've been thinking about how I'd test this with RSpec
[21:47:09] guymanndude: essentially ensuring that a date that I pass to epoch_date is never 1970-01-01
[21:47:20] guymanndude: but I'm a little stumped on how I'd mock this out
[21:53:02] ledestin: has joined #ruby
[21:53:29] pupsicle: Not sure mocking is the right way to approach testing your method.
[21:54:58] pupsicle: Just in a sense that it is a pure function, there is nothing to mock.
[21:56:42] jusa: has joined #ruby
[21:59:33] mim1k: has joined #ruby
[21:59:37] Kneecaps: has joined #ruby
[22:01:42] HoierM: has joined #ruby
[22:08:02] djbkd: has joined #ruby
[22:08:35] mim1k: has joined #ruby
[22:16:24] benlieb: has joined #ruby
[22:20:30] djuls: has joined #ruby
[22:27:26] headius: has joined #ruby
[22:28:53] watersoul: has joined #ruby
[22:30:33] cgfbee: has joined #ruby
[22:31:17] hanna`: has joined #ruby
[22:31:18] stanc: has joined #ruby
[22:31:42] ytti_: has joined #ruby
[22:31:51] DefV_: has joined #ruby
[22:31:54] c-c_: has joined #ruby
[22:31:56] cjohnson_: has joined #ruby
[22:31:58] mcfiredrill: has joined #ruby
[22:31:58] gs: has joined #ruby
[22:32:21] xsdg_: has joined #ruby
[22:32:21] async_pr1: has joined #ruby
[22:32:21] unreal_: has joined #ruby
[22:32:36] patr0clus: has joined #ruby
[22:33:04] patr0clus: has joined #ruby
[22:33:51] patr0clus: has joined #ruby
[22:36:21] djuls-: has joined #ruby
[22:36:50] gil_: has joined #ruby
[22:36:50] gil_: has joined #ruby
[22:36:52] jinie: has joined #ruby
[22:38:05] Emmanuel_Chanel: has joined #ruby
[22:38:41] GinoMan: has joined #ruby
[22:39:08] tekk: has joined #ruby
[22:40:14] Biohazard: has joined #ruby
[22:40:16] Puffball_: has joined #ruby
[22:40:29] forgot: has joined #ruby
[22:40:30] is_null: has joined #ruby
[22:40:31] is_null: has joined #ruby
[22:40:33] nofxxxx: has joined #ruby
[22:40:37] jud: has joined #ruby
[22:40:37] jud: has joined #ruby
[22:40:39] Some-body_: has joined #ruby
[22:40:41] FastJack: has joined #ruby
[22:40:47] icedragon: has joined #ruby
[22:40:53] KillerFox: has joined #ruby
[22:40:55] SegFaultAX: has joined #ruby
[22:41:16] Meeh: has joined #ruby
[22:41:19] saneax: has joined #ruby
[22:41:20] kent\n: has joined #ruby
[22:41:51] sunrunner20: has joined #ruby
[22:41:53] KnownSyntax: has joined #ruby
[22:41:53] KnownSyntax: has joined #ruby
[22:42:45] djbkd: has joined #ruby
[22:42:57] djbkd: has joined #ruby
[22:43:04] gheegh: has joined #ruby
[22:43:41] eightlimbs: has joined #ruby
[22:43:47] djbkd: has joined #ruby
[22:44:31] spheric: has joined #ruby
[22:44:34] djbkd: has joined #ruby
[22:45:24] Radar: has joined #ruby
[22:46:21] FastJack_: has joined #ruby
[22:48:38] ur5us: has joined #ruby
[22:49:28] djbkd: has joined #ruby
[22:55:28] LightStalker: has joined #ruby
[22:55:40] djbkd: has joined #ruby
[22:55:49] nowhere_man: has joined #ruby
[22:57:01] bmurt: has joined #ruby
[23:04:09] patarr: has joined #ruby
[23:06:34] jgt2: has joined #ruby
[23:09:35] mathys: has joined #ruby
[23:13:23] segmond: has joined #ruby
[23:16:22] djbkd: has joined #ruby
[23:17:37] bkxd: has joined #ruby
[23:24:45] djbkd: has joined #ruby
[23:25:57] jackjackdripper: has joined #ruby
[23:29:58] Nicmavr: has joined #ruby
[23:30:13] MarkBilk: has joined #ruby
[23:32:20] Guest44644: has joined #ruby
[23:33:02] AlexRussia: has joined #ruby
[23:37:34] JoshS: has joined #ruby
[23:39:48] ecuanaso: has joined #ruby
[23:42:52] Brent___: has joined #ruby
[23:48:06] choke: has joined #ruby
[23:48:08] jtd: has joined #ruby
[23:48:46] eightlimbed: has joined #ruby
[23:53:01] roychri: has joined #ruby
[23:57:33] jusa: has joined #ruby
[23:58:14] benlieb: has joined #ruby