« Back to channel list

#ruby - 23 May 2019

« Back 1 day Forward 1 day »
[00:10:57] fphilipe_: has joined #ruby
[00:11:03] skryking: has joined #ruby
[00:11:30] tf2ftw: has joined #ruby
[00:20:39] jenrzzz: has joined #ruby
[00:27:00] octos: has joined #ruby
[00:28:41] FancyEagle: has joined #ruby
[00:35:30] laaron: has joined #ruby
[00:39:47] laaron: has joined #ruby
[00:46:20] brool: has joined #ruby
[00:52:16] fredolinhares: has joined #ruby
[00:55:55] darix: has joined #ruby
[00:56:12] Vingador: has joined #ruby
[00:56:12] AJA4350: has joined #ruby
[00:57:29] esp32_prog: has joined #ruby
[01:10:26] orbyt_: has joined #ruby
[01:11:52] Kestrel-029: has joined #ruby
[01:13:58] weteamsteve: has joined #ruby
[01:15:31] Nicmavr: has joined #ruby
[01:15:50] Paraxial: has joined #ruby
[01:18:12] fphilipe_: has joined #ruby
[01:25:27] budonyc: has joined #ruby
[01:26:54] Fusl: has joined #ruby
[01:29:04] AJA4351: has joined #ruby
[01:30:37] Kestrel-029: has joined #ruby
[01:35:13] deepredsky: has joined #ruby
[01:42:30] jenrzzz: has joined #ruby
[01:45:46] Vingador: has joined #ruby
[01:57:16] skryking: has joined #ruby
[01:59:25] cropcircle: has joined #ruby
[02:02:34] octos: has joined #ruby
[02:14:08] jenrzzz: has joined #ruby
[02:18:59] hekumar: has joined #ruby
[02:23:41] duderonomy: has joined #ruby
[02:28:17] jenrzzz: has joined #ruby
[02:35:40] fphilipe_: has joined #ruby
[02:36:37] AJA4351: has joined #ruby
[02:44:46] jenrzzz: has joined #ruby
[02:45:31] Nicmavr: has joined #ruby
[02:45:47] esp32_prog: has joined #ruby
[02:48:22] Talion: has joined #ruby
[02:48:31] Talion: Hello all
[02:48:43] Talion: I am getting an error while trying to install mysql2 gem
[02:48:54] Talion: https://www.irccloud.com/pastebin/ZVjuxiNc/
[02:48:55] ruby[bot]: Talion: we in #ruby do not like irccloud.com, it has no syntax highlighting, distracting formatting and loads slowly for most. Please use https://gist.github.com
[02:49:21] Talion: May i have a help please?
[02:50:52] Talion: https://dpaste.de/TCJC
[02:50:58] Talion: This may be better
[02:53:16] mozzarella: Talion: well, is mariadb installed?
[02:53:24] mad_al: has joined #ruby
[02:53:29] Talion: its installed
[02:53:57] Talion: [root@nebula one]# rpm -qa | grep MariaDB
[02:53:57] Talion: MariaDB-devel-10.3.15-1.el7.centos.x86_64
[02:53:58] Talion: MariaDB-common-10.3.15-1.el7.centos.x86_64
[02:53:58] Talion: MariaDB-client-10.3.15-1.el7.centos.x86_64
[02:53:58] Talion: MariaDB-compat-10.3.15-1.el7.centos.x86_64
[02:55:51] Talion: just installed MariaDB-server also
[02:56:08] Talion: [root@nebula one]# rpm -qa | grep MariaDB
[02:56:08] Talion: MariaDB-devel-10.3.15-1.el7.centos.x86_64
[02:56:08] Talion: MariaDB-common-10.3.15-1.el7.centos.x86_64
[02:56:08] Talion: MariaDB-server-10.3.15-1.el7.centos.x86_64
[02:56:08] Talion: MariaDB-client-10.3.15-1.el7.centos.x86_64
[02:56:08] Talion: MariaDB-compat-10.3.15-1.el7.centos.x86_64
[02:56:10] Talion: same error
[03:00:03] mozzarella: well, where is it installed?
[03:00:13] Talion: Centos 7.6
[03:03:03] mozzarella: Talion: no I mean the library
[03:03:11] mozzarella: what does 'find / -name libmariadb.so 2>/dev/null' say?
[03:03:17] code_zombie: has joined #ruby
[03:04:19] FancyEagle: has joined #ruby
[03:04:34] Talion: it doesnt find libmariadb.so but it found libmariadb.so.19 wierd?
[03:04:37] Talion: [root@nebula ~]# find / -name libmariadb.so 2>/dev/null
[03:04:38] Talion: [root@nebula ~]# find / -name libmariadb.so
[03:04:38] Talion: [root@nebula ~]# find / -name libmariadb*
[03:04:38] Talion: /usr/lib64/libmariadbd.so
[03:04:38] Talion: /usr/lib64/pkgconfig/libmariadb.pc
[03:04:38] Talion: /usr/lib64/libmariadbd.a
[03:04:38] Talion: /usr/lib64/libmariadbd.so.19
[03:04:39] Talion: /usr/lib64/libmariadbclient.a
[03:05:20] Talion: ah its in the first line sorry, didnt see.
[03:05:48] mozzarella: there's an extra d there
[03:05:49] Talion: [root@nebula ~]# find / -name libmariadb*
[03:05:49] Talion: /usr/lib64/libmariadbd.so
[03:07:03] Talion: So it should work normally ?
[03:07:10] mozzarella: no idea why it's called that way, it's properly called libmariadb.so here
[03:07:21] mozzarella: it doesn't have the right name
[03:07:43] Talion: shall i rename it ?
[03:08:31] mozzarella: I suggest you ask the centos people why that is, and maybe try creating symlinks or changing the makefile
[03:08:58] mozzarella: if you rename them it's probably going to break a bunch of stuff
[03:08:59] jenrzzz: has joined #ruby
[03:09:49] braincrash: has joined #ruby
[03:10:02] mozzarella: try this: ln -s /usr/lib64/libmariadb.so /usr/lib64/libmariadbd.so
[03:10:41] mozzarella: and check if you at least get a different error message when building the gem…
[03:12:55] Talion: it worked
[03:13:08] Talion: ln -s /usr/lib64/libmariadbd.so /usr/lib64/libmariadb.so
[03:13:26] mozzarella: of course I mixed it up
[03:13:29] Talion: But i think there is a problem with mariadb package at centos?
[03:13:54] mozzarella: I don't know, I suggest you ask them
[03:13:57] Talion: it shouldnt be there normally ?
[03:13:58] mozzarella: I don't use centos
[03:14:06] Talion: just saying
[03:14:29] Talion: Appreciated mozzarella, thanks.
[03:15:53] fphilipe_: has joined #ruby
[03:23:49] jenrzzz: has joined #ruby
[03:33:47] jenrzzz: has joined #ruby
[03:44:25] bambanx: has joined #ruby
[03:47:16] jenrzzz: has joined #ruby
[03:54:37] galeido: has joined #ruby
[03:55:16] jenrzzz: has joined #ruby
[03:58:19] fphilipe_: has joined #ruby
[04:03:36] jenrzzz: has joined #ruby
[04:23:50] jenrzzz: has joined #ruby
[04:29:35] molly: has joined #ruby
[04:34:02] esp32_prog: has joined #ruby
[04:48:10] sameerynho: has joined #ruby
[04:52:24] Ai9zO5AP: has joined #ruby
[04:54:49] jenrzzz: has joined #ruby
[05:10:42] fphilipe_: has joined #ruby
[05:12:29] reber: has joined #ruby
[05:12:56] jenrzzz: has joined #ruby
[05:20:41] conta: has joined #ruby
[05:21:25] sauvin: has joined #ruby
[05:25:16] Swyper: has joined #ruby
[05:32:46] salerace: has joined #ruby
[05:51:10] _whitelogger: has joined #ruby
[05:56:35] conta: has joined #ruby
[05:58:51] fphilipe_: has joined #ruby
[06:00:22] schne1der: has joined #ruby
[06:04:45] jenrzzz: has joined #ruby
[06:10:45] arand: has joined #ruby
[06:13:45] xco: has joined #ruby
[06:22:17] esp32_prog: has joined #ruby
[06:26:52] Kestrel-029: has joined #ruby
[06:29:14] slackmare: has joined #ruby
[06:48:19] kapilp: has joined #ruby
[06:49:45] JanMrlth: has left #ruby: ("http://quassel-irc.org - Chat comfortably. Anywhere.")
[06:50:41] jenrzzz: has joined #ruby
[06:51:22] andikr: has joined #ruby
[06:51:35] TomyWork: has joined #ruby
[06:57:46] aupadhye: has joined #ruby
[07:21:05] schne1der: has joined #ruby
[07:22:51] lxsameer: has joined #ruby
[07:23:24] donofrio__: has joined #ruby
[07:24:43] faces: has joined #ruby
[07:25:15] jtdowney14: has joined #ruby
[07:25:36] KramerC_: has joined #ruby
[07:25:39] mahlon_: has joined #ruby
[07:26:15] m27frogy: has joined #ruby
[07:26:37] dionysus69: has joined #ruby
[07:27:26] ErhardtMundt_: has joined #ruby
[07:27:40] Brian-W-Gray: has joined #ruby
[07:29:13] Hanmac: has joined #ruby
[07:31:59] michael_mbp: has joined #ruby
[07:35:10] alireza: has joined #ruby
[07:35:26] alireza: is there a reason to use RuntimeError for custom exceptions instead of StandardError or vice versa?
[07:35:32] alireza: 'cause they're direct relatives?
[07:43:52] mosh: has joined #ruby
[07:45:30] esp32_prog: has joined #ruby
[07:46:39] deepredsky: has joined #ruby
[07:48:58] blackmesa: has joined #ruby
[08:00:12] _whitelogger: has joined #ruby
[08:02:36] mikecmpbll: has joined #ruby
[08:07:22] Sylario: has joined #ruby
[08:08:45] jefffrails35: has joined #ruby
[08:12:11] lupine: has joined #ruby
[08:14:02] duderonomy: has joined #ruby
[08:23:38] laaron: has joined #ruby
[08:30:10] Linuus: How would you test this code in a nice way? https://gist.github.com/Linuus/f13248caab72718cc7b6818cdfde873b
[08:30:48] Linuus: The `sync_with_remote` method makes a call to an external API. The method has been tested in isolation by passing in an API client mock.
[08:32:30] Linuus: Now I want to test that this perform method which instantiates a thing and then calls the sync method. I could pass an API client mock to the perform method which passes it along to the sync method, but that seems messy...
[08:41:05] ShalokShalom: has joined #ruby
[08:42:49] Jonopoly: has joined #ruby
[08:43:54] al2o3-cr: has joined #ruby
[08:47:53] ellcs: has joined #ruby
[09:15:31] Nicmavr: has joined #ruby
[09:16:01] jenrzzz: has joined #ruby
[09:21:30] blackmesa1: has joined #ruby
[09:26:49] blackmesa: has joined #ruby
[09:27:53] Swyper: has joined #ruby
[09:30:37] Kestrel-029: has joined #ruby
[09:35:54] alexeev: has joined #ruby
[09:45:28] marmotini_: has joined #ruby
[10:06:46] sysvalve: has joined #ruby
[10:10:11] Swyper: has joined #ruby
[10:12:34] TomyWork: has joined #ruby
[10:20:04] tf2ftw: has joined #ruby
[10:26:15] conta: has joined #ruby
[10:27:14] kapilp: has joined #ruby
[10:28:16] mikecmpbll: has joined #ruby
[10:33:57] AJA4350: has joined #ruby
[10:37:27] laaron: has joined #ruby
[10:40:54] mniip: has joined #ruby
[10:47:29] Caerus: has joined #ruby
[10:51:22] Swyper: has joined #ruby
[10:56:08] Swyper: has joined #ruby
[11:02:56] Swyper: has joined #ruby
[11:06:11] Swyper: has joined #ruby
[11:13:31] UncleCid__: has joined #ruby
[11:16:17] jenrzzz: has joined #ruby
[11:17:06] dar123: has joined #ruby
[11:18:08] Swyper: has joined #ruby
[11:26:47] Nicmavr: has joined #ruby
[11:29:28] Swyper: has joined #ruby
[11:32:08] tf2ftw: has joined #ruby
[11:35:22] alexeev: has joined #ruby
[11:39:39] Paraxial: has joined #ruby
[11:43:39] gb_away: has joined #ruby
[11:46:13] AJA4350: has joined #ruby
[11:53:02] cd: has joined #ruby
[12:01:11] conta2: has joined #ruby
[12:17:14] conta: has joined #ruby
[12:17:58] Phage: has joined #ruby
[12:17:58] Phage: has joined #ruby
[12:19:20] banisterfiend: has joined #ruby
[12:24:11] _whitelogger: has joined #ruby
[12:26:43] conta: has joined #ruby
[12:29:25] Tuor_: has joined #ruby
[12:31:12] Dbugger: has joined #ruby
[12:34:06] _axx: linuus why not test Thing.sync_with_remote in isolation?
[12:35:02] _axx: Eh, sorry, i mean, why test the job if it works in isolation
[12:36:11] _axx: linuus i probably would probably do a "Thing receives sync_with_remote" check in the job spec
[12:39:49] blackmesa: has joined #ruby
[12:41:52] Kestrel-029: has joined #ruby
[12:43:14] teclator: has joined #ruby
[12:46:12] Dbugger: has joined #ruby
[12:56:51] Nicmavr: has joined #ruby
[13:13:03] budonyc: has joined #ruby
[13:14:16] hmaronon: has joined #ruby
[13:16:29] jenrzzz: has joined #ruby
[13:26:52] Kestrel-029: has joined #ruby
[13:28:38] banisterfiend: has joined #ruby
[13:36:05] AJA4350: has joined #ruby
[13:36:15] cthulchu_: has joined #ruby
[13:37:05] Zoddo: has joined #ruby
[13:37:32] noboruma: has joined #ruby
[13:44:03] pwnd_nsfw: has joined #ruby
[13:48:21] hightower2: has joined #ruby
[13:51:42] luminousnine: has joined #ruby
[13:51:42] luminousnine: has joined #ruby
[13:52:50] Zoddo: Ruby n00b here. What is the status of rubyforge.org ? It seems down/very slow. Is this normal?
[13:53:35] Zoddo: What is/are(?) the prefered ways of accessing databases (over odbc)? (which libs/methods)
[13:56:51] Nicmavr: has joined #ruby
[13:57:11] bougyman: zodd_: since you asked for prefernce, mine is Sequel.
[13:57:50] Zoddo: bougyman, Sequel is a lib I presume?
[13:58:15] Zoddo: as SQL is pronounced the same way
[14:02:06] Zoddo: ah. I see. I understand there is also some port of Perl DBI.
[14:02:33] Zoddo: Does an article which provides a comparison exist or some metrics on what is popular or not?
[14:10:19] jeremycw: has joined #ruby
[14:24:11] bougyman: https://sequel.jeremyevans.net/ you saw that, right?
[14:29:16] ytti: sequal is so great
[14:29:33] ytti: one of the main reasons i hate switching away from ruby
[14:29:42] ytti: haven't found anything as nice in other languages i'm considering
[14:34:13] gigetoo: has joined #ruby
[14:37:28] Zoddo: bougyman, yes. ty
[14:37:40] Zoddo: ytti. Check out SQLAlchemy in Python
[14:37:50] ytti: i have, and i don't like it
[14:37:54] Zoddo: Together with Alembic
[14:38:12] deepredsky: has joined #ruby
[14:38:14] ytti: on python i use peewee
[14:40:26] ytti: example of peewee model: http://p.ip.fi/w733
[14:40:44] Zoddo: never heard of it. It might be great, but is it sustainable: is it maintained, is there a community etc. Ie: what will be its state in 5 years time/is it worth investing in when developing a major project on it
[14:42:25] pwnd_nsfw`: has joined #ruby
[14:42:25] Zoddo: Not ment as a (negative) remark regarding pweewee, but a remark about software (libraries) in general
[14:43:00] ytti: if i want sustainable and serious major project, i'm not going to choose python to begin with :)
[14:43:33] ytti: (nor ruby)
[14:43:43] AJA4351: has joined #ruby
[14:44:08] Zoddo: looks neat
[14:44:49] octos: has joined #ruby
[14:44:55] Jonopoly: whats a good all-around OO project to do
[14:45:08] Jonopoly: so i can do in most (if not all) languages
[14:45:29] Jonopoly: to show a basic understanding of OO ?
[14:48:23] Zoddo: Jonopoly, not entirely sure what your question is, nor iof this is the place for it, but maybe it is worth your time to check out: http://rosettacode.org/wiki/Rosetta_Code
[14:51:33] hmaronon: has joined #ruby
[14:54:41] twobitsprite: has joined #ruby
[14:54:52] twobitsprite: Is there something like the "requests" module from python for ruby?
[14:55:35] Jonopoly: Rosetta?? haha
[14:55:38] Jonopoly: Thanks zodd_
[14:56:01] Jonopoly: cucumber so annoying at times
[14:56:13] Jonopoly: wish there was a "slow" down property T_T
[14:57:06] z64: twobitsprite: you can take a look at the gems "rest-client" or "httparty"; there's others, but those are probably the most basic ones off the top of my head that are similar to requests
[14:59:49] r29v: has joined #ruby
[15:01:12] polishdub: has joined #ruby
[15:01:46] ytti: https://github.com/httprb/http
[15:03:32] jenrzzz: has joined #ruby
[15:07:28] englishm: has joined #ruby
[15:11:22] haxx0r: has joined #ruby
[15:12:44] FastJack: has joined #ruby
[15:24:20] rippa: has joined #ruby
[15:29:56] laaron: has joined #ruby
[15:33:24] orbyt_: has joined #ruby
[15:35:35] jenrzzz: has joined #ruby
[15:37:08] laaron: has joined #ruby
[15:37:18] banisterfiend: has joined #ruby
[15:55:12] hays: has joined #ruby
[16:07:49] octos: has joined #ruby
[16:08:39] havenwood: twobitsprite: +1 HTTP.rb
[16:08:58] havenwood: It's the most similar to Requests.
[16:17:42] Zoddo: how to try/catch or ruby equivalent a db connection to check how/why the connection errors? So far all my odbc attempts whether it being odbc, odbc-dbi or odbc-sequel
[16:18:31] Zoddo: quite sure the DSN is ok as it works ok and from other programming languages
[16:18:45] Zoddo: *works ok from shell
[16:25:58] iffraff: has joined #ruby
[16:27:40] iffraff: Hello, I', a complete ruby novice. I have a new job and they are using ruby and they are using foreman, to start stuff up from a procfile. I've noticed that the processes are starting up asynchronously. I was wondering if there is anyway to have them run synchronously.
[16:29:11] tdy: has joined #ruby
[16:30:47] Jonopoly_: has joined #ruby
[16:30:57] Zoddo: nm. found it
[16:32:59] Dbugger: has joined #ruby
[16:34:00] Dbugger: has joined #ruby
[16:35:26] noboruma_: has joined #ruby
[16:36:59] Zoddo: https://dpaste.de/jn0Q
[16:37:08] noboruma: has joined #ruby
[16:37:08] Zoddo: what is wrong there please?
[16:38:06] havenwood: zodd_: ruby-odbc issue: https://stackoverflow.com/questions/1419397/rubyodbc-cannot-allocate-sqlhenv/2631898
[16:38:42] havenwood: zoUse snake_case instead of headlessCamelCase for local variables in Ruby
[16:40:32] r29v: has joined #ruby
[16:41:17] Inline: has joined #ruby
[16:41:37] Zoddo: havenwood, ty. looking into it now
[16:42:02] Kestrel-029: has joined #ruby
[16:42:06] havenwood: iffraff: Does it work to limit to a single worker process?
[16:42:09] havenwood: iffraff: foreman start -c listener=1,workers=1
[16:42:13] havenwood: or is it -m?
[16:45:33] nowhere_man: has joined #ruby
[16:47:45] cisco: has joined #ruby
[16:51:13] salerace: has joined #ruby
[16:52:48] esp32_prog: has joined #ruby
[16:54:25] iffraff: havenwood: ah, that might work. I'll give that a try. thank you
[16:55:01] c0dec: has joined #ruby
[16:56:00] blackmesa: has joined #ruby
[16:56:39] conta: has joined #ruby
[16:57:37] duderonomy: has joined #ruby
[17:00:57] Al1: has joined #ruby
[17:03:38] AJA4350: has joined #ruby
[17:17:27] zacts: has joined #ruby
[17:21:31] jenrzzz: has joined #ruby
[17:27:56] banisterfiend: has joined #ruby
[17:29:00] gix: has joined #ruby
[17:31:12] banisterfiend: has joined #ruby
[17:34:06] jenrzzz: has joined #ruby
[17:35:56] banisterfiend: finally got my irc client to connect outisde the vpn :)
[17:36:49] govg: has joined #ruby
[17:49:25] ravenous_: has joined #ruby
[17:49:42] twobitsprite: has joined #ruby
[17:52:34] emilford: has joined #ruby
[17:52:48] octos: has joined #ruby
[17:54:04] salerace: has joined #ruby
[17:54:32] gix: has joined #ruby
[17:55:53] molly: has joined #ruby
[17:57:37] ramfjord: has joined #ruby
[18:02:56] doodlebug: has joined #ruby
[18:04:46] schne1der: has joined #ruby
[18:04:48] doodlebug: has joined #ruby
[18:06:46] iffraff: has joined #ruby
[18:07:17] octos: has joined #ruby
[18:09:31] AJA4351: has joined #ruby
[18:09:32] codefriar: has joined #ruby
[18:10:08] cisco: has joined #ruby
[18:10:44] codefriar: If I've loaded a yml file with Psych.load_file is there anyway I can dynamically get a part of that object? ie: foo["#{bar}"] but bar = [key][1]
[18:11:44] havenwood: codefriar: So bar is a String with square braces in it?
[18:12:23] codefriar: havenwood yep. Trying to create a reusable method to pull an arbitrary array out of an object loaded from yml. So I can add to the array, and write the file back.
[18:14:17] havenwood: foo.dig *bar.scan(/[^\[\]]+/)
[18:15:09] jhass: sound's like you're reinventing Hash#dig
[18:17:01] havenwood: codefriar: By 1, do you mean an Array index?
[18:18:04] jhass: where does the string come from?
[18:19:48] havenwood: &>> foo = {'key' => [nil, :payload]}; bar = '[key][1]'; foo.dig *bar.scan(/(?<=\[).+?(?=\])/).map { |key| Integer(key, exception: false) || key }
[18:19:51] rubydoc: # => :payload (https://carc.in/#/r/6yr7)
[18:20:23] havenwood: codefriar: +1 where does the string come from?
[18:20:50] octos: has joined #ruby
[18:20:53] codefriar: havenwood let me backup. I'm needing to open a yml, and add an entry to an array. In this first instance, the yml file is a static site generator list of sub pages.
[18:21:05] codefriar: The string comes from my futzing arround in pry
[18:23:56] codefriar: havenwood make sense?
[18:24:40] codefriar: havenwood here's the file in question
[18:24:41] codefriar: https://gitlab.com/NickBusey/HomelabOS/blob/master/mkdocs.yml
[18:25:41] havenwood: codefriar: And what are you trying to add to it?
[18:26:18] codefriar: havenwood writing a script to automate adding new packages. as part of that, I need to append to the array of pages under software
[18:26:51] Nicmavr: has joined #ruby
[18:26:55] codefriar: havenwood basically appending something like this: {"NewPackage":"/software/newpackage.md"}
[18:31:25] havenwood: codefriar: site.dig('pages', 4, 'Included Software') << extra_included_software
[18:32:32] octos: has joined #ruby
[18:32:38] havenwood: codefriar: https://gist.github.com/havenwood/e7dd41176b053f84d63a195ab3aed8b0
[18:32:57] codefriar: havenwood wow. thank you
[18:33:01] codefriar: havenwood++
[18:36:07] havenwood: codefriar: If you're ever going to be writing from more than one process, Ruby stdlib has YAML::Store for transactional file storage in YAML.
[18:36:16] havenwood: https://docs.ruby-lang.org/en/2.6.0/YAML/Store.html
[18:37:31] havenwood: codefriar: That way, your transactions will succeed or fail together and you can enable atomic writes as well.
[18:38:06] havenwood: See the PStore docs for YAML::Store options: https://docs.ruby-lang.org/en/2.6.0/PStore.html
[18:41:03] esp32_prog: has joined #ruby
[18:42:47] molly: has joined #ruby
[18:48:01] codefriar: havenwood i wish I could pass an array into dig :(
[18:48:23] codefriar: havenwood ie: ["pages", 4, "Included Software"]
[18:48:31] jhass: you can, just prepend a *
[18:48:51] jhass: data.dig(*the_array)
[18:49:01] codefriar: Oh damn, that's slick wth is happening?
[18:49:20] jeremycw: has joined #ruby
[18:49:24] jhass: * is called the splat parameter, it passes each array element as an individual argument to the method
[18:49:36] codefriar: jhass thats f'ing awesome
[18:50:05] jhass: works in general for any method call of course
[18:51:09] jhass: view it as the inverse of a varargs argument in a method definition, that is a method parameter that collects all (remaining) positional arguments into an array: def foo(*args)
[18:55:05] octos: has joined #ruby
[18:59:43] octos: has joined #ruby
[19:03:15] octos: has joined #ruby
[19:05:09] octos: has joined #ruby
[19:07:26] fphilipe_: has joined #ruby
[19:07:43] houhoulis: has joined #ruby
[19:10:28] laaron: has joined #ruby
[19:11:01] altious: has joined #ruby
[19:11:53] yoshie902a: has joined #ruby
[19:12:03] yoshie902a: Does anyone know what ‘if_dne” means?
[19:12:25] jhass: not without context context context
[19:12:50] yoshie902a: def self.[](id, &if_dne)
[19:12:51] yoshie902a: all.fetch id&.intern, &if_dne
[19:13:02] yoshie902a: Oops, sorry, should have made a gist
[19:13:31] jhass: call example?
[19:14:01] jhass: looks like terrible code tbh :D
[19:14:28] phaul: it's just a name of an argument. like id. except it's a block argument
[19:14:52] jhass: my current best guess is Does Not Exist
[19:15:26] yoshie902a: https://gist.github.com/joshm1204/f1f8d13867dcdc2eae65d0c3d17bb572
[19:16:47] jhass: yup, Hash#fetch's block get's called when the given key does not exist in the hash
[19:18:02] yoshie902a: what is the & mean
[19:18:33] jhass: in the argument list it binds any given block argument to the given variable name (as a proc)
[19:18:51] jhass: in the call it does the reverse essentially, it passes the given proc as a block argument
[19:19:09] gix-: has joined #ruby
[19:19:29] jhass: >> def foo(&block); block; end; a_proc = foo { 1 + 1 }; a_proc.call
[19:19:35] ruby[bot]: jhass: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
[19:19:59] jhass: eh, whatever
[19:20:23] AJA4351: has joined #ruby
[19:20:35] jhass: second example: def foo; 1 + yield; end; a_proc = proc { 1 }; foo(&a_proc)
[19:23:13] yoshie902a: so essentially, if_dne is a block that is getting passed into the method and then it runs the all.fetch id&.intern, &if_dne. &if_dne being the block that was passed in.
[19:23:35] jhass: no if there, but yeah
[19:23:57] jhass: if there's no block if_dne will be nil and &nil will just pass no block
[19:24:35] jhass: simple terms: Product#[] forwards any given block to Hash#fetch
[19:25:13] yoshie902a: ok, thank you
[19:25:25] Bounga: has joined #ruby
[19:25:31] yoshie902a: Can you tell me what self[__method__]
[19:25:49] yoshie902a: i have never seen this syntax either
[19:25:56] havenwood: yoshie902a: In Ruby 2.6 you can combine lines 8 & 9 using: .to_h { |id, attrs| ...
[19:26:10] havenwood: >> def foo; __method__ end; foo
[19:26:15] ruby[bot]: havenwood: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
[19:26:19] havenwood: &>> def foo; __method__ end; foo
[19:26:20] rubydoc: # => :foo (https://carc.in/#/r/6yrx)
[19:26:32] havenwood: yoshie902a: __method__ is the method name as a symbol
[19:26:42] havenwood: yoshie902a: self is Product
[19:26:51] Nicmavr: has joined #ruby
[19:28:07] yoshie902a: so i could remove .map and replace with .to_h?
[19:28:29] yoshie902a: assuming it’s is ruby 2.6
[19:28:42] twobitsprite: ytti, havenwood: thanks, that http.rb looks perfect
[19:28:50] yoshie902a: Nice, thank you
[19:30:39] twobitsprite: has left #ruby: ()
[19:33:29] jrafanie: has joined #ruby
[19:33:51] yoshie902a: One last request, what does this line do? `Product[product_id] { Product.membership }`
[19:34:08] yoshie902a: The pattern, not the specific membership method
[19:34:41] yoshie902a: Oh, nevermind, It is the block we discussed. I think
[19:35:32] samort7: has joined #ruby
[19:36:52] doodleb89: has joined #ruby
[19:43:57] havenwood: yoshie902a: Here are some refactoring suggestions: https://gist.github.com/havenwood/ad3c014f383d122190f32f2a3fdc577b
[19:45:04] havenwood: yoshie902a: Alternatively, you could make it a *real* ActiveModel backed by the YAML. :) I gave a talk on how to back your Models with an API (or YAML file works too) at RailsConf.
[19:45:20] jhass: I think the id&. is a really big smell here btw
[19:45:34] jhass: why would you ever pass nil there and silently handle it
[19:46:09] yoshie902a: Can you point me to how to have an active model backed by YAML?
[19:46:16] yoshie902a: that sounds interesting
[19:46:44] havenwood: yoshie902a: My talk on it will be posted here: https://www.youtube.com/playlist?list=PLE7tQUdRKcyaOq3HlRm9h_Q_WhWKqm5xc
[19:47:36] havenwood: yoshie902a: You can get pretty far with the Active Model docs: https://guides.rubyonrails.org/active_model_basics.html
[19:48:20] havenwood: yoshie902a: I'll write an article on it and maybe even show how to use YAML::Store.
[19:48:35] havenwood: You can make a fine Model backed by YAML::Store.
[19:49:07] havenwood: We should write a gem that does just that, if someone hasn't already.
[19:49:17] havenwood: If there is one, I don't know about it.
[19:49:56] havenwood: Just found: https://github.com/zilkey/active_hash
[19:50:09] havenwood: I'll look into it.
[19:50:21] havenwood: Need write support ;)
[19:51:08] yoshie902a: :) THat would be wonderful.
[19:51:13] havenwood: yoshie902a: My talk is "An API-Backed Model with Square's Ruby SDK", but you can use anything that can CRUD rather than an API.
[19:51:54] yoshie902a: The youtube video you posted does not seem to mention active model with YAML
[19:52:20] havenwood: yoshie902a: My talk isn't posted yet - they're just being added now.
[19:52:36] havenwood: It should be posted in the next week or two.
[19:53:22] yoshie902a: got it. thank you, I would love to read your article when you publish
[19:54:08] yoshie902a: Any way you could post your slides now?
[19:54:23] yoshie902a: or send a link?
[19:55:02] budonyc: has joined #ruby
[19:55:57] havenwood: I don't have them ready to post. Let me take a quick stab at a generic YAML solution. I can make it work properly later.
[19:56:56] Nicmavr: has joined #ruby
[19:58:32] Inline: has joined #ruby
[20:00:05] octos: has joined #ruby
[20:00:12] yoshie902a: havenwood: in case this is helpful, here is a more complete version of the product model
[20:00:13] yoshie902a: https://gist.github.com/yoshie902a/627845570d0ea88fe0911a3d619b0c58
[20:01:01] havenwood: yeah, actually thinking about this a generic one isn't going to work for your particular case - but you can make it work custom anyhow.
[20:01:34] yoshie902a: It would be helpful to see for learning purposes
[20:01:48] yoshie902a: and I could see how I could adapt it
[20:02:06] blackmesa: has joined #ruby
[20:02:43] voodoofish430: has joined #ruby
[20:06:21] spacesuitdiver: has joined #ruby
[20:08:37] yoshie902a: havenwood: updated just for you… https://gist.github.com/yoshie902a/627845570d0ea88fe0911a3d619b0c58
[20:14:26] SID790: has joined #ruby
[20:19:11] octos: has joined #ruby
[20:23:00] doodlebug: has joined #ruby
[20:26:09] SeepingN: has joined #ruby
[20:26:40] dviola: has joined #ruby
[20:29:19] esp32_prog: has joined #ruby
[20:30:11] weteamsteve: has joined #ruby
[20:32:24] jenrzzz: has joined #ruby
[20:46:10] jenrzzz: has joined #ruby
[20:48:37] jrafanie_: has joined #ruby
[20:56:16] SID790: has left #ruby: ("Konversation terminated!")
[20:57:28] hays: has joined #ruby
[21:02:19] Cache_Money: has joined #ruby
[21:02:38] hays: has joined #ruby
[21:03:45] Cache_Money: I have an array of hashes. Inside each hash is a `values` key with an array of floats. I’d like to order the hash objects inside the outter array by the last item in the `values` key. Can anyone help me with a way to go about this?
[21:04:45] jhass: .sort_by {|hash| hash["values"].last }
[21:05:34] jhass: .sort_by returns a new sorted array, sort_by! sorts the existing array in place
[21:08:01] Cache_Money: jhass: Awesome, that worked perfectly! Thanks!!
[21:08:19] fphilipe_: has joined #ruby
[21:12:40] fredolinhares: has joined #ruby
[21:15:36] Nicmavr: has joined #ruby
[21:18:47] hays: has joined #ruby
[21:18:52] houhoulis: has joined #ruby
[21:19:52] dragonkh: has joined #ruby
[21:21:42] dragonkh: has left #ruby: ()
[21:24:22] hays: has joined #ruby
[21:28:50] evdubs: has joined #ruby
[21:28:55] blackmesa: has joined #ruby
[21:41:19] havenwood: yosh, oh no, they left
[21:41:57] havenwood: anyhow, I got pulled into meetings and didn't finish it, but here's about half way to a YAML-based read/write model: https://gist.github.com/havenwood/f23bd816ce5535132fbcffe0d028179a
[21:42:04] havenwood: maybe i'll finish it and make it generalizable this weekend
[21:45:12] AJA4350: has joined #ruby
[21:45:26] doodleb57: has joined #ruby
[21:46:46] iNs: has joined #ruby
[21:54:45] c0dec: has joined #ruby
[21:58:37] Exuma: has joined #ruby
[21:59:06] Exuma: ruby 2.6.3 Q: If I have x = BigDecimal(100); y = x; and then I modify x... x -= BigDecimal(1)
[21:59:19] Exuma: will that modify y under any circumstnaces? im trying to read about clone and dup
[21:59:33] Exuma: and it is super confusing related to wording... the object_id isnt changing when i check it myself
[21:59:36] Exuma: so i am just not sure
[22:07:50] laaron: has joined #ruby
[22:07:57] jhass: ruby is entirely pass by reference, there's no pass by value whatsoever, all copying has to happen explicitly via .dup and .clone
[22:09:05] jhass: now BigDecimal#- returns a new instance, x -= y is just a shorthand for x = x - y
[22:09:19] Exuma: so why do the object_ids match?
[22:11:06] faces: has joined #ruby
[22:11:37] jhass: &>> require "bigdecimal"; x = BigDecimal(10); y = x; x -= 1; x.object_id == y.object_id
[22:11:39] rubydoc: # => false (https://carc.in/#/r/6ytj)
[22:12:19] Exuma: &>> require "bigdecimal"; x = BigDecimal(10); y = x.dup; y.object_id == x.object_id
[22:12:19] rubydoc: # => true (https://carc.in/#/r/6ytk)
[22:13:40] jhass: ah looks like BigDecimal#dup just returns self because it's immutable
[22:14:05] Exuma: so basically im 100% safe not using .dup at all, anywhere dealing with bigdecimal?
[22:14:37] jhass: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2558
[22:15:08] jhass: given they made it pointless to use it, yeah
[22:15:57] havenwood: &>> require 'bigdecimal'; require 'bigdecimal/util'; 0.to_d.frozen?
[22:16:02] rubydoc: # => true (https://carc.in/#/r/6ytl)
[22:17:29] havenwood: &>> require 'bigdecimal'; require 'bigdecimal/util'; require 'fiddle'; big_decimal = 0.to_d; Fiddle::Pointer.new(big_decimal.object_id << 1)[1] = 0; big_decimal.frozen?
[22:17:30] rubydoc: # => false (https://carc.in/#/r/6ytm)
[22:17:38] esp32_prog: has joined #ruby
[22:21:44] Exuma: what did that show
[22:22:06] havenwood: Exuma: nothing important
[22:22:17] havenwood: Exuma: you can unfreeze things if you use Fiddle
[22:22:24] Exuma: haha, gotcha
[22:23:00] havenwood: Or freeze everything that wasn't frozen and thaw everything that was: require 'fiddle'; ObjectSpace.each_object { |object| Fiddle::Pointer.new(object.object_id << 1)[1] ^= 1 }
[22:23:05] havenwood: (Ruby won't take nicely to that.0
[22:28:03] xco: has joined #ruby
[22:28:13] xco: Can this be refactored futher?
[22:28:14] xco: (filetype == 'jpg' || filetype == 'jpeg' || filetype == 'gif' || filetype == 'png')
[22:29:47] phaul: xco Array#any? {} Array#member? come to mind
[22:30:09] phaul: combined with %w(word word word)
[22:31:36] jhass: %(jpg jpeg gif png).include? filetype
[22:32:50] jhass: haven't seen anybody use member? :D
[22:33:06] phaul: you have now :)
[22:33:34] xco: has joined #ruby
[22:33:35] jhass: no I haven't just mentioning it!
[22:34:35] xco: phaul: so i’d do something like %w(jpg jpeg).any? { filetype} right?
[22:35:18] phaul: no , follow jhass's example :) any? would require == check
[22:35:38] xco: my internet went off can you please copy and paste it so i see it?
[22:35:45] ruby[bot]: You can find a log of this channel at https://irclog.whitequark.org/ruby/
[22:36:29] xco: this is cool! thanks
[22:36:32] ruby[bot]: You can find a log of this channel at https://irclog.whitequark.org/ruby/
[22:36:41] xco: phaul: thanks
[22:37:11] havenwood: xco: https://ruby-community.com/ruboto/facts
[22:37:35] xco: havenwood: you rock.
[22:37:47] ruby[bot]: phaul: You can find a list of my commands on http://ruby-community.com/ruboto/commands and my factoids on http://ruby-community.com/ruboto/facts
[22:37:49] spacesuitdiver: has joined #ruby
[22:38:02] mikecmpbll: has joined #ruby
[22:38:10] ruby[bot]: you can find an overview of the factoids I know about at http://ruby-community.com/ruboto/facts
[22:38:22] phaul: :( that's not what I expected tbh. I wanted Beatles and helpa
[22:39:26] doodlebug: has joined #ruby
[22:39:28] havenwood: I need somebody! !help. Not just anybody. !help. You know I need someone. !help
[22:42:36] ruby[bot]: jhass: I don't know anything about helpa
[22:43:14] jhass: !fact add helpa I need somebody! !help. Not just anybody. !help. You know I need someone. !help
[22:43:14] ruby[bot]: jhass: I will remember that helpa is I need somebody! !help. Not just anybody. !help. You know I need someone. !help
[22:43:14] phaul: jhass: I think it's Radar's log bot
[22:43:27] jhass: I know :P
[22:45:26] doodlebug: has joined #ruby
[22:51:15] fphilipe_: has joined #ruby
[22:52:34] AJA4351: has joined #ruby
[22:56:56] Nicmavr: has joined #ruby
[22:58:00] Swyper: has joined #ruby
[23:04:51] mochiyoda_: has joined #ruby
[23:15:37] Kestrel-029: has joined #ruby
[23:33:04] nowhere_man: has joined #ruby
[23:44:08] jenrzzz: has joined #ruby
[23:45:25] doodleb80: has joined #ruby
[23:54:18] fphilipe_: has joined #ruby