#ruby - 16 November 2018
« Back 1 day Forward 1 day »
[05:52:34] Inside: by that I mean... get a long-term stable UUID of some sort that represents the file
[05:59:09] marz_d`ghostman: I already have an existing spec files for some of my .rb files. Is there a command to automatically generate spec files for newly created .rb files?
[06:30:04] baweaver: Slides and other content from my talk - https://twitter.com/keystonelemur/status/1063306367392342016
[06:50:55] marz_d`ghostman: Is it possible to create an instance variable from a module included in a class? Like inside self.included method of a module?
[06:53:42] marz_d`ghostman: baweaver: I have created a module specifically for Logging which I just want to include in a class. In the said module, I want to create a specific log file for each instance of the class where I include it. So as to separate logging functionalities.
[06:54:31] baweaver: I'd just have a universal logger unless you have some seriously gnarly application
[06:56:28] marz_d`ghostman: I guess I'll just have to create the logger in the class itself to make it simple
[06:57:08] marz_d`ghostman: Every instance of a class will run a different sync, so I want to log it on different files depending on the directory it is syncing
[07:08:11] marz_d`ghostman: baweaver: Is this a good design though? https://gist.github.com/marzdgzmn/f38b095c15eb737c7a544f46358fef28
[10:52:35] vasilakisFiL: hi, accessing a hash value by key is extremely fasst. Is it possible to access the value of the first key with the same performance ?
[10:56:42] phaul: That's becasue the enumeration doesn't have to deal with the key lookups at all, it just walks the entries by the link pointers. That's how Hash is Enumerable. But I'm speculating, and I don't actually know the implementation in detail
[10:59:25] vasilakisFiL: for the record here are the results: https://gist.github.com/vasilakisfil/6bd0375681ba65d8b6fa1d3cf2e720bd
[11:00:17] vasilakisFiL: ah no my bad again, I am saying it right: HASH[:aaaa] is the fastest by far
[11:04:04] vasilakisFiL: yeah maybe it is actually, does it make difference ? let me check initializing before the faked data
[11:05:56] vasilakisFiL: now made it to be the first, now it seems like directly accessing the key is even faster
[11:49:09] canton7: grr12314, from phaul's doc: Matches rxp against the contents of $_. Equivalent to rxp =~ $_.. Looking at the doc for =~ (in the same page): "If a match is found, the operator returns index of first match in string, otherwise it returns nil."
[13:18:31] ruby[bot]: phaul: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `' for nil:NilClass
[15:25:47] marahin: hey guys. I'm doing something wrong here. https://gist.github.com/Marahin/6f68bc9cfa2527cde06091d95afd88b8 This is my CI script that runs two jobs, as ruby threads. However, if any of the jobs fail, or the script is interrupted by ^C, all jobs and this script should be killed.
[15:49:29] marahin: So its interesting, because it seems that the job that is spawned and still continues to run in the background isn't part of Thread.list
[15:49:46] havenwood: marahin: Shelling out to commands. Yeah, looks like so: https://gist.github.com/Marahin/6f68bc9cfa2527cde06091d95afd88b8#file-ci-rb-L19
[15:51:20] havenwood: marahin: I'd suggest looking at spawning processes rather than shelling out from threads. Sec, let me find an article.
[15:51:48] havenwood: marahin: https://saveriomiroddi.github.io/Executing-and-killing-ruby-parallel-background-jobs/
[15:54:10] marahin: havenwood: thank you. Do you know, if there's a way to check for status of the forked processes, like I do with threads?
[16:06:25] havenwood: marahin: Jesse Storimer wrote a great little book on Processes in Ruby that's worth a read.
[16:09:41] havenwood: marahin: Or for most platforms you can use Process::getpgid: https://docs.ruby-lang.org/en/2.5.0/Process.html#method-c-getpgid
[16:11:05] marahin: havenwood: I'll give these a read. Yeah, we're using Macs or anything unix like, so it shouldn't be an issue
[16:11:42] marahin: and where the example is working, when I try to apply that to a collection of jobs, its exiting my binding.pry instantly :(
[16:12:26] havenwood: marahin: join or detach those processes - in your case here, looks like you want to joinn
[16:14:47] marahin: (bin/ci:19:in `<main>': undefined method `irb' for #<Binding:0x007fee8520b9f0> (NoMethodError))
[16:16:58] marahin: i thought that maybe i can tinker with the code examples in the article you've sent me and get more or less a working result
[16:17:09] marahin: but I think I need to understand whats happening exactly with fork and Process.detach first
[16:18:56] havenwood: marahin: I'm assuming this example doesn't fail if you change the jobs to be say "ls" and "pwd"?
[23:55:22] jayjo: im looking at this ruby project: https://github.com/helpyio/helpy that uses bundle exec rake db:migrate - where can I find that migrate script in the project?