Activity Graph

Page 1 of 13 | Next »


[09:18:52] elomatreb: Quit: mep mep


[22:48:40] elomatreb: Quit: mep mep
[22:48:59] elomatreb: has joined #ruby-offtopic
[22:48:59] elomatreb: has joined #ruby


[02:21:58] elomatreb: to understand recursion, start by understanding recursion


[15:48:53] elomatreb: has joined #ruby
[15:48:54] elomatreb: has joined #ruby-offtopic
[17:57:41] elomatreb: Quit: mep mep
[17:58:32] elomatreb: has joined #ruby-offtopic
[17:58:32] elomatreb: has joined #ruby
[18:17:33] elomatreb: Quit: mep mep
[18:17:57] elomatreb: has joined #ruby-offtopic
[18:17:57] elomatreb: has joined #ruby


[21:59:21] elomatreb: Quit: mep mep


[16:49:48] elomatreb: *.net *.split


[05:12:43] elomatreb: Quit: mep mep
[05:13:57] elomatreb: has joined #ruby-offtopic
[05:13:57] elomatreb: has joined #ruby


[17:24:20] elomatreb: You can use Integer#times with map to get this easily
[17:25:58] elomatreb: Probably equivalent or slightly faster
[17:29:44] elomatreb: galaxie: 0.to_s, 1.to_s, ...


[16:51:37] elomatreb: Net: If you want high-quality random numbers, use the SecureRandom API
[16:53:18] elomatreb: There isn't really a downside to it, I assume the regular rand is seeded from something like microtime (it's not a static seed at least)
[17:08:56] elomatreb: May I ask why you want to use srand in the first place? It shouldn't be necessary with either API unless you really want the repeatable results behavior, and even then the default doesn't matter to you


[23:46:47] elomatreb: *.net *.split


[09:56:00] elomatreb: There is the --user-install option for installing to your home directory instead of the global default
[09:56:20] elomatreb: You may need to add something additional to your PATH though if you want to use executables installed by gem
[10:00:51] elomatreb: rake usually doesn't install anything, it's a task runner system (rake = Ruby Make)


[22:49:02] elomatreb: The pattern also has more benefits when testing, since you can start to use things like mock objects
[22:52:59] elomatreb: At a certain point you are right, they are technically very similar and the difference is at least partially aesthetic
[22:54:23] elomatreb: But using a singleton class with a method-based interface is definitely the preferred pattern in the larger ruby community, instead of exposing global "primitive" objects


[17:24:14] elomatreb: You have both choices available by default in Ruby, YAML can serialize complex types unlike JSON but fewer languages have YAML parsers in their standard library


[11:47:25] elomatreb: kidPalooma: I was in a similar situation regarding metadata and I didn't really find anything enjoyable, switched to doing those scripts in Python with mutagen


[04:19:18] elomatreb: 1xx - Do something else


