<Disavowed>
Hey Verity - how's the project going??
<Verity>
return an array of numbers from 1 to the legnthj of the str
<matthewd>
(1..n).reduce(:*) is n factorial, which is the number of permutations in a collection of that size
<Verity>
Disavowed, well, I think. I finally figured out the crc problem
<Disavowed>
Oh neat! Are you still enjoying Ruby as a language?
<Verity>
its funny you ask
<Verity>
in fact I love it
<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
<Verity>
although I'm already enjoying ruby much more
ace05 has joined #ruby
<Verity>
I never liked all of that indenting
<Verity>
and I can use printf here
genpaku has quit [Remote host closed the connection]
<Verity>
plus the syntax seems more clean
<Verity>
I'll have more to go on soon hopefully, these are my initial impressions
<Verity>
I made a simple encryption program too, just for fun
<Verity>
its not the most secure
<Verity>
but I found some great ruby features along the way
<allisio>
Ruby has the best features.
<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
<Disavowed>
What features are you enjoying?
genpaku has joined #ruby
enterprisey has joined #ruby
Rodya_ has quit [Remote host closed the connection]
<Verity>
I'm still learning it, but map is great
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Verity>
also many of the methods that all objects seem to have
Pumukel has quit [Ping timeout: 240 seconds]
Vile` has joined #ruby
<allisio>
>> Object.instance_methods.size
<Verity>
so conversions are painless, once you know the tricks
<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.
Rodya_ has quit [Ping timeout: 246 seconds]
<Verity>
I dont like that its M$ but its open source at least
<Verity>
or something close to it
<Verity>
its lighghtweight and fast and has increased my productivity with ruby
<Verity>
I have access to rubymine for 1 year free though, so I may try that
<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
<matthewd>
Verity: How are you going on your original project?
DaniG2k has joined #ruby
<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
<Verity>
I need to send start of transmission, wait for ack, etc]
<Verity>
so that will be my next step now that I'm getting some of the basics down
<Verity>
I'm really glad I decided to use ruby
<Verity>
unless the serial port doesnt work right in the end, lol
<Verity>
I havent tested it yet, I'm assuming it will work
<Verity>
no errors when I call the methods, etc
<Verity>
so I had a strange glitch, also, matthewd and Disavowed. I couldnt figure out why two bytes were being appended to the packet
<Verity>
and one of them always seemed to be 194 or something
<Verity>
it didnt make any sense
<Verity>
the reason ended up being, packet << Digest::CRC8.hexdigest(packet) returned "bb"
<Verity>
and .hex on it wasnt doing what I thought, somehow, someway
<Verity>
I tried and tried to understand, but couldn't
<Verity>
then, I guessed.
<Verity>
packet << Digest::CRC8.digest(packet) fixed it.
<Verity>
a perfect byte returned, a nd easily appended
mutter2017 has joined #ruby
<Verity>
also, packet << " " until packet.length > 5 this is my padding code. I'm not sure if its the best
<Verity>
it seems to work great
<Verity>
I enjoy how readable ruby code is
oliv_____ has quit [Remote host closed the connection]
<matthewd>
Are you working to a defined protocol, or is specifying it part of your task?
<Verity>
its defined
<Verity>
7 byte packet, soh, 5 data bytes, 8 bit crc
<Verity>
ack + nak, with start and eot
<Verity>
and provisions for all states of transmission
<Verity>
on send + recieve side
ledestin has joined #ruby
<Verity>
receive
<matthewd>
And spaces for padding?
<Verity>
its actually supposed to be 0xFF, I meant to change that
<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
<ruby[bot]>
Verity: # => /tmp/execpad-7df220ee167c/source-7df220ee167c:2: syntax error, unexpected $undefined ...check link for more (https://eval.in/761607)
<Verity>
ah, I see
<matthewd>
or even ?\xFF
oliv_____ has joined #ruby
bronson has quit [Ping timeout: 240 seconds]
<Disavowed>
allisio: Thank you, you saint.
<Verity>
why the ?\xFF vs \xFF
<allisio>
? is for "character literals".
<allisio>
The latter is just a SyntaxError.
<Verity>
is it?
<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
<ruby[bot]>
Verity: # => /tmp/execpad-4c8bec10970c/source-4c8bec10970c:2: syntax error, unexpected $undefined ...check link for more (https://eval.in/761611)
<Verity>
oh, its a syntax error
<matthewd>
Verity: \x is a thing you do inside a string
<Verity>
>> "hello" << "\xFF"; << ?\xFF
<ruby[bot]>
Verity: # => /tmp/execpad-64bedcd68bd4/source-64bedcd68bd4:2: syntax error, unexpected <<, expecting keyword_end ...check link for more (https://eval.in/761612)
<havenwood>
Verity: Please try things in your own REPL first. Just use @ruby[bot] for showing others.
<Radar>
^
<allisio>
^
<Verity>
^
<Verity>
captain planet
<allisio>
You should still go sit in the corner for a while.
<Verity>
and also, how can I get this on one line : if packet.length < 6 packet << EOT end
<Verity>
I thought indents dont matter
<Verity>
but I have to put them on their own line with the end etc
<elomatreb>
You need to separate the condition from the if body, either use a ; or `then`
<Radar>
Verity: Are you doing the thing again where you talk about code without actually showing the code?
<elomatreb>
Alternatively, use the modifier-if, i.e. `packet << EOT if packet.length < 6`
mutter2017 has joined #ruby
<Radar>
[14:50:02] <Verity>should I be putting some of my code into a function here
<Radar>
I'm referring to ^
<Radar>
+1 for using the modifier-if
enterprisey has joined #ruby
thadtheman has quit [Ping timeout: 240 seconds]
mooser has quit [Ping timeout: 240 seconds]
mostlybadfly has joined #ruby
<Verity>
ok
tk422 has quit [Ping timeout: 260 seconds]
kernelPaniq has quit [Remote host closed the connection]
kernelPaniq has joined #ruby
<Verity>
why might I choosde if packet.length < 6; packet << EOT end vs packet << EOT if packet.length < 6
jenrzzz has quit [Ping timeout: 260 seconds]
<elomatreb>
That ; in there is pretty awkward imo, and it's the accepted convention
CloCkWeRX has joined #ruby
spicerack has joined #ruby
Robtop__ has joined #ruby
cam27 has quit [Quit: cam27]
<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
pwnd_nsfw` has quit [Ping timeout: 260 seconds]
thadtheman has joined #ruby
agent_white has quit [Remote host closed the connection]
<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?
<ineb>
wkoszek: i hope you know that it is a bad thing what youre trying to do
Pumukel has quit [Remote host closed the connection]
<wkoszek>
ineb: I have a self-signed, which is pretty popular to just get encryption.
<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)
Pumukel has joined #ruby
zapata has quit [Ping timeout: 264 seconds]
lightheaded has quit [Remote host closed the connection]
<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.
<tau>
dminuoso i see. is monkey patching advisable in ruby? is it 'good'?
<dminuoso>
tau: No.
lightheaded has joined #ruby
<tau>
dminuso so is it bad in ruby?
<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'.
<ineb>
And as you correctly figured out, it overwrites the Kernel.puts method
<dminuoso>
tau: Well it's common enough to mention it -> but you effectively violate design contracts if you do it.
oliv_____ has quit [Remote host closed the connection]
<ineb>
tau: to further answer your question. Socket is getting the puts from IO
<tau>
dminuoso i see.
Chch has quit [Quit: Leaving]
<tau>
ineb but, i have the feeling i should use self.puts in Socket(when monkey patching it) isnt it?
<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
<dminuoso>
tau: Which is why it's so damn popular
<tau>
dminuoso i see.
<ineb>
tau: you can check by yourself. Install pry as alternative to irb, and create a socket object
<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.
<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
<tau>
dminuoso so, monkey patching in ruby is okay when one knows what he is doing, right?
<dminuoso>
tau: As with all the tools, yes.
Verity has quit [Ping timeout: 246 seconds]
<dminuoso>
tau: The issue with monkey patching is just that if you do it it will have unknown effects.
<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?
<tau>
dminuoso yea. i see.
lightheaded has quit [Ping timeout: 258 seconds]
<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?
<tau>
dminuoso yes.
<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
<dminuoso>
tau: So yeah.. dont modify foreign classes unless you know what you are doing.
<tau>
i mean, how to know which modules a given class includes?
<tau>
dminuoso i see.
<dminuoso>
tau: There is no immediate way to do it.
<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?
<tau>
there is no place where it says 'Socket includes IO module'.
<dminuoso>
tau: It does indirectly.
<tau>
dminuoso how so?
<dminuoso>
tau: it inherits from BasicSocket which in turn inherits from IO
<dminuoso>
Scroll to the top, to the left there is a card that says "Parent"
<tau>
oh
<tau>
i see.
<tau>
i see it now.
<tau>
but BasicSocket says 'Parent' , it gives the feeling that Socket inherits from BasicSocket.
<tau>
i mean
<tau>
i wonder that Socket class is defined as : class Socket\ninclude IO ... end
<tau>
isnt it?
<dminuoso>
tau: It gives that feeling because it actually does inherit.
<dminuoso>
tau: No.
<ineb>
and BasicSocket inherits from IO
<tau>
dminuoso lemme show you a snippet of code.
<dminuoso>
tau: IO is a class, you cannot include classes.
<tau>
yes.
mooser has joined #ruby
<tau>
i thought IO was a module(according to ineb)
<tau>
hold on
<tau>
lemme give a snippet
<tau>
it will clarify better what i mean.
<dminuoso>
tau: The thing is: there is not much of a difference between classes and modules.
<dminuoso>
They are almost 100% identical.
zapata has joined #ruby
<dminuoso>
Ruby just imposes a few arbitrary rules on them. Like you cant inherit from a module, or include/prepend/extend a class.
hutch34 has quit [Ping timeout: 240 seconds]
Pumukel has joined #ruby
<ineb>
tau: i wrote IO module but i should have written IO class. sorry.
<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.
<dminuoso>
tau: It would be the same, except for these arbitrary class/module rules I mentioned
<tau>
i think it may clarify better.
<tau>
ineb no worries.
<ineb>
dminuoso: dont forget super here.
<dminuoso>
tau: Right. including and inheriteting are not really any different.
<dminuoso>
ineb: Nope.
<dminuoso>
ineb: super does not apply, it acts exactly the same.
<tau>
dminuoso hmm, lemme give you another snippet.
<tau>
hold on
thadtheman has quit [Ping timeout: 260 seconds]
nofxx has quit [Ping timeout: 260 seconds]
<tau>
oh
<tau>
dminuoso i see. i thought that
<tau>
hold on
mooser has quit [Ping timeout: 240 seconds]
<tau>
so
<tau>
i think i understood.
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
<tau>
i was thinking that i always had to use 'self.method' to access instance methods.
<tau>
from a given class instance.
<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.
<tau>
dminuso are the two forms equivalent, isnt it?
<tau>
i got confused because i was reading a ruby tutorial and everyone was using self.method for class instances.
banisterfiend has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<tau>
i may help you, wkoszek.
<tau>
just have to check for time.
<tau>
i'll drop you a channel where i usually hang, so you can find me there.
<tau>
its #vy
thadtheman has joined #ruby
<tau>
dminuoso thank you for the insight.
<tau>
it helped a lot.
<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, ..):
_sfiguser has quit [Remote host closed the connection]
last_staff has joined #ruby
lightheaded has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
siovene has joined #ruby
P1ro has quit [Remote host closed the connection]
cfec0b8d has joined #ruby
bastelfreak has quit [Ping timeout: 264 seconds]
roshanavand has joined #ruby
bronson has joined #ruby
thadtheman has quit [Ping timeout: 268 seconds]
bronson has quit [Ping timeout: 268 seconds]
Xiti has quit [Quit: Xiti]
andikr has joined #ruby
P1ro has joined #ruby
Sauvin is now known as bocaneri
roamingdog has joined #ruby
harfangk has joined #ruby
<dminuoso>
tau: It's rather Python that's a bit bizarre in that respect actually.
vali has joined #ruby
conta has joined #ruby
<dminuoso>
tau: self in Ruby is a little different
biberu has joined #ruby
<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.
<tau>
how do you 'think' about self in ruby?
roamingdog has quit [Ping timeout: 264 seconds]
<dminuoso>
tau: It's a little closer to "this" from JavaScript if you are familiar with that.
wnd has quit [Excess Flood]
<dminuoso>
But only so much.
<tau>
i see.
vondruch has quit [Ping timeout: 246 seconds]
davorb has quit [Read error: Connection reset by peer]
<tau>
dminuoso i'm just curious why in some ruby docs(they dont mention you dont need self to call a class instance method).
akkad has quit [Excess Flood]
wnd has joined #ruby
davorb has joined #ruby
<ineb>
tau: you can learn all the details about your questions if you learn rubys object model.
<ineb>
there a quite some resources about it on the web
thatsnotjack has quit [Ping timeout: 256 seconds]
<dminuoso>
tau: "self" is the default receiver for a method if no other is specified.
<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()
<matthewd>
Yeah, it's not necessary (except a few corner cases) -- more like C++, Java, etc
<dminuoso>
tau: Now this self business has a lot of implications. It also helps understand how class methods work.
<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.
<tau>
dminuoso true.
<dminuoso>
tau: For example ever noticed how class methods are defined on something that has to do with "self" ?
<dminuoso>
Such as def self.foo; end
<tau>
yes.
<dminuoso>
If you remember, I told you that inside a class definition self becomes the object itself. :-)
<dminuoso>
And def foo.bar; end just creates a singleton method on foo, *whatever* foo is.
<tau>
those def method.name are a bit tricky to understand.
<tau>
i'll write a snippet now.
<dminuoso>
tau: they just create a singleton method on an object.
<dminuoso>
tau: A method that only belongs to that object and nothing else.
<tau>
dminuoso hold on
fmartingr has joined #ruby
jgnagy has quit [Remote host closed the connection]
<matthewd>
tau: The only thing you should have as `foo` in a `def foo.bar` definition is `self`
<dminuoso>
tau: "alpha" has to be an object of some kind.
<dminuoso>
tau: Which it is not.
<matthewd>
You *can* do other things, but it's not something you generally *should* do
<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.
hutch34 has joined #ruby
jgnagy has quit [Ping timeout: 240 seconds]
<dminuoso>
And you just define that method onto self (whatever that may be)
<tau>
dminuoso i wonder what def alpha.foo means inside that class. i mean the usability of it.
<dminuoso>
tau: The usefulness depends on the circumstance. Generally you will only define singleton methods on class objects.
<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, ..)
<dminuoso>
Yeah probably
stan has quit [Read error: Connection reset by peer]
lightheaded has quit [Remote host closed the connection]
lightheaded has joined #ruby
<tau>
hold on
<tau>
i'll add some commentaries to that snippet which maps to some of my doubts.
<matthewd>
tau: If the LHS needs arguments, then you need to give them (and the expression then needs to be in parens)
<tau>
i see.
<matthewd>
But again: don't ever do this
<tau>
matthewd excellent.
<tau>
ruby has an amazing syntax.
<tau>
it may be confusing sometimes.
<tau>
due to its power i think.
jenrzzz has quit [Ping timeout: 260 seconds]
ineb has left #ruby [#ruby]
ta_ has joined #ruby
<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.
jenrzzz has joined #ruby
<tau>
methewd yeah.
vondruch has joined #ruby
aganov has joined #ruby
<tau>
mathewd how long have you been using ruby?
lightheaded has quit [Remote host closed the connection]
lightheaded has joined #ruby
<tau>
thank you guys for the insight.
<tau>
i'm off now.
<matthewd>
I'm not sure.. maybe 12 years?
<matthewd>
No worries!
jpterry has quit [Ping timeout: 268 seconds]
lightheaded has quit [Ping timeout: 240 seconds]
lightheaded has joined #ruby
Autolycus has quit []
ace05 has quit [Read error: Connection reset by peer]
jpterry has joined #ruby
Rodya_ has joined #ruby
roamingdog has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
Rodya_ has quit [Ping timeout: 246 seconds]
flying has joined #ruby
nOwz has quit [Ping timeout: 268 seconds]
roamingdog has quit [Ping timeout: 240 seconds]
ujjain has quit [Read error: Connection reset by peer]
<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
<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.
<fmartingr>
Thank you for the links anyway, I will take a look at them later :)
enterprisey has quit [Remote host closed the connection]
<morfin>
env CC=clang38 CXX=clang++38 rbenv helped me
nobitanobi has quit [Remote host closed the connection]
nobitanobi has joined #ruby
jameser has quit [Ping timeout: 260 seconds]
johnny56_ has joined #ruby
johnny56 has quit [Ping timeout: 264 seconds]
maattdd has quit [Ping timeout: 260 seconds]
jonatin has quit [Remote host closed the connection]
zeddan has quit [Ping timeout: 240 seconds]
nobitanobi has quit [Ping timeout: 260 seconds]
jgnagy has joined #ruby
jonatin has joined #ruby
jgnagy has quit [Ping timeout: 240 seconds]
<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'?
<elomatreb>
Ruby Hashes normally return their keys in the order they were inserted, it shouldn't sort anything by itself
<canton7>
very old ruby versions (1.8-era?) don't keep hashes sorted by insertion order, iirc
<morfin>
heh that's weird
jaruga has quit [Read error: Connection reset by peer]
<Silthias>
hmm ok, this is going into an erb tempalte and puppet perhaps thats messing it up slightly
<morfin>
because i expect to have unordered hashmap
jaruga has joined #ruby
<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
leito has quit [Ping timeout: 240 seconds]
rajat has quit [Ping timeout: 260 seconds]
thadtheman has quit [Ping timeout: 240 seconds]
nOwz has joined #ruby
jameser has joined #ruby
certainty has joined #ruby
pandaant has quit [Remote host closed the connection]
JeanCarloMachado has joined #ruby
nowhere_man has joined #ruby
leito has joined #ruby
mark_66 has quit [Read error: Connection reset by peer]
User458764 has joined #ruby
User458764 has quit [Max SendQ exceeded]
mark_66 has joined #ruby
User458764 has joined #ruby
psychicist__ has quit [Ping timeout: 256 seconds]
thadtheman has joined #ruby
thadtheman has quit [Max SendQ exceeded]
tvw has joined #ruby
hutch34 has joined #ruby
rajat has joined #ruby
Verity has joined #ruby
<Verity>
key.bytes.each do |kb| msg_arr.map! {|mb| mb = mb^kb} end ---------------------- is there a better way to write this
Xeago has quit [Ping timeout: 256 seconds]
DaveTaboola has quit [Ping timeout: 240 seconds]
hutch34 has quit [Ping timeout: 260 seconds]
Rodya_ has joined #ruby
ldnunes has joined #ruby
Xeago has joined #ruby
Rodya_ has quit [Ping timeout: 268 seconds]
nobitanobi has joined #ruby
rhyselsmore has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
cfec0b8d has quit [Remote host closed the connection]
cfec0b8d has joined #ruby
thadtheman has joined #ruby
<herwin>
Verity: i believe ^ has the associative property, meaning (mb^k1)^k2 == mb^(k1^k2)
<herwin>
in that case, you could pre-calculate the ^ of key
<herwin>
and that removes the need for the outer loop
thadtheman has quit [Ping timeout: 268 seconds]
herbmillerjr has quit [Ping timeout: 240 seconds]
herbmillerjr has joined #ruby
ta_ has quit [Remote host closed the connection]
vali has quit [Remote host closed the connection]
vali has joined #ruby
doublemalt_ has joined #ruby
synthroid has joined #ruby
ahrs has quit [Read error: Connection reset by peer]
hutch34 has joined #ruby
rajat has quit [Quit: Leaving]
ahrs has joined #ruby
dionysus70 has joined #ruby
dionysus69 has quit [Ping timeout: 268 seconds]
esObe__ has quit [Remote host closed the connection]
millerti has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Pumukel has quit [Remote host closed the connection]
dionysus70 has quit [Ping timeout: 240 seconds]
ddffg has quit [Ping timeout: 260 seconds]
GodFather has quit [Ping timeout: 260 seconds]
leito has quit [Ping timeout: 264 seconds]
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
eclecticjohny has joined #ruby
ddffg has joined #ruby
eclecticjohny has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
binaryplease has quit [Ping timeout: 240 seconds]
valentin has joined #ruby
valentin has quit [Remote host closed the connection]
jusa has joined #ruby
valentin has joined #ruby
hutch34 has quit [Ping timeout: 268 seconds]
vali has quit [Ping timeout: 256 seconds]
bronson has joined #ruby
psychicist__ has joined #ruby
aupadhye has joined #ruby
nadir has quit [Quit: Connection closed for inactivity]
valentinul has joined #ruby
jusa has quit [Ping timeout: 260 seconds]
leito has joined #ruby
valentin has quit [Ping timeout: 258 seconds]
User458764 has joined #ruby
vali has joined #ruby
bronson has quit [Ping timeout: 268 seconds]
User458764 has quit [Client Quit]
Rodya_ has joined #ruby
User458764 has joined #ruby
psychicist__ has quit [Ping timeout: 240 seconds]
zeddan has joined #ruby
Verity has quit [Ping timeout: 246 seconds]
cam27 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
nOwz has quit [Ping timeout: 264 seconds]
duckpupp1 has joined #ruby
Rodya_ has quit [Ping timeout: 246 seconds]
iamayam has quit [Ping timeout: 276 seconds]
zeddan has quit [Ping timeout: 246 seconds]
nOwz has joined #ruby
nOwz has quit [Client Quit]
t-recx has joined #ruby
davorb has quit [Read error: Connection reset by peer]
cdg has joined #ruby
davorb has joined #ruby
ramortegui has joined #ruby
cdg has quit [Read error: Connection reset by peer]
pankaj has joined #ruby
last_staff has quit [Quit: last_staff]
cdg has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eclecticjohny has joined #ruby
vali has quit [Quit: vali]
chouhoulis has quit [Remote host closed the connection]
TomyWork has joined #ruby
jgnagy has joined #ruby
__Yiota has joined #ruby
jdm has quit [Remote host closed the connection]
Pumukel has joined #ruby
jgnagy has quit [Ping timeout: 246 seconds]
bmurt has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
blackmesa has quit [Ping timeout: 240 seconds]
iamayam has joined #ruby
tvw has quit [Read error: Connection reset by peer]
shinnya has joined #ruby
oliv_____ has joined #ruby
Pumukel has quit [Remote host closed the connection]
millerti has joined #ruby
valentinul has quit [Remote host closed the connection]
valentinul has joined #ruby
hutch34 has joined #ruby
patarr has joined #ruby
Guest61791 is now known as silverdust
roshanavand has quit [Ping timeout: 246 seconds]
silverdust has quit [Changing host]
silverdust has joined #ruby
armyriad has quit [Ping timeout: 268 seconds]
armyriad has joined #ruby
lmc has joined #ruby
govg has quit [Ping timeout: 268 seconds]
erlend has quit [Remote host closed the connection]
jaruga has quit [Quit: jaruga]
jameser has joined #ruby
Pumukel has joined #ruby
nobitanobi has quit [Read error: Connection reset by peer]
milardovich has joined #ruby
armyriad has quit [Ping timeout: 264 seconds]
nobitanobi has joined #ruby
armyriad has joined #ruby
bkxd has quit [Ping timeout: 260 seconds]
certainty has quit [Ping timeout: 240 seconds]
Rodya_ has joined #ruby
Rodya_ has quit [Ping timeout: 240 seconds]
t-recx has quit [Quit: t-recx]
joast has quit [Quit: Leaving.]
terens has quit [Remote host closed the connection]
gnufied has joined #ruby
centrx has joined #ruby
Snickers has quit [Ping timeout: 256 seconds]
davidt has joined #ruby
davidt has quit [Client Quit]
blackmesa has joined #ruby
gdonald has quit [Read error: Connection reset by peer]
cdg_ has joined #ruby
gdonald has joined #ruby
cdg has quit [Read error: Connection reset by peer]
ddffg has quit [Quit: Leaving]
phoo1234567 has joined #ruby
joast has joined #ruby
blackmesa has quit [Ping timeout: 240 seconds]
psychicist__ has joined #ruby
ivanacostarubio has joined #ruby
jdm has joined #ruby
ddffg has joined #ruby
binaryplease has joined #ruby
igniting has quit [Ping timeout: 240 seconds]
Pumukel has quit [Remote host closed the connection]
sepp2k has joined #ruby
ozcanesen has joined #ruby
unshadow has quit [Quit: leaving]
lubekpl has joined #ruby
zeddan has joined #ruby
User458764 has joined #ruby
Silthias has quit [Ping timeout: 268 seconds]
byte512 has quit [Quit: Bye.]
ferr1 has quit [Quit: WeeChat 1.7]
zeddan has quit [Ping timeout: 260 seconds]
chuff has joined #ruby
blackpajamas has joined #ruby
blackmesa has joined #ruby
Pumukel has joined #ruby
eclecticjohny has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
maloik has quit [Remote host closed the connection]
maloik has joined #ruby
yehowyada has joined #ruby
spicerack has quit [Remote host closed the connection]
bronson has joined #ruby
pankaj has quit [Remote host closed the connection]
Cohedrin has joined #ruby
Silthias has joined #ruby
lightheaded has quit [Remote host closed the connection]
lightheaded has joined #ruby
bronson has quit [Read error: Connection reset by peer]
chouhoulis has joined #ruby
bronson has joined #ruby
Rodya_ has joined #ruby
milardovich has quit [Remote host closed the connection]
tristanp has quit []
jameser has quit [Read error: Connection reset by peer]
lightheaded has quit [Ping timeout: 240 seconds]
jameser has joined #ruby
milardovich has joined #ruby
milardovich has quit [Remote host closed the connection]
polishdub has joined #ruby
milardovich has joined #ruby
tristanp has joined #ruby
Rodya_ has quit [Ping timeout: 246 seconds]
cpruitt has joined #ruby
spicerack has joined #ruby
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<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.
<LyndsySimon>
Is there any way to make the syntax above work?
<elomatreb>
You can achieve that behavior, but it would require doing some metaprogramming-y stuff. Not as simple as a syntax
<LyndsySimon>
I'm fine with that.
mbertul has joined #ruby
__Yiota has quit [Client Quit]
pandaant has joined #ruby
jameser has joined #ruby
antoniobeyah has joined #ruby
<LyndsySimon>
Well, I'm fine with doing magical stuff in `Base`, if I can make it clean in `Parent` and `Child`.
<elomatreb>
I *think* that should be possible
jgnagy has quit [Ping timeout: 260 seconds]
blackmesa has quit [Ping timeout: 260 seconds]
<elomatreb>
You know how you get methods to work on the class instead of on instances I assume?
synthroid has quit [Remote host closed the connection]
<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.
patarr has quit [Ping timeout: 264 seconds]
tercenya has quit [Client Quit]
* baweaver
points at Module mixins
tercenya has joined #ruby
<elomatreb>
Ruby classes are instances of the class `Class` too, we're taking advantage of that in the example with the instance variables
<LyndsySimon>
baweaver: I'm very familiar with Module mixins :)
flying has quit []
brent__ has joined #ruby
brent__ has quit [Remote host closed the connection]
brent__ has joined #ruby
<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`.
<LyndsySimon>
That gets really fun when you're dealing with an inheritance hierarchy, and your metaclasses are descendants of the resultant classes' ancestors' metaclasses.
<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
__Yiota has joined #ruby
ResidentBiscuit has joined #ruby
tanukisofubi has joined #ruby
<LyndsySimon>
It's cool. To be honest, I have a hard time talking about complex topics in two different languages at once anyhow.
tanukisofubi has quit [Client Quit]
Qchmqs has quit [Ping timeout: 240 seconds]
sofubi has joined #ruby
ta_ has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
montanonic has joined #ruby
aganov has quit [Remote host closed the connection]
Cohedrin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Arpanet69 has quit [Quit: Leaving]
mbertul has quit [Remote host closed the connection]
Cohedrin has joined #ruby
Cohedrin has quit [Client Quit]
[Butch] has joined #ruby
certainty has joined #ruby
yasu_ has joined #ruby
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
amclain has joined #ruby
Uranio has joined #ruby
cam27 has joined #ruby
doublemalt_ has quit [Ping timeout: 260 seconds]
User458764 has joined #ruby
certainty has quit [Ping timeout: 240 seconds]
synthroid has joined #ruby
Uranio has quit [Client Quit]
synthroi_ has joined #ruby
vimto has quit [Ping timeout: 260 seconds]
grrrkit has joined #ruby
nobitanobi has quit [Remote host closed the connection]
<LyndsySimon>
I was concerned that modifications made to the parent classes at runtime wouldn't be reflected.
Snickers has joined #ruby
marxarelli has joined #ruby
<LyndsySimon>
Nevermind, I see the bug.
spicerack has joined #ruby
JeanCarloMachado has quit [Ping timeout: 256 seconds]
jsrn_ has quit [Quit: Leaving]
<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
<LyndsySimon>
Yeah there is - `(@members || [])` could have returned an empty array.
<LyndsySimon>
I guess I could have done `(@members ||= [])`...
synthroid has joined #ruby
<elomatreb>
^ that's how it's usually done, to the point where I didn't notice it wasn't ||=
* LyndsySimon
nods
<LyndsySimon>
OK.
hxegon has joined #ruby
roamingdog has joined #ruby
<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
rmosolgo has joined #ruby
<LyndsySimon>
Right. I'm adapting back and forth between my actual use case and the exemplar.
<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.
montanonic has quit [Ping timeout: 260 seconds]
synthroi_ has quit [Ping timeout: 268 seconds]
jottr has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
roamingdog has quit [Ping timeout: 240 seconds]
nowhere_man has quit [Ping timeout: 240 seconds]
sofubi has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
<havenwood>
tilaioe: embed Julia in Ruby, problem solved?
Guest96 has joined #ruby
<tilaioe>
No, I hate julia.
__Yiota has joined #ruby
<tilaioe>
I don't even know Julia at all.
<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.
[Butch]_ has joined #ruby
Lord_of_Life has joined #ruby
Renich has quit [Ping timeout: 256 seconds]
ramortegui has quit [Quit: Ex-Chat]
[Butch] has quit [Ping timeout: 240 seconds]
[Butch]_ is now known as [Butch]
Renich__ is now known as Renich
<baweaver>
"I hate X" "I don't even know X at all" - that's not a very wise way to approach things.
Renich has quit [Quit: Renich]
ramortegui has joined #ruby
byte512 has joined #ruby
renchan has quit [Quit: Leaving...]
Synthead has quit [Read error: Connection reset by peer]
mooser has quit [Remote host closed the connection]
mooser has joined #ruby
mensvaga has joined #ruby
<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?
SeepingN has joined #ruby
<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' })
<mensvaga>
I mean, I haven'
<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.
hahuang61 has joined #ruby
nofxx has joined #ruby
thatkid has quit [Quit: Page closed]
TomyWork has quit [Ping timeout: 240 seconds]
binaryplease has quit [Quit: binaryplease]
binaryplease has joined #ruby
jonjoe has joined #ruby
certainty has joined #ruby
nadir has joined #ruby
jonjoe has quit [Client Quit]
Jayson_Virissimo has joined #ruby
certainty has quit [Ping timeout: 258 seconds]
snguyen has joined #ruby
Rodya_ has quit [Remote host closed the connection]
marsjaninzmarsa has joined #ruby
renchan has joined #ruby
sofubi has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
nobitanobi has joined #ruby
Cohedrin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ahrs has quit [Remote host closed the connection]
<mensvaga>
Is there a way to automatically define nested structures in a hash as hashes?
<baweaver>
Hash takes a block to new that defines the default value of an unknown key
<mensvaga>
I see.
<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
<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?
<ebernhardson>
i couldn't find anything relevant in the `gem build` docs
cdg_ has quit [Ping timeout: 258 seconds]
centrx has joined #ruby
centrx has quit [Changing host]
centrx has joined #ruby
<wizard2011>
@adam12 whats that github link for?
<adam12>
wizard2011: It answers your question about what Geminabox is.
sofubi has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
ebernhardson has left #ruby [#ruby]
aupadhye has quit [Ping timeout: 240 seconds]
psychicist__ has quit [Ping timeout: 258 seconds]
zeddan has joined #ruby
pandaant has joined #ruby
tvw has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<wizard2011>
@adam12 so this geminabox is a server , whats being hosted from it?
leito has quit [Read error: No route to host]
bmurt has joined #ruby
rippa has joined #ruby
zeddan has quit [Ping timeout: 260 seconds]
<wizard2011>
whos in here with me that can help me with coding
morfin has quit []
BSaboia has joined #ruby
gusrub has quit [Remote host closed the connection]
lmc has quit [Read error: Connection reset by peer]
s2013 has joined #ruby
lmc has joined #ruby
tomphp has joined #ruby
<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.
dionysus69 has quit [Ping timeout: 260 seconds]
aupadhye has joined #ruby
thadtheman has joined #ruby
Arpanet69 has joined #ruby
Pumukel has joined #ruby
jusa has quit [Ping timeout: 240 seconds]
leito has joined #ruby
<havenwood>
wizard2011: What's your Ruby question? Ask away!
j0n3 has joined #ruby
davorb has quit [Read error: Connection reset by peer]
<wizard2011>
@Jayson_Virissimo thanks thats very true I didnt really think about it like that
aupadhye has quit [Ping timeout: 260 seconds]
gchristensen has joined #ruby
davorb has joined #ruby
blackmesa has joined #ruby
Jackneill has joined #ruby
Pumukel has quit [Ping timeout: 260 seconds]
cagomez has joined #ruby
<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.
skord has joined #ruby
cam27 has joined #ruby
tenderlove has quit [Read error: Connection reset by peer]
tenderlove has joined #ruby
fmartingr has quit [Quit: Connection closed for inactivity]
oliv_____ has quit [Remote host closed the connection]
mooser has quit [Remote host closed the connection]
ozcanesen has joined #ruby
blackmesa has quit [Ping timeout: 246 seconds]
olivi____ has joined #ruby
raspado has quit [Quit: Leaving...]
valentinul has quit [Ping timeout: 258 seconds]
<hanmac>
gchristensen: i found this methods in Object which seems to control that:
<ruby[bot]>
hanmac: # => [:pretty_print, :pretty_print_cycle, :pretty_print_instance_variables, :pretty_print_inspect, :prett ...check link for more (https://eval.in/762122)
aupadhye has joined #ruby
HoierM has joined #ruby
mooser has joined #ruby
JeanCarloMachado has joined #ruby
Lord_of_Life has quit [Excess Flood]
<gchristensen>
hanmac: hrmm bizarre. I don't have any of those :/ I'll dig around for related looking things.
Lord_of_Life has joined #ruby
username1 has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
wizard2011 has quit [Quit: Leaving]
<hanmac>
gchristensen: did you require pp yet? this functions only appear after requiring pp
Arpanet69 has quit [Ping timeout: 260 seconds]
Xiti has quit [Quit: Xiti]
dionysus69 has joined #ruby
Heero has quit [Ping timeout: 255 seconds]
cagomez has quit []
Heero_ has joined #ruby
RushPL has quit [Ping timeout: 255 seconds]
leito has quit [Ping timeout: 258 seconds]
cagomez has joined #ruby
RushPL has joined #ruby
<gchristensen>
ah, sorry, so I do have them but they're not formatted how I'd expect
heftig has quit [Ping timeout: 255 seconds]
<gchristensen>
they're returning regular strings whereas the formatting from pry is colored in elaborate ways
jwheare has quit [Ping timeout: 254 seconds]
heftig has joined #ruby
<baweaver>
adaedra: derp. Monday hits hard.
Miah_ has quit [Ping timeout: 255 seconds]
Miah_ has joined #ruby
jwheare has joined #ruby
renchan has quit [Remote host closed the connection]
<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
<postmodern>
Verity, you'll need to convert the polynomial equation into an iterative or inductive one
mooser has quit []
<allisio>
That can just be #with_index these days, for reference.
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
Rodya_ has quit [Remote host closed the connection]
<Verity>
thats I needed
<postmodern>
oh much easier to read +1
milardovich has quit [Remote host closed the connection]
<Verity>
oh
<Verity>
a char has an index
workmad3 has quit [Ping timeout: 246 seconds]
hahuang61 has quit [Quit: WeeChat 1.7]
certainty has quit [Ping timeout: 258 seconds]
<Verity>
nvm
patarr_ has quit [Ping timeout: 260 seconds]
<postmodern>
Verity, also remember chars don't always equal bytes, aka UTF-8 and UTF-16 you can have multi-byte chars
maattdd has joined #ruby
<Verity>
for me they will be bytes, luckily
<Verity>
I think>?
<Verity>
for this protocol we will be using ascii only
thadtheman has quit [Ping timeout: 240 seconds]
cagomez has quit [Remote host closed the connection]
gusrub has quit [Remote host closed the connection]
<Verity>
I don't understand enumerators and map
<Verity>
=\
<Verity>
I'm using htem, but not fully understanding
<Verity>
I'm using irb for guess + check sometimes
<Verity>
not good.
<Verity>
when I get the result I needed, I've found my code
<Verity>
or perhaps thats how its intended
Lord_of_Life has quit [Excess Flood]
nobitanobi has joined #ruby
hahuang65 has quit [Quit: WeeChat 1.7]
cagomez has quit [Remote host closed the connection]
lxsameer has joined #ruby
cagomez has joined #ruby
blackmesa has quit [Ping timeout: 240 seconds]
<postmodern>
Verity, also i'd ignore the polynomial part of that video. focus on implementing the algorithm using xor (^) and shift (<< >>) operators
hahuang65 has joined #ruby
<Verity>
well I have a generator polynomial from my professor
<Verity>
in the form of 0x156 (hex)
<Verity>
and the 1 is "the carry"
<Verity>
but I'm afraid I don't understand
milardovich has joined #ruby
<Verity>
he said I could just copy paste his C++ code if I can call it in ruby
nobitanobi has quit [Remote host closed the connection]
<Verity>
but I'd rather understand this algorithm and how to implement it in ruby
nobitanobi has joined #ruby
Lord_of_Life has joined #ruby
Lord_of_Life has quit [Excess Flood]
patarr has joined #ruby
<matthewd>
It may be more pedagogically expedient to implement as a stand-alone class, without digest-crc as a base
<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
GodFather has joined #ruby
cdg has joined #ruby
nobitanobi has quit [Remote host closed the connection]
<Verity>
alright
milardovich has quit [Remote host closed the connection]
cagomez has quit [Remote host closed the connection]
<Verity>
then it may not be possible to easily change the generator polynomial in the derived digest-crc8 class
<Verity>
?
cagomez has joined #ruby
username1 has joined #ruby
[Butch] has quit [Quit: I'm out . . .]
<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
g0d355__ has quit [Remote host closed the connection]
<ruby[bot]>
Verity: # => ["0110100001100101011011000110110001101111", "0110100001100101011011000110110001101111", "0110100001 ...check link for more (https://eval.in/762178)
<Verity>
why it it putting all into each one
Suslov has quit [Remote host closed the connection]
Suslov has joined #ruby
ldnunes has quit [Quit: Leaving]
<havenwood>
Verity: bit_array.class #=> String
<havenwood>
Verity: String#<<
esObe_ has quit [Ping timeout: 240 seconds]
<havenwood>
Verity: Note the different output if: bit_array = []
<allisio>
Verity: `b.to_s(2).rjust(8, "0")` should just be `'%08b' % b`.
<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
<Jayson_Virissimo>
Why is it called bit_array, when it is a string?
<Verity>
turning it into an array comes next
<Verity>
or maybe not
<Verity>
I need to access all of the bits of a msg to run a crc calculation on it
<Verity>
I really don't know the best way
<Verity>
this doesnt seem like a common ruby task so examples are sparse
millerti has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
hahuang65 has quit [Read error: Connection reset by peer]
polishdub has quit [Quit: Leaving]
<matthewd>
Those all end up with 1 and 0 characters, which isn't what your function's going to need
<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
Arpanet69 has quit [Ping timeout: 268 seconds]
<Verity>
in C I would need to use a mask to get at the bits
<matthewd>
You have a C++ implementation, right? Just translate that directly.
<Verity>
yeah he showed me the exact code today
<Verity>
and said I could use it, even
<Verity>
but its probably better to reimplement than to create a C lib and call it
ramortegui has quit [Quit: Ex-Chat]
hahuang65 has joined #ruby
<Verity>
I also doubted if I could do it
<Verity>
as ruby would be so different than how its done in C, I would think
<allisio>
In Ruby, you can index into an Integer to get its bits.
<Verity>
my first step is probably to convert the entire message into an actual array of bits
<Verity>
especially if you know what the problem is
<Verity>
its not helpful the last several things you've said to me
centrx has quit []
<Verity>
they serve only to feed your own sadistic pleasures
<allisio>
Calm down.
<allisio>
And use your local REPL.
<Verity>
I am
<Verity>
I could send the log of it
<Verity>
its not pretty
<allisio>
Your signal-to-noise ratio is through the floor, man.
<Verity>
it's not
<Verity>
I stand by my statement
<Verity>
the trolling continues
dar123 has joined #ruby
<Verity>
use my local REPL? As if I haven't tried 100s of variations
<Verity>
nothing is resulting in the array I require
<allisio>
Who are you blaming?
nobitanobi has joined #ruby
hahuang65 has quit [Quit: WeeChat 1.7]
hahuang65 has joined #ruby
<Verity>
I'm blaming you for your trolling. For my difficulties figuring this out I blame God, the system, and myself
<allisio>
In that order?
<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
<Verity>
and yes, that order
cam27 has joined #ruby
Arvik_ has joined #ruby
<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.
<Verity>
you mean unpack each character as a different type?
<allisio>
#unpack can do all sorts of things, but sure, that's one potential use case.
<ivanacostarubio>
topic softwarecriollo ⚡️💻
bkxd has quit [Ping timeout: 240 seconds]
willardg has joined #ruby
ivanacostarubio has left #ruby [#ruby]
<havenwood>
Verity: A good place to start is showing example input values and the corresponding desired output values.
<allisio>
matthewd: What's wrong with `unpack1('B*').chars.map &:to_i`?
<baweaver>
the 1
<allisio>
It's 2017.
* baweaver
ducks
<eam>
ruby needs vec()
CloCkWeRX has quit [Ping timeout: 256 seconds]
marxarelli is now known as marxarelli|afk
<Verity>
why is that any better than bit_array = "a".unpack('B*')[0].split("")
<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
<Verity>
I could reverse the order no problem now
<allisio>
matthewd: Yeah, fair enough.
<Verity>
I need an array of bits
<allisio>
Does your approach give you an array of bits?
<Verity>
let me take a look
<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?
<Verity>
havenwood, no
linoespinoza has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Verity>
I'll need to shift the bits into an 8 bit register next
<havenwood>
Verity: Then we can't help you unless random bits suffice.
<Verity>
and then to the left of that is a carry bit, when it goes 1 I xor the register with the polynomial
<Verity>
0x156
<baweaver>
?xy
<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
<havenwood>
Verity: Like `"hi" => ["0110", "0110"]` or `"bye" => ["0110", "0111", "0110"]`. A gist is ideal if it's complex enough to warrant multiple examples.
<allisio>
I'm trying to make sense of your preference for #each_char.
Bob8989|2 has joined #ruby
<Verity>
why is it b-48 and wha os 18>>
<allisio>
Don't take the bait.
<Verity>
also % and ?a ---? hard code to understand
<Verity>
how could I ever have put that together from the docs
<havenwood>
allisio: The intermediary Enumerator seems preferable to the intermediary Array.
<Verity>
I dont even understand it looking at it
<Verity>
I google "ruby %" and guess what comes up
Guest96 has quit [Remote host closed the connection]
<Verity>
a hopless approach
<Verity>
e
<nofxx>
Verity, isn't pack/unpack better for that kinda of bit stuff
<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.
<Verity>
nofxx, yeah I'm using unpack
<Verity>
it just doesnt unpack to an array of ints
olivi____ has quit [Remote host closed the connection]
<nofxx>
Verity, doesn't make a sense, 1 bit can be at most a boolean, it's up to you to group'em
olivi____ has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
Guest96 has joined #ruby
xnxq has joined #ruby
<nofxx>
Verity, eg the numbers you provide to unpack.... check the docs, don't remember...
dar123 has quit [Read error: Connection reset by peer]
<allisio>
havenwood: Yeah, makes sense.
charliesome has joined #ruby
esObe_ has joined #ruby
chrisgopher has quit [Remote host closed the connection]
lmc has quit [Remote host closed the connection]
blackmesa has joined #ruby
am55 has joined #ruby
cam27 has quit [Read error: Connection reset by peer]
Pumukel has quit [Read error: Connection reset by peer]
ddffg has quit [Quit: Leaving]
Pumukel has joined #ruby
cam27 has joined #ruby
jusa has joined #ruby
elifoster has quit [Ping timeout: 240 seconds]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<matthewd>
Can we please see the code this is going to be fed into? Please?
<Verity>
it doesnt exist yet, I need to write it
<Verity>
let me type up the c++ code and I'll send that
<Verity>
give me a bit
IRCFrEAK has joined #ruby
IRCFrEAK has quit [K-Lined]
<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
<Verity>
or my program will have crc errors when it communicates with the others
choke has quit [Client Quit]
<ytti_>
standard library has crc32
thadtheman has joined #ruby
<Verity>
ytti_, I need to use 8 bit w/ custom generator polynomial
<Verity>
believe me if I could do that I would. I'd rather learn ruby writing my state machine and processing bytes
<Verity>
not working with all of the bits and struggling like this
<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
<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.
certainty has quit [Ping timeout: 240 seconds]
rakm has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
tolerablyjake has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Verity>
well my professor said I will need to shift bits into a register