<havenwood>
nakilon: An academic went 8 bit. Nobody has dared 4 bit. You'll get a PhD if you can muster the courage.
<havenwood>
University Of Havenwood is accepting thesis papers.
<havenwood>
One bit for the exponent. >.>
<nakilon>
actually floats being too long was confusing people -- many thought (and maybe think it today) that having many bits and being float is kind of the same thing
neshpion has quit [Quit: WeeChat 2.9]
<nakilon>
havenwood we could use even less than one bit
<nakilon>
with Huffman coding
yokel has quit [Ping timeout: 260 seconds]
gix has quit [Ping timeout: 272 seconds]
Rudd0 has joined #ruby
ChmEarl has quit [Quit: Leaving]
donofrio has quit [Remote host closed the connection]
<nakilon>
accidental breaking the last published version of my gem caused multiple bug reports that made me happy to know there are people using it
<nakilon>
I wonder what average fraction of people push their code to public Github repos so the real number of users could be estimated by the number of related projects in Github sidebar
yokel has joined #ruby
jmcgnh has quit [Ping timeout: 260 seconds]
jmcgnh has joined #ruby
splud has joined #ruby
<splud>
I'm getting a bit of grief with some code that checks for an env variable, turns it into an array: $somevar = (ENV['VARNAME'] ? ENV['VARNAME'] : "").upcase.split(" ")
<splud>
going from memory there.
<splud>
idea is elsewehere in the code would like to check: if ( $somevar,includes?("FLAG") )
<splud>
or unless () etc.
<splud>
it is intended as a debug variable, triggering additional verbosity or early exit from a script.
<splud>
if the VARNAME isn't defined, I should have an empty string for split to act on, which should result in an empty array, not _nil_ right?
<splud>
thankls nakilon, though that's just simplifying the env-to-array assignment.
BSaboia has quit [Quit: This computer has gone to sleep]
xco has joined #ruby
sagax has quit [Remote host closed the connection]
<nakilon>
splud not sure I understand your problem then; you want to have a special env var with space-separated flag words; the idea looks ok
Nerium has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
Nerium has quit [Ping timeout: 256 seconds]
teclator has joined #ruby
ramfjord has quit [Ping timeout: 272 seconds]
<riceandbeans>
Did Chef die off?
yokel has quit [Ping timeout: 240 seconds]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sagax has joined #ruby
yokel has joined #ruby
lxsameer has quit [Ping timeout: 246 seconds]
xco has joined #ruby
<splud>
ah, sorted it out - elsewhere in code, there was something calling the msg() method that was making use of the debug_flags sooner than intended. Inherited code - someone has inline code buried among function def's.
<splud>
gaaa.
<splud>
Thank you for your help - I implemented the cleaner split.
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
klaas has joined #ruby
xco has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
supercoven has joined #ruby
rapha has joined #ruby
<rapha>
hi all
<rapha>
sooo, a = {name: "Peter"}; b = {name: "Mary"}; a.merge!(b), will end up with a == {name: "Mary"}. if instead I want something like a == {name: ["Peter", "Mary"]}, would that be done by handing a block to #merge! or some other way?
<jhass>
rapha: yes, using merge with a block is a possible solution
<rapha>
jhass: ... but not the route you would go, yourself?
<jhass>
probably it would be :)
<jhass>
I never had the need of something like that personally
BSaboia has quit [Quit: This computer has gone to sleep]
<rapha>
lucky you :-D
<jhass>
I mean in the overall scope of the problem there might even be a nice way to not have those intermediate hashes but built the target hash right away from the source data, dunno :)
<nakilon>
rapha, is Shane your name?
<jhass>
or maybe hashes is not how I would represent the data at all
<nakilon>
you might need wrap values in Array() since they are initially not arrays in your example
<rapha>
nakilon: no, I have nothing at all to do with the famous Quake III player if that's what you're getting at. I've had this nick when he was still pooping in his diapers.
<nakilon>
lol
<rapha>
jhass: these data (deeply nested Hashes and Arrays) have gone through many iterations of how to represent them. In the end, Hashes and Arrays was the least troublesome.
<rapha>
nakilon: Yes, that wrapping is what's giving me trouble. Because only when a second thing of something comes along does it need to become an Array. As long as it's only one thing, please no Array.
<nakilon>
you mean if the values are the same it should remain a scalar?
<jhass>
uh, I hate datastructures that do that
<nakilon>
that would need some `if`
<rapha>
wait, let me make an example
<rapha>
jhass: this is my first time with something like this. trying a lot to not develop any feelings of hate here :-/
yokel has joined #ruby
<jhass>
in my experience it just needlessly splatters the code with conditionals for checking whether it's an array or not further down
<tsujp36>
Example with heading: The `subject` is memoized within an example but not across examples
<tsujp36>
Appears to contradict example with heading: Use `subject(:name)` to define a memoized helper method
imode has quit [Ping timeout: 256 seconds]
<tsujp36>
Can anyone help? I cannot grok this
<jhass>
not sure, I don't think I see the contradiction :) Can you expand?
<tsujp36>
Okay so as a tiny preface to that in the same page: `his helper method is memoized.The value is cached across multiple calls in the same example but not across examples` is this referring just to the helper method name or to both the helper method name and the subject?
<tsujp36>
It reads like the former but I assume it's the latter?
<jhass>
subject behaves the same, no matter whether you call it as "subject" or with an explicit given name
funnel has quit [Ping timeout: 240 seconds]
* nakilon
just does not use this fancy subject thing at all
<tsujp36>
Okay so it's referring just to the helper name, so onto the within-an-example bit
<jhass>
in other words, subject { .. } is largely equivalent to let(:subject) { .. } and subject(:foo) { .. } is largely equivalent to let(:foo) { .. }
<tsujp36>
Their example of " The `subject` is memoized within an example but not across examples " reads to me as making a local variable (for example purposses as they say), and defining the subject as that variable with the last item, `3` popped off such that it is now [1, 2] (still typing)
<jhass>
"it" = "the local variable"
<jhass>
yes
<tsujp36>
So now within the example we have an expect and it trys to re-create the subject 3 times, `3.times { subject }` but as this is memoized that only really runs ones, so thats just avoiding performance loss. So the rest of that check of 1, 2, 3 to 1, 2 passes
<tsujp36>
But how does the next line of .eq(3) pass if the subject is [1, 2]?
<jhass>
subject is the return value of the block, so the return value of pop here
<jhass>
the first expectation is on element_list, not subject
<tsujp36>
OHHHHHHHHHHHHH
<tsujp36>
ugh im an idiot, element_list.pop evaluates to 3
<jhass>
:)
<tsujp36>
.'. subject equals 3
<tsujp36>
okay let me see if I dun goofed the second example
<jhass>
sure :)
<tsujp36>
okay the second one with `$count` doesn't change it because the inputs don't change, it's just `2.times { global_count }`
<tsujp36>
so `global_count` and `global_count` = no input change = only run it once = $count stays at 1
yokel has joined #ruby
<jhass>
nakilon: it's mostly handy when combined with the shorthand expectation stuff, subject { foo }; it { should be bar }; not sure that's still around with should being phased out though?
<nakilon>
yeah, should became obsolete years ago, but anyway, you are adding the knowledge about special commands of the Rspec DSL just to short some lines by 203 characters
<nakilon>
and if it "wasn't a big knowledge" then you won't even come to ask us how does it work
<nakilon>
*2-3 characters
<jhass>
tsujp36: sounds about right :)
<tsujp36>
perhaps I should've taken 5 and done this step through before coming to IRC hoho
<tsujp36>
dumb mistakes gonna happen I guess
<tsujp36>
Thank you jhass
<jhass>
nah, don't worry :)
<jhass>
yw
<tsujp36>
If you have a thing to buy you coffee with lmk, cos you helped me before too
<jhass>
nakilon: looks like they're keeping around should for that syntax, even when disabled otherwise
<jhass>
you can do is_expected.to alternatively but that becomes pretty moot indeed
cnsvc has quit [Ping timeout: 240 seconds]
<tsujp36>
what's wrong with is_expected.to ?
<tsujp36>
is there an alternative to both is_expected.to and shoulda?
<tsujp36>
should*
cnsvc has joined #ruby
<jhass>
if the goal of the mechanism is to make things shorther, is it { is_expected.to ... } really that much shorther than it { expect(subject).to ... }? ;)
<jhass>
maybe read the next page first to better understand what we're talking about :D
<tsujp36>
Ack
yokel has quit [Ping timeout: 240 seconds]
yokel has joined #ruby
cliluw has quit [Ping timeout: 265 seconds]
coniptor has quit [Ping timeout: 240 seconds]
<tsujp36>
given that subject is calling let under the hood is subject now also lazily-evaluated the same as let?
yokel has quit [Ping timeout: 256 seconds]
<tsujp36>
That is, my understanding of let is the following:
<tsujp36>
(1) `let` does not set the implicit `subject`. (2) `let` does not allow expectations on the implicit `subject`. (3) `let` sets instance variables on an `example_group` for use between each `example`.
<tsujp36>
Are these correct or is there a flaw in my understanding there?
<tsujp36>
prefix that list with "let is the same as subject except for 1, 2, 3 ..."
yokel has joined #ruby
ur5us has joined #ruby
<Tuor>
hi, I would like to copy a directory and all it's content as it is (ownership, permissions, links, if possible extended attributes and ACL) to a new path. I googled and found the rsync gem, but I can't find a way of copying directories, I can only copy files with it. Maybe I have to list all directories and files and create the new directories and then rsync every file. But I'm wondering, isn't there a simpler way? I could call the rsync binary and let it
<Tuor>
do the job. What should I do?
robinimus has quit [Quit: Leaving.]
<jhass>
tsujp36:I don't actually know. My comparision to let was functional and not based implementation details. With an as involved DSL as RSpec I would also abstain to model its behavior in terms of its implementation details. My persional expectation would be that subject is lazilily evaluated such as let (that's why subject! is a thing)
coniptor has joined #ruby
<jhass>
but I don't think you're wrong anywhere
robinimus has joined #ruby
<jhass>
Tuor: honestly, shelling out to rsync doesn't sound too bad here
<Tuor>
jhass: it's doing something. :) I'll have to wait for the result
<jhass>
cool
<jhass>
rapha: fyi hope your real code doesn't use var names like that :D also a underscore prefix is generally convention for "I don't care about this var"
<Guest51811>
Hello, hope all are well... I'm a newbie migrating to ruby- I'm trying to figure out basic things like db migrations, configs etc. I'm using sinatra currently trying to set up migrations and db connections for different environments. I'm using rake to create db's, but eventho I'm setting environment to test for some reason development db is also created. here are my files https://hastebin.com/umiripipal.rb - thanks in advance for help
<jhass>
it captures the block, so some_method { this_is_the_block }
<jhass>
the curly braces part goes into the var block
<jhass>
in this case there's really no point to doing that though
<Tuor>
ah ok.
<jhass>
since instead the implicit block argument is invoked, using yield
<jhass>
Ediz: somehow I doubt there's deep integration between activerecord and sinatra, so you're setting sinatra to the test env but that probably doesn't affect activerecord's configuration much
yokel has quit [Ping timeout: 256 seconds]
tsujp36 has quit [Remote host closed the connection]
<jhass>
and for development AR defaults to also creating the test db (it's meant for unit/integration tests)
<Ediz>
ok... thank you. I need to look deeper to figure this out
kith has joined #ruby
Colpop4323 has joined #ruby
yokel has joined #ruby
Colpop4323 has quit [Remote host closed the connection]
<jhass>
Ediz: gist is, use development for development, ignore test until you're writing unit or integration tests, set RACK_ENV=production when deploying, don't set the environment anywhere in code explicitly. Also no need to load you models for your migrations.
<Ediz>
I'm aware :) just testing how things work depending on ENV on my local one by one to see them working
<Ediz>
tyvm
zacts has joined #ruby
<rapha>
jhass: oh! my own personal convention was always "if i'm walking a tree, then each _ in front of the variable name is one level further down". is there a convention for that, too?
<rapha>
(but yes, these variable names were just for the MWE, the actual code has more descriptive ones)
alexherbo2 has quit [Ping timeout: 244 seconds]
<rapha>
jhass: how do the asterisks in your code work / what are they? is it like in C?
Colpop4323 has quit [Remote host closed the connection]
Colpop4323 has joined #ruby
ur5us has quit [Ping timeout: 244 seconds]
Colpop4323 has quit [Remote host closed the connection]
<rapha>
jhass: seems the Array() isn't needed either. just [] is enough for it to work. even though i'm still puzzled at those asterisks.
Ediz has quit [Read error: Connection reset by peer]
Ediz has joined #ruby
Ediz is now known as Guest12825
<jhass>
rapha: yeah, the [] was meant to replace the entire Array() << business. I'm not aware of a "one level deeper" convention, IME that represents different data anyhow and can have its own descriptive name, no need for some semi hungarian notation IMO
<jhass>
rapha: * is splatting, it takes an array and transforms it into a comma separated list at syntax level
<jhass>
if the argument is not array like, it's just kept as is
<jhass>
it's the same thing you see in method calls
<jhass>
well, that's the documentation for the rake task db:create, which is defined by activerecord, which while not being strictly coupled to it, is built in deep lockstep with the entire rails framework
<jhass>
rake is just a generic task runner tool, pretty much anything can contribute tasks
<jhass>
the name is pretty much a pun on make, think of it like that :)
<Ediz>
right
<Ediz>
well
<Ediz>
I've not touched rails yet it was suprising to see it there
<Ediz>
also not applying to my case since its using RACK_ENV
<Ediz>
and not RAILS_ENV
<jhass>
yeah, that's due to the integration code I linked earlier :)
yokel has joined #ruby
hiroaki has joined #ruby
yokel has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #ruby
robinimus1 has joined #ruby
robinimus has quit [Read error: Connection reset by peer]
ujjain2 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
robotmay has joined #ruby
kintarowonders has quit [Read error: Connection reset by peer]
kintarowonders has joined #ruby
zacts has quit [Quit: leaving]
yokel has joined #ruby
ujjain2 has joined #ruby
ujjain2 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
yokel has quit [Ping timeout: 264 seconds]
dualfade has quit [Ping timeout: 265 seconds]
dualfade has joined #ruby
ellcs has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Max SendQ exceeded]
robinimus1 has quit [Quit: Leaving.]
robinimus has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Excess Flood]
bsdbandit-01 has joined #ruby
yokel has joined #ruby
ellcs has quit [Ping timeout: 240 seconds]
vondruch has joined #ruby
ujjain2 has joined #ruby
drincruz has joined #ruby
yokel has quit [Ping timeout: 256 seconds]
BSaboia has quit [Quit: This computer has gone to sleep]
zacts has joined #ruby
robinimus has left #ruby [#ruby]
roadt has quit [Ping timeout: 260 seconds]
cow[moo] has joined #ruby
meinside has quit [Quit: Connection closed for inactivity]
coniptor has joined #ruby
ellcs has joined #ruby
GodFather has quit [Ping timeout: 240 seconds]
TCZ has joined #ruby
yokel has joined #ruby
howdoi has joined #ruby
iNs has quit [Remote host closed the connection]
iNs has joined #ruby
<rapha>
jhass: okay, got it (splatting - only knew a,b=[1,2] works so far)! as for the Array() thing, what i meant was that this here works, too: `new_tree[k] = new_tree.has_key?(k) ? [*new_tree[k], *vv] << vv : vv`
yokel has quit [Ping timeout: 246 seconds]
<jhass>
rapha: drop the << vv, that would add a duplicate!
<jhass>
a, b = foo I would call array decomposition :)
braincrash has joined #ruby
yokel has joined #ruby
cliluw has quit [Read error: Connection reset by peer]
cliluw has joined #ruby
cliluw has quit [Read error: Connection reset by peer]
cliluw has joined #ruby
cliluw has quit [Ping timeout: 265 seconds]
cliluw has joined #ruby
yokel has quit [Ping timeout: 260 seconds]
strmpnk has left #ruby [#ruby]
bmurt has joined #ruby
SuperLag has joined #ruby
schne1der has quit [Quit: schne1der]
schne1der has joined #ruby
yokel has joined #ruby
zacts has quit [Quit: leaving]
wallace_mu has joined #ruby
roadt has joined #ruby
donofrio has joined #ruby
yokel has quit [Ping timeout: 246 seconds]
twodayslate has joined #ruby
yokel has joined #ruby
roadt has quit [Ping timeout: 260 seconds]
yokel has quit [Ping timeout: 260 seconds]
yokel has joined #ruby
Ediz has quit [Quit: Leaving]
GodFather has joined #ruby
vondruch has quit [Ping timeout: 240 seconds]
yokel has quit [Ping timeout: 258 seconds]
akem has quit [Ping timeout: 258 seconds]
x0n has quit [Ping timeout: 240 seconds]
x0n has joined #ruby
GodFather has quit [Ping timeout: 272 seconds]
BSaboia has joined #ruby
<elxbarbosa>
it seems that ruby will become a lot more like python, all those "end" might not be needed in future versions :)
ChmEarl has joined #ruby
elxbarbosa has left #ruby ["ERC (IRC client for Emacs 27.1)"]
TCZ has quit [Quit: Leaving]
dfucci has quit [Ping timeout: 272 seconds]
BSaboia has quit [Quit: This computer has gone to sleep]
x0n has quit [Ping timeout: 265 seconds]
Colpop4323 has joined #ruby
yokel has joined #ruby
<apotheon>
I'm not quite ready for Ruby to become like Python.
<jhass>
we can always reenact the python 2/3 split and stay on Ruby 2 :D
Colpop4323 has quit [Remote host closed the connection]
<apotheon>
okay
<apotheon>
Actually, re-enact the Perl 5/6 split, and push Ruby 3 to rename itself, if it actually becomes like Python.
<apotheon>
Then we could have a proper Ruby 3.
<jhass>
Ruby 3xPi
<apotheon>
Was Ruby's "endless" method syntax supposed to be only for one-line methods, or was that supposed to apply to multiline methods as well?
dfucci has joined #ruby
<jhass>
last I heard for onliners
<apotheon>
Yeah, if it's just for oneliners I think it's no skin off my nose.
<apotheon>
If it's multiliners, too, I expect a lot of Ruby code to get *much* uglier.
dfucci has quit [Ping timeout: 256 seconds]
<jhass>
I mean, there's \ and ;, heh
<jhass>
makes me wonder if a; b counts as a single line in that context
yokel has quit [Ping timeout: 258 seconds]
dfucci has joined #ruby
akem has joined #ruby
yokel has joined #ruby
yokel has quit [Ping timeout: 264 seconds]
akem has quit [Quit: Leaving]
Asa has joined #ruby
Asa is now known as Guest51828
yokel has joined #ruby
cliluw has quit [Ping timeout: 272 seconds]
Guest51828 has quit [Ping timeout: 240 seconds]
Mia has joined #ruby
Mia has quit [Changing host]
Mia has joined #ruby
Axy has quit [Ping timeout: 258 seconds]
znz_jp has quit [Remote host closed the connection]
<Tuor>
Hi, this is my code right now: https://paste.ubuntu.com/p/cNHDnw8P9B/. On line 28 - 34 I create a list of disks. When line 30 is false, the disks array still gets an item added, but it is nil. How can I only add none nil item to the disks list?
yokel has quit [Ping timeout: 272 seconds]
znz_jp has joined #ruby
x0n has joined #ruby
<jhass>
Tuor: best move the conditional into a select: snapshot.children(false).select {|child| ... match? }.map {|child| snapshot + child }
cd has joined #ruby
BSaboia has joined #ruby
yokel has joined #ruby
ellcs has quit [Ping timeout: 244 seconds]
ujjain2 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Dara has joined #ruby
cliluw has joined #ruby
braincrash has quit [Ping timeout: 246 seconds]
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cow[moo] has joined #ruby
coniptor has quit [Ping timeout: 256 seconds]
Mia has quit [Read error: Connection reset by peer]
x0n has quit [Ping timeout: 246 seconds]
yokel has quit [Ping timeout: 246 seconds]
coniptor has joined #ruby
<Tuor>
jhass: ok works thank you!
<Tuor>
will be able to use that in different place to. :)
<Tuor>
I did once write a little ruby program and got a lot of help from this channel (thank you!) but it's some years ago and I didn't really use it since then. Did a lot of bash since then and some puppet... now I had a nice little project which makes more sense to write in an object oriented language then bash and finally I can write some ruby again! :)
<jhass>
well, I prefer { } for blocks when chaining, but otherwise it's pretty much what I wrote, so I can't complain :D
<Tuor>
Ah ok. Yes, I did put it into a method and now I'm calling it 2 times. less code :)
<Tuor>
there are a lot of enumerable methods! wow
<havenwood>
Tuor: They tend to be quite useful too. :)
<Tuor>
I'm checking them out. Will for shure have to use them. :) thx!
mikecmpbll has quit [Quit: inabit. zz.]
Dara has quit [Remote host closed the connection]
dasher00 has quit [Ping timeout: 240 seconds]
ujjain2 has quit [Ping timeout: 260 seconds]
impermanence has quit [Ping timeout: 265 seconds]
ropeney_ has quit [Ping timeout: 240 seconds]
znz_jp has quit [Remote host closed the connection]
ropeney has joined #ruby
Milos has quit [Read error: Connection reset by peer]
Milos has joined #ruby
x0n has joined #ruby
ujjain2 has joined #ruby
ropeney_ has joined #ruby
ropeney has quit [Ping timeout: 246 seconds]
znz_jp has joined #ruby
x0n has quit [Ping timeout: 258 seconds]
chouhoulis has joined #ruby
troulouliou_div2 has joined #ruby
CrazyEddy has joined #ruby
neshpion has joined #ruby
x0n has joined #ruby
impermanence has joined #ruby
x0n has quit [Ping timeout: 260 seconds]
cliluw has quit [Read error: Connection reset by peer]
<ruby[bot]>
ellcs: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
<ellcs>
msg is supposed to be the class/module
<jhass>
why's this classes/modules over just constants?
<jhass>
(with string or integer values)
<ellcs>
because i want to pass integers and strings to further functions
<jhass>
you mean you don't?
<ellcs>
maybe i just expose the whole source code.
<ellcs>
&>> case Integer; in Integer; puts "hi"; end
<rubydoc>
stderr: -e:4: warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!... check link for more (https://carc.in/#/r/9px8)
<jhass>
I think personally I would limit the complexity of messages, enforce JSON or something
<jhass>
but an approach that could keep what you want could to just containerize the whole stuff
<ellcs>
my project idea was to write a simple parallel