[22:10:36] elomatreb: be nice to the bot :(


[08:52:01] elomatreb: Quit: mep mep
[08:52:32] elomatreb: has joined #ruby-offtopic
[08:52:32] elomatreb: has joined #ruby


[01:35:10] elomatreb: Quit: mep mep
[01:36:34] elomatreb: has joined #ruby-offtopic
[01:36:34] elomatreb: has joined #ruby
[01:36:50] elomatreb: Client Quit
[01:47:38] elomatreb: has joined #ruby-offtopic
[01:47:38] elomatreb: has joined #ruby
[02:12:15] elomatreb: Quit: mep mep
[02:13:08] elomatreb: has joined #ruby-offtopic
[02:13:08] elomatreb: has joined #ruby
[05:54:15] elomatreb: Quit: mep mep
[05:59:18] elomatreb: has joined #ruby-offtopic
[05:59:18] elomatreb: has joined #ruby
[06:11:02] elomatreb: Quit: mep mep
[06:11:57] elomatreb: has joined #ruby-offtopic
[06:11:57] elomatreb: has joined #ruby


[17:52:13] elomatreb: You need to share the full gist URL
[17:56:35] elomatreb: Turning the array of words you got by split'ing back into a cohesive string
[17:57:45] elomatreb: Your ifs are executed, the result is just discarded immediately because you're assigning the result of a call to #each
[17:58:16] elomatreb: #each always returns the collection it was called on, not what you do with that in the iterations
[17:59:17] elomatreb: No, you are assigning to the "correct" variable, but when all the words are done, the assignment in line 2 overrides what you changed
[18:00:19] elomatreb: https://eval.in/1072074 for a reduced demo


[13:03:17] elomatreb: Quit: mep mep
[13:03:50] elomatreb: has joined #ruby
[13:03:51] elomatreb: has joined #ruby-offtopic


[09:25:26] elomatreb: *.net *.split


[08:01:40] elomatreb: Chaining? Hashes are ordered, if that's what you mean
[08:02:44] elomatreb: You can use #uniq to get O(n) deduplication, FWIW
[08:03:31] elomatreb: Yes, but you don't have to implement it yourself
[08:04:28] elomatreb: Ruby hashes are not as straightforward as the classical hash table you might find in a textbook (i.e. they also contain a linked list to satisfy the order property), but for the most part they work like you'd expect


[21:11:44] elomatreb: Probably, yes. It's not considered particularly bad style
[21:44:33] elomatreb: You have variables named player_1 in the play method, and variables named player_one in the initialize


[14:05:36] elomatreb: Pretty sure that hasn't been the case in a *long* time, when I did Wordpress I used something gettext based


[14:45:13] elomatreb: Ping timeout: 260 seconds
[14:45:37] elomatreb: has joined #ruby
[14:45:38] elomatreb: has joined #ruby-offtopic


[13:20:09] elomatreb: A deadlock is an error condition, blocking is perfectly normal
[13:21:02] elomatreb: And not necessarily your computing, threading was a thing long before multiprocessors were available for 99% of systems
[22:14:22] elomatreb: If you have a file that is guaranteed to be required first you can just require it once in there and set Y = X, it should carry over to other files
[22:15:37] elomatreb: Not really, since ruby doesn't have a proper module system, sadly


[10:42:14] elomatreb: clorisu: Nothing in line 16 can prevent the expression in the lower lines from running, are you getting output that you don't expect?
[10:49:12] elomatreb: You're not outputting the age of the tree anywhere, only the height
[10:54:23] elomatreb: In line 18 you're adding one to it, and in line 19 you're outputting @height


[20:19:28] elomatreb: *.net *.split


[00:33:29] elomatreb: Quit: ZNC - https://znc.in
[00:34:41] elomatreb: has joined #ruby-offtopic
[00:34:41] elomatreb: has joined #ruby
[01:39:54] elomatreb: ! as well, btw
[01:42:49] elomatreb: Not necessarily just that, e.g. Array#pop is destructive but doesn't have a bang
[01:47:08] elomatreb: Some styleguides tell you to use it to indicate "dangerous (in some form, e.g. self-modifying or may raise) alternative to the method without the bang"


[16:33:02] elomatreb: d1rewolf: match only gets you the first match (if any) by design, you probably want String#scan
[19:36:41] elomatreb: One difference to Python might be that bundler and friends don't do the "environment changing" that virtualenv does, you need to prefix commands or use explicit stubs to *force* it to use your specified versions
[19:38:51] elomatreb: Does it actually apply bundler constraints or is it just a side effect of isolating the installed gems?
[19:41:00] elomatreb: The fallback behavior from what I remember if you don't prefix bundle exec is to use the latest installed version of a gem
[19:44:02] elomatreb: In short, Rubygems: Gemfile goes in -> *magic* -> something is executed
[22:20:41] elomatreb: RedNifre: What do you mean? There is Float for machine floating point numbers, or Rational if you need precision
[22:23:29] elomatreb: Or anything else for that matter :)
[22:27:12] elomatreb: Floats are often the source of bugs or weird behaviors in games, e.g. if you use them for coordinates your points become more spaced out if you go far from the center
[22:27:47] elomatreb: It depends on the numbers
[22:27:52] elomatreb: >> 0.1 + 0.1 + 0.1
[22:28:05] elomatreb: #=> 0.30000000000000004
[22:31:42] elomatreb: Hash.new(0.0)
[22:32:24] elomatreb: There is a caveat with this if you want to use it with "complicated" objects instead of the "primitives" like numbers, reading the docs of Hash#new is worthwhile
[22:45:56] elomatreb: RedNifre: Enumerable#
[22:46:20] elomatreb: ignore that, sorry
[22:46:51] elomatreb: Enumerable#sort_by will help you and was what I meant to say
[22:50:17] elomatreb: Hashes are ordered and implement Enumerable, so the to_a step is not necesssary fwiw


[22:04:33] elomatreb: #RubyOnRails, but you need to authenticate with nickserv to talk
[22:07:11] elomatreb: Those spammers still at it?


