« Back to channel list

#ruby - 06 July 2018

« Back 1 day Forward 1 day »
[00:12:23] taylorzr: has joined #ruby
[00:23:32] herbmillerjr: has joined #ruby
[00:24:27] bradleyprice: has joined #ruby
[00:31:41] caleBOT: has joined #ruby
[00:40:10] kurko_: has joined #ruby
[00:42:16] rshetty: has joined #ruby
[00:45:35] edwardly: has joined #ruby
[00:45:35] edwardly: has joined #ruby
[00:58:48] jrafanie: has joined #ruby
[01:00:12] nicht: has joined #ruby
[01:12:17] cadillac_: has joined #ruby
[01:13:02] apeiros: has joined #ruby
[01:13:30] NightMonkey: has joined #ruby
[01:18:34] dinfuehr: has joined #ruby
[01:21:00] NightMonkey: has joined #ruby
[01:28:19] kryptoz: has joined #ruby
[01:30:34] Es0teric: has joined #ruby
[01:32:03] edwardly: has joined #ruby
[01:32:57] edwardly: has joined #ruby
[01:33:28] r29v: has joined #ruby
[01:33:30] kmurphy4: has joined #ruby
[01:33:42] keggsmurph21: has joined #ruby
[01:35:58] kmurphy4: has joined #ruby
[01:41:18] r29v: has joined #ruby
[01:47:51] ramfjord: has joined #ruby
[02:09:46] BTRE: has joined #ruby
[02:11:48] r29v: has joined #ruby
[02:12:47] bradleyprice: has joined #ruby
[02:12:58] aiguuu: has joined #ruby
[02:17:44] graphene: has joined #ruby
[02:17:49] raynold: has joined #ruby
[02:18:22] MagePsycho: has joined #ruby
[02:20:25] r29v: has joined #ruby
[02:21:15] jnollette: has joined #ruby
[02:26:26] rshetty: has joined #ruby
[02:29:19] mynameisdebian: has joined #ruby
[02:33:28] nicht: has joined #ruby
[02:37:51] caleBOT: has joined #ruby
[02:38:06] nowhere_man: has joined #ruby
[02:38:28] darkhanb: has joined #ruby
[02:40:28] kryptoz: has joined #ruby
[02:51:52] s3nd1v0g1us: has joined #ruby
[02:54:42] Alina-malina: has joined #ruby
[02:58:06] akaiiro: has joined #ruby
[03:07:19] r29v: has joined #ruby
[03:09:35] kapil___: has joined #ruby
[03:10:37] BloopMonster: has joined #ruby
[03:11:24] braincrash: has joined #ruby
[03:17:33] Eletious: has joined #ruby
[03:22:18] Ethan: has joined #ruby
[03:25:01] akkiguru: has joined #ruby
[03:35:03] Nicmavr: has joined #ruby
[03:37:55] karapetyan: has joined #ruby
[03:39:12] donofrio: has joined #ruby
[03:48:01] caleBOT: has joined #ruby
[03:49:54] zlogan2003: has joined #ruby
[03:57:12] mynameisdebian: has joined #ruby
[04:01:43] kryptoz: has joined #ruby
[04:13:49] StarSeed0000: has joined #ruby
[04:18:43] graphene: has joined #ruby
[04:25:05] Xeago_: has joined #ruby
[04:36:53] donofrio: has joined #ruby
[04:46:04] brettgilio: has joined #ruby
[04:47:10] brettgilio: has joined #ruby
[04:49:18] bradleyprice: has joined #ruby
[04:49:21] rshetty: has joined #ruby
[04:50:20] nowhere_man: has joined #ruby
[04:56:15] anisha: has joined #ruby
[05:05:38] r29v: has joined #ruby
[05:07:54] unshackled: has joined #ruby
[05:08:02] DTZUZO: has joined #ruby
[05:08:24] ramfjord: has joined #ruby
[05:13:11] rshetty: has joined #ruby
[05:17:34] sauvin: has joined #ruby
[05:19:58] Asher: has joined #ruby
[05:25:06] mikhael_k33hl: has joined #ruby
[05:25:49] mikhael_k33hl: I'm using sinatra and I have an init.rb inside a folder. How do I require or include all other files inside the folder within my init.rb? Dir[__dir__].each {|file| require file} doesn't seem to work
[05:27:11] dionysus69: has joined #ruby
[05:30:31] mikhael_k33hl: I guess I'll go with Dir[File.basename(File.join(__dir__, '*.rb'))].each do |file| , thought there was a more elegant way to do it. :(
[05:30:42] mikhael_k33hl: typo, that was suppose to be :)
[05:39:52] mikhael_k33hl: has left #ruby: ()
[05:43:25] aiguuu: has joined #ruby
[05:45:02] wget: has joined #ruby
[05:45:02] wget: has joined #ruby
[05:53:52] aceruser: has joined #ruby
[05:55:55] mynameisdebian: has joined #ruby
[05:56:26] pwnd_nsfw`: has joined #ruby
[05:59:36] tolerablyjake: has joined #ruby
[06:00:06] aupadhye: has joined #ruby
[06:02:24] alex``: has joined #ruby
[06:05:08] apeiros: has joined #ruby
[06:17:34] jraavis: has joined #ruby
[06:20:07] hfp_work: has joined #ruby
[06:21:18] andikr: has joined #ruby
[06:22:48] rshetty: has joined #ruby
[06:30:05] dionysus69: has joined #ruby
[06:34:59] rshetty: has joined #ruby
[06:35:41] amar: has joined #ruby
[06:36:55] mtkd: has joined #ruby
[06:41:48] konsolebox: has joined #ruby
[06:47:13] aceruser: has joined #ruby
[06:48:27] Technato1: has joined #ruby
[06:58:00] cgfbee: has joined #ruby
[06:59:17] Technato1: has joined #ruby
[07:04:46] caleBOT_: has joined #ruby
[07:05:20] yohji: has joined #ruby
[07:08:04] Mia: has joined #ruby
[07:08:05] Mia: has joined #ruby
[07:09:58] pauliesaint: has joined #ruby
[07:17:50] yxhuvud: has joined #ruby
[07:20:24] sysvalve: has joined #ruby
[07:23:22] vindvaki: has joined #ruby
[07:24:01] akkiguru: has joined #ruby
[07:25:33] claudiuinberlin: has joined #ruby
[07:26:52] crankharder: has joined #ruby
[07:27:03] apeiros: has joined #ruby
[07:30:23] TomyWork: has joined #ruby
[07:33:40] biberu: has joined #ruby
[07:34:42] rshetty: has joined #ruby
[07:37:01] graphene: has joined #ruby
[07:40:50] burgestrand: has joined #ruby
[07:42:17] clemens3: has joined #ruby
[07:45:37] kryptoz: has joined #ruby
[07:52:22] akkiguru: has joined #ruby
[07:53:58] Dbugger: has joined #ruby
[07:54:41] Mike11: has joined #ruby
[07:55:58] guille-moe: has joined #ruby
[08:00:35] schleppel: has joined #ruby
[08:01:57] conta: has joined #ruby
[08:04:25] lele: has joined #ruby
[08:10:11] ramfjord: has joined #ruby
[08:10:36] Sylario: has joined #ruby
[08:11:21] bradleyprice: has joined #ruby
[08:12:24] mozzarella: has joined #ruby
[08:16:54] amar: has joined #ruby
[08:17:40] graphene: has joined #ruby
[08:17:59] naku: has joined #ruby
[08:19:04] amar: has joined #ruby
[08:21:05] naku: I have problems with irb / rails console on linux. Sometimes when i type it starts inseting \r and empty space. Like: Shift.where(asd: "dd")\r .where(something_else: "dd")\r
[08:21:56] jraavis: has joined #ruby
[08:23:50] havenwood: mikh, ah, they left. anyhoo: Dir.glob('*.rb', base: __dir__) { |filename| require filename }
[08:24:16] havenwood: naku: Does it still happen if you disable Spring?
[08:24:47] havenwood: export DISABLE_SPRING
[08:24:54] havenwood: export DISABLE_SPRING=1
[08:25:10] naku: okay set it and try to reproduce
[08:26:49] caleBOT_: has joined #ruby
[08:29:29] naku: echo $DISABLE_SRING
[08:29:36] naku: irb(main):002:0> Driver.select(:id, :name).joins(:shifts)..merge(Shift.in_time_range(Time.now - 6.hours, Time.now + 30.minutes)).merge(Shift.normal)\r .merge(Shift.in_time_range(Time.now - 6.hours, Time.now + 30.minutes)).merge(Shift.normal)\r .merge(Shift.in_time_range(Time.now - 6.hours, Time.now +
[08:29:36] naku: 30.minutes)).merge(Shift.normal)\r
[08:29:54] naku: Still nasty stuff in console
[08:31:28] naku: btw. echo $DISABLE_SPRING outputs 1
[08:31:53] havenwood: naku: Does `spring stop` say it's stopped? Maybe not Spring-related.
[08:32:27] naku: it says: Spring is not running
[08:32:45] naku: I really have no idea why this happens
[08:32:58] havenwood: naku: You might want to also try the #RubyOnRails channel.
[08:33:08] havenwood: naku: Sounds like a Readline issue, but I don't know what's going on.
[08:33:32] havenwood: naku: Time to switch to Pry? :-P
[08:34:33] naku: haha! Hmmm...
[08:34:56] Xiti: has joined #ruby
[08:35:04] naku: From "i dont care" to "pry is the best" in 5 minutes.
[08:37:55] nowhere_man: has joined #ruby
[08:38:49] naku: has left #ruby: ("Leaving")
[08:39:20] apeiros: havenwood: what what whaaaat? Dir.glob has a base kwarg? OMIGOSH THIS IS AWESOME!
[08:40:15] apeiros: so much annoying code I can cut out, aaahahaha, niiice!
[08:40:16] havenwood: apeiros: Recent addition! :-D
[08:40:19] havenwood: apeiros: https://bugs.ruby-lang.org/issues/13056
[08:41:18] reber: has joined #ruby
[08:41:19] havenwood: apeiros: And: Dir[blarg, base: '...']
[08:41:49] apeiros: hm? Dir::[] is Dir.glob, so that's expected?
[08:42:29] havenwood: apeiros: yeah, Dir.glob with File::FNM_SHORTNAME and no block
[08:42:49] tty: has joined #ruby
[08:43:00] havenwood: >> File.constants.grep /\AFNM/
[08:43:01] ruby[bot]: havenwood: # => [:FNM_NOESCAPE, :FNM_PATHNAME, :FNM_DOTMATCH, :FNM_CASEFOLD, :FNM_EXTGLOB, :FNM_SYSCASE, :FNM_SHORTN ...check link for more (https://eval.in/1032599)
[08:43:03] apeiros: now you make me look up File::FNM_SHORTNAME
[08:43:34] apeiros: "Valid only on Microsoft Windows" ok
[08:43:46] apeiros: that went right to /brain/trash
[08:43:56] havenwood: haha, yeah - that's as far as i got with it too
[08:44:11] havenwood: the DOTMATCH is interesting - actually matches . and ..
[08:45:30] havenwood: Dir.glob('??', File::FNM_DOTMATCH).include?('..') #=> true
[08:46:31] chkhanch: has joined #ruby
[08:49:10] havenwood: >> File.fnmatch('?', '/', File::FNM_PATHNAME)
[08:49:11] ruby[bot]: havenwood: # => false (https://eval.in/1032620)
[08:49:56] havenwood: >> File::FNM_PATHNAME | File::FNM_DOTMATCH
[08:49:58] ruby[bot]: havenwood: # => 6 (https://eval.in/1032624)
[08:50:20] def_jam: has joined #ruby
[08:50:28] eb0t: has joined #ruby
[08:51:31] graphene: has joined #ruby
[08:52:17] havenwood: interesting they just use bitwise OR of the consts for the flags
[08:53:56] havenwood: >> File.constants.grep(/\AFNM/).reduce(0) { |acc, const| acc | File.const_get(const) }
[08:53:57] ruby[bot]: havenwood: # => 31 (https://eval.in/1032635)
[08:55:16] rshetty: has joined #ruby
[08:57:10] ur5us: has joined #ruby
[09:03:02] kapil___: has joined #ruby
[09:07:06] rann: has joined #ruby
[09:12:21] rajdesai: has joined #ruby
[09:16:52] camilasan: has joined #ruby
[09:19:34] rawste: has joined #ruby
[09:19:46] camilasan: has joined #ruby
[09:25:36] ur5us: has joined #ruby
[09:26:15] rippa: has joined #ruby
[09:26:30] kapil___: has joined #ruby
[09:27:53] cabotto: has joined #ruby
[09:32:39] rshetty: has joined #ruby
[09:33:37] DarkUnicorn: has joined #ruby
[09:34:06] rajdesai: has joined #ruby
[09:34:59] BloopMonster: has joined #ruby
[09:44:29] rshetty: has joined #ruby
[09:56:41] tvw: has joined #ruby
[10:02:52] Nomekrax: has left #ruby: ("!invoke void")
[10:06:31] craysiii: has joined #ruby
[10:11:00] apeiros: havenwood: that's common for C flag stuff
[10:12:28] jraavis: has joined #ruby
[10:13:43] zenspider: yup yup. summable enums
[10:16:41] zenspider: you see the same thing all across unix. file perms, etc.
[10:17:23] apeiros: yepp. bitfields. convenient stuff for set behaviour.
[10:26:16] cabotto: has joined #ruby
[10:28:23] FernandoBasso: has joined #ruby
[10:30:06] caleBOT: has joined #ruby
[10:31:57] n3b: has joined #ruby
[10:32:25] sina: has joined #ruby
[10:34:15] KnownSyntax: has joined #ruby
[10:35:09] cyberg: has joined #ruby
[10:36:03] cabotto: has joined #ruby
[10:36:50] Es0teric: has joined #ruby
[10:40:04] rajdesai: has joined #ruby
[10:41:27] herbmillerjr: has joined #ruby
[10:45:01] lele: has joined #ruby
[10:46:08] cabotto: has joined #ruby
[10:55:38] jrafanie: has joined #ruby
[10:59:47] pauliesaint: has joined #ruby
[11:06:53] bradleyprice: has joined #ruby
[11:10:48] chmurifree: has joined #ruby
[11:11:46] rajdesai: has joined #ruby
[11:17:10] GodFather: has joined #ruby
[11:18:17] TinkerT: has joined #ruby
[11:23:46] pauliesaint: has joined #ruby
[11:29:54] pauliesaint: has joined #ruby
[11:31:23] pauliesaint: has left #ruby: ()
[11:31:55] pauliesaint: has joined #ruby
[11:33:52] nowhere_man: has joined #ruby
[11:35:11] pauliesaint: has joined #ruby
[11:37:39] ldnunes: has joined #ruby
[11:42:24] Technato1: has joined #ruby
[11:43:18] karapetyan: has joined #ruby
[11:47:08] kryptoz: has joined #ruby
[11:48:52] bak1an: has joined #ruby
[11:52:00] Mia: has joined #ruby
[11:52:01] Mia: has joined #ruby
[11:57:33] pauliesaint: has joined #ruby
[12:01:02] Technato1: has joined #ruby
[12:04:57] jcalla: has joined #ruby
[12:10:42] ramfjord: has joined #ruby
[12:11:53] hfp_work: has joined #ruby
[12:12:30] Inline: has joined #ruby
[12:13:53] yqt: has joined #ruby
[12:17:42] bradleyprice: has joined #ruby
[12:19:06] epochwolf: has joined #ruby
[12:29:42] fmcgeough: has joined #ruby
[12:33:54] rajdesai: has joined #ruby
[12:35:57] jraavis: has joined #ruby
[12:48:04] AJA4350: has joined #ruby
[12:54:31] TomyWork: has joined #ruby
[12:56:10] rshetty: has joined #ruby
[12:57:16] fmcgeough: has joined #ruby
[12:57:17] rshetty: has joined #ruby
[13:00:17] codymj: has joined #ruby
[13:01:32] rshetty: has joined #ruby
[13:12:03] rajdesai: has joined #ruby
[13:20:52] fiftysix: has joined #ruby
[13:21:52] fiftysix: some years ago, i wrote a little script with a helpful library called Nokogiri ... is that still the simplest way of extracting info from (not too badly written) HTML? or should something else be used nowadays?
[13:25:26] Hanmac: has joined #ruby
[13:27:03] Technato1: has joined #ruby
[13:27:55] _seanc_: has joined #ruby
[13:33:31] soniya29: has joined #ruby
[13:33:44] simmaniac: has joined #ruby
[13:34:29] simmaniac: has joined #ruby
[13:35:24] Quintasan: fiftysix: Nokogiri is still the go to library if you want to scrape HTML.
[13:36:27] fiftysix: okay, thank you quintasan! no need to scrape, i already have it downloaded to disk. just need to extract some info.
[13:37:05] karapetyan: has joined #ruby
[13:37:48] bsamorim: has joined #ruby
[13:40:07] bmurt: has joined #ruby
[13:44:39] bmurt: has joined #ruby
[13:49:13] apparition: has joined #ruby
[13:49:22] Rapture: has joined #ruby
[13:49:56] RougeR: has joined #ruby
[13:49:56] RougeR: has joined #ruby
[13:51:14] knight33: has joined #ruby
[13:57:41] rikkipitt: has joined #ruby
[13:58:39] soniya29: has joined #ruby
[14:00:04] fiftysix: quintasan, is there a simple way to print just the text contained in a nokogiri result node?
[14:00:21] fiftysix: (i.e. without any <span>s or <em>s or whatever that might be contained in that text)
[14:01:21] elomatreb: Doesn't #text do that?
[14:04:26] caleBOT: has joined #ruby
[14:05:02] fiftysix: elomatreb, aha! much better than #inner_html, thanks!
[14:12:37] kapil___: has joined #ruby
[14:12:59] fiftysix: hmm, this one is more difficult now: <p><span>Blah</span>Foobar</p> ... i've already extracted "Blah", but now I want "Foobar" without the "Blah" ... is there a way to do that? Or do I have to somehow #remove the <span> first?
[14:14:58] Nicmavr: has joined #ruby
[14:22:15] npgm: has joined #ruby
[14:22:26] fiftysix: awesome, almost done. just need to put it into CSV
[14:22:51] subr: has joined #ruby
[14:22:51] subroot: has joined #ruby
[14:24:20] elomatreb: The standard library contains a pretty good CSV library
[14:27:32] fiftysix: The result: https://gist.github.com/sixtyfive/aa636b7befcded15d8d19736cab8d087 (thank you again, elomatreb and quintasan!)
[14:28:11] mtkd: has joined #ruby
[14:28:35] apeiros: fiftysix: you… have directories which are named .html?!?
[14:28:47] apeiros: ACTION needs to learn the short-cut for interrobang
[14:28:48] YokoBR: has joined #ruby
[14:29:44] elomatreb: Web site crimes
[14:30:24] apeiros: `info.scan(/(\n.*)/).last.first` --> just `info.scan(/\n.*/).last`
[14:30:25] fiftysix: apeiros, no.
[14:30:36] apeiros: fiftysix: then why `next if File.directory?(filename)`?
[14:30:52] apeiros: your glob guarantees that there'll ever only be things which end in ".html"
[14:30:58] chkhanch: has joined #ruby
[14:31:05] fiftysix: apeiros, omg how awkward! that's from a snippet I copied from StackExchange :-(
[14:31:49] YokoBR: please, I'm receiving this error msg .rvm/gems/ruby-2.2.6/gems/activesupport-4.1.16/lib/active_support/dependencies.rb:247:in `require': incompatible library version - /home/jeff/.rvm/gems/ruby-2.2.6/gems/pg-0.17.1/lib/pg_ext.so (LoadError)
[14:31:50] Mike11: has joined #ruby
[14:38:57] apeiros: YokoBR: is there a question in that?
[14:39:10] Es0teric: has joined #ruby
[14:39:38] YokoBR: sorry apeiros
[14:40:21] apeiros: no need to apologize. I'm just trying to help you getting help :)
[14:42:11] elomatreb: has joined #ruby
[14:42:22] YokoBR: I'm really new to ruby. Like, never used it. I'm helping a friend to move his app from a server to another, but it seems that his app is too outdated. I'm trying to fix the gems versions on Gemfile, but totally forgot to remove Gemfile.lock
[14:42:47] apeiros: you shouldn't really remove Gemfile.lock
[14:43:12] apeiros: instead you should use the appropriate bundler commands to upgrade the app as much as possible.
[14:43:39] apeiros: `bundle update` is usually a good first step (how good depends to a good bit on the quality of the Gemfile)
[14:43:47] YokoBR: I've remove it, removed some gems version requirements, but I'm stuck at this error activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require': incompatible library version - /home/jeff/.rvm/gems/ruby-2.2.6/gems/pg-1.0.0/lib/pg_ext.so (LoadError)
[14:45:36] amar_: has joined #ruby
[14:48:02] apeiros: can you gist the full exception (that line is the most important, though)?
[14:51:55] shinnya: has joined #ruby
[14:53:05] veloutin: has joined #ruby
[14:56:14] troys: has joined #ruby
[14:56:20] chkhanch: has joined #ruby
[14:56:39] dviola: has joined #ruby
[14:57:13] YokoBR: there you go https://gist.github.com/jersobh/cf8ca8558329e42fe9982a7f35a9f464
[14:59:27] anisha: has joined #ruby
[15:03:38] jraavis: has joined #ruby
[15:04:12] amar_: has joined #ruby
[15:06:24] discopatrick: has joined #ruby
[15:06:52] fiftysix: has joined #ruby
[15:09:04] chouhoulis: has joined #ruby
[15:19:07] soniya29: has joined #ruby
[15:20:36] akaiiro: has joined #ruby
[15:21:53] apeiros: YokoBR: sorry, offline life interrupts me…
[15:26:54] YokoBR: apeiros: what is that "offline life"? never heard about it lol
[15:34:40] eckhardt_: has joined #ruby
[15:35:17] Es0teric: has joined #ruby
[15:36:01] troulouliou_dev: has joined #ruby
[15:38:33] karapetyan: has joined #ruby
[15:39:58] karapetyan: has joined #ruby
[15:40:01] cagomez: has joined #ruby
[15:40:10] biberu: has joined #ruby
[15:44:13] slm1: has joined #ruby
[15:44:36] Zaab1t: has joined #ruby
[15:48:07] apeiros: YokoBR: can you gist your Gemfile? it seems you are missing a `gem 'pg'` in it.
[15:50:24] howdoi: has joined #ruby
[15:50:48] cthulchu: has joined #ruby
[15:52:19] YokoBR: aspiers: it has gem pg. I was using only in production group, then I set it in general
[15:53:57] tolerablyjake: has joined #ruby
[15:54:32] mikecmpbll: has joined #ruby
[15:54:38] YokoBR: apeiros: there you go https://gist.github.com/jersobh/c3aca161c76046179ec69c32b837e750
[15:55:27] apeiros: YokoBR: you can edit existing gists and add files
[15:55:49] apeiros: yeah, `rails server -e development` so your dev config says pg, so you need pg not only in prod.
[15:56:31] fiftysix: has joined #ruby
[15:58:37] YokoBR: gems/pg-0.21.0/lib/pg.rb:4:in `require': incompatible library version - /home/jeff/.rvm/gems/ruby-2.2.6/gems/pg-0.21.0/lib/pg_ext.so (LoadError)
[15:59:12] apeiros: if you remember, that's the original error (just with slightly different versions), where I asked you for the full exception ;-)
[15:59:40] YokoBR: yep, I've just changed the pg version
[15:59:49] YokoBR: and ran it in development mode
[16:00:26] YokoBR: but both production and development modes thrown the same error
[16:00:46] apeiros: which version is your postgres db?
[16:01:39] YokoBR: 9.1 I guess
[16:01:52] apeiros: "guess" is not good enough.
[16:02:05] apeiros: "It works with PostgreSQL 9.0 and later." is why I ask.
[16:02:41] amar_: has joined #ruby
[16:13:30] YokoBR: Oh, it's 9.0 or later for sure
[16:13:38] YokoBR: I'm just between 9.1 and 9.3
[16:13:41] zxq2: i'm trying to determine when IO::select might raise an IOError. the documentation i've looked at has been no help. any pointers?
[16:14:07] jcarl43: has joined #ruby
[16:14:21] alessand1o: has joined #ruby
[16:14:32] apeiros: YokoBR: in that case, open a shell in a directory without gemfile and try whether the following works: `gem install pg; irb -r pg`
[16:14:38] zxq2: more generally, in ruby, it seems difficult in some cases to determine what exceptions a method might raise.
[16:15:20] apeiros: oh, actually it seems 1.0.0 is already out. so probably better `gem install -v 0.21.0 pg; irb -r pg`
[16:15:30] dionysus69: has joined #ruby
[16:16:04] apeiros: zxq2: sadly that's true.
[16:16:38] apeiros: other than code analysis, there's no real way. and code analysis even needs to consider underlying methods.
[16:16:46] amar_: has joined #ruby
[16:19:21] zxq2: gotcha thanks
[16:20:17] YokoBR: but same error
[16:21:56] apeiros: well then, I really need the full exception. so something goes with your pg gem. are you sure that there are no other installations or remnants of old installations of pg on your computer?
[16:22:07] apeiros: (the db, not the gem)
[16:25:00] BloopMonster: has joined #ruby
[16:26:31] rshetty: has joined #ruby
[16:29:12] ramfjord: has joined #ruby
[16:30:32] chouhoulis: has joined #ruby
[16:30:34] discopatrick: has joined #ruby
[16:30:40] rawste: has joined #ruby
[16:32:04] r29v: has joined #ruby
[16:34:43] ramfjord_: has joined #ruby
[16:35:35] sameerynho: has joined #ruby
[16:36:24] Paraxial: has joined #ruby
[16:36:27] scrptktty: has joined #ruby
[16:36:43] canurabus: has joined #ruby
[16:38:22] darix: omg it is apeiros
[16:41:11] Lytol: has joined #ruby
[16:41:19] canurabus: Hi all. Im having some trouble understanding a ruby code snippet ( < 10 lines): https://8n1.org/13401/ee0b. This custom hash class overloads the [] method, but I don't understand what the 'inject' part is actually doing.
[16:42:50] canurabus: ive read the docs for inject, but I dont understand how its being used here or how to invoke the specialized [] method.
[16:43:00] fiftysix: has joined #ruby
[16:47:19] karapetyan: has joined #ruby
[16:48:00] lxsameer: has joined #ruby
[16:48:28] Demos[m]: what's the convention for initialize methods that can initialize the class as if it were a dict?
[16:48:41] Demos[m]: I've just been doing def initialize(params = {}) @whatever = params.fetch(...) end
[16:50:07] fluxAeon: has joined #ruby
[16:50:33] trippafagioli: has joined #ruby
[16:51:26] trippafagioli: Hi, I'm pretty new at ruby and i was wondering, how can I tell ubuntu to run a ruby script whenever it boots up?
[16:51:50] havenwood: trippafagioli: These days, Ubuntu uses SystemD for startup init.
[16:52:08] havenwood: trippafagioli: Alternatively, you can trigger cronjobs on boot.
[16:52:25] caleBOT: has joined #ruby
[16:52:37] havenwood: trippafagioli: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
[16:53:02] havenwood: trippafagioli: http://www.mikeperham.com/2014/09/22/dont-daemonize-your-daemons/
[16:53:23] havenwood: trippafagioli: https://www.raspberrypi-spy.co.uk/2013/07/running-a-python-script-at-boot-using-cron/
[16:53:46] trippafagioli: thanks a lot! I'll check and see if I can manage to run it
[16:57:47] lxsameer: has joined #ruby
[17:03:55] cyberg: has joined #ruby
[17:05:36] rshetty: has joined #ruby
[17:06:26] flips: has joined #ruby
[17:06:49] claudiuinberlin: has joined #ruby
[17:07:46] lxsameer: has joined #ruby
[17:10:21] soniya29: has joined #ruby
[17:12:05] StarSeed0000: has joined #ruby
[17:16:06] psychicist__: has joined #ruby
[17:17:51] lxsameer: has joined #ruby
[17:18:11] petrichorx_: has joined #ruby
[17:18:26] elomatreb: canurabus: Still relevant?
[17:19:30] rshetty: has joined #ruby
[17:22:05] amar_: has joined #ruby
[17:26:22] samosaphile: has joined #ruby
[17:27:29] soniya29: has joined #ruby
[17:27:55] lxsameer: has joined #ruby
[17:28:07] akaiiro: has joined #ruby
[17:29:03] samosaphile: hey, any idea how to write something in ruby which takes hex and converts to IP? like ... example input: 55905E48 desired output: 85.144.94.72
[17:33:31] Zarthus: irb(main):008:0> IPAddr.new "55905E48".hex, Socket::AF_INET
[17:33:31] Zarthus: => #<IPAddr: IPv4:85.144.94.72/255.255.255.255>
[17:33:38] clemens3: has joined #ruby
[17:35:17] GodFather: has joined #ruby
[17:37:41] lxsameer: has joined #ruby
[17:37:44] samosaphile: oh, didn't know it'd be that easy
[17:39:12] samosaphile: but what if you wanted to ignore the 255 part or not print/show it
[17:39:35] havenwood: >> '55905E48'.scan(/../).map(&:hex).join('.')
[17:39:35] Zarthus: that's just the return value of IPAddr#inspect
[17:39:36] ruby[bot]: havenwood: # => "85.144.94.72" (https://eval.in/1032980)
[17:40:34] havenwood: >> IPAddr.new("55905E48".hex, Socket::AF_INET).to_s
[17:40:35] ruby[bot]: havenwood: # => uninitialized constant IPAddr (NameError) ...check link for more (https://eval.in/1032981)
[17:40:35] havenwood: #=> "85.144.94.72"
[17:41:42] dionysus69: has joined #ruby
[17:42:31] rawste: has joined #ruby
[17:42:36] petrichorx_: has joined #ruby
[17:43:18] havenwood: >> ['55905E48'].pack('H*').unpack('C*').join('.')
[17:43:19] ruby[bot]: havenwood: # => "85.144.94.72" (https://eval.in/1032982)
[17:43:21] caleBOT_: has joined #ruby
[17:43:50] havenwood: >> ['55905E48'].pack('H*').bytes.join
[17:43:51] ruby[bot]: havenwood: # => "851449472" (https://eval.in/1032983)
[17:43:56] havenwood: >> ['55905E48'].pack('H*').bytes.join('.')
[17:43:57] ruby[bot]: havenwood: # => "85.144.94.72" (https://eval.in/1032984)
[17:45:16] havenwood: samosaphile: Those ^ are a few ways.
[17:46:47] samosaphile: wow, thanks so much havenwood and Zarthus
[17:47:59] lxsameer: has joined #ruby
[17:49:42] rshetty: has joined #ruby
[17:51:08] GodFather_: has joined #ruby
[17:51:49] samosaphile: ...no idea how that works tho ._.
[17:51:56] bsamorim: has joined #ruby
[17:52:00] elomatreb: On the other hand, IPAddr can also deal correctly with IPv6 addresses
[17:52:34] havenwood: samosaphile: Happy to help you understand if you're interested.
[17:52:59] trippafagioli: has joined #ruby
[17:53:09] karapetyan: has joined #ruby
[17:53:28] havenwood: samosaphile: This one, for example: '55905E48'.scan(/../).map(&:hex).join('.')
[17:53:39] jrafanie: has joined #ruby
[17:53:50] havenwood: samosaphile: '55905E48'.scan(/../) #=> ["55", "90", "5E", "48"]
[17:53:58] samosaphile: havenwood: im interested .. just don't know where to begin.. like i really don't understand any of it :/
[17:54:01] havenwood: samosaphile: So you scan for every two characters, which is one hex octet.
[17:54:09] havenwood: samosaphile: Do you know what hex is?
[17:54:26] samosaphile: ye, like base 16
[17:54:50] havenwood: samosaphile: Yup, so two chars are from "00" (0) to "FF" (255).
[17:55:00] havenwood: >> '00'.hex
[17:55:01] ruby[bot]: havenwood: # => 0 (https://eval.in/1032986)
[17:55:08] havenwood: >> 'FF'.hex
[17:55:09] ruby[bot]: havenwood: # => 255 (https://eval.in/1032987)
[17:55:52] havenwood: samosaphile: So if you map every two characters to the hex value: ["55", "90", "5E", "48"].map(&:hex) #=> [85, 144, 94, 72]
[17:56:01] havenwood: >> '55'.hex
[17:56:02] ruby[bot]: havenwood: # => 85 (https://eval.in/1032988)
[17:56:14] dionysus69: has joined #ruby
[17:56:36] havenwood: samosaphile: Then you can turn an Array into a String: [85, 144, 94, 72].join('.') #=> "85.144.94.72"
[17:56:57] havenwood: samosaphile: Put it together, and: '55905E48'.scan(/../).map(&:hex).join('.')
[17:57:15] havenwood: samosaphile: Every two characters (each octet), mapped to hex, and joined by dots.
[17:57:52] havenwood: samosaphile: the `/../` is Regexp, if you're not familiar.
[17:58:12] elomatreb: And the difference between the hex number and the dotted-decimal notation is really just notational convention, they all just represent a 32-bit integer
[17:58:34] havenwood: same with the bytes too
[17:59:14] elomatreb: dotted-decimal used to be more relevant when we had subnet classes, but CIDR subnets don't have to stick to the "boundaries" it shows
[17:59:42] samosaphile: going to ask noob questions
[18:00:34] havenwood: Speaking of packing an unpacking, the previous feedback on my silly project was great. If anyone else has suggestions, I'm all ears!: https://github.com/havenwood/digest-sip_hash/blob/master/lib/digest/sip_hash.rb
[18:01:21] havenwood: 'somepseudorandomlygeneratedbytes' seems not so psuedo-random ;-P
[18:01:38] samosaphile: when you did >> '55'.hex <-- what does the dot behind hex do? dot = method? is there a way to find like a list of like dot commands in ruby intrepreter?
[18:01:47] soniya29_: has joined #ruby
[18:02:06] havenwood: samosaphile: It's syntax that denotes calling a method.
[18:02:13] whathappens: has joined #ruby
[18:02:17] Zarthus: havenwood: it doens't get said enough, but you (and a lot of the ruby ops) really go the extra mile when it comes to offering support. It's really nice to see, and on behalf of myself and probably all the lost souls you've helped; Thank you.
[18:02:52] elomatreb: Ruby syntax allows you to leave the parentheses off method calls, '55'.hex is equivalent to '55'.hex(), which may be a little more familiar if you're coming from other languages
[18:03:05] havenwood: Zarthus: I appreciate the kind words. Thank you for helping too!!
[18:03:22] samosaphile: sorry, am abit slow... this probably going to take me like 2 weeks to actually get it lol
[18:04:09] havenwood: samosaphile: '55' is the "receiver" of the method call. You "send" it a method call, and it "responds".
[18:04:41] havenwood: samosaphile: String#hex is the method. The class of '55' is String.
[18:04:47] havenwood: >> '55'.class
[18:04:48] ruby[bot]: havenwood: # => String (https://eval.in/1032989)
[18:04:56] havenwood: '55'.method(:hex).owner
[18:05:27] havenwood: >> '55'.respond_to? :hex
[18:05:28] ruby[bot]: havenwood: # => true (https://eval.in/1032990)
[18:05:41] havenwood: >> '55'.send :hex
[18:05:42] ruby[bot]: havenwood: # => 85 (https://eval.in/1032991)
[18:07:22] havenwood: samosaphile: It kinda looks like gibberish, but if you want to see how Ruby is parsing the code, you can enable a debug mode to look at each rule of parse.y (the Yacc grammar) that's being used: ruby -yydebug -e "'55'.hex"
[18:07:47] havenwood: samosaphile: You can see how Ruby is lexing and parsing the code:
[18:08:15] havenwood: >> require 'ripper'; Ripper.lex "'55'.hex"
[18:08:16] ruby[bot]: havenwood: # => [[[1, 0], :on_tstring_beg, "'"], [[1, 1], :on_tstring_content, "55"], [[1, 3], :on_tstring_end, "'"] ...check link for more (https://eval.in/1032992)
[18:08:35] havenwood: >> require 'ripper'; Ripper.sexp "'55'.hex"
[18:08:36] ruby[bot]: havenwood: # => [:program, [[:call, [:string_literal, [:string_content, [:@tstring_content, "55", [1, 1]]]], :".", [ ...check link for more (https://eval.in/1032993)
[18:08:56] havenwood: samosaphile: Note, at the lexing step, Ruby doesn't know what the dot does yet, just that it's a dot: :on_period, "."
[18:09:16] samosaphile: i'm actually still confused over <Zarthus> that's just the return value of IPAddr#inspect like where do you add #inspect in irb(main):008:0> IPAddr.new "55905E48".hex, Socket::AF_INET => #<IPAddr: IPv4:85.144.94.72/255.255.255.255>
[18:09:32] Zarthus: It's implicit
[18:09:58] Zarthus: irb (the REPL I was using) automatically calls #inspect on the last returned value
[18:10:10] havenwood: It's only once the grammar is parsed that the dot becomes a method call:
[18:10:11] havenwood: >> RubyVM::InstructionSequence.compile("'55'.hex").to_a.last
[18:10:12] ruby[bot]: havenwood: # => [1, [:trace, 1], [:putstring, "55"], [:opt_send_without_block, {:mid=>:hex, :flag=>16, :orig_argc=>0 ...check link for more (https://eval.in/1032994)
[18:10:43] Zarthus: I'm not sure if that is helping his confusion, havenwood :P
[18:10:45] samosaphile: IPAddr.new("55905E48".hex, Socket::AF_INET).to_s <- this does work tho... not sure why doing .to_s makes it ignore 255 part
[18:11:13] Zarthus: samosaphile: .to_s is short for "to_string", a method defined in IPAddr meant to convert the value to a normal string
[18:11:15] havenwood: Zarthus: Yeah, probably not. Sometimes it's nice to have a bit of context that's over your head though, rather than nothing.
[18:11:30] havenwood: Zarthus: If the question of "what is this dot!??!" is burning enough.
[18:11:47] havenwood: Sometimes you just need to know enough to know that you don't care to know more. ;-P
[18:12:09] Zarthus: next week we'll dive into the assembly of it all :P
[18:14:01] StarSeed0000: has joined #ruby
[18:14:22] whathappens: has joined #ruby
[18:14:33] Zarthus: samosaphile: in laymans terms, think of #inspect as "give me some value that I can use for debugging", and #to_s as "give me something I can use/read", though it's not true for all scenarios
[18:14:42] havenwood: First gem I've seen using RubyVM::AST.parse: https://github.com/ioquatix/covered
[18:16:58] Zarthus: i can't believe he managed to get the gem name "covered"
[18:19:54] jrich523_: has joined #ruby
[18:22:39] bradleyprice: has joined #ruby
[18:24:57] mniip: has joined #ruby
[18:28:42] tolerablyjake: has joined #ruby
[18:31:17] samosaphile: too much new info at same time, braincrashed x_x..
[18:34:02] amar: has joined #ruby
[18:34:29] knight33: has joined #ruby
[18:34:46] nicht: has joined #ruby
[18:39:58] fiftysix: has joined #ruby
[18:41:00] graphene: has joined #ruby
[18:41:12] bradleyp_: has joined #ruby
[18:42:51] mynameisdebian: has joined #ruby
[18:47:02] alex``: has joined #ruby
[18:47:11] bradleyprice: has joined #ruby
[18:56:02] mikecmpbll: has joined #ruby
[19:21:12] zlogan2003: has joined #ruby
[19:24:12] graphene: has joined #ruby
[19:31:28] BloopMonster: has joined #ruby
[19:32:28] za1b1tsu: has joined #ruby
[19:36:22] caleBOT: has joined #ruby
[19:38:26] tolerablyjake: has joined #ruby
[19:38:37] guille-moe: has joined #ruby
[19:39:01] hfp_work: has joined #ruby
[19:43:46] blackmesa: has joined #ruby
[19:44:08] fredlinhares: has joined #ruby
[19:44:49] cthulchu_: has joined #ruby
[19:44:51] StarSeed0000: has joined #ruby
[19:54:15] mtkd: has joined #ruby
[19:54:43] blackmesa1: has joined #ruby
[19:56:26] pauliesaint: has joined #ruby
[19:56:27] graphene: has joined #ruby
[19:59:51] quobo: has joined #ruby
[20:02:23] cincy_kal: has joined #ruby
[20:02:42] tdy: has joined #ruby
[20:02:49] cincy_kal: Can anyone give me insight into running methods asynchronously?
[20:03:14] cincy_kal: lets say you have a large amount of data being aggregated in a method. The method does something like:
[20:03:50] tty: has joined #ruby
[20:04:02] cincy_kal: 1. get base object: User 2. get user contact info 3. get user posts 4. get user comments 5. get user upvotes 6. get user downvotes, etc and then you return that all in an aggregated data structure
[20:05:08] blackmesa1: has joined #ruby
[20:05:13] elomatreb: Ruby itself does not offer any async features beyond bare threads, you'll want to check out a gem like concurrent-ruby that offers e.g. a Promise implementation
[20:05:26] cincy_kal: if each step of the method takes a while (for example's sake lets say 2 seconds), then you have 12+ seconds of execution. Now if you could spawn each of those steps off asynchronously, it would go much faster
[20:05:36] havenwood: cincy_kal: Are you talking about Rails queries?
[20:06:59] cincy_kal: not necessarily. basically I have a larger complicated database. running a report requires aggregating this data. I do have concurrent-ruby gem and tried using Concurrent::Future but any time i get the value it is always nil whereas if i do it without async i get the values just fine
[20:07:00] gnufied__: has joined #ruby
[20:07:41] havenwood: cincy_kal: Are you talking ActiveRecord here?
[20:07:54] cincy_kal: I use Sequel
[20:11:10] havenwood: cincy_kal: concurrent-ruby should work fine with Sequel - have a gist of your futures code?
[20:12:51] ur5us: has joined #ruby
[20:13:02] cincy_kal: i can make one real quick
[20:13:12] yxhuvud: has joined #ruby
[20:13:20] havenwood: cincy_kal: 12+ seconds sounds like something that needs query optimizations, or if that's not possible, maybe jobs for workers that get returned via channels
[20:13:33] havenwood: cincy_kal: what DB?
[20:13:39] havenwood: cincy_kal: what web framework?
[20:14:17] havenwood: multiple seconds is too many seconds!
[20:15:45] elomatreb: Or too many records :P
[20:18:32] cincy_kal: https://gist.github.com/jtcrank/6435843efb2aaaf45acfb4f42afc6433
[20:18:52] cincy_kal: sequel, postgresql, padrino
[20:19:26] ^mtkd: has joined #ruby
[20:20:02] hfp_work: has joined #ruby
[20:20:21] cincy_kal: I agree multiple seconds is too many. there is a LOT of data spread among tables, but also mutations that data goes through. I have eagerloaded as much of the data as possible.
[20:26:59] havenwood: cincy_kal: Are your pg index and cache hit rate approaching 100%?
[20:27:39] havenwood: http://www.craigkerstiens.com/2012/10/01/understanding-postgres-performance/
[20:29:06] tvw: has joined #ruby
[20:29:18] cincy_kal: its indexed. and i exaggerated the times a bit, I was mostly looking for some insight into splitting the logic asynchronously
[20:30:06] za1b1tsu: has joined #ruby
[20:40:02] Es0teric: has joined #ruby
[20:41:56] r29v: has joined #ruby
[20:43:49] c0ncealed2: has joined #ruby
[20:48:53] graphene: has joined #ruby
[20:51:47] lele: has joined #ruby
[20:52:32] canurabus: saw this description the ruby docs for object.instance_variable_set: Sets the instance variable names by symbol to object, thereby frustrating the efforts of the class's author to attempt to provide proper encapsulation. The variable did not have to exist prior to this call."
[20:57:57] ur5us: has joined #ruby
[20:59:09] ur5us: has joined #ruby
[20:59:12] knight33: has joined #ruby
[21:09:43] zenspider: has joined #ruby
[21:18:56] zenspider: has joined #ruby
[21:18:58] naftilos76: has joined #ruby
[21:21:01] graphene: has joined #ruby
[21:24:33] blackmesa1: has joined #ruby
[21:34:20] sotrhraven: has joined #ruby
[21:36:49] sotrhraven: I know that ruby runs on a vm and they are working on a jit compiler. Would it be possible to have backend compiling? To say gcc, similar to what nim is doing with their compiler.
[21:37:15] clemens3: has joined #ruby
[21:37:59] hfp_work: has joined #ruby
[21:39:10] noobineer: has joined #ruby
[21:42:26] jrafanie: has joined #ruby
[21:43:31] caleBOT: has joined #ruby
[21:43:38] zlogan85: has joined #ruby
[21:44:48] hfp_work: has joined #ruby
[21:46:09] kujira: has joined #ruby
[21:50:31] ur5us: has joined #ruby
[21:54:11] zenspider: sotrhraven: yes and no. to what end? why are you asking?
[21:58:39] sotrhraven: well, you could get the speed of a compiled binary. Also targeting several back ends such as clang, js etc...
[21:59:51] sotrhraven: It feels backwards to me tbh seeing that ruby is written in c. Also ffi with those backend languages would be much easier.
[22:00:20] jrafanie: has joined #ruby
[22:01:01] jrafanie: has joined #ruby
[22:01:21] hfp_work: has joined #ruby
[22:04:09] sotrhraven: I am curious. Been looking at other languages and how things have been done. Ruby is my favorite.
[22:05:20] jrafanie: has joined #ruby
[22:05:53] lele: has joined #ruby
[22:06:20] venmx: has joined #ruby
[22:07:51] Paraxial: has joined #ruby
[22:09:22] zenspider: sotrhraven: no. "compiling" doesn't necessarily imply speed. Ruby is incredibly dynamic and does a bunch of stuff that makes in inherently slow(er). Nor would it mean much of anything to FFI (I'm not even sure what you are implying there).
[22:11:06] jrafanie: has joined #ruby
[22:13:46] ur5us: has joined #ruby
[22:14:38] konsolebox: sotrhraven: you can also write c++
[22:14:48] sotrhraven: ok not implying anything. I must just not understand the topic.
[22:15:26] sotrhraven: yes, c++ I might go do that
[22:16:46] sotrhraven: sorry like I said was just wandering, I seem to have wandered to far
[22:19:21] lele: has joined #ruby
[22:26:41] tdy: has joined #ruby
[22:26:42] kujira: has joined #ruby
[22:29:12] InfinityFye: has joined #ruby
[22:29:21] InfinityFye: has left #ruby: ()
[22:36:26] raynold: has joined #ruby
[22:42:57] sameerynho: has joined #ruby
[22:43:18] zenspider: sotrhraven: "you could get the speed of a compiled binary" yeah, you kinda are. but it's no big deal, just needs clarifying
[22:44:43] akaiiro: has joined #ruby
[22:45:02] elomatreb: If you want a Ruby-like syntax that compiles to what I think you mean you might check out Crystal
[22:48:25] sotrhraven: elomatreb: I have looked into Crystal. Currently I have problems running it on my distro.
[22:48:52] elomatreb: I can't really help with that, sorry
[22:50:36] Demos[m]: hm looking at it now
[22:50:46] Demos[m]: I've used nim quite a bit
[22:51:24] sotrhraven: no worries, I will get back to figuring out Nim.
[22:51:40] sotrhraven: Ruby will always be my favorite though
[22:52:14] Demos[m]: yeah I just learned ruby over the past month or so and it's like lisp but extremely no parentheses
[22:52:41] Demos[m]: also ruby tooling <3
[22:52:45] elomatreb: Lisp used up the Strategic Parentheses Reserve
[22:52:58] sotrhraven: yes, blocks are awesome, and the tooling is excellent
[22:53:35] sotrhraven: also the expressiveness
[22:53:58] Demos[m]: yeah the flexable syntax
[22:54:09] Demos[m]: nim has that too, at least a bit
[22:55:54] sotrhraven: gonna go grab some grub, also I am in florida and just heard some wicked thunder. Nice talking to all of you.
[23:02:12] banisterfiend: has joined #ruby
[23:08:08] caleBOT__: has joined #ruby
[23:09:12] mynameisdebian: has joined #ruby
[23:10:25] ellcs: has joined #ruby
[23:10:43] whathappens: has joined #ruby
[23:11:34] RougeR: has joined #ruby
[23:13:04] ruby[bot]: -bb $a:Kimmich$#ruby-banned Kimmich!*@*$#ruby-banned
[23:14:19] graphene: has joined #ruby
[23:16:12] taylorzr: has joined #ruby
[23:20:40] d5sx43: has joined #ruby
[23:21:00] nowhere_man: has joined #ruby
[23:21:43] StarSeed0000: has joined #ruby
[23:28:47] r29v: has joined #ruby
[23:33:19] donald: has joined #ruby
[23:36:05] donald: has left #ruby: ()
[23:38:14] zachk: has joined #ruby
[23:38:15] zachk: has joined #ruby
[23:39:35] whathappens: has joined #ruby
[23:42:01] \void: has joined #ruby
[23:54:23] nowhere_man: has joined #ruby