« Back to channel list

#ruby - 27 March 2017

« Back 1 day Forward 1 day »
[00:09:41] thadtheman: has joined #ruby
[00:17:49] Pumukel: has joined #ruby
[00:18:11] tmtwd: has joined #ruby
[00:18:12] JeanCarloMachado: has joined #ruby
[00:19:57] l4v2: has joined #ruby
[00:24:57] enterprisey: has joined #ruby
[00:26:50] ragesoss: has joined #ruby
[00:27:40] jonatin: has joined #ruby
[00:34:53] olivier__: has joined #ruby
[00:41:34] bronson: has joined #ruby
[00:43:40] milardovich: has joined #ruby
[00:44:33] Renich__: has joined #ruby
[00:46:25] solocshaw: has joined #ruby
[00:49:15] zeddan: has joined #ruby
[00:49:25] ace05: has joined #ruby
[00:54:19] charliesome: has joined #ruby
[00:54:44] postmodern: has joined #ruby
[01:04:31] bmurt: has joined #ruby
[01:06:50] d^sh: has joined #ruby
[01:07:24] hahuang65: has joined #ruby
[01:09:09] l4v2: has left #ruby: ()
[01:15:31] mooser: has joined #ruby
[01:15:43] l4v2: has joined #ruby
[01:18:25] l4v2: has left #ruby: ()
[01:21:01] aglorei: has joined #ruby
[01:25:46] olivier__: has joined #ruby
[01:27:52] cam27: has joined #ruby
[01:30:41] cam27: has joined #ruby
[01:31:06] cam27: has left #ruby: ()
[01:31:19] cam27: has joined #ruby
[01:31:58] cam27: has joined #ruby
[01:34:22] cyphase: has joined #ruby
[01:39:37] cam27: has joined #ruby
[01:40:37] inkshark: has joined #ruby
[01:42:52] milardovich: has joined #ruby
[01:42:57] cam27: has left #ruby: ()
[01:43:40] cam27: has joined #ruby
[01:45:06] duckpupp1: has joined #ruby
[01:47:43] kent\n: has joined #ruby
[01:48:49] Pumukel: has joined #ruby
[01:50:33] cam27: has joined #ruby
[01:52:40] milardovich: has joined #ruby
[01:54:39] houhoulis: has joined #ruby
[01:56:12] Verity: has joined #ruby
[01:56:18] Verity: very nice
[01:56:41] eclecticjohny: has joined #ruby
[01:59:32] Jameser: has joined #ruby
[02:00:51] Verity: has joined #ruby
[02:00:55] Verity: it didnt work
[02:00:58] Verity: NoMemoryError: failed to allocate memory
[02:00:59] Verity: from (irb):49:in `permutation' @_@
[02:01:02] Verity: and then all of my programs closed
[02:01:24] allisio: >> n = 474733953312345340626; 10.times.reduce('') { |s, c| n, b = n.divmod(128); s << b }
[02:01:26] ruby[bot]: allisio: # => "Ruby is <3" (https://eval.in/761584)
[02:03:17] allisio: As matthewd pointed out earlier, you don't have near enough memory to store 45! permutations at once.
[02:03:27] d^sh: has joined #ruby
[02:03:33] thadtheman: has joined #ruby
[02:05:07] libastral: has joined #ruby
[02:05:45] hutch34: has joined #ruby
[02:06:16] allisio: >> begin; a = [1]; loop { a += a }; rescue NoMemoryError; a.size; end
[02:06:17] ruby[bot]: allisio: # => 8388608 (https://eval.in/761588)
[02:06:45] allisio: Which is interesting, 'cause that's not even a power of 2.
[02:07:57] allisio: I take that back. :/
[02:08:43] Tau: has joined #ruby
[02:08:54] Verity: I cant calculate it
[02:09:14] Verity: how much RAM I would need to hold all permutations of the phrase "the quick brown fox jumps over the lazy dog"
[02:09:19] Verity: it seems like it would be many gigabytes
[02:11:17] matthewd: Verity: Well I told you how many permutations there are earlier, so the RAM calculation is trivial from there
[02:11:32] Verity: ACTION scrolls up
[02:12:00] allisio: >> (1..'the quick brown fox jumps over the lazy dog'.size).reduce(:*).to_s.gsub /(\d)(?=(\d{3})+$)/, '\1,'
[02:12:01] ruby[bot]: allisio: # => "60,415,263,063,373,835,637,355,132,068,513,997,507,264,512,000,000,000" (https://eval.in/761589)
[02:12:19] allisio: Too many RAMs.
[02:12:49] allisio: All the RAMs in this supercluster, to be sure.
[02:12:57] matthewd: Multiply by 43 bytes per string, divide by 1073741824: 2419442228716867912939070424946119909000000000 gigabytes
[02:13:53] Verity: why do I divide by that number
[02:13:59] Verity: and what on earth is all of this (1..'the quick brown fox jumps over the lazy dog'.size).reduce(:*).to_s.gsub /(\d)(?=(\d{3})+$)/, '\1,'
[02:14:04] matthewd: Bytes in a gigabyte
[02:14:06] Verity: 1..'phrase'
[02:14:10] Verity: matled, ah
[02:14:18] Verity: matthewd, ah
[02:14:27] matthewd: >> (1.."hello".size).to_a
[02:14:28] ruby[bot]: matthewd: # => [1, 2, 3, 4, 5] (https://eval.in/761590)
[02:15:25] Verity: >> (1..", world!".size).to_a
[02:15:26] ruby[bot]: Verity: # => [1, 2, 3, 4, 5, 6, 7, 8] (https://eval.in/761591)
[02:16:05] Verity: well thats easy enough
[02:16:09] Disavowed: Hey Verity - how's the project going??
[02:16:16] Verity: return an array of numbers from 1 to the legnthj of the str
[02:16:23] matthewd: (1..n).reduce(:*) is n factorial, which is the number of permutations in a collection of that size
[02:16:28] Verity: Disavowed, well, I think. I finally figured out the crc problem
[02:17:02] Disavowed: Oh neat! Are you still enjoying Ruby as a language?
[02:17:49] Verity: its funny you ask
[02:17:51] Verity: in fact I love it
[02:18:03] Verity: and more and more I feel as though I prefer it to python, but I do need to go deeper with python to be sure
[02:18:09] Verity: although I'm already enjoying ruby much more
[02:18:11] ace05: has joined #ruby
[02:18:16] Verity: I never liked all of that indenting
[02:18:20] Verity: and I can use printf here
[02:18:26] Verity: plus the syntax seems more clean
[02:18:45] Verity: I'll have more to go on soon hopefully, these are my initial impressions
[02:19:11] Verity: I made a simple encryption program too, just for fun
[02:19:18] Verity: its not the most secure
[02:19:28] Verity: but I found some great ruby features along the way
[02:19:40] allisio: Ruby has the best features.
[02:20:07] Disavowed: Verity: I know things about CPython that no-one should ever have to know, but I greatly prefer Ruby for many of the reasons you just delineated
[02:20:19] Disavowed: What features are you enjoying?
[02:20:25] genpaku: has joined #ruby
[02:20:28] enterprisey: has joined #ruby
[02:20:55] Verity: I'm still learning it, but map is great
[02:21:04] Verity: also many of the methods that all objects seem to have
[02:21:09] Vile`: has joined #ruby
[02:21:14] allisio: >> Object.instance_methods.size
[02:21:14] Verity: so conversions are painless, once you know the tricks
[02:21:15] ruby[bot]: allisio: # => 56 (https://eval.in/761592)
[02:21:20] Verity: I learned about packing and unpacking today
[02:21:33] Rodya_: has joined #ruby
[02:21:37] Verity: >> "hello".unpack('C*')
[02:21:37] ruby[bot]: Verity: # => [104, 101, 108, 108, 111] (https://eval.in/761593)
[02:21:49] Verity: actually that was yesterday
[02:21:52] Verity: but its great, regardless
[02:22:26] Verity: I've had some moments where I assumed something would work and it did
[02:22:40] Verity: that was nice
[02:22:42] allisio: Disavowed: I recently tried to do a deep dive into CPython, but I started hitting walls pretty quickly.
[02:23:04] Disavowed: It's funny you should mention map - It's a core tennet of functional programming and FP is a second class citizen in Python.
[02:23:16] Disavowed: allisio: I read one a while back - I'll see if I can dig it out for you
[02:23:23] Disavowed: My C is horrific but it was so well written
[02:23:33] zeddan: has joined #ruby
[02:23:52] allisio: Disavowed: Well, I wanted to try my hand at "fixing" the fact that `chr()` doesn't use "\b" as the repr() of 0x8, for instance.
[02:24:26] Verity: oh one more thing, Disavowed, I found my "IDE" for ruby -- I think
[02:24:36] allisio: Turns out the starting point was "Python/clinic/bltinmodule.c.h".
[02:25:14] Disavowed: allisio: Oh that's annoying - I had no idea that's what it did to be quite honest but I can see exactly why you'd want to fix that
[02:25:17] rhyselsmore: has joined #ruby
[02:25:19] Disavowed: Verity: What did you go with?
[02:25:25] allisio: >> require 'objspace'; ObjectSpace.memsize_of 'the quick brown fox jumps over the lazy dog' # matthewd: Not quite 43. :)
[02:25:26] ruby[bot]: allisio: # => 20 (https://eval.in/761599)
[02:25:55] Verity: I was going to try rubymine but I dont like signing in to use software. So I found visual studio code. On the left, hide/unhide file browser, I can edit my test text files right in there in tabs. Then its got console in the bottom for irb or running the program. It's also got colorizing and ruby highlighting. It has completion for variables you've added. There are plugins for syntax error and debugging, that I've yet to try.
[02:26:12] Verity: I dont like that its M$ but its open source at least
[02:26:15] Verity: or something close to it
[02:26:42] Verity: its lighghtweight and fast and has increased my productivity with ruby
[02:26:55] Verity: I have access to rubymine for 1 year free though, so I may try that
[02:27:27] Disavowed: allisio: I think this was the series: https://tech.blog.aknin.name/2010/04/02/pythons-innards-introduction/ although I suspect it's a little broad for your use case. I really enjoyed reading it from a language design perspective
[02:27:51] Disavowed: Verity: if I was using windows, I would use Visual Studio for sure
[02:27:59] Disavowed: It's one of the best IDEs around in my opinion.
[02:28:12] Disavowed: I have a similarly low opinion of all things microsoft
[02:28:13] Verity: https://code.visualstudio.com/
[02:28:15] Verity: this is vs code
[02:28:17] Verity: its cross platform!
[02:28:20] Verity: if you may not have seen it
[02:28:25] Verity: its really quite nice, actually.
[02:28:41] Verity: its blowing up right now
[02:28:46] Verity: and there are many great plugins
[02:29:09] Rodya_: has joined #ruby
[02:29:09] milardovich: has joined #ruby
[02:29:09] Verity: it seems to fit ruby well
[02:29:19] Verity: I dont need the bulk of a full ide
[02:29:20] Disavowed: Verity: I appreciate the link but you'll pry vim and tmux from my cold, dead hands!
[02:29:27] Disavowed: I actually hadn't seen it though - it looks very nice
[02:29:46] Verity: do you use any special plugins for ruby, with vim?
[02:29:47] Disavowed: I might actually have a play with this
[02:29:53] Verity: or just basical syntax highlighting
[02:30:35] Disavowed: Yeah a few. I'm particularly fond of anything written by Mr. Pope: https://github.com/tpope?tab=repositories
[02:30:47] Verity: I've been learning some vim. I have a basic setting going on a vps
[02:30:53] Verity: I'll check that link
[02:30:57] Disavowed: The Rails one is wonderful
[02:31:00] Disavowed: I think I use this too: https://github.com/vim-ruby/vim-ruby
[02:31:41] Disavowed: Verity: My tip would be to take a look at plugins like Nerdtree, MRU and Command T - once you can hop between files quickly, Vim becomes very usable, very quickly
[02:31:57] matthewd: Verity: How are you going on your original project?
[02:32:29] DaniG2k: has joined #ruby
[02:32:50] Verity: I've got the file read and the packets are built correctly. I could improve my padding code, perhaps. It may just be preference. I've started to add more constants and am beginning to think about the state machine
[02:33:11] Verity: I need to send start of transmission, wait for ack, etc]
[02:33:21] Verity: so that will be my next step now that I'm getting some of the basics down
[02:33:31] Verity: I'm really glad I decided to use ruby
[02:33:40] Verity: unless the serial port doesnt work right in the end, lol
[02:33:47] Verity: I havent tested it yet, I'm assuming it will work
[02:33:52] Verity: no errors when I call the methods, etc
[02:35:06] Verity: so I had a strange glitch, also, matthewd and Disavowed. I couldnt figure out why two bytes were being appended to the packet
[02:35:12] Verity: and one of them always seemed to be 194 or something
[02:35:14] Verity: it didnt make any sense
[02:35:26] Verity: the reason ended up being, packet << Digest::CRC8.hexdigest(packet) returned "bb"
[02:35:37] Verity: and .hex on it wasnt doing what I thought, somehow, someway
[02:35:43] Verity: I tried and tried to understand, but couldn't
[02:35:46] Verity: then, I guessed.
[02:35:49] Verity: packet << Digest::CRC8.digest(packet) fixed it.
[02:36:05] Verity: a perfect byte returned, a nd easily appended
[02:36:14] mutter2017: has joined #ruby
[02:36:20] Verity: also, packet << " " until packet.length > 5 this is my padding code. I'm not sure if its the best
[02:36:24] Verity: it seems to work great
[02:36:33] Verity: I enjoy how readable ruby code is
[02:36:54] matthewd: Are you working to a defined protocol, or is specifying it part of your task?
[02:37:01] Verity: its defined
[02:37:19] Verity: 7 byte packet, soh, 5 data bytes, 8 bit crc
[02:37:27] Verity: ack + nak, with start and eot
[02:37:37] Verity: and provisions for all states of transmission
[02:37:42] Verity: on send + recieve side
[02:37:43] ledestin: has joined #ruby
[02:37:55] matthewd: And spaces for padding?
[02:38:07] Verity: its actually supposed to be 0xFF, I meant to change that
[02:38:39] Verity: I have a week from wednesday to complete it, and I'm on schedule so far with the packets built and loaded into the array
[02:42:24] bronson: has joined #ruby
[02:43:20] Verity: >> "hello".chars
[02:43:21] ruby[bot]: Verity: # => ["h", "e", "l", "l", "o"] (https://eval.in/761602)
[02:43:39] Verity: >> "hello".chars << 0xFF
[02:43:40] allisio: Hey, why do you do that?
[02:43:40] ruby[bot]: Verity: # => ["h", "e", "l", "l", "o", 255] (https://eval.in/761603)
[02:44:14] Verity: is chars deprecated?
[02:44:22] astrobunny: has joined #ruby
[02:44:37] Verity: oh, it has to be a minimum size
[02:44:42] Verity: thats why we pad it
[02:44:50] Verity: the receiver expects 7 bytes
[02:45:01] havenwood: Verity: If something is deprecated it'll have a deprecation warning.
[02:45:10] Disavowed: Is there any way to see a list of clases in a module at runtime?
[02:45:19] Verity: havenwood, alrigth
[02:45:19] allisio: >> 'foo'.ljust 7, 'x' # Verity
[02:45:20] ruby[bot]: allisio: # => "fooxxxx" (https://eval.in/761605)
[02:45:40] allisio: Regrettably(?), you can't provide a codepoint as the second argument.
[02:45:47] Verity: >> 'hello'.ljust 7, 0xFF
[02:45:48] ruby[bot]: Verity: # => no implicit conversion of Fixnum into String (TypeError) ...check link for more (https://eval.in/761606)
[02:46:01] havenwood: Disavowed: module.constants
[02:46:14] jeyraof^mbpr: has joined #ruby
[02:46:19] Verity: >> 'hello'.ljust 7, \xFF
[02:46:20] allisio: Disavowed: `mod.constants.grep(Class)`, even.
[02:46:20] ruby[bot]: Verity: # => /tmp/execpad-7df220ee167c/source-7df220ee167c:2: syntax error, unexpected $undefined ...check link for more (https://eval.in/761607)
[02:46:36] Verity: ah, I see
[02:46:37] matthewd: or even ?\xFF
[02:47:07] olivier__: has joined #ruby
[02:47:15] Disavowed: allisio: Thank you, you saint.
[02:47:49] Verity: why the ?\xFF vs \xFF
[02:48:02] allisio: ? is for "character literals".
[02:48:07] allisio: The latter is just a SyntaxError.
[02:48:22] matthewd: Verity: My general advice would be not to try to treat a string as a list of bytes; treat it as a list of characters, and only consider the real "rawness" at the very last moment you absolutely must
[02:48:32] matthewd: >> ?x == "x"
[02:48:32] ruby[bot]: matthewd: # => true (https://eval.in/761608)
[02:48:42] allisio: >> ?\M-~ == "\xFE"
[02:48:43] ruby[bot]: allisio: # => true (https://eval.in/761609)
[02:48:53] allisio: Shame about there not being a way to get "\xFF" with a metacharacter.
[02:49:07] Verity: I tried that a bit, but I need to be careful not to oversize the packet
[02:49:15] Verity: so I need to be aware of the sizes
[02:49:21] havenwood: >> module Disavowed; class Puppies; end; class Kittens; end; module Smurfs; end; end; Disavowed.constants.map { |const| Disavowed.const_get const }.grep Class
[02:49:22] ruby[bot]: havenwood: # => [Disavowed::Puppies, Disavowed::Kittens] (https://eval.in/761610)
[02:49:24] Verity: >> "hello" << \xFF
[02:49:25] ruby[bot]: Verity: # => /tmp/execpad-4c8bec10970c/source-4c8bec10970c:2: syntax error, unexpected $undefined ...check link for more (https://eval.in/761611)
[02:49:31] Verity: oh, its a syntax error
[02:49:49] matthewd: Verity: \x is a thing you do inside a string
[02:49:50] Verity: >> "hello" << "\xFF"; << ?\xFF
[02:49:52] ruby[bot]: Verity: # => /tmp/execpad-64bedcd68bd4/source-64bedcd68bd4:2: syntax error, unexpected <<, expecting keyword_end ...check link for more (https://eval.in/761612)
[02:50:07] havenwood: Verity: Please try things in your own REPL first. Just use @ruby[bot] for showing others.
[02:50:33] Verity: captain planet
[02:50:43] allisio: You should still go sit in the corner for a while.
[02:50:58] Verity: I'm already in the corner, pretty much
[02:51:10] allisio: Are you gonna bite?
[02:52:02] ahrs: has joined #ruby
[02:53:38] Trynemjoel: has joined #ruby
[02:55:03] allisio: Is this a bug? https://eval.in/761613
[02:57:20] roamingdog: has joined #ruby
[02:57:57] matthewd: allisio: I don't think so; all tracepoints seem to be more scoped to syntax than semantics
[02:58:08] Verity: 20 13 05 0D 46 1F 09 13 4A 46 27 0A 0A 0F 15 0F 09 48
[02:58:18] matthewd: If you just want to know when a class comes into existence, inherited would be a better fit
[03:02:14] flegent: has joined #ruby
[03:02:50] Verity: packet.ljust 7, ?\xFF leaves my packet at 5 bytes
[03:03:18] gdonald: has joined #ruby
[03:03:38] Xiti: has joined #ruby
[03:03:54] matthewd: Verity: That returns a new string; you need an assignment in there
[03:03:59] pwnd_nsfw`: has joined #ruby
[03:04:38] uxp: has joined #ruby
[03:05:09] matthewd: >> a = "foo"; b = a.ljust(5, "X"); [a, b]
[03:05:10] ruby[bot]: matthewd: # => ["foo", "fooXX"] (https://eval.in/761614)
[03:05:41] shinnya: has joined #ruby
[03:05:55] Verity: I'll save some ram like this
[03:05:59] Verity: a nice clean solution
[03:06:00] Verity: PAD = 0xFF.chr
[03:06:04] Verity: packet << PAD until packet.length > 5
[03:06:09] Verity: and self documenting
[03:06:37] Verity: but I will mess around with ljust right now to learn it well
[03:07:19] RenatoSilva: has joined #ruby
[03:07:37] Verity: so the () are by choice there
[03:08:50] solocshaw: has joined #ruby
[03:11:19] matthewd: Saving RAM is not a rubyish concern; in general, favour non-mutating methods
[03:12:58] matthewd: (you've previously seen one of the reasons for that: you might be mutating something that's referenced from elsewhere)
[03:15:30] allisio: In any case, doing with an explicit loop what you could do with a built-in method call is pretty silly.
[03:16:18] allisio: Sunob points for being less performant too.
[03:16:58] gix: has joined #ruby
[03:17:41] matthewd: Also that. Using a method whose entire purpose is padding a string to a defined length is pretty self documenting.
[03:18:25] Verity: perhaps I'll look into this a bit
[03:18:39] Pumukel: has joined #ruby
[03:19:39] Verity: how often should I use ()
[03:19:46] Verity: and is it ok one line to use, thee next not
[03:20:55] Verity: its fixed
[03:21:22] Verity: >> pkt = "1hi"; packet = packet.ljust(6, PAD);
[03:21:23] ruby[bot]: Verity: # => uninitialized constant PAD (NameError) ...check link for more (https://eval.in/761615)
[03:21:29] matthewd: Beyond the obvious "when it's necessary", I use them when I'm using the return value, as opposed to a more statement-like invocation
[03:21:31] Verity: so thats how I can change it
[03:21:57] solocshaw: has joined #ruby
[03:22:07] tristanp: has joined #ruby
[03:22:15] astrobunny: has joined #ruby
[03:22:19] flegent: has joined #ruby
[03:23:49] _tk421_: has joined #ruby
[03:27:55] zeddan: has joined #ruby
[03:30:19] Verity: how can I write pad as hex
[03:30:26] Verity: PAD = 255 is what I'm doing now
[03:30:35] Verity: PAD = 255.chr, really
[03:30:49] Verity: PAD = ?\xFF is error
[03:30:56] Verity: incompatible character encodings: UTF-8 and ASCII-8BIT (Encoding::CompatibilityError)
[03:32:15] matthewd: Ah, right. You'd want "\xFF".b
[03:32:36] allisio: >> 'abc' << ?\xFF
[03:32:37] ruby[bot]: allisio: # => "abc\xFF" (https://eval.in/761616)
[03:32:45] matthewd: 0xFF.chr is a reasonable option too
[03:33:13] matthewd: allisio: Because that's not an 8-bit string, and the end-goal is to have one of those for writing out
[03:33:54] jdm: has joined #ruby
[03:35:54] Verity: ruby is so great
[03:36:14] Verity: I'm worried about one thing, though.
[03:36:17] Verity: https://github.com/postmodern/digest-crc
[03:36:26] Verity: defining my own CRC class
[03:39:29] Verity: I have a specific generator polynomial and divisor constant
[03:39:42] tk422: has joined #ruby
[03:40:40] Verity: this table I'm not too sure about
[03:42:12] allisio: You can do whatever you want in Digest::CRC#update.
[03:44:11] thadtheman: has joined #ruby
[03:49:56] Rodya_: has joined #ruby
[03:50:03] Verity: should I be putting some of my code into a function here
[03:50:15] Verity: the part that oepns the file and builds the packets
[03:50:50] Verity: I dont want to make a function for no reason, often its not clear to me when its beneficial
[03:53:36] nofxx: has joined #ruby
[03:54:36] mutter2017: has joined #ruby
[04:01:04] jenrzzz: has joined #ruby
[04:01:42] CloCkWeRX: has joined #ruby
[04:02:17] Verity: im going to split it up
[04:02:24] Verity: buidlking the packets is the same every time, so it gets a func
[04:02:38] Verity: but sending them needs a state machine, so it might reallyh clutter the code also
[04:02:42] Verity: so it will have a function
[04:03:03] Verity: but then, how far do I break it down, does sending a packet inside the state machine have a function
[04:06:30] agent_white: has joined #ruby
[04:09:06] mooser: has joined #ruby
[04:09:21] Verity: and also, how can I get this on one line : if packet.length < 6 packet << EOT end
[04:09:32] Verity: I thought indents dont matter
[04:09:38] Verity: but I have to put them on their own line with the end etc
[04:10:06] elomatreb: You need to separate the condition from the if body, either use a ; or `then`
[04:10:43] Radar: Verity: Are you doing the thing again where you talk about code without actually showing the code?
[04:10:48] elomatreb: Alternatively, use the modifier-if, i.e. `packet << EOT if packet.length < 6`
[04:10:58] mutter2017: has joined #ruby
[04:11:01] Radar: [14:50:02] <Verity> should I be putting some of my code into a function here
[04:11:03] Radar: I'm referring to ^
[04:11:14] Radar: +1 for using the modifier-if
[04:11:37] enterprisey: has joined #ruby
[04:14:06] mostlybadfly: has joined #ruby
[04:16:52] kernelPaniq: has joined #ruby
[04:18:50] Verity: why might I choosde if packet.length < 6; packet << EOT end vs packet << EOT if packet.length < 6
[04:19:46] elomatreb: That ; in there is pretty awkward imo, and it's the accepted convention
[04:20:16] CloCkWeRX: has joined #ruby
[04:21:07] spicerack: has joined #ruby
[04:21:28] Robtop__: has joined #ruby
[04:24:23] Verity: so 'packet << EOT if packet.length < 6' is actually preferred over 'if packet.length < 6 then packet << EOT end' its more than just preference
[04:25:43] thadtheman: has joined #ruby
[04:37:11] mutter2017: has joined #ruby
[04:41:14] renchan: has joined #ruby
[04:42:46] Autolycus: has joined #ruby
[04:43:16] bronson: has joined #ruby
[04:44:15] RenatoSilva: Verity: it's preference because they do the same thing
[04:45:13] RenatoSilva: however writing ugly code is always a preference :)
[04:45:44] Suslov: has joined #ruby
[04:47:08] astrobunny: has joined #ruby
[04:48:21] jusa: has joined #ruby
[04:49:07] Pumukel: has joined #ruby
[05:00:37] vampirehunter: has joined #ruby
[05:01:15] davorb: has joined #ruby
[05:03:20] tenderlove: has joined #ruby
[05:05:20] thadtheman: has joined #ruby
[05:08:48] flegent: has joined #ruby
[05:10:23] muelleme_: has joined #ruby
[05:11:50] zeddan: has joined #ruby
[05:14:50] agent_white: has joined #ruby
[05:15:40] jenrzzz: has joined #ruby
[05:15:41] jenrzzz: has joined #ruby
[05:18:53] astrobunny: has joined #ruby
[05:21:41] spyder55: has joined #ruby
[05:24:28] enterprisey: has joined #ruby
[05:30:11] spyder55: has joined #ruby
[05:30:40] Beverage1: has joined #ruby
[05:32:39] thadtheman: has joined #ruby
[05:32:47] LiquidInsect: has joined #ruby
[05:34:30] wkoszek: has joined #ruby
[05:34:56] wkoszek: How can I open an issue at https://github.com/ruby/xmlrpc
[05:35:55] Radar: wkoszek: You can't. They don't have it enabled.
[05:36:42] astrobunny: has joined #ruby
[05:36:44] wkoszek: Radar: This is a part of the core Ruby library. I just wonder if the report should be made in ruby/ruby?
[05:36:54] Radar: wkoszek: I am not sure where it should go.
[05:38:12] wkoszek: Radar: I'll e-mail the hstb@ and ask him
[05:39:21] ThatsNotJack: has joined #ruby
[05:43:57] muelleme_: has joined #ruby
[05:47:30] cyphase: has joined #ruby
[05:49:51] charliesome: has joined #ruby
[05:52:16] astrobunny: has joined #ruby
[05:53:03] Pumukel: has joined #ruby
[05:53:09] wkoszek: I'm attempting to understand if this module would let me do XML RPC request via SSL, but without cert validation. I could a piece of code: https://github.com/ruby/xmlrpc/blob/master/lib/xmlrpc/client.rb#L445
[05:53:13] Rodya_: has joined #ruby
[05:53:36] thadtheman: has joined #ruby
[05:54:30] gdonald: has joined #ruby
[05:55:35] igniting: has joined #ruby
[05:55:55] Tau: i need some help to understand something.
[05:55:58] Tau: someone on?
[05:58:04] ineb: wkoszek: OpenSSL::SSL::VERIFY_NONE is the option youre looking for
[05:58:08] Tau: http://codepad.org/vhbB5exn
[05:58:26] wkoszek: ineb: Yeah, but from what I see, I have no way to pass it in this module
[05:58:29] Tau: wkoszek i'm not sure whether that explains all of it though.
[05:58:44] ineb: wkoszek: maybe monkeypatch? https://paste.xinu.at/d192QO/
[05:59:40] Tau: i'm trying to understand something else too: in ruby, it seems i can just extend existing classes by using : class Name # define new methods end then the underlying class gets extended. whats the name of it? is it inheritance?
[06:00:08] ineb: wkoszek: i hope you know that it is a bad thing what youre trying to do
[06:03:13] certainty: has joined #ruby
[06:03:17] Chch: has joined #ruby
[06:03:28] Tau: ii'm trying to see where socket.puts is defined in here https://ruby-doc.org/stdlib-2.4.0/libdoc/socket/rdoc/Socket.html#method-i-connect_nonblock it seems it is not listed in the part of the class methods either.
[06:04:23] dminuoso: tau: It's called reopening that class.
[06:04:43] wkoszek: ineb: I have a self-signed, which is pretty popular to just get encryption.
[06:04:48] dminuoso: tau: Depending on the scenario it's also called monkey patching (which is usually the case when you modify a class/module that does not belong to you)
[06:04:55] Pumukel: has joined #ruby
[06:05:25] dminuoso: tau: However! Module.prepend is generally the better solution to do that. You just define your own module with the additions, and then you prepend it into the original class.
[06:05:40] Tau: dminuoso i see. is monkey patching advisable in ruby? is it 'good'?
[06:05:49] lightheaded: has joined #ruby
[06:06:01] Tau: dminuso so is it bad in ruby?
[06:06:07] ineb: tau: and your explanation with your puts problem is almost right. However, Socket#puts is a instance method, not a class method. A class method would be called with self.puts, however, the instance method is just called with plain 'puts'.
[06:06:24] ineb: And as you correctly figured out, it overwrites the Kernel.puts method
[06:06:24] dminuoso: tau: Well it's common enough to mention it -> but you effectively violate design contracts if you do it.
[06:06:55] ineb: tau: to further answer your question. Socket is getting the puts from IO
[06:06:57] Tau: dminuoso i see.
[06:07:25] Tau: ineb but, i have the feeling i should use self.puts in Socket(when monkey patching it) isnt it?
[06:07:48] dminuoso: tau: I personally advise against it. The problem is that sometimes it's faster to simply monkey patch ThirdPartyClass than to fork the repository, make a change, commit it and make a pull request, and wait for that version to be released to rubygems.org
[06:07:57] dminuoso: tau: Which is why it's so damn popular
[06:08:28] Tau: dminuoso i see.
[06:08:32] ineb: tau: you can check by yourself. Install pry as alternative to irb, and create a socket object
[06:08:40] ineb: show-source Socket.new(AF_INET, SOCK_STREAM, 0).puts
[06:08:51] ineb: shows you how Socket#puts is defined
[06:09:04] dminuoso: tau: Though there are a select few cases where monkey patching has valid use cases, in particular when you *add* methods to core classes.
[06:09:22] dminuoso: tau: For example ActiveSupport extends a lot of Ruby core classes to the point where you can do fancy stuff like: time = Time.now - 5.hours.ago
[06:09:44] Tau: dminuoso so, monkey patching in ruby is okay when one knows what he is doing, right?
[06:09:53] dminuoso: tau: As with all the tools, yes.
[06:10:13] dminuoso: tau: The issue with monkey patching is just that if you do it it will have unknown effects.
[06:10:19] Tau: ineb i have the feeling that Socket.puts comes from a module. it seems to not be defined in the class Socket, isnt it?
[06:10:33] Tau: dminuoso yea. i see.
[06:10:44] dminuoso: tau: For example: Let's say you start using the File api. Now you would expect that API to have an .open method right?
[06:10:54] Tau: dminuoso yes.
[06:11:09] dminuoso: So you write code that assumes that File.open("foo.js") does a specific thing. Now if someone monkey patched that method to delete a file for whatever bizarre reason, your code will be faulty
[06:11:15] ineb: tau: yes, IO module, as i wrote.
[06:12:27] Tau: ineb oh. i see. thank you.
[06:12:32] antgel: has joined #ruby
[06:12:39] Tau: ineb but how could i find that info in that page https://ruby-doc.org/stdlib-2.4.0/libdoc/socket/rdoc/Socket.html#method-i-connect_nonblock
[06:12:52] dminuoso: tau: So yeah.. dont modify foreign classes unless you know what you are doing.
[06:12:57] Tau: i mean, how to know which modules a given class includes?
[06:13:10] Tau: dminuoso i see.
[06:13:28] dminuoso: tau: There is no immediate way to do it.
[06:13:44] Tau: dminuoso yeah, well, i believe that monkey matching would be mostly safe when it is aggregating new methods to a class but not changing existing methods, wouldnt you agree?
[06:13:47] aufi: has joined #ruby
[06:14:03] dminuoso: tau: klass.anscestors.select { |e| e.is_a?(Module) }
[06:14:07] Tau: dminuoso you mean knowing if a class includes a given module?
[06:14:23] Tau: dminuoso but i ask knowing that from the docs.
[06:14:25] dminuoso: tau: The easiest way is to check against ancestors directly
[06:14:28] Tau: https://ruby-doc.org/stdlib-2.4.0/libdoc/socket/rdoc/Socket.html#method-i-connect_nonblock
[06:14:36] Tau: there is no place where it says 'Socket includes IO module'.
[06:14:47] dminuoso: tau: It does indirectly.
[06:14:54] Tau: dminuoso how so?
[06:15:00] dminuoso: tau: it inherits from BasicSocket which in turn inherits from IO
[06:15:18] dminuoso: Scroll to the top, to the left there is a card that says "Parent"
[06:15:34] Tau: i see it now.
[06:16:02] Tau: but BasicSocket says 'Parent' , it gives the feeling that Socket inherits from BasicSocket.
[06:16:24] Tau: i wonder that Socket class is defined as : class Socket\ninclude IO ... end
[06:16:25] Tau: isnt it?
[06:16:27] dminuoso: tau: It gives that feeling because it actually does inherit.
[06:16:33] ineb: and BasicSocket inherits from IO
[06:16:43] Tau: dminuoso lemme show you a snippet of code.
[06:16:52] dminuoso: tau: IO is a class, you cannot include classes.
[06:17:02] mooser: has joined #ruby
[06:17:04] Tau: i thought IO was a module(according to ineb)
[06:17:07] Tau: hold on
[06:17:10] Tau: lemme give a snippet
[06:17:16] Tau: it will clarify better what i mean.
[06:17:16] dminuoso: tau: The thing is: there is not much of a difference between classes and modules.
[06:17:21] dminuoso: They are almost 100% identical.
[06:17:28] zapata: has joined #ruby
[06:17:49] dminuoso: Ruby just imposes a few arbitrary rules on them. Like you cant inherit from a module, or include/prepend/extend a class.
[06:18:01] Pumukel: has joined #ruby
[06:18:17] ineb: tau: i wrote IO module but i should have written IO class. sorry.
[06:18:35] dminuoso: tau: But in effect whether you said: class Socket; include IO; end; or class Socket < IO; end #=> would make no difference whatsoever to inheritance and rules.
[06:18:57] Tau: http://codepad.org/6USKopbp
[06:18:58] dminuoso: tau: It would be the same, except for these arbitrary class/module rules I mentioned
[06:19:01] Tau: i think it may clarify better.
[06:19:05] Tau: ineb no worries.
[06:19:21] ineb: dminuoso: dont forget super here.
[06:19:22] dminuoso: tau: Right. including and inheriteting are not really any different.
[06:19:29] dminuoso: ineb: Nope.
[06:19:35] dminuoso: ineb: super does not apply, it acts exactly the same.
[06:19:35] Tau: dminuoso hmm, lemme give you another snippet.
[06:19:37] Tau: hold on
[06:20:41] Tau: dminuoso i see. i thought that
[06:20:42] Tau: hold on
[06:23:09] Tau: i think i understood.
[06:23:23] jenrzzz: has joined #ruby
[06:23:24] jenrzzz: has joined #ruby
[06:23:24] Tau: i was thinking that i always had to use 'self.method' to access instance methods.
[06:23:30] Tau: from a given class instance.
[06:24:00] Tau: but it seems it is not really required. if i have a class instance with two methods alpha and beta i can just call alpha from beta without using self.alpha.
[06:24:13] Tau: dminuso are the two forms equivalent, isnt it?
[06:27:14] Tau: i got confused because i was reading a ruby tutorial and everyone was using self.method for class instances.
[06:28:07] wkoszek: By the way, I'd still be interested in getting some testers for my Ruby builds: https://github.com/wkoszek/ruby_packages
[06:28:33] rippa: has joined #ruby
[06:29:33] Tau: i may help you, wkoszek.
[06:29:38] Tau: just have to check for time.
[06:30:02] Tau: i'll drop you a channel where i usually hang, so you can find me there.
[06:30:17] Tau: its #vy
[06:32:49] thadtheman: has joined #ruby
[06:32:50] Tau: dminuoso thank you for the insight.
[06:32:54] Tau: it helped a lot.
[06:33:51] Tau: i'm just curious what to name 'self', i mean it seems to be available naturally in classes but it is not mentioned anywhere(as it happens in python) class name:\n def method(self, ..):
[06:36:13] last_staff: has joined #ruby
[06:37:01] lightheaded: has joined #ruby
[06:39:23] jenrzzz: has joined #ruby
[06:39:23] jenrzzz: has joined #ruby
[06:41:11] siovene: has joined #ruby
[06:42:01] cfec0b8d: has joined #ruby
[06:43:26] roshanavand: has joined #ruby
[06:44:12] bronson: has joined #ruby
[06:51:09] andikr: has joined #ruby
[06:51:13] P1ro: has joined #ruby
[06:54:07] roamingdog: has joined #ruby
[06:54:27] harfangk: has joined #ruby
[06:58:22] dminuoso: tau: It's rather Python that's a bit bizarre in that respect actually.
[06:58:24] vali: has joined #ruby
[06:58:43] conta: has joined #ruby
[06:58:47] dminuoso: tau: self in Ruby is a little different
[06:59:40] biberu: has joined #ruby
[06:59:41] dminuoso: tau: There's certain things in Ruby that change what "self" means. For example if you open a class, then "self" will refer to the class object itself. If you open a method, then "self" will refer to the instance of a given class.
[06:59:42] Tau: how do you 'think' about self in ruby?
[07:00:01] dminuoso: tau: It's a little closer to "this" from JavaScript if you are familiar with that.
[07:00:11] dminuoso: But only so much.
[07:00:39] Tau: dminuoso i'm just curious why in some ruby docs(they dont mention you dont need self to call a class instance method).
[07:00:47] wnd: has joined #ruby
[07:00:49] davorb: has joined #ruby
[07:00:58] ineb: tau: you can learn all the details about your questions if you learn rubys object model.
[07:01:08] ineb: there a quite some resources about it on the web
[07:01:23] dminuoso: tau: "self" is the default receiver for a method if no other is specified.
[07:01:43] dminuoso: tau: For example, if you write: foo.bar then foo will receive the method bar. but if you only write bar(), then it's the same as writing self.bar()
[07:01:43] matthewd: Yeah, it's not necessary (except a few corner cases) -- more like C++, Java, etc
[07:03:16] akkad: has joined #ruby
[07:06:14] Tau: i wonder if there are bindings for this : http://wiki.tcl-lang.org/5016
[07:06:43] dminuoso: tau: Now this self business has a lot of implications. It also helps understand how class methods work.
[07:06:45] Tau: i have a project thats written in python but ruby is a better language for it. i plan to migrate to ruby and maybe have bindings for that in ruby.
[07:06:56] Tau: dminuoso true.
[07:07:00] dminuoso: tau: For example ever noticed how class methods are defined on something that has to do with "self" ?
[07:07:03] dminuoso: Such as def self.foo; end
[07:07:21] dminuoso: If you remember, I told you that inside a class definition self becomes the object itself. :-)
[07:07:33] dminuoso: And def foo.bar; end just creates a singleton method on foo, *whatever* foo is.
[07:08:00] Tau: those def method.name are a bit tricky to understand.
[07:08:13] Tau: i'll write a snippet now.
[07:08:23] dminuoso: tau: they just create a singleton method on an object.
[07:08:30] dminuoso: tau: A method that only belongs to that object and nothing else.
[07:08:53] Tau: dminuoso hold on
[07:09:20] fmartingr: has joined #ruby
[07:10:36] jgnagy: has joined #ruby
[07:12:11] Tau: http://codepad.org/qurslRJZ
[07:13:18] bigkevmcd: has joined #ruby
[07:13:41] dminuoso: tau: Try that in your Ruby.
[07:13:57] Tau: dminuoso i tried.
[07:13:58] matthewd: tau: The only thing you should have as `foo` in a `def foo.bar` definition is `self`
[07:14:09] dminuoso: tau: "alpha" has to be an object of some kind.
[07:14:11] dminuoso: tau: Which it is not.
[07:14:19] matthewd: You *can* do other things, but it's not something you generally *should* do
[07:14:42] dminuoso: tau: My point is just that when you do say: def self.foo; end there is nothing magical to it, because the object "self" exists in that (and every) context.
[07:14:45] hutch34: has joined #ruby
[07:14:50] dminuoso: And you just define that method onto self (whatever that may be)
[07:15:18] Tau: dminuoso i wonder what def alpha.foo means inside that class. i mean the usability of it.
[07:15:31] snickers: has joined #ruby
[07:15:35] dminuoso: >> def self.foo; end; puts self.methods.include?(:foo)
[07:15:36] ruby[bot]: dminuoso: # => true ...check link for more (https://eval.in/761671)
[07:15:41] zeddan: has joined #ruby
[07:16:10] dminuoso: tau: The usefulness depends on the circumstance. Generally you will only define singleton methods on class objects.
[07:16:13] matthewd: dminuoso: I really don't think this is a helpful lesson as a follow-on to "how to self". They both have 'self' in their title, but they're a long way apart on any reasonable spectrum (relevance, utility, clarity, ..)
[07:16:21] dminuoso: Yeah probably
[07:17:02] lightheaded: has joined #ruby
[07:17:21] Tau: hold on
[07:17:35] Tau: i'll add some commentaries to that snippet which maps to some of my doubts.
[07:18:41] Stan: has joined #ruby
[07:19:51] Tau: http://codepad.org/c9l1AqrR
[07:20:06] jenrzzz: has joined #ruby
[07:20:06] jenrzzz: has joined #ruby
[07:20:26] Tau: i gave the wrong code.
[07:21:12] matthewd: tau: This is really not useful. Don't do that.
[07:21:30] Tau: mathewd i see.
[07:21:40] Qchmqs: has joined #ruby
[07:22:23] matthewd: Basically, I'm not sure what you're expecting it to do, but it's not what it does do
[07:22:36] dminuoso: tau: methods are not first class objects like they are in JavaScript.
[07:22:51] mark_66: has joined #ruby
[07:23:04] Tau: hold on
[07:23:10] Tau: lemme try to clarify my doubt.
[07:23:27] Kug3lis: has joined #ruby
[07:23:45] matthewd: I think "in quite the same way" would be more accurate than "like" there
[07:24:39] Tau: i think i got the right question: http://codepad.org/SteOhoOY
[07:25:10] matthewd: tau: Yeah.. that's not a thing.
[07:25:28] matthewd: Methods are called on objects
[07:25:33] lightheaded: has joined #ruby
[07:25:48] matthewd: Which method you got the object from doesn't affect which methods it responds to
[07:26:26] matthewd: Line 21 is defining beta on `nil`
[07:26:46] matthewd: 26 could equally be `nil.beta` and it would work just the same
[07:27:04] Tau: i'm a bit confused with something now.
[07:27:05] matthewd: (because nil is the object that `a.alpha` returns)
[07:27:47] Tau: http://codepad.org/qPHgAsru
[07:28:07] Tau: matthewd yes, alpha returns nill. but i can call beta on it and it gets called too.
[07:28:16] matthewd: As I said, *you are defining beta on nil*
[07:28:43] matthewd: >> def nil.hello; puts 'howdy'; end; nil.hello
[07:28:44] ruby[bot]: matthewd: # => howdy ...check link for more (https://eval.in/761686)
[07:28:47] matthewd: ^ what you are doing
[07:28:54] Tau: matthewd but when i defined beta on nil, the function couldnt be 'aware' of what it returns because it wasnt executed.
[07:28:56] Tau: get it?
[07:29:11] Tau: when i do def (a.alpha).beta puts "it works" end
[07:29:27] Tau: indeed.
[07:29:30] Tau: it was first executed.
[07:29:32] Tau: i got it.
[07:29:39] Tau: matthewd i didnt notice that, sorry.
[07:29:42] Tau: yes, now i got it.
[07:30:42] Tau: interesting.
[07:31:00] Tau: so, when i do def method.name it executes the method.
[07:31:25] Tau: but what to do when the method receives arguments?
[07:31:31] wkoszek: ACTION needs to figure out how to make ruby be ruby-2.4 after ./configure && make
[07:31:45] wkoszek: ACTION wanted to take his ruby_packages repo and push it to a ppa
[07:32:06] matthewd: tau: You're not defining `method.method`. You're defining `*value*.method`
[07:32:09] Tau: http://codepad.org/MyTMneiS
[07:32:18] Tau: mathewd yes. i see.
[07:32:25] Tau: i got it.
[07:32:42] matthewd: tau: If the LHS needs arguments, then you need to give them (and the expression then needs to be in parens)
[07:32:59] matthewd: But again: don't ever do this
[07:33:00] Tau: matthewd excellent.
[07:33:14] Tau: ruby has an amazing syntax.
[07:33:20] Tau: it may be confusing sometimes.
[07:33:26] Tau: due to its power i think.
[07:35:19] ineb: has left #ruby: ()
[07:35:55] tAn: has joined #ruby
[07:36:15] matthewd: A big difference between ruby and python is that there are, by design, a bunch of ways to do a given thing. That often means there are ways to string things together in a needlessly complicated way.
[07:36:32] jenrzzz: has joined #ruby
[07:37:00] Tau: methewd yeah.
[07:37:31] vondruch: has joined #ruby
[07:38:38] aganov: has joined #ruby
[07:38:51] Tau: mathewd how long have you been using ruby?
[07:45:44] lightheaded: has joined #ruby
[07:46:29] Tau: thank you guys for the insight.
[07:46:31] Tau: i'm off now.
[07:46:35] matthewd: I'm not sure.. maybe 12 years?
[07:46:44] matthewd: No worries!
[07:50:36] lightheaded: has joined #ruby
[07:53:49] jpterry: has joined #ruby
[07:55:22] Rodya_: has joined #ruby
[07:56:04] roamingdog: has joined #ruby
[07:59:35] flying: has joined #ruby
[08:01:07] fmartingr: If you've been 12 years maybe you can point me to some article or something that explain the `@` notation on class attributes, I come from python and don't quite get it... ^_^U
[08:01:51] mikecmpbll: has joined #ruby
[08:02:43] jenrzzz: has joined #ruby
[08:02:43] jenrzzz: has joined #ruby
[08:04:36] ytrjkr: has joined #ruby
[08:04:52] herwin: fmartingr: http://ruby-doc.com/docs/ProgrammingRuby/html/tut_classes.html
[08:05:33] antgel: has joined #ruby
[08:05:47] pandaant: has joined #ruby
[08:05:57] burgestrand: has joined #ruby
[08:06:10] spider-mario: has joined #ruby
[08:07:51] matthewd: I was going to suggest https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-python/, but it doesn't look like it really addresses instance variables
[08:10:19] fmartingr: Im going to put an example from a thing I did in python and how I tried to replicate it in ruby (without success). I ended up using the constructors but that was not quite what I wanted.
[08:10:37] fmartingr: Thank you for the links anyway, I will take a look at them later :)
[08:11:43] mooser: has joined #ruby
[08:12:26] jsrn_: has joined #ruby
[08:12:39] ujjain: has joined #ruby
[08:12:40] ujjain: has joined #ruby
[08:14:17] banisterfiend: has joined #ruby
[08:15:42] fmartingr: https://gist.github.com/fmartingr/8ba47fb4faeeb4c8bc9cbf0bfabbddc5
[08:16:37] matthewd: fmartingr: I think I'd do that with a nested constant
[08:16:43] dionysus69: has joined #ruby
[08:19:44] fmartingr: I'd give a try. I have only been using ruby for some hourse so some stuff I do may be crap ^^
[08:19:59] kristofferR: has joined #ruby
[08:20:03] fmartingr: I'm still getting used to some stuff about the language.
[08:20:11] binaryplease: has joined #ruby
[08:22:54] bob_f: has joined #ruby
[08:26:38] esObe_: has joined #ruby
[08:26:42] binaryplease1: has joined #ruby
[08:26:50] burgestrand: fmartingr Don't worry, crap happens :)
[08:27:07] maattdd: has joined #ruby
[08:31:42] montanonic: has joined #ruby
[08:32:19] esObe__: has joined #ruby
[08:33:38] nOwz: has joined #ruby
[08:34:16] yurikoles: has joined #ruby
[08:35:00] certainty: has joined #ruby
[08:35:35] fivmo: has joined #ruby
[08:37:06] fivmo: has left #ruby: ()
[08:41:28] ddffg: has joined #ruby
[08:41:29] Silthias: has joined #ruby
[08:44:44] gdonald: has joined #ruby
[08:45:08] bronson: has joined #ruby
[08:45:22] hutch34: has joined #ruby
[08:46:48] govg: has joined #ruby
[08:52:32] lxsameer: has joined #ruby
[08:53:33] tomphp: has joined #ruby
[08:54:22] dionysus69: has joined #ruby
[08:55:23] Tau: has joined #ruby
[08:56:04] Rodya_: has joined #ruby
[09:03:30] certainty: has joined #ruby
[09:04:48] blackmesa: has joined #ruby
[09:05:17] jenrzzz: has joined #ruby
[09:05:25] burgestrand: has joined #ruby
[09:06:30] DaniG2k: has joined #ruby
[09:07:26] workmad3: has joined #ruby
[09:11:17] jgnagy: has joined #ruby
[09:11:22] awc: has joined #ruby
[09:15:07] ferr1: has joined #ruby
[09:15:18] psychicist__: has joined #ruby
[09:16:36] Kug3lis_: has joined #ruby
[09:16:57] zeddan: has joined #ruby
[09:17:44] maattdd_: has joined #ruby
[09:20:06] charliesome: has joined #ruby
[09:21:24] stoffus: has joined #ruby
[09:23:14] Sylario: has joined #ruby
[09:23:29] govg: has joined #ruby
[09:25:30] thadtheman: has joined #ruby
[09:27:27] jenrzzz: has joined #ruby
[09:28:54] ameliabot: has joined #ruby
[09:30:44] llaine: has joined #ruby
[09:38:40] ddffg: has joined #ruby
[09:40:04] maattdd: has joined #ruby
[09:41:51] arquebus: has joined #ruby
[09:42:55] CloCkWeRX: has joined #ruby
[09:43:50] nobitanobi: has joined #ruby
[09:46:53] thadtheman: has joined #ruby
[09:51:21] lyda: has left #ruby: ()
[09:51:55] morfin: has joined #ruby
[09:52:20] morfin: do you know ruby-build respects CC and CXX in /etc/make.conf(FreeBSD)?
[09:52:33] muelleme_: has joined #ruby
[09:56:10] darix: morfin: probably not
[09:56:42] Rodya_: has joined #ruby
[10:00:52] troulouliou_div2: has joined #ruby
[10:04:18] mdw: has joined #ruby
[10:05:38] marr: has joined #ruby
[10:05:55] jaruga: has joined #ruby
[10:10:22] howdoi: has joined #ruby
[10:10:37] fivmo: has joined #ruby
[10:11:35] CloCkWeRX: has joined #ruby
[10:13:27] certainty: has joined #ruby
[10:14:05] thadtheman: has joined #ruby
[10:15:46] hutch34: has joined #ruby
[10:19:59] Flonk: has joined #ruby
[10:35:51] johnzorn: has joined #ruby
[10:40:31] GodFather: has joined #ruby
[10:42:38] lightheaded: has joined #ruby
[10:43:04] lightheaded: has joined #ruby
[10:43:22] thadtheman: has joined #ruby
[10:43:39] rhyselsmore: has joined #ruby
[10:43:54] jusa: has joined #ruby
[10:46:00] bronson: has joined #ruby
[10:47:01] Arpanet69: has joined #ruby
[10:51:22] unshadow: has joined #ruby
[11:00:47] uwgiqq: has joined #ruby
[11:01:25] davorb: has joined #ruby
[11:01:37] thadtheman: has joined #ruby
[11:01:47] rajat: has joined #ruby
[11:03:16] Jameser: has joined #ruby
[11:04:51] zeddan: has joined #ruby
[11:04:59] Fernando-Basso: has joined #ruby
[11:05:19] morfin: env CC=clang38 CXX=clang++38 rbenv helped me
[11:06:44] nobitanobi: has joined #ruby
[11:07:42] johnny56_: has joined #ruby
[11:11:57] jgnagy: has joined #ruby
[11:13:00] jonatin: has joined #ruby
[11:20:17] Silthias: I've got a hash that I'd like to iterate over (.each) and then print the key,value pair out ot it, but maintaining the order of the key. using .each appears to be sorting it at the same time, is it possible to do 'neatly'?
[11:21:16] elomatreb: Ruby Hashes normally return their keys in the order they were inserted, it shouldn't sort anything by itself
[11:21:53] canton7: very old ruby versions (1.8-era?) don't keep hashes sorted by insertion order, iirc
[11:22:29] morfin: heh that's weird
[11:22:49] Silthias: hmm ok, this is going into an erb tempalte and puppet perhaps thats messing it up slightly
[11:22:59] morfin: because i expect to have unordered hashmap
[11:23:16] jaruga: has joined #ruby
[11:26:59] Silthias: so backtracking though, it looks like the input hash thats being used has already been sorted, hence the ordering being different from what I'd expect, cheers for the answers though
[11:32:59] nOwz: has joined #ruby
[11:35:07] Jameser: has joined #ruby
[11:35:31] certainty: has joined #ruby
[11:36:46] JeanCarloMachado: has joined #ruby
[11:36:49] nowhere_man: has joined #ruby
[11:40:53] leito: has joined #ruby
[11:42:41] User458764: has joined #ruby
[11:42:46] mark_66: has joined #ruby
[11:43:13] User458764: has joined #ruby
[11:45:02] thadtheman: has joined #ruby
[11:45:29] tvw: has joined #ruby
[11:46:40] hutch34: has joined #ruby
[11:48:46] rajat: has joined #ruby
[11:49:53] Verity: has joined #ruby
[11:50:11] Verity: key.bytes.each do |kb| msg_arr.map! {|mb| mb = mb^kb} end ---------------------- is there a better way to write this
[11:51:17] Rodya_: has joined #ruby
[11:51:19] ldnunes: has joined #ruby
[11:52:50] Xeago: has joined #ruby
[11:58:37] nobitanobi: has joined #ruby
[12:02:04] cfec0b8d: has joined #ruby
[12:02:34] thadtheman: has joined #ruby
[12:08:42] herwin: Verity: i believe ^ has the associative property, meaning (mb^k1)^k2 == mb^(k1^k2)
[12:09:10] herwin: in that case, you could pre-calculate the ^ of key
[12:09:25] herwin: and that removes the need for the outer loop
[12:10:20] herbmillerjr: has joined #ruby
[12:17:14] vali: has joined #ruby
[12:18:26] doublemalt_: has joined #ruby
[12:19:44] synthroid: has joined #ruby
[12:21:17] hutch34: has joined #ruby
[12:22:25] ahrs: has joined #ruby
[12:24:53] dionysus70: has joined #ruby
[12:37:17] eclecticjohny: has joined #ruby
[12:42:12] ddffg: has joined #ruby
[12:44:36] valentin: has joined #ruby
[12:45:08] jusa: has joined #ruby
[12:45:15] valentin: has joined #ruby
[12:46:56] bronson: has joined #ruby
[12:46:57] psychicist__: has joined #ruby
[12:47:39] aupadhye: has joined #ruby
[12:48:44] valentinul: has joined #ruby
[12:50:58] leito: has joined #ruby
[12:51:51] User458764: has joined #ruby
[12:51:53] vali: has joined #ruby
[12:52:31] Rodya_: has joined #ruby
[12:52:45] User458764: has joined #ruby
[12:53:07] zeddan: has joined #ruby
[12:53:16] cam27: has joined #ruby
[12:53:32] User458764: has joined #ruby
[12:53:48] duckpupp1: has joined #ruby
[12:59:35] nOwz: has joined #ruby
[13:00:07] t-recx: has joined #ruby
[13:01:51] cdg: has joined #ruby
[13:02:00] davorb: has joined #ruby
[13:02:11] ramortegui: has joined #ruby
[13:03:13] pankaj: has joined #ruby
[13:03:22] cdg: has joined #ruby
[13:05:25] eclecticjohny: has joined #ruby
[13:11:30] TomyWork: has joined #ruby
[13:12:46] jgnagy: has joined #ruby
[13:12:55] __Yiota: has joined #ruby
[13:16:47] Pumukel: has joined #ruby
[13:19:29] bmurt: has joined #ruby
[13:22:07] iamayam: has joined #ruby
[13:25:44] shinnya: has joined #ruby
[13:25:48] olivier__: has joined #ruby
[13:29:30] millerti: has joined #ruby
[13:32:13] valentinul: has joined #ruby
[13:33:09] hutch34: has joined #ruby
[13:34:29] patarr: has joined #ruby
[13:35:36] silverdust: has joined #ruby
[13:41:27] armyriad: has joined #ruby
[13:41:40] lmc: has joined #ruby
[13:47:28] Jameser: has joined #ruby
[13:48:12] Pumukel: has joined #ruby
[13:50:02] milardovich: has joined #ruby
[13:50:12] nobitanobi: has joined #ruby
[13:50:55] armyriad: has joined #ruby
[13:53:13] Rodya_: has joined #ruby
[14:02:06] gnufied: has joined #ruby
[14:04:24] centrx: has joined #ruby
[14:06:39] davidt: has joined #ruby
[14:06:43] blackmesa: has joined #ruby
[14:07:10] cdg_: has joined #ruby
[14:07:43] gdonald: has joined #ruby
[14:09:39] phoo1234567: has joined #ruby
[14:15:33] joast: has joined #ruby
[14:16:21] psychicist__: has joined #ruby
[14:17:26] ivanacostarubio: has joined #ruby
[14:18:23] jdm: has joined #ruby
[14:18:47] ddffg: has joined #ruby
[14:19:39] binaryplease: has joined #ruby
[14:23:16] sepp2k: has joined #ruby
[14:23:34] ozcanesen: has joined #ruby
[14:25:45] lubekpl: has joined #ruby
[14:28:56] zeddan: has joined #ruby
[14:30:12] User458764: has joined #ruby
[14:34:49] chuff: has joined #ruby
[14:35:16] blackpajamas: has joined #ruby
[14:35:41] blackmesa: has joined #ruby
[14:36:25] Pumukel: has joined #ruby
[14:46:08] maloik: has joined #ruby
[14:46:38] yehowyada: has joined #ruby
[14:47:45] bronson: has joined #ruby
[14:48:50] Cohedrin: has joined #ruby
[14:50:00] Silthias: has joined #ruby
[14:51:36] lightheaded: has joined #ruby
[14:52:04] chouhoulis: has joined #ruby
[14:52:12] bronson: has joined #ruby
[14:53:58] Rodya_: has joined #ruby
[14:56:05] Jameser: has joined #ruby
[14:56:07] milardovich: has joined #ruby
[14:56:14] polishdub: has joined #ruby
[14:56:24] milardovich: has joined #ruby
[14:57:02] tristanp: has joined #ruby
[14:59:12] cpruitt: has joined #ruby
[14:59:34] spicerack: has joined #ruby
[15:02:35] __Yiota: has joined #ruby
[15:02:54] Jameser: has joined #ruby
[15:04:22] mbertul: has joined #ruby
[15:11:36] haylon: has joined #ruby
[15:13:06] dionysus69: has joined #ruby
[15:13:42] LyndsySimon: I'm struggling this morning getting class variables and inheritance to work the way I want. Here's the syntax I want:
[15:13:52] jgnagy: has joined #ruby
[15:14:09] LyndsySimon: https://usercontent.irccloud-cdn.com/file/ThEVtnrR/
[15:14:12] __Yiota: has joined #ruby
[15:14:15] zeddan: has joined #ruby
[15:14:31] zinggggg: has joined #ruby
[15:14:50] LyndsySimon: I understand why class variables (e.g., @@members) work the way they do, and that's not what I want. I understand how class instance variables work, and that's not quite what I want either.
[15:15:07] LyndsySimon: Is there any way to make the syntax above work?
[15:16:23] elomatreb: You can achieve that behavior, but it would require doing some metaprogramming-y stuff. Not as simple as a syntax
[15:16:36] LyndsySimon: I'm fine with that.
[15:16:57] mbertul: has joined #ruby
[15:17:02] pandaant: has joined #ruby
[15:17:03] Jameser: has joined #ruby
[15:17:04] antoniobeyah: has joined #ruby
[15:17:07] LyndsySimon: Well, I'm fine with doing magical stuff in `Base`, if I can make it clean in `Parent` and `Child`.
[15:17:35] elomatreb: I *think* that should be possible
[15:18:28] elomatreb: You know how you get methods to work on the class instead of on instances I assume?
[15:18:35] bkxd: has joined #ruby
[15:19:15] zeddan_: has joined #ruby
[15:20:00] lightheaded: has joined #ruby
[15:24:16] elomatreb: LyndsySimon: https://eval.in/761991 -- Does this look like what you need?
[15:24:28] Jameser: has joined #ruby
[15:25:20] elomatreb: The interesting bit is just the inherited hook, that adds all members of the parent class to the child class
[15:28:14] LyndsySimon: elomatreb: Hmm... I think so. Thank you!
[15:28:36] LyndsySimon: I don't understand the self.inherited method yet, but I'm sure I'll figure it out shortly.
[15:29:00] patarr1: has joined #ruby
[15:29:35] elomatreb: When class A inherits from class B (A < B), that method will be called on B and A will be passed as an argument (other, in the example)
[15:29:44] tercenya: has joined #ruby
[15:30:05] igniting: has joined #ruby
[15:30:29] jgnagy: has joined #ruby
[15:30:46] LyndsySimon: I think I'm grokking it.
[15:31:07] gregf_: has joined #ruby
[15:31:58] LyndsySimon: My background is predominately Python, and inheritance there is both more flexible (e.g., multiple inheritance is fine) and more structured (e.g., classes are themselves instances of a metaclass). It seems like Ruby's inheritance model is closer to that of smalltalk.
[15:32:38] baweaver: ACTION points at Module mixins
[15:32:44] tercenya: has joined #ruby
[15:32:47] elomatreb: Ruby classes are instances of the class `Class` too, we're taking advantage of that in the example with the instance variables
[15:33:51] LyndsySimon: baweaver: I'm very familiar with Module mixins :)
[15:35:25] brent__: has joined #ruby
[15:35:50] LyndsySimon: elomatreb: Let me reiterate. In order to execute logic when class `A` is defined in Python, you write a class `M` and define it's `__new__` method, then explicitly set `M` to be the metaclass of `A`.
[15:35:50] brent__: has joined #ruby
[15:36:43] LyndsySimon: That gets really fun when you're dealing with an inheritance hierarchy, and your metaclasses are descendants of the resultant classes' ancestors' metaclasses.
[15:38:16] elomatreb: I'm not familiar with Python, sorry. You can do weird stuff like that in Ruby too, having a lot of modules injected in method lookup paths sounds similar
[15:38:37] __Yiota: has joined #ruby
[15:38:51] ResidentBiscuit: has joined #ruby
[15:39:44] tanukisofubi: has joined #ruby
[15:39:54] LyndsySimon: It's cool. To be honest, I have a hard time talking about complex topics in two different languages at once anyhow.
[15:42:10] sofubi: has joined #ruby
[15:44:04] tAn: has joined #ruby
[15:44:19] montanonic: has joined #ruby
[15:47:58] Cohedrin: has joined #ruby
[15:48:41] [Butch]: has joined #ruby
[15:49:06] certainty: has joined #ruby
[15:49:30] yasu_: has joined #ruby
[15:50:20] amclain: has joined #ruby
[15:50:54] Uranio: has joined #ruby
[15:51:37] cam27: has joined #ruby
[15:52:23] User458764: has joined #ruby
[15:53:58] synthroid: has joined #ruby
[15:55:01] synthroid: has joined #ruby
[15:56:58] grrrkit: has joined #ruby
[16:03:34] LyndsySimon: elomatreb: Thoughts on this modification? https://eval.in/762044
[16:03:51] LyndsySimon: I was concerned that modifications made to the parent classes at runtime wouldn't be reflected.
[16:04:18] snickers: has joined #ruby
[16:04:36] marxarelli: has joined #ruby
[16:05:33] LyndsySimon: Nevermind, I see the bug.
[16:05:38] spicerack: has joined #ruby
[16:08:22] elomatreb: I'm not sure how I feel about even allowing runtime modifications on something like this. I think I'd expect values defined by a class method (if they're used like member here they're often called macros) not never change
[16:08:41] elomatreb: But if you need/want, something along those lines should work
[16:10:03] elomatreb: If it should be dynamic we could probably leave the inherited hook completely, and just chain up until we reach Base
[16:11:10] DLSteve: has joined #ruby
[16:14:01] LyndsySimon: elomatreb: Here we go: https://eval.in/762062
[16:14:41] LyndsySimon: I don't know if it will happen in my use case - but I would feel better either accounting for it, or explicitly disallowing it.
[16:14:57] elomatreb: << mutates the Array, no need to assign it after </nitpick>
[16:16:08] LyndsySimon: Yeah there is - `(@members || [])` could have returned an empty array.
[16:16:46] LyndsySimon: I guess I could have done `(@members ||= [])`...
[16:16:50] synthroid: has joined #ruby
[16:17:11] elomatreb: ^ that's how it's usually done, to the point where I didn't notice it wasn't ||=
[16:17:24] LyndsySimon: ACTION nods
[16:17:51] hxegon: has joined #ruby
[16:17:57] roamingdog: has joined #ruby
[16:18:18] elomatreb: One difference between the solution is that yours only allows declaring one member per method call, mine allowed any number (`member 1, 2, 3, ...`), but that was just a side effect
[16:18:43] rmosolgo: has joined #ruby
[16:18:48] LyndsySimon: Right. I'm adapting back and forth between my actual use case and the exemplar.
[16:18:52] rmosolgo: has left #ruby: ()
[16:19:34] LyndsySimon: In my use case, `self.member` is `self.column`, and is instantiating a class that contains information about a single column in a table of data.
[16:20:03] jottr: has joined #ruby
[16:28:01] gusrub: has joined #ruby
[16:29:30] Pumukel: has joined #ruby
[16:30:32] dcluna: has joined #ruby
[16:33:08] _aeris_: has joined #ruby
[16:38:49] nowhere_man: has joined #ruby
[16:42:40] pulkit4tech: has joined #ruby
[16:43:49] Rodya_: has joined #ruby
[16:47:30] yehowyada: has joined #ruby
[16:48:31] JeanCarloMachado: has joined #ruby
[16:48:56] raspado: has joined #ruby
[16:49:53] tercenya: has joined #ruby
[16:50:00] govg: has joined #ruby
[16:50:29] Xiti: has joined #ruby
[16:51:31] sofubi: has joined #ruby
[16:53:03] Pumukel: has joined #ruby
[16:53:50] Pumukel: has joined #ruby
[16:53:54] esObe_: has joined #ruby
[16:54:30] Pumukel: has joined #ruby
[16:54:49] djbkd: has joined #ruby
[16:58:23] thatkid: has joined #ruby
[16:58:50] gusrub: has joined #ruby
[17:01:11] jottr: has joined #ruby
[17:04:53] Cohedrin: has joined #ruby
[17:06:14] enterprisey: has joined #ruby
[17:06:54] gusrub: has joined #ruby
[17:08:03] agent_white: has joined #ruby
[17:11:33] pilne: has joined #ruby
[17:15:03] agent_white: Mornin' folks
[17:16:32] mooser: has joined #ruby
[17:17:47] doublemalt_: has joined #ruby
[17:18:07] thatkid: https://gist.github.com/anonymous/cb0b977c45fad4fdcb8a09b3de67d650
[17:18:21] muelleme_: has joined #ruby
[17:18:23] thatkid: I'm trying to write into a file inside a loop
[17:18:45] tilaioe: has joined #ruby
[17:18:54] tilaioe: Can I do multiple precision in ruby?
[17:18:54] thatkid: but the file created new version by removing the existing lines. How can I keep the old lines?
[17:19:03] roamingdog: has joined #ruby
[17:19:08] tilaioe: Is there something like the mpmath library or the
[17:19:53] tilaioe: are there some other external libraries too for the mature complex math stuff, like symbolic math, and numericals/
[17:20:18] tilaioe: If so I'd learn ruby, I like it, but I'd like to enquire more about the libraries beforhand
[17:20:22] tilaioe: Is anyone here?
[17:20:28] tilaioe: Lots of people are not here ?
[17:20:33] tilaioe: thatkid: ?hi
[17:20:48] havenwood: tilaioe: yup
[17:20:53] Hanmac: thatkid: hm seems you want 'a' instead of 'w' ?
[17:21:02] thatkid: yup, exactly,
[17:21:07] havenwood: tilaioe: https://ruby-doc.org/stdlib/libdoc/bigdecimal/rdoc/BigDecimal.html
[17:21:09] thatkid: I got it, thanks
[17:22:40] montanonic: has joined #ruby
[17:22:55] tilaioe: havenwood: What about the other libs for math? or science stuff/
[17:23:12] havenwood: tilaioe: Some are in the stdlib, it's a large stdlib.
[17:23:13] havenwood: tilaioe: https://github.com/SciRuby
[17:23:42] tilaioe: wow, really, I didn't expect ruby to have libs like python? Is it true then,?
[17:24:02] tilaioe: that it has really good libraries like the numpy,sympy,scipy in python?
[17:24:15] havenwood: tilaioe: http://ruby-gsl.sourceforge.net/
[17:26:00] Renich__: has joined #ruby
[17:26:48] havenwood: tilaioe: :P https://github.com/rcqls/jl4rb
[17:26:52] havenwood: tilaioe: embed Julia in Ruby, problem solved?
[17:27:04] Guest96: has joined #ruby
[17:27:13] tilaioe: No, I hate julia.
[17:27:14] __Yiota: has joined #ruby
[17:27:21] tilaioe: I don't even know Julia at all.
[17:28:10] havenwood: tilaioe: Well, Ruby doesn't have as many math and science libs as Python but it has quite a few and some surprising stuff in stdlib.
[17:29:25] [Butch]_: has joined #ruby
[17:29:29] Lord_of_Life: has joined #ruby
[17:31:44] baweaver: "I hate X" "I don't even know X at all" - that's not a very wise way to approach things.
[17:33:37] ramortegui: has joined #ruby
[17:34:37] byte512: has joined #ruby
[17:41:33] mooser: has joined #ruby
[17:42:11] mensvaga: has joined #ruby
[17:42:53] mensvaga: If I have a string that represents an ERB template, and I have a data structure, how do I get ERB to process the template and return the string?
[17:44:00] SeepingN: has joined #ruby
[17:44:06] mensvaga: It seems like there's no way to do something like this: data = {'name' => 'mensvaga'} ; template="Hello, <%= data['name'] %>!"; puts ERB.render(template, { 'data' => 'data' })
[17:44:22] mensvaga: I mean, I haven'
[17:44:40] mensvaga: I haven't tried what I just wrote; but it looks like all of the ERB examples I've found use some sort of class binding or something.
[17:45:54] hahuang61: has joined #ruby
[17:46:08] nofxx: has joined #ruby
[17:48:02] binaryplease: has joined #ruby
[17:49:17] jonjoe: has joined #ruby
[17:49:53] certainty: has joined #ruby
[17:50:59] nadir: has joined #ruby
[17:53:13] Jayson_Virissimo: has joined #ruby
[17:56:04] snguyen: has joined #ruby
[17:56:26] marsjaninzmarsa: has joined #ruby
[17:57:31] renchan: has joined #ruby
[17:58:55] nobitanobi: has joined #ruby
[18:01:14] mensvaga: Is there a way to automatically define nested structures in a hash as hashes?
[18:01:33] mensvaga: a = {} ; a['b']['c']='d'
[18:01:55] mensvaga: Instead of: a['b']={} ; a['b']['c']='d'
[18:02:15] g0d355__: has joined #ruby
[18:02:28] baweaver: auto-vivification
[18:03:17] baweaver: >> vivified_hash = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }; vivified_hash[1][2][3][4][5][6][7] = 8; vivified_hash
[18:03:18] ruby[bot]: baweaver: # => {1=>{2=>{3=>{4=>{5=>{6=>{7=>8}}}}}}} (https://eval.in/762105)
[18:03:43] baweaver: &ri Hash#new
[18:03:43] `derpy: No results
[18:03:51] baweaver: &ri Hash#initialize
[18:03:51] `derpy: No results
[18:03:58] `derpy: http://ruby-doc.org/core-2.4.0/Hash.html
[18:04:21] baweaver: Hash takes a block to new that defines the default value of an unknown key
[18:04:56] baweaver: in this case it passes the hash and the unknown key, and you're getting the default_proc (the function you passed to Hash.new) and throwing that to a new Hash inside that one
[18:05:00] baweaver: trippy, no?
[18:05:59] mensvaga: Eh; it makes sense.
[18:06:17] mensvaga: Thanks for showing me it.
[18:06:50] sofubi: has joined #ruby
[18:06:54] ahrs: has joined #ruby
[18:09:28] blackmesa: has joined #ruby
[18:10:09] Rodya_: has joined #ruby
[18:11:06] dionysus69: has joined #ruby
[18:11:27] wizard2011: has joined #ruby
[18:12:17] wizard2011: hey whats up room o
[18:12:28] adam12: wizard2011: o/
[18:13:48] zeddan: has joined #ruby
[18:13:53] wizard2011: whats up adam
[18:15:34] tercenya: has joined #ruby
[18:16:28] adam12: wizard2011: same old. what you saying?
[18:16:42] Cohedrin: has joined #ruby
[18:17:30] sofubi: has joined #ruby
[18:17:36] wizard2011: @adam12 nothing just here bored just another day
[18:17:56] adam12: I don't think I could ever be bored. Build all the things!
[18:18:38] wizard2011: @adam12 whats that mean "buiild all the things"?
[18:18:59] adam12: wizard2011: I like building things / writing code. I could probably find something to build every minute of every day.
[18:19:40] wizard2011: @adam12 what type of applications you build?
[18:19:52] jusa: has joined #ruby
[18:20:02] adam12: wizard2011: I dunno - whatever catches my fancy. Just 10 minutes ago I was humouring myself with a Geminabox-as-a-Service
[18:22:04] User458764: has joined #ruby
[18:22:53] ebernhardson: has joined #ruby
[18:23:14] wizard2011: @adam12 Im not that great with coding please explain what exactly is a Geminabox?
[18:23:27] adam12: wizard2011: https://github.com/geminabox/geminabox
[18:23:36] ebernhardson: when building a gem, is there a way to either: A) Specify the directory the build gem should be put in or B) Report the name of the gem file that was created so a script can move it to an output diretory?
[18:24:17] ebernhardson: i couldn't find anything relevant in the `gem build` docs
[18:25:51] centrx: has joined #ruby
[18:25:58] centrx: has joined #ruby
[18:26:20] wizard2011: @adam12 whats that github link for?
[18:26:31] adam12: wizard2011: It answers your question about what Geminabox is.
[18:26:38] elifoster: has joined #ruby
[18:28:01] wizard2011: ok thanks adam
[18:28:07] snickers: has joined #ruby
[18:28:21] tomphp: has joined #ruby
[18:28:59] AgentVenom: has joined #ruby
[18:29:19] TomyLobo2: has joined #ruby
[18:30:37] User458764: has joined #ruby
[18:33:29] montanonic: has joined #ruby
[18:33:54] cajone: has joined #ruby
[18:37:35] Renich: has joined #ruby
[18:38:17] tilaioe: has left #ruby: ("WeeChat 1.7")
[18:41:35] adaedra: &ri Hash.new baweaver
[18:41:35] `derpy: baweaver: http://ruby-doc.org/core-2.4.0/Hash.html#method-c-new
[18:42:13] ebernhardson: has left #ruby: ()
[18:44:01] zeddan: has joined #ruby
[18:44:03] pandaant: has joined #ruby
[18:44:22] tvw: has joined #ruby
[18:45:45] wizard2011: @adam12 so this geminabox is a server , whats being hosted from it?
[18:46:01] bmurt: has joined #ruby
[18:47:39] rippa: has joined #ruby
[18:50:23] wizard2011: whos in here with me that can help me with coding
[18:51:47] BSaboia: has joined #ruby
[18:53:26] s2013: has joined #ruby
[18:53:44] lmc: has joined #ruby
[18:55:44] tomphp: has joined #ruby
[18:56:03] Jayson_Virissimo: wizard2011: It's usually better to just ask a question, and if someone has something relevant to say, they'll respond. Otherwise it sounds like you are asking someone to agree to help without them even knowing what they are going to help with and what kind of time commitment that would entail.
[18:56:52] aupadhye: has joined #ruby
[18:56:57] thadtheman: has joined #ruby
[18:58:13] Arpanet69: has joined #ruby
[18:58:31] Pumukel: has joined #ruby
[18:59:36] leito: has joined #ruby
[19:01:04] havenwood: wizard2011: What's your Ruby question? Ask away!
[19:01:25] j0n3: has joined #ruby
[19:01:37] wizard2011: @Jayson_Virissimo thanks thats very true I didnt really think about it like that
[19:01:56] gchristensen: has joined #ruby
[19:02:31] davorb: has joined #ruby
[19:02:58] blackmesa: has joined #ruby
[19:03:37] Jackneill: has joined #ruby
[19:04:55] cagomez: has joined #ruby
[19:05:08] gchristensen: Hi, how do I control how pry pretty-prints objects? I have a few special objects that pretty-print very nicely, and I can't for the life of me figure out how.
[19:07:19] skord: has joined #ruby
[19:07:52] cam27: has joined #ruby
[19:08:39] tenderlove: has joined #ruby
[19:09:50] ozcanesen: has joined #ruby
[19:10:11] olivier__: has joined #ruby
[19:13:36] Hanmac: gchristensen: i found this methods in Object which seems to control that:
[19:13:36] Hanmac: >> require "pp"; Object.instance_methods.grep(/pretty/)
[19:13:37] ruby[bot]: hanmac: # => [:pretty_print, :pretty_print_cycle, :pretty_print_instance_variables, :pretty_print_inspect, :prett ...check link for more (https://eval.in/762122)
[19:14:11] aupadhye: has joined #ruby
[19:14:16] HoierM: has joined #ruby
[19:14:29] mooser: has joined #ruby
[19:16:15] JeanCarloMachado: has joined #ruby
[19:17:10] gchristensen: hanmac: hrmm bizarre. I don't have any of those :/ I'll dig around for related looking things.
[19:17:58] Lord_of_Life: has joined #ruby
[19:18:21] username1: has joined #ruby
[19:20:56] Hanmac: gchristensen: did you require pp yet? this functions only appear after requiring pp
[19:23:37] dionysus69: has joined #ruby
[19:23:49] Heero_: has joined #ruby
[19:24:56] cagomez: has joined #ruby
[19:25:38] RushPL: has joined #ruby
[19:26:25] gchristensen: ah, sorry, so I do have them but they're not formatted how I'd expect
[19:26:43] gchristensen: they're returning regular strings whereas the formatting from pry is colored in elaborate ways
[19:27:23] heftig: has joined #ruby
[19:27:49] baweaver: adaedra: derp. Monday hits hard.
[19:28:51] miah_: has joined #ruby
[19:29:24] jwheare: has joined #ruby
[19:32:15] gusrub: has joined #ruby
[19:35:11] gchristensen: has left #ruby: ("WeeChat 0.4.2")
[19:36:14] postmodern: has joined #ruby
[19:36:21] Sirecote: has joined #ruby
[19:36:48] gdonald: has joined #ruby
[19:37:53] leito: has joined #ruby
[19:37:56] manveru: has joined #ruby
[19:38:08] Verity: has joined #ruby
[19:38:12] peteretep: has joined #ruby
[19:38:18] Verity: https://github.com/postmodern/digest-crc could someone help me out?
[19:38:22] Verity: under defining your own CRC class
[19:38:34] Verity: the method we used in school had a generator polynomial
[19:38:36] Rush: has joined #ruby
[19:38:38] Verity: and didnt use a table
[19:38:59] Suslov: has joined #ruby
[19:39:00] Verity: how can I derive my own CRC class from digest-crc that will generate the proper 8 bit crc (using the same generator poly)
[19:39:18] Verity: if I dont use the same, my crcs wont match those of the other students
[19:40:16] blackmesa: has joined #ruby
[19:40:18] sjumsa: has joined #ruby
[19:40:41] milardovich: has joined #ruby
[19:40:42] postmodern: Verity, inherit from CRC8 and override the update method
[19:41:24] postmodern: Verity, update(data) must process a String, updating @crc accordingly, and return self, anything else in there is up to you
[19:41:28] Verity: https://github.com/postmodern/digest-crc/blob/master/lib/digest/crc8.rb
[19:41:38] Verity: can you tell me what part of that is the generator polynomial
[19:41:45] Verity: I have one, ie 0x156
[19:42:00] tolerablyjake: has joined #ruby
[19:42:19] Verity: that cant be right
[19:42:20] Verity: or can it
[19:42:25] ekinmur: has joined #ruby
[19:42:26] milardovich: has joined #ruby
[19:42:28] Verity: mine has a 1 for "the carry"
[19:42:30] chrisgopher: has joined #ruby
[19:42:32] Verity: having trouble understanding all of this
[19:43:09] AndBobsYourUncle: has joined #ruby
[19:43:09] postmodern: Verity, & 0xff isolates the lower 8 bits (aka byte)
[19:44:10] montanonic: has joined #ruby
[19:44:30] zeddan: has joined #ruby
[19:45:44] HalcyonicStorm: has joined #ruby
[19:46:19] zzak: has joined #ruby
[19:46:42] workmad3: has joined #ruby
[19:47:01] moogumbo: has joined #ruby
[19:47:26] rprimus: has joined #ruby
[19:48:27] wsmoak: has joined #ruby
[19:48:30] Verity: postmodern, and the "generator polynomial" ?
[19:48:46] Verity: https://www.youtube.com/watch?v=HEkAAmdzK_U&t=1m45s
[19:49:02] mrsolo: has joined #ruby
[19:49:07] avdi: has joined #ruby
[19:50:36] certainty: has joined #ruby
[19:50:46] bcavileer: has joined #ruby
[19:50:46] centrx: has joined #ruby
[19:50:49] ggherdov: has joined #ruby
[19:51:32] postmodern: Verity, read up on enumerators. each_byte iterates over each byte. you can do each_byte.each_with_index { |b,i| ... } to get the index (starting at 0) of each byte
[19:52:20] postmodern: Verity, you'll need to convert the polynomial equation into an iterative or inductive one
[19:52:28] allisio: That can just be #with_index these days, for reference.
[19:53:45] Verity: thats I needed
[19:53:51] postmodern: oh much easier to read +1
[19:54:28] Verity: a char has an index
[19:55:51] postmodern: Verity, also remember chars don't always equal bytes, aka UTF-8 and UTF-16 you can have multi-byte chars
[19:56:00] maattdd: has joined #ruby
[19:56:26] Verity: for me they will be bytes, luckily
[19:56:30] Verity: I think>?
[19:56:35] Verity: for this protocol we will be using ascii only
[19:57:14] postmodern: Verity, most each_* methods will return an Enumerator if you don't give it a block (ex: each_byte.with_index { |b,i| ... }) http://www.rubydoc.info/stdlib/core/Enumerator
[19:57:21] cagomez: has joined #ruby
[19:57:39] postmodern: Verity, http://www.rubydoc.info/stdlib/core/Enumerator#with_index-instance_method
[19:58:21] Verity: I don't understand enumerators and map
[19:58:29] Verity: I'm using htem, but not fully understanding
[19:58:33] Verity: I'm using irb for guess + check sometimes
[19:58:35] Verity: not good.
[19:58:46] Verity: when I get the result I needed, I've found my code
[19:58:51] Verity: or perhaps thats how its intended
[19:59:44] nobitanobi: has joined #ruby
[20:00:16] lxsameer: has joined #ruby
[20:00:20] cagomez: has joined #ruby
[20:00:38] postmodern: Verity, also i'd ignore the polynomial part of that video. focus on implementing the algorithm using xor (^) and shift (<< >>) operators
[20:00:43] hahuang65: has joined #ruby
[20:00:54] Verity: well I have a generator polynomial from my professor
[20:01:01] Verity: in the form of 0x156 (hex)
[20:01:07] Verity: and the 1 is "the carry"
[20:01:12] Verity: but I'm afraid I don't understand
[20:01:17] milardovich: has joined #ruby
[20:01:19] Verity: he said I could just copy paste his C++ code if I can call it in ruby
[20:01:28] Verity: but I'd rather understand this algorithm and how to implement it in ruby
[20:01:40] nobitanobi: has joined #ruby
[20:01:58] Lord_of_Life: has joined #ruby
[20:02:31] patarr: has joined #ruby
[20:02:43] matthewd: It may be more pedagogically expedient to implement as a stand-alone class, without digest-crc as a base
[20:03:02] matthewd: Both because you can then start with a 1-to-1 translation of the C++ code, and because it's your first ruby class
[20:03:11] GodFather: has joined #ruby
[20:03:28] cdg: has joined #ruby
[20:05:20] Verity: then it may not be possible to easily change the generator polynomial in the derived digest-crc8 class
[20:06:11] cagomez: has joined #ruby
[20:07:24] username1: has joined #ruby
[20:09:13] postmodern: Verity, i think matthewd means, it would be simpler to just focus on the algorithm first, and not worry about fitting it into digest-crc's API
[20:14:37] dionysus69: has joined #ruby
[20:14:51] cagomez: has joined #ruby
[20:15:08] milardovich: has joined #ruby
[20:15:45] fearoffish: has joined #ruby
[20:16:46] fearoffish: has left #ruby: ()
[20:17:20] chouhoulis: has joined #ruby
[20:18:59] bkxd: has joined #ruby
[20:19:45] blackmesa: has joined #ruby
[20:20:41] ineb: has joined #ruby
[20:21:41] cagomez: has joined #ruby
[20:22:51] Rodya_: has joined #ruby
[20:23:28] milardovich: has joined #ruby
[20:23:53] cagomez: has joined #ruby
[20:24:18] milardovich: has joined #ruby
[20:28:35] Rodya__: has joined #ruby
[20:30:40] thadtheman: has joined #ruby
[20:33:37] centrx: has joined #ruby
[20:33:38] centrx: has joined #ruby
[20:35:15] Arpanet69: has joined #ruby
[20:37:27] sagax: has joined #ruby
[20:38:50] centrx: has joined #ruby
[20:41:15] webopsx: has joined #ruby
[20:42:59] brent__: has joined #ruby
[20:45:46] dar123: has joined #ruby
[20:49:20] bmurt: has joined #ruby
[20:52:08] centrx: has joined #ruby
[20:54:55] gloscombe: has joined #ruby
[20:56:29] gusrub: has joined #ruby
[20:59:24] thadtheman: has joined #ruby
[21:02:05] davorb: has joined #ruby
[21:03:34] Pumukel: has joined #ruby
[21:06:06] rhyselsmore: has joined #ruby
[21:08:50] willardg: has joined #ruby
[21:09:56] RenatoSilva: has joined #ruby
[21:10:00] enterprisey: has joined #ruby
[21:13:55] esObe_: has joined #ruby
[21:13:59] kies: has joined #ruby
[21:14:47] ghoti: has joined #ruby
[21:15:11] Verity: >> "hello".each_byte.map {|b| puts << b.to_s(2).rjust(8, "0")}
[21:15:12] ruby[bot]: Verity: # => ...check link for more (https://eval.in/762176)
[21:15:29] Verity: >> bit_array = []; "hello".each_byte.map {|b| bit_array << b.to_s(2).rjust(8, "0")}
[21:15:30] ruby[bot]: Verity: # => [["01101000", "01100101", "01101100", "01101100", "01101111"], ["01101000", "01100101", "01101100", ...check link for more (https://eval.in/762177)
[21:15:52] Suslov: has joined #ruby
[21:16:04] esObe__: has joined #ruby
[21:16:52] willardg: has left #ruby: ("Textual IRC Client: www.textualapp.com")
[21:16:57] jobewan: has joined #ruby
[21:17:02] Verity: >> bit_array = ""; "hello".each_byte.map {|b| bit_array << b.to_s(2).rjust(8, "0")}
[21:17:03] ruby[bot]: Verity: # => ["0110100001100101011011000110110001101111", "0110100001100101011011000110110001101111", "0110100001 ...check link for more (https://eval.in/762178)
[21:17:10] Verity: why it it putting all into each one
[21:17:33] Suslov: has joined #ruby
[21:17:57] havenwood: Verity: bit_array.class #=> String
[21:18:05] havenwood: Verity: String#<<
[21:19:18] havenwood: Verity: Note the different output if: bit_array = []
[21:20:32] allisio: Verity: `b.to_s(2).rjust(8, "0")` should just be `'%08b' % b`.
[21:23:03] Verity: I'm not sure what that is or how to use it, and I can't find any reference to it with a google search
[21:23:05] Jayson_Virissimo: Why is it called bit_array, when it is a string?
[21:24:55] Verity: turning it into an array comes next
[21:25:02] Verity: or maybe not
[21:25:13] Verity: I need to access all of the bits of a msg to run a crc calculation on it
[21:25:17] Verity: I really don't know the best way
[21:25:24] Verity: this doesnt seem like a common ruby task so examples are sparse
[21:25:34] allisio: The answer is String#unpack.
[21:25:40] allisio: >> 'Verity'.unpack 'B*'
[21:25:41] ruby[bot]: allisio: # => ["010101100110010101110010011010010111010001111001"] (https://eval.in/762189)
[21:26:04] choke: has joined #ruby
[21:27:09] matthewd: Those all end up with 1 and 0 characters, which isn't what your function's going to need
[21:27:11] Verity: I'm supposed to shift bits into an 8 bit register and then when the first 1 bit goes into the "carry" to the left of this register, I xor the register with the generator polynomial, then I need to do this for all msg
[21:27:42] Verity: in C I would need to use a mask to get at the bits
[21:27:49] matthewd: You have a C++ implementation, right? Just translate that directly.
[21:28:00] Verity: yeah he showed me the exact code today
[21:28:04] Verity: and said I could use it, even
[21:28:18] Verity: but its probably better to reimplement than to create a C lib and call it
[21:28:37] hahuang65: has joined #ruby
[21:28:42] Verity: I also doubted if I could do it
[21:28:53] Verity: as ruby would be so different than how its done in C, I would think
[21:28:54] allisio: In Ruby, you can index into an Integer to get its bits.
[21:29:24] Verity: my first step is probably to convert the entire message into an actual array of bits
[21:29:26] Verity: I'll try that now
[21:29:36] Verity: I think I was almost there
[21:29:42] Verity: it must be easy, actually
[21:30:16] Verity: >> "hello".unpack('B*').to_a
[21:30:17] ruby[bot]: Verity: # => ["0110100001100101011011000110110001101111"] (https://eval.in/762190)
[21:30:41] allisio: You're not learning at all. :<
[21:31:03] havenwood: ACTION gives a shoutout to Ruby 2.4's String#unpack1
[21:31:57] gusrub: has joined #ruby
[21:32:11] Verity: I wouldn't say I'm "not learning at all"
[21:32:16] Verity: I'm just as caught up as anyone else
[21:32:20] Verity: aside from the crc issue
[21:32:25] Verity: which they didnt have to learn a new language for
[21:32:29] Verity: just a small obstacle I will overcome
[21:32:32] linoespinoza: has joined #ruby
[21:32:50] Verity: we already did the crc in a previous lab
[21:33:00] matthewd: Verity: allisio didn't say you weren't progressing through the problem
[21:33:19] enterprisey: has joined #ruby
[21:33:46] Verity: right, he said I "wasn't learning at all". Simply not a true statement
[21:33:54] Verity: I could write a multitude of simple ruby programs now
[21:34:00] Verity: I couldn't a few days ago
[21:34:03] Verity: I've learned something.
[21:34:11] cagomez: has joined #ruby
[21:34:16] Verity: It just doesnt come as easily to me as some, no need to insult
[21:34:38] jenrzzz: has joined #ruby
[21:34:38] jenrzzz: has joined #ruby
[21:35:17] tercenya: has joined #ruby
[21:35:59] allisio: havenwood: We Erlang yet?
[21:37:40] Verity: oh it already is an array, why is it in quotes
[21:37:48] Verity: thats confusing
[21:37:54] Verity: with no []
[21:38:10] allisio: &ri String#unpack
[21:38:10] `derpy: http://ruby-doc.org/core-2.4.0/String.html#method-i-unpack
[21:38:13] Verity: I would have expected to see [0,1,1,0] etc
[21:39:18] Verity: thats how I'm used to seeing an array of numbers
[21:39:52] allisio: It's not an array of numbers.
[21:40:16] Verity: NoMethodError: undefined method `bytes' for ["01100001"]:Array
[21:40:19] Verity: that was why I thought that
[21:44:00] gdonald: has joined #ruby
[21:45:08] willardg: has joined #ruby
[21:45:42] willardg: has left #ruby: ()
[21:48:38] cagomez: has joined #ruby
[21:50:28] cagomez_: has joined #ruby
[21:51:37] certainty: has joined #ruby
[21:54:09] Verity: >> "a".unpack('B*').each {|b| bit_array << b}
[21:54:10] ruby[bot]: Verity: # => undefined local variable or method `bit_array' for main:Object (NameError) ...check link for more (https://eval.in/762200)
[21:54:14] Verity: why is this so difficult
[21:55:21] baweaver: where are you defining bit array?
[21:55:32] Verity: bit_array = [] line before
[21:56:09] baweaver: might that be why it's not working there?
[21:56:59] baweaver: Error messages are quite informative.
[21:57:49] allisio: Error: computers aren't magic.
[21:59:04] Verity: >> i = 0; "a".unpack('B*').each do |bit| bit_array[i] = bit; i+=1; end
[21:59:05] ruby[bot]: Verity: # => undefined local variable or method `bit_array' for main:Object (NameError) ...check link for more (https://eval.in/762201)
[21:59:15] Verity: >> bit_array = []; i = 0; "a".unpack('B*').each do |bit| bit_array[i] = bit; i+=1; end
[21:59:16] ruby[bot]: Verity: # => ["01100001"] (https://eval.in/762202)
[22:00:35] hahuang65: has joined #ruby
[22:00:46] matthewd: Verity: What does the C++ code look like?
[22:01:17] br0d1n: has joined #ruby
[22:01:58] Verity: I'll have to go get it
[22:02:08] Verity: It's quite different than what I would expect the ruby code to be
[22:02:54] Verity: what is going on here!!!!
[22:03:26] Verity: >> bit_array = "a".unpack('B*').to_a; bit_array.class; bit_array[1];
[22:03:27] ruby[bot]: Verity: # => nil (https://eval.in/762203)
[22:03:36] allisio: Please stop.
[22:03:44] Verity: => ["01100001"]
[22:03:48] Verity: how is that nil
[22:03:55] Verity: allisio you're just trolling again
[22:03:58] Verity: especially if you know what the problem is
[22:04:11] Verity: its not helpful the last several things you've said to me
[22:04:20] Verity: they serve only to feed your own sadistic pleasures
[22:04:25] allisio: Calm down.
[22:04:29] allisio: And use your local REPL.
[22:04:37] Verity: I could send the log of it
[22:04:40] Verity: its not pretty
[22:04:40] allisio: Your signal-to-noise ratio is through the floor, man.
[22:04:50] Verity: I stand by my statement
[22:04:54] Verity: the trolling continues
[22:05:04] dar123: has joined #ruby
[22:05:20] Verity: use my local REPL? As if I haven't tried 100s of variations
[22:05:33] Verity: nothing is resulting in the array I require
[22:05:42] allisio: Who are you blaming?
[22:05:59] nobitanobi: has joined #ruby
[22:06:50] hahuang65: has joined #ruby
[22:06:55] Verity: I'm blaming you for your trolling. For my difficulties figuring this out I blame God, the system, and myself
[22:07:15] allisio: In that order?
[22:07:38] Verity: for example, your last 4 messages have had nothing to do with my question about it claiming to be an array but not containing the data I would expect
[22:07:40] Verity: and yes, that order
[22:08:05] cam27: has joined #ruby
[22:08:33] Arvik_: has joined #ruby
[22:08:57] allisio: You're deliberately failing to recall that I pointed you at precisely the documentation you'd need to read in order to solve the problem God has burdened you with on this blessed day.
[22:09:09] allisio: Let's try that again.
[22:09:12] allisio: &ri String#unpack
[22:09:12] `derpy: http://ruby-doc.org/core-2.4.0/String.html#method-i-unpack
[22:12:43] Verity: irb(main):033:0> "a".unpack('B*').class
[22:12:43] Verity: => Array ???
[22:12:52] Verity: string or array, which is it
[22:13:00] Verity: I cant .split I just found on stack exchange
[22:13:03] Verity: because it says its an array
[22:13:09] Verity: but I also cant access its elements
[22:13:10] allisio: It's not lying to you.
[22:14:06] Verity: >> ary = "a".unpack('B*').class
[22:14:06] Verity: => Array; ary[1]
[22:14:07] ruby[bot]: Verity: # => Array (https://eval.in/762204)
[22:14:12] Verity: a = 01100001
[22:14:26] Verity: [1] shold be 1, not nil
[22:14:36] allisio: File a bug report.
[22:17:53] mikecmpbll: has joined #ruby
[22:17:57] havenwood: Verity: [Array][1] #=> ?
[22:18:11] havenwood: Verity: You're setting `ary` to `Array` above.
[22:18:58] Verity: oh right, that was just a typo
[22:19:12] Verity: "a".unpack('B*').each {|bit| printf("Bit:%d | Type:%s", bit, bit.class)}
[22:19:16] Verity: this was my latest attempt, just now
[22:19:25] Verity: let me make sure I wasnt somehow setting it to 'Array'
[22:19:49] Verity: Bit:294913 | Type:String=> ["01100001"]
[22:19:57] bkxd: has joined #ruby
[22:21:06] Verity: havenwood, it says array
[22:21:09] Verity: thats the real point here
[22:21:11] Verity: and its not
[22:21:15] Verity: its not an array
[22:21:43] Verity: of if it is, its an array of 1 string
[22:21:55] Verity: and what would the point of that be
[22:22:02] havenwood: Verity: it's an Array with one String
[22:22:28] Verity: >> "a".unpack('B*')[0].split("")
[22:22:29] ruby[bot]: Verity: # => ["0", "1", "1", "0", "0", "0", "0", "1"] (https://eval.in/762205)
[22:22:37] matthewd: The point would be that this is not the right approach, as I said an hour ago.
[22:22:46] milardovich: has joined #ruby
[22:22:46] Verity: how is it not? I just finally got it
[22:22:51] Verity: it was a nightmare
[22:23:02] Verity: and devastated my psyche, but I'm here there
[22:23:06] Verity: there now*
[22:23:16] allisio: String#unpack returns an Array because you can specify that you want to unpack more than one datum.
[22:23:23] allisio: >> 'ab'.unpack 'CC'
[22:23:24] ruby[bot]: allisio: # => [97, 98] (https://eval.in/762206)
[22:23:49] Verity: you mean unpack each character as a different type?
[22:24:13] allisio: #unpack can do all sorts of things, but sure, that's one potential use case.
[22:24:27] ivanacostarubio: topic softwarecriollo ⚡️💻
[22:24:38] willardg: has joined #ruby
[22:24:42] ivanacostarubio: has left #ruby: ()
[22:24:58] havenwood: Verity: A good place to start is showing example input values and the corresponding desired output values.
[22:25:45] allisio: matthewd: What's wrong with `unpack1('B*').chars.map &:to_i`?
[22:26:06] allisio: It's 2017.
[22:26:08] baweaver: ACTION ducks
[22:26:22] eam: ruby needs vec()
[22:27:08] Verity: why is that any better than bit_array = "a".unpack('B*')[0].split("")
[22:27:21] matthewd: allisio: As I still haven't seen the code it's going to get fed into, I remain dubious that an array of bits (and especially one in that order) is what's actually needed
[22:27:38] Verity: I could reverse the order no problem now
[22:27:40] allisio: matthewd: Yeah, fair enough.
[22:27:52] Verity: I need an array of bits
[22:28:06] allisio: Does your approach give you an array of bits?
[22:28:16] Verity: let me take a look
[22:28:21] havenwood: Verity: We can give you random Arrays of bits all day long. Do you have example input values and corresponding output values for your spec?
[22:28:32] Verity: havenwood, no
[22:28:39] Verity: I'll need to shift the bits into an 8 bit register next
[22:28:45] havenwood: Verity: Then we can't help you unless random bits suffice.
[22:28:56] Verity: and then to the left of that is a carry bit, when it goes 1 I xor the register with the polynomial
[22:29:03] ruby[bot]: it seems like you are asking for a specific solution to a problem, instead of asking about your problem. This often leads to bad solutions and increases frustration for you and those trying to help you. More: http://meta.stackexchange.com/a/66378
[22:30:15] havenwood: Verity: Like `"hi" => ["0110", "0110"]` or `"bye" => ["0110", "0111", "0110"]`. A gist is ideal if it's complex enough to warrant multiple examples.
[22:30:39] havenwood: Verity: You can update a gist to perfect your query.
[22:31:05] havenwood: Verity: It's easy that way for folk dropping by the channel to look at your best effort at giving realistic data and requirements.
[22:31:11] havenwood: Verity: gist.github.com
[22:31:29] Verity: well that would have been, "hello" => [0, 1, 1, 0, 0, 0, 0, 1]
[22:31:51] Verity: I just realized I'm still not quite there, I have an array of strings of length 1!!!!
[22:31:56] havenwood: Verity: Are you sure?
[22:31:59] User458764: has joined #ruby
[22:32:22] Verity: "a" => [0, 1, 1, 0, 0, 0, 0, 1]
[22:32:43] lmc: has joined #ruby
[22:32:51] Verity: "a".ord is the number I need to convert to a binary array, thats when the doc stopped helping
[22:33:31] Pumukel: has joined #ruby
[22:33:57] havenwood: >> 'a'.ord.to_s(2).each_char.map(&:to_i)
[22:33:57] ruby[bot]: havenwood: # => [1, 1, 0, 0, 0, 0, 1] (https://eval.in/762207)
[22:35:07] Verity: plus I need to add the padding
[22:35:08] allisio: 18>> ('%08b' % ?a).bytes.map { |b| b - 48 }
[22:35:09] ruby[bot]: allisio: # => [0, 1, 1, 0, 0, 0, 0, 1] (https://eval.in/762208)
[22:35:19] havenwood: Verity: So give us real examples of what you want, in a Gist.
[22:35:27] havenwood: Verity: https://gist.github.com/
[22:35:38] allisio: Verity: https://gist.github.com/
[22:35:57] havenwood: Verity: Maybe preparing examples will help you with clarity around the problem domain.
[22:36:05] Verity: https://gist.github.com/anonymous/89be07bef3037dc8847b0c1de7469e27
[22:36:30] Verity: I'll try to understand allisio solution to it
[22:36:53] havenwood: Verity: What version of Ruby?
[22:37:02] havenwood: Verity: 'a'.unpack1('B*').each_char.map(&:to_i)
[22:37:12] dar123: has joined #ruby
[22:37:24] allisio: I'm trying to make sense of your preference for #each_char.
[22:37:27] Bob8989|2: has joined #ruby
[22:37:49] Verity: why is it b-48 and wha os 18>>
[22:38:08] allisio: Don't take the bait.
[22:38:10] Verity: also % and ?a ---? hard code to understand
[22:38:21] Verity: how could I ever have put that together from the docs
[22:38:30] havenwood: allisio: The intermediary Enumerator seems preferable to the intermediary Array.
[22:38:36] Verity: I dont even understand it looking at it
[22:38:56] Verity: I google "ruby %" and guess what comes up
[22:39:05] Verity: a hopless approach
[22:39:19] nofxx: Verity, isn't pack/unpack better for that kinda of bit stuff
[22:39:21] havenwood: allisio: Since `str.chars` is shorthand for `str.each_char.to_a`, there's no reason to have the `.to_a` when you're about to map to an Array.
[22:39:42] Verity: nofxx, yeah I'm using unpack
[22:39:54] Verity: it just doesnt unpack to an array of ints
[22:42:34] nofxx: Verity, doesn't make a sense, 1 bit can be at most a boolean, it's up to you to group'em
[22:42:47] olivier__: has joined #ruby
[22:44:38] Guest96: has joined #ruby
[22:44:39] xnxq: has joined #ruby
[22:44:44] nofxx: Verity, eg the numbers you provide to unpack.... check the docs, don't remember...
[22:45:37] allisio: havenwood: Yeah, makes sense.
[22:47:25] charliesome: has joined #ruby
[22:47:28] esObe_: has joined #ruby
[22:48:07] blackmesa: has joined #ruby
[22:49:47] am55: has joined #ruby
[22:51:54] Pumukel: has joined #ruby
[22:52:27] cam27: has joined #ruby
[22:55:25] jusa: has joined #ruby
[22:57:44] Verity: >> bit_array = []; 'a'.unpack('B*')[0].each_char {|bit| bit_array += bit.to_i}
[22:57:45] ruby[bot]: Verity: # => no implicit conversion of Fixnum into Array (TypeError) ...check link for more (https://eval.in/762210)
[22:58:49] Verity: <havenwood> Verity: 'a'.unpack1('B*').each_char.map(&:to_i) gives me errr
[22:59:05] havenwood: Verity: What's the error?
[22:59:32] havenwood: Verity: (Latest stable Ruby is 2.4.1.)
[22:59:39] Verity: NoMethodError: undefined method `unpack1' for "a":String
[22:59:41] Verity: I'm on 2.3
[22:59:59] havenwood: Verity: So the method doesn't exist yet.
[23:00:38] Verity: why didnt my method work
[23:01:18] allisio: You tried to add a Fixnum to an Array.
[23:01:51] Verity: is that not what goes into an arrya
[23:02:42] davorb: has joined #ruby
[23:04:44] elifoster: has joined #ruby
[23:05:37] xnxq: has joined #ruby
[23:08:35] Verity: is that not what goes into an array
[23:11:11] SeepingN: not that way
[23:11:37] olivier__: has joined #ruby
[23:11:45] havenwood: Verity: See the docs: https://ruby-doc.org/core/Array.html#method-i-2B
[23:13:45] charliesome: has joined #ruby
[23:14:36] esObe_: has joined #ruby
[23:14:57] choke: has joined #ruby
[23:16:58] beermouse: has joined #ruby
[23:17:44] czerasz: has joined #ruby
[23:18:52] czerasz: has joined #ruby
[23:18:57] choke: has joined #ruby
[23:20:02] roamingdog: has joined #ruby
[23:20:35] bkxd: has joined #ruby
[23:21:44] havenwood: >> [] << 'Verity'
[23:21:45] ruby[bot]: havenwood: # => ["Verity"] (https://eval.in/762231)
[23:23:45] Verity: >> 'a'.unpack('B*')[0].split("").map{|bit| puts bit}
[23:23:46] ruby[bot]: Verity: # => 0 ...check link for more (https://eval.in/762234)
[23:24:10] chrisgopher: has joined #ruby
[23:24:46] Verity: I'm not quite sure why this isnt working
[23:24:49] Verity: tried a new operator
[23:24:57] Verity: >> bit_array = []; 'a'.unpack('B*')[0].split("").map{|bit| bit_array += bit.to_i}
[23:24:58] ruby[bot]: Verity: # => no implicit conversion of Fixnum into Array (TypeError) ...check link for more (https://eval.in/762238)
[23:25:17] havenwood: Verity: Did you look at the Array#+ docs I linked above?
[23:25:25] havenwood: Verity: What argument does that method expect?
[23:25:28] Verity: yes but I never know which part to read
[23:25:38] Verity: or am I suppose dto just read it all, and then how do I know which part I need to use
[23:25:44] havenwood: Verity: "Returns a new array built by concatenating the two arrays together to produce a third array."
[23:26:40] havenwood: Verity: So the method you chose to use, Array#+, adds two Arrays together.
[23:27:44] havenwood: Verity: https://rubymonk.com/learning/books/1-ruby-primer/chapters/1-arrays/lessons/2-arrays-introduction
[23:28:20] rakm: has joined #ruby
[23:28:51] Verity: >> bit_array = []; 'a'.unpack('B*')[0].split("").map{|bit| bit_array.insert(-1, bit.to_i)}
[23:28:52] ruby[bot]: Verity: # => [[0, 1, 1, 0, 0, 0, 0, 1], [0, 1, 1, 0, 0, 0, 0, 1], [0, 1, 1, 0, 0, 0, 0, 1], [0, 1, 1, 0, 0, 0, 0, ...check link for more (https://eval.in/762239)
[23:28:57] Verity: I'm close
[23:29:05] Verity: its an array of arrays though
[23:29:16] Verity: naybe thats not so bad
[23:29:32] Verity: this is all wrong
[23:29:40] Verity: its the SAME array repeatedly
[23:30:11] Verity: where did I go wrong?
[23:30:35] choke: has joined #ruby
[23:31:01] matthewd: Can we please see the code this is going to be fed into? Please?
[23:31:23] Verity: it doesnt exist yet, I need to write it
[23:31:32] Verity: let me type up the c++ code and I'll send that
[23:31:40] Verity: give me a bit
[23:32:00] IRCFrEAK: has joined #ruby
[23:32:27] Verity: all I know is that I need to calculate the crc using ruby or a ruby gem. It really doesnt matter which. The most important part is that the generator polynomial has to match
[23:32:35] Verity: or my program will have crc errors when it communicates with the others
[23:33:51] ytti_: standard library has crc32
[23:34:21] thadtheman: has joined #ruby
[23:35:51] Verity: ytti_, I need to use 8 bit w/ custom generator polynomial
[23:36:14] Verity: believe me if I could do that I would. I'd rather learn ruby writing my state machine and processing bytes
[23:36:21] Verity: not working with all of the bits and struggling like this
[23:36:24] matthewd: Verity: My concern is that until we know how the processing function is implemented, it's dangerous to fuss over the exact format of the intermediate data.. otherwise you're going to spend hours on getting one particular array format, then potentially find the function is better implemented with some other arrangement
[23:38:03] choke: has joined #ruby
[23:38:17] dar123: has joined #ruby
[23:39:36] xnxq: has joined #ruby
[23:42:22] Verity: matthewd, https://github.com/postmodern/digest-crc/blob/master/lib/digest/crc8.rb
[23:42:32] Verity: is there a generator polynomial in there?
[23:42:46] Verity: my algorithm has no table
[23:43:32] matthewd: I don't know, but assume it's used to generate the table
[23:43:47] allisio: Verity: Line 54 is the "generator polynomial".
[23:44:08] matthewd: But that's [part of] the reason we're talking about just implementing the existing algorithm, without digest-crc
[23:45:07] dviola: has joined #ruby
[23:46:16] BabyMario: has joined #ruby
[23:46:19] BabyMario: has left #ruby: ()
[23:52:25] certainty: has joined #ruby
[23:52:43] Verity: <ChaiTRex> h0wlevd: That one over part is important.
[23:53:16] Verity: where did that come from, https://www.youtube.com/watch?v=4wyvyZGcZw0&t=3m30s
[23:53:19] Verity: this is why I need the bits
[23:54:42] thadtheman: has joined #ruby
[23:56:44] matthewd: I understand that you need the data in the bits. I'm waiting to see the code to confirm that means we want an actual array of ones and zeros.
[23:59:36] Verity: well my professor said I will need to shift bits into a register