[15:09:09] elomatreb: Can you use the non-blocking operations for this?
[15:12:11] elomatreb: Mmh, isn't there a way to just give the subprocess your own stdout in the Open3 call?
[16:28:00] elomatreb: The answer would have been to collect/#to_a the enumerators in the block :s
[19:17:51] elomatreb: Two aspects: 1) Legally, obey the restrictions of the source license 2) socially, if it's just a minor change or something like that and/or the gem is still maintained, a pull request may be better
[19:19:31] elomatreb: If you've written the code, opening a pull request can't hurt. Although the owner doesn't appear too active
[19:22:23] elomatreb: The problem is more that if this project now becomes active again and adds a new feature, your two implementations have diverged and people who want to use the gem will have to choose.
[19:22:41] elomatreb: Esp. if you use the same toplevel namespace this is really annoying to deal with
[19:32:32] elomatreb: What would wrapping that get you over SecureRandom.uuid, if I may ask?
[20:17:28] elomatreb: baweaver: ^ heresy


[10:32:25] elomatreb: alex-kid: Generally you approach this kind of thing in Ruby by using default values for arguments, and selecting these so that all different behaviors are special cases of one general behavior
[10:33:49] elomatreb: This sadly is the downside of non-strict typing, as there is no consistent concept of signature in Ruby
[10:36:07] elomatreb: There are keyword arguments that work basically like named parameters, not sure what you mean by inner/outer
[10:38:28] elomatreb: No, Ruby does not have this
[10:41:05] elomatreb: You can't differentiate between named parameters and positionals (and optional vs. required) at runtime, you need to look at the source
[10:42:38] elomatreb: For methods that are defined in Ruby (i.e. not a native extension) you can look at Method#source to get their source code, and interpret that. But don't.


[07:33:41] elomatreb: ri is your friend, at least for pretty much anything in the standard library
[07:37:24] elomatreb: Did you build your Ruby without documentation by accident?
[07:42:46] elomatreb: It's really nice yeah. If you use pry as your REPL it also has built-in ri commands, so you don't have to leave
[07:44:12] elomatreb: Syntax highlighting and a whole bunch of convenience features


[08:32:35] elomatreb: That's certainly a unique task, what's it for if you don't mind me asking?
[08:33:47] elomatreb: You could probably superficially ruby-ize it by using ranges/upto instead of the loops, but that's largely a cosmetic change


[18:56:28] elomatreb: Modify seems to be a lambda, [] is a way of calling the lambda with the passed parameter


[21:42:48] elomatreb: stevefink: Depends on what a_complex_object is, if it's a variable you will get an array that contains the same object multiple times
[21:42:59] elomatreb: But if it's a method that creates a new instance you will get new instances
[21:44:37] elomatreb: It should, but e.g. if you modify one element you will also modify all the others (since there's only one)
[21:49:52] elomatreb: No, that creates new strings :)


