Mia has quit [Write error: Connection reset by peer]
jenrzzz has joined #ruby
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
drincruz has joined #ruby
jenrzzz has quit [Ping timeout: 272 seconds]
m27frogy has quit [Ping timeout: 246 seconds]
vondruch has joined #ruby
m27frogy has joined #ruby
TomyWork has quit [Remote host closed the connection]
TomyWork has joined #ruby
akem__ has joined #ruby
akem_ has quit [Ping timeout: 260 seconds]
infinityfye has quit [Ping timeout: 246 seconds]
Ediz has joined #ruby
<Ediz>
Hello everyone
<Ediz>
Today I published my first gem, I'm not sure if this is the place to ask for this but I'd love to have my code to be reviewed and would love to have any opinions/comments regarding it so I can improve. I kindly ask, if you have spare time you'd like to help me with, to check my code and let me know your comments on how I can improve and if I've done anything wrong there. https://github.com/edizarca/simple_rate_limiter
<Ediz>
tyvm in advance please be harsh :D
stryek has joined #ruby
<jhass>
Ediz: people would generally not commit .gem files and also for gems skip Gemfile.lock (so CI more realistically tests dependency trees of people using the gem). You also committed a GPL as LICENSE and a MIT as LICENSE.txt, which is highly confusing. If you want to dual license I would recommend combining that into one file and explaining the dual licensing. Not sure if .rspec_status is a file to be
<jhass>
committed, never saw it before. Same for the coverage folder. You also don't want to commit the .bundle folder. You might want to give the README a lot more love, especially the first paragraph with the TODO.
<jhass>
Ediz: you're violating naming conventions a bit by calling the gem simple_rate_limiter but use RateLimiter as a namespace
<jhass>
code wise from a quick glance it looks pretty good, maybe a bit heavy on the get_ prefix side for my personal taste, but nicely modular and structured
rubydoc_ has quit [Remote host closed the connection]
rubydoc_ has joined #ruby
phaul has quit [Ping timeout: 240 seconds]
<Ediz>
tyvm jhass!
<Ediz>
I really appreciate it
jmcgnh has joined #ruby
phaul has joined #ruby
sleetdrop has joined #ruby
bmurt has joined #ruby
TheBrayn has joined #ruby
phaul has quit [Ping timeout: 240 seconds]
rubydoc_ has quit [Ping timeout: 256 seconds]
sleetdrop has quit [Remote host closed the connection]
ignorand has joined #ruby
phaul has joined #ruby
rubydoc_ has joined #ruby
rubydoc_ has quit [Excess Flood]
rubydoc_ has joined #ruby
rubydoc_ has quit [Remote host closed the connection]
rubydoc_ has joined #ruby
jcalla has joined #ruby
ignorand has quit [Disconnected by services]
jenrzzz has joined #ruby
rubydoc_ has quit [Ping timeout: 240 seconds]
jenrzzz has quit [Ping timeout: 264 seconds]
phaul has quit [Ping timeout: 264 seconds]
rubydoc_ has joined #ruby
phaul has joined #ruby
rubydoc_ has quit [Excess Flood]
impermanence has quit [Quit: Connection closed]
akem__ is now known as akem
phaul has quit [Ping timeout: 264 seconds]
phaul has joined #ruby
phaul has quit [Ping timeout: 240 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bmurt has joined #ruby
cow[moo] has joined #ruby
orbyt_ has joined #ruby
phaul has joined #ruby
jcalla has quit [Quit: Leaving]
jcalla has joined #ruby
ChmEarl has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cow[moo] has joined #ruby
cow[moo] has quit [Client Quit]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
al2o3-cr has joined #ruby
phaul has quit [Ping timeout: 240 seconds]
phaul has joined #ruby
cow[moo] has joined #ruby
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
phaul has quit [Ping timeout: 246 seconds]
phaul has joined #ruby
cow[moo] has joined #ruby
phaul has quit [Ping timeout: 260 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cow[moo] has quit [Client Quit]
cthulchu_ has joined #ruby
rippa has joined #ruby
shokohsc has joined #ruby
phaul has joined #ruby
phaul has quit [Ping timeout: 272 seconds]
infinityfye has quit [Ping timeout: 240 seconds]
phaul has joined #ruby
jenrzzz has joined #ruby
akem has quit [Quit: Leaving]
cow[moo] has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
questi has joined #ruby
<questi>
to install rb file dependencies i can install them as a gem?
<questi>
sudo gem install lib
jenrzzz has joined #ruby
<jhass>
?xy
<jhass>
questi: what's your actual problem? :)
<jhass>
why do you want to "install rb file dependencies" as a gem?
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<questi>
it was on a first page of google :)
<questi>
quick way to install required libs
orbyt_ has joined #ruby
orbyt_ has quit [Client Quit]
akem has joined #ruby
rippa has joined #ruby
jcalla has quit [Ping timeout: 260 seconds]
vondruch has quit [Read error: Connection reset by peer]
orbyt_ has joined #ruby
drincruz has quit [Ping timeout: 246 seconds]
lucasb has joined #ruby
bmurt has joined #ruby
jcalla has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
drincruz has joined #ruby
<riceandbeans>
I want to take a File.stat('/path').mode and compare it to what I'd normally use, say 0755, but the numbers are coming out in an unexpected way
<riceandbeans>
If I pp the File.stat it looks right, if I take the field the number is an Integer but weird
<riceandbeans>
mode=0100644 (file rw-r--r--),
<riceandbeans>
Really I just want the 0644 there
<jhass>
>> 0o755
<jhass>
&>> 0o755
* jhass
kicks the bots
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<riceandbeans>
jhass: but look
<jhass>
riceandbeans: 0755 is octal usually, 493 as an integer
<riceandbeans>
Anyway, that's a normal looking mode
<jhass>
octal is just an integer representation
<riceandbeans>
Sure, so is hex and binary
<jhass>
.mode & 0o777
<riceandbeans>
But when the field in a pp shows the octal I kind of expected calling the method to print octal too
<jhass>
an integer doesn't have an "inherent representation"
<riceandbeans>
file modes are a special case anyway
<riceandbeans>
It's not really one whole octal value, it's an array of them
<riceandbeans>
But here it's treated as one
<Tuor>
Hi, I worked a little on my deduplication utility https://gitlab.com/nod0n/dedup. I don't remember who was intrested in it. (it has a README now), any comments / suggestion to improve it?
<jhass>
no, it's one whole integer
<jhass>
there's no "octal value", there's an "octal representation"
<riceandbeans>
Doesn't change that it's not 1, but 3 and another that carries other data
<jhass>
1 or 3 what, what are naming here
<riceandbeans>
say, 0755, file mode
<jhass>
it's just a bitfield
<riceandbeans>
that's really [0,7,5,5]
<jhass>
0brrrwwwxxx
<jhass>
no, it's stored litterally as 0755 or 493 in decimal or 111101101 in binary
<havenwood>
Tuor: When you want an offset with #each_with_index, like +1, consider: each.with_index(1)
<havenwood>
Tuor: #with_index takes an offset unlike #each_with_index, for whatever historical reason.
<havenwood>
Tuor: With OptionParser I think it's nicer to use the :into keyword with #parse! with a collection like a Hash or Struct.
<jhass>
riceandbeans: sorry, I should've written 0buruwuxgrgwgxorowox where u = owner, g = group, o = others, r = read, w = write, x = execute
<jhass>
so now we can compose, 0b110100100.to_s(8) => "644"
<riceandbeans>
TIL it's not stored as separate values.
<Tuor>
havenwood: thank you, I think it makes sense. Let's see if I did understand it. ;)
orbyt_ has joined #ruby
bocaneri has quit [Remote host closed the connection]
TomyWork has quit [Quit: Leaving]
htmnc has joined #ruby
<htmnc>
when I'm defining static methods for a class, is there any meaningful difference between defining self.<methodname> vs using the scope resolution explicitly via def <class>::<methodname>? they seem to execute in exactly the same ways
<htmnc>
I've been trying to google around but I'm not sure what keywords to use since when I say 'scope resolution' and all that I get a bunch of stack overflow questions about what '::' is instead of comparing the two
<adam12>
htmnc: None.
<htmnc>
thanks!
<adam12>
htmnc: Long ago, :: was used to denote class method calls. It kinda fell out of favour.
<htmnc>
yeah makes sense, I think when I first learned ruby 1.9 was 'new'
<adam12>
htmnc: It's in Why's book and mentioned, so it's at least 1.8 days.
<htmnc>
makes sense, I'll have to double check but it's probably in my copy of The Ruby Programming Language
<adam12>
htmnc: wrt self vs <class name>, inside a class definition, self resolves to <class name> anyways.
<htmnc>
ohhh wait so if I inherit a class is self. more generic than <explicit parent class>:: because of that?
<adam12>
htmnc: Don't follow.
<havenwood>
Tuor: Same as: Dedup.new(DEFAULTS)
<Tuor>
Ah ok.
<adam12>
havenwood: It's interesting syntax.
<adam12>
havenwood: I'm not sure I've ever seen Struct with that. Do you know if it's using the Object's call?
<htmnc>
so if I have a class A and a class B < A, and within A I define a method A::foo, I was sorta thinking that self.foo would be more explicitly B::foo adam12
<htmnc>
it's not really important because inheritance I just for some reason had the thought that the self. might be more polymorphic
<havenwood>
adam12: Yeah, it's like semi documented. There should be a ::[] but it's only mentioned under ::new.
<adam12>
havenwood: Yeah. I looked at struct.c and saw it in call-seq. I can't recall ever seeing it before.
<adam12>
havenwood: Even source doesnt' lend much of a clue...
<havenwood>
adam12: I tried to go off the beaten trail for this gist, for whatever reason.
questi has quit [Ping timeout: 240 seconds]
<adam12>
htmnc: It probably won't make a difference because of the scope during parsing.
<htmnc>
adam12, makes sense, thank you
phaul has quit [Ping timeout: 260 seconds]
phage has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
jenrzzz has joined #ruby
<Tuor>
havenwood: My option should be like this: '--dry-run' but my symbol is :dry_run (as :'dry-run' would be ugly). How can I map it?
<havenwood>
Tuor: See my `--glow-in-the-dark` example.
jenrzzz has quit [Ping timeout: 240 seconds]
<havenwood>
Tuor: --[no-]glow_in_the_dark
<Tuor>
havenwood: ah now i get it. thx!
ur5us_ has joined #ruby
<Tuor>
second question, '--main MAIN_PATH' and '--secondary SECONDARY_PATH' should be able to be passed each one or more times. How can I get optparse to add it to the array? Example: dedup.rb --main 1 --main 2 --secondary 3
<Tuor>
havenwood: I'm sorry, but I can't see where they use the same options multiple times, or more important, where they make it possible to use the same option multiple times.
<havenwood>
Tuor: Just got back. I can show you how to make a custom type coercion for "multiple" some other time.
jenrzzz has quit [Ping timeout: 272 seconds]
<havenwood>
Tuor: The most straightforward way is to use the pre-made Array type conversion, but that'd mean comma delimiting rather than passing the argument multiple times.
<havenwood>
Tuor: You can make a custom type coercion that'll do the multiple times way though too.
<havenwood>
Tuor: Or use the old-school syntax, like you have done.
<Tuor>
ah ok. ',' could be part of a "path". '/tmp/this,is,a,valid,path'. I found the ',' separator way on the internet, but that's why I didn't use it. Would be intresting, having a custom coercion, but sadly not tonight. I have to work tomorrow. :) Thank you and have a good night.
jenrzzz has joined #ruby
Synthead has quit [Quit: Leaving]
TCZ has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
dfucci has quit [Ping timeout: 260 seconds]
jenrzzz has quit [Ping timeout: 272 seconds]
cd has joined #ruby
orbyt_ has joined #ruby
phaul has quit [Ping timeout: 272 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
dfucci has joined #ruby
phaul has joined #ruby
gix has joined #ruby
dfucci has quit [Ping timeout: 260 seconds]
BenDover has quit [Quit: BenDover]
dfucci has joined #ruby
phaul has quit [Ping timeout: 240 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
TCZ has quit [Quit: Diabe? tkwi w szczegó?ach]
helpa has quit [Remote host closed the connection]
helpa has joined #ruby
dfucci has quit [Ping timeout: 246 seconds]
Iarfen has quit [Remote host closed the connection]
ruurd has joined #ruby
ruurd has quit [Client Quit]
ruurd has joined #ruby
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
phaul has joined #ruby
dfucci has joined #ruby
phaul has quit [Remote host closed the connection]
phaul has joined #ruby
Technodrome has joined #ruby
hiroaki has quit [Ping timeout: 256 seconds]
dfucci has quit [Ping timeout: 246 seconds]
<riceandbeans>
Is there a less horrid way to write this?
<riceandbeans>
expect(File.stat(filepath).mode.to_s(8)[3]).to be >= 4
<ruurd>
regexp the mode string?
<riceandbeans>
i just feel like ^^^^^ looks unclear
<ruurd>
obscure at least.
<ruurd>
as in what is this person testing here exactly?
<riceandbeans>
Yeah, well, I'm not winning anyone over with that test
<riceandbeans>
Hence asking how would I make it at least less ugly
<jhass>
riceandbeans: (.mode & 0o700 >> 6).to be >= 0o4
<leftylink>
also note that a positive index with to_s(8) is going to cause a person much unhappiness
<riceandbeans>
leftylink: In what case would File.stat.mode.to_s(8) return a positive index?
e2 has joined #ruby
<leftylink>
you're using a positive index right there, with [3]
<leftylink>
as for your question... I'll take a look on my filesystem and see if it'll ever be an issue
<leftylink>
with any luck, it'll nevver be an issue
<riceandbeans>
lol
<jhass>
(.mode & 0x700).to be >= 0o400 is fine too
<riceandbeans>
I don't understand that line
<riceandbeans>
I mean, the first hove
<riceandbeans>
half rather
<jhass>
learn bitmasks, valuable tool in your belt well beyond this
<riceandbeans>
I mean, I understand file mode levels as sums of 1,2,4
<jhass>
0b110 & 0b101 #=> 0b100
<jhass>
that's just an artifact of being a bitfield
<jhass>
that the sums are powers of two
<riceandbeans>
I don't understand the other thing you just did either
<riceandbeans>
IS that just like the commonality?
xvx has quit [Ping timeout: 264 seconds]
<riceandbeans>
of 110 and 101, they both had 1
<riceandbeans>
or rather the 100
<jhass>
yes, it's binary and
<jhass>
0b110 | 0b101 #=> 0b111 # binary or
<riceandbeans>
Why in the first one did you >> 6
<jhass>
that's a shift
<jhass>
0b1100 >> 2 #=> 0b11
<jhass>
each octal digits is three binary digits, we want to extract the binary digits 7-9, so we have to "get rid" of 1-6
<leftylink>
a little weird isn't it... File::Stat has world_readable? and world_writable? and readable?, writable? (for the effective uid), but not something like owner_readable?. too bad.
<leftylink>
maybe not weird, just nobody ever asks for that
drincruz has quit [Ping timeout: 240 seconds]
<riceandbeans>
leftylink: Instead they do horrible things like I wrote, or if they're smarter they do stuff like jhass
<jhass>
heh, "smarter", second example above should be 0o not 0x too of course
<leftylink>
well, with 2.5 or above one can use less brainpower with allbits?, but behind the scenes allbits? is just doing the bitwise AND and comparing
<leftylink>
so, good to know
<jhass>
mh, allbits? still requires you to understand bitmasks
<riceandbeans>
I feel like Perl is my native tongue and I couldn't do bitmasks with Perl either so I feel particularly dumb right now and like i need to study this
<leftylink>
I am waiting for anyone in this channel to say "I'm not an allbit, I'm an orbit"
<leftylink>
anyone
<leftylink>
... guess not
<leftylink>
they would have said it by now, they've had 15 minutes since I first brought up allbits
<riceandbeans>
The random fundamental stuff you don't get when you don't go to school at all
<jhass>
fwiw I always have to open pry and verify these too
<riceandbeans>
jhass: I don't think this is right
<riceandbeans>
I have pry open all the time
<riceandbeans>
# ls /etc/rc.conf
<riceandbeans>
15562782 .rw-r--r-- 1.1k root wheel 21 Nov 20:19 /etc/rc.conf