[19:41:12] elomatreb: They get put into a shared directory in your home dir somewhere, usually
[19:41:45] elomatreb: `gem uninstall gemname` uninstalls a gem, bundle install will then install it again
[19:45:10] elomatreb: What are you doing that's raising that error?
[19:45:46] elomatreb: If it's a bundle gem you may need to prefix with `bundle exec ` to get it to load your environment correctly
[19:49:18] elomatreb: You may have a look through the bundler docs (https://bundler.io/docs.html), but I don't know if there is a comprehensive article like that, sorry
[19:49:50] elomatreb: In short it basically forces the command after the exec to actually and only use the gems defined in the gemfile, as opposed to mixing and matching with other gems that just happen to also be installed on the machine
[19:53:28] elomatreb: havenwood: lol nice
[20:18:38] elomatreb: README: README.md
[20:22:19] elomatreb: two letters are always ccTLDs, yeah
[20:22:41] elomatreb: Except it's not actually the region that is getting the money, it's some shell corporation


[14:02:55] elomatreb: If you say so
[19:34:32] elomatreb: If it's refinement-based it's fine though? Use it if you want to


[00:07:00] elomatreb: *.net *.split
[00:15:40] elomatreb: has joined #ruby


[12:42:00] elomatreb: Although these are API docs mostly. They have examples usually, but it's not a coordinated overview of the language
[14:27:24] elomatreb: Isn't this like a dynamic programming version of knapsack?
[14:31:18] elomatreb: Is there some criterion by which you want the bottles to be selected?
[23:13:01] elomatreb: Why shouldn't it? send is a public method, after all
[23:13:56] elomatreb: public_send isn't private?
[23:14:42] elomatreb: >> "it's not".public_send :length
[23:19:53] elomatreb: Which probably isn't entirely uncommon, it's a convenient pattern e.g. for implementing a command-like system


[15:30:31] elomatreb: You could also look into something like pstore to get transactional security
[16:22:13] elomatreb: I feel like we should report this as a crime against *something*
[16:23:11] elomatreb: Honest advice: A preprocessor is most certainly not the solution you're looking for
[16:23:42] elomatreb: Post the actual problem you want to solve, and we can help (now it seems like you decided on a solution and want to know how to realize it)
[16:23:56] elomatreb: Alec: In the context of Ruby, I meant
[16:30:01] elomatreb: If we're talking code generation a proper, safe macro system is the way to go IMO, e.g. like Rust has


[10:45:47] elomatreb: The only *proper* way to do this is using a tool that doesn't allow this to happen, i.e. avoid shelling out with string interpolation
[10:50:01] elomatreb: If you just want to substitute characters something simple like String#tr is worth a look
[10:51:25] elomatreb: A blacklist of "dangerous" files will not work out in the long run, your OS protects the files
[10:56:42] elomatreb: I'm not quite sure what the problem you're worried about is btw. Are you creating files?
[11:03:44] elomatreb: And 0-bytes. And a bunch more depending on filesystem and/or platform (e.g. NTFS has an infinite number of illegal filenames)
[11:04:01] elomatreb: Or rather, NTFS as used by Windows
[11:05:01] elomatreb: Uh could you not throw slurs around like that please?
[11:08:44] elomatreb: leitz: Looking at your code, the worst that could happen is the user accidentally overwriting a file, but only if they have write access in the first place
[11:09:34] elomatreb: Usually in a case like this the best way to proceed is to print a warning and ask for confirmation, but you can't e.g. end up borking /etc/passwd because a regular user can't do that anyway
[11:11:12] elomatreb: Depending on the data you're storing you're often much better off with a database instead of files, also solves this problem
[11:12:41] elomatreb: But if you do need to store files the usual approach is to both sandbox your application as much as possible, and/or to store files in an "abstract" manner that doesn't directly translate to real-fs paths
[11:15:04] elomatreb: You also need to reject/remove slashes, otherwise you still end up accidentally references directories. E.g. your example will try to reference a directory called "Now_isnt_a_good_time_to_write_"
[11:18:03] elomatreb: Oh I missed the gsub, lol. That should cover most cases, but you could still end up with weird directories (e.g. `...` is a perfectly valid name, but looks really awkward and hides in ls output)
[11:19:55] elomatreb: Uh, yeah. Sorry, I've been up all night
[11:20:28] elomatreb: The more you escape/remove though, the more you need to worry about collisions
[11:25:58] elomatreb: Ruby is object-oriented in all aspects, but you see a lot of patterns that are often described as functional
[11:30:37] elomatreb: You technically can for sure, but defs outside of classes are no less object-oriented than with classes. They define methods on the implicit "main" object
[11:31:52] elomatreb: Your code will quickly become really spaghetti-y probably, but there's nothing stopping your from trying
[11:32:04] elomatreb: Not really no.
[11:33:02] elomatreb: 1. Any data structure is also a class, including the primitives like string and integers 2. Major difference to functional languages is that nothing prevents you from causing side effects
[11:38:04] elomatreb: Certainly, but don't be surprised when people mix and match approaches
[20:31:34] elomatreb: FernandoBasso: Yes, everything external needs a method, and attr_accessor will not work with class variables. Generally they're not want you want anyway though
[20:33:29] elomatreb: Yep, and `def foo=(value)` for the setter
[20:35:15] elomatreb: Beware of the slightly weird behavior of class variables when combined with inheritance btw


[03:13:29] elomatreb: JJonah: You could abuse Array#flatten, that gets you a relatively simple solution
[03:14:36] elomatreb: Something like https://eval.in/1036353
[03:20:46] elomatreb: Complexity should be something like O(n*m) where n is the totally flattened array size and m is the nesting depth
[03:37:46] elomatreb: Oh that's even better
[03:50:45] elomatreb: evdubs: That gets very difficult. You could instead try a metaprogramming-based solution, e.g. with the method_added hook


[02:43:50] elomatreb: evdubs_: You can write a log method that runs a block, and based on the log level decides not to run the block
[02:44:45] elomatreb: That just controls printing though, if you do `Log.debug expensive_method_call` it will still run the method even if it won't print the output
[02:46:08] elomatreb: Oh, logger actually supports the technique I mentioned: https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html#class-Logger-label-How+to+log+a+message
[02:46:32] elomatreb: The block form is what you want
[02:46:50] elomatreb: It won't do as much optimization as in Java, but it'll still save you the method call
[04:29:06] elomatreb: memo1: You can access the environment variables with the ENV global (e.g. `ENV["HOME"]`)
[23:38:22] elomatreb: But for playing around a local repl is probably more useful
[23:39:06] elomatreb: It wraps your input, click the link to see how
[23:41:55] elomatreb: Not sure, sorry. There are some other books linked in the topic, but I don't know if they check that box
[23:42:51] elomatreb: I doubt that exists, rubys grammar is notoriously horrifying
[23:44:37] elomatreb: If you want to play around check out https://github.com/pry/pry


[21:19:35] elomatreb: Feels like a weird special case for how rarely they're used
[21:22:17] elomatreb: You'd probably have to restrict it to literals (i.e. no variables/expressions) in order to keep it at least a little unambigous


[09:50:16] elomatreb: Ping timeout: 256 seconds
[10:20:52] elomatreb: has joined #ruby


[01:58:57] elomatreb: You can break across lines and indent, if it helps readability go for it
[16:56:43] elomatreb: Generally finalizers are a very fragile way to deal with resources, Ruby prefers you use explicit management (e.g. blocks) where applicable
[19:03:27] elomatreb: cthulchu: About the ordering part? Unless you have parallel code that is breaking assumptions the ordering guarantee is reliable


[14:10:47] elomatreb: Making a name uppercase gives it constant-like treatment in Ruby, you can assign anything to local variables (lowercase names) too but it's kind of useless
[14:23:14] elomatreb: Because Ruby ifs don't work like preprocessor ifs.
[14:23:50] elomatreb: If you want to achieve what you can assign like `h["modifiers"] = ...` in an if after the hash initialization
[14:25:18] elomatreb: modified yours: https://hastebin.com/toyaxezeve.rb
[14:25:47] elomatreb: It doesn't add it if the condition isn't met, yeah
[14:26:38] elomatreb: In general this seems like a kind of dirty approach though, is there a good reason you can't just always have the key and just set it to the value, and ignore it later if it is nil?
[14:27:31] elomatreb: Ruby will automatically remove null fields
[14:27:39] elomatreb: The JSON serializer, that is
[14:28:23] elomatreb: Yeah I misread, sorry
[14:28:39] elomatreb: And you have a schema to conform to?
[15:33:56] elomatreb: You can, but in order to specify to_modifiers you also have to provide some value for from_mandatory_modifiers
[15:34:11] elomatreb: Alternatively you can use keyword arguments if you want specifying one but not the other to be convenient


[16:23:53] elomatreb: Esp. the very recent versions are very worthwhile for server use because of their performance gains
[16:25:23] elomatreb: And ruby maintenance is very genereous compared to other projects, e.g. 1.8.7 was supported for like 5 years?
[16:26:50] elomatreb: Aren't you paying Redhat for backport support? People here are here on their free time
[16:32:57] elomatreb: Arguably the problem here isn't ruby, but the promises that OSes make about stability that really don't hold true
[16:33:17] elomatreb: Because even if you backport ruby fixes, the library you may depend on probably won't receive this treatment


[14:01:21] elomatreb: Doesn't #text do that?
[14:24:20] elomatreb: The standard library contains a pretty good CSV library
[14:29:44] elomatreb: Web site crimes
[14:41:19] elomatreb: Quit: ZNC - https://znc.in
[14:42:11] elomatreb: has joined #ruby
[17:18:26] elomatreb: canurabus: Still relevant?
[17:52:00] elomatreb: On the other hand, IPAddr can also deal correctly with IPv6 addresses
[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: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
[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
[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:15:45] elomatreb: Or too many records :P
[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:52] elomatreb: I can't really help with that, sorry
[22:52:45] elomatreb: Lisp used up the Strategic Parentheses Reserve


[16:44:19] elomatreb: Calling .values on it goes through it and gives you all the values (without the keys) in a big list
[16:45:12] elomatreb: You said you know Python? Hashes are the Ruby equivalent of dictionaries
[16:48:51] elomatreb: Pretty much, yeah
[16:49:10] elomatreb: You can use any type of object as keys and values, e.g. strings and symbols are commonly used
[16:51:08] elomatreb: Just assigning different values to a single key overwrites, so to actually store multiple values you'd need to use an array as the value
[16:51:34] elomatreb: You can also nest Hashes, but at a certain point it makes more sense to construct a proper class for your objects