<havenwood>
lmat: I commented on adam12's gist with an alternative that's equivalent.
cer0 has joined #ruby
<havenwood>
Either is better than toggling booleans. It does make me think of the flipflop operator, heh.
<havenwood>
lmat: A meta suggestion, but paste links to code as text rather than an image. It's easier for folk to try your code or modify it in a suggestion.
ur5us has joined #ruby
<havenwood>
lmat: gist.github.com or dpaste.org are nice options.
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dionysus70 has quit [Remote host closed the connection]
ramfjord has quit [Ping timeout: 256 seconds]
ruurd has quit [Remote host closed the connection]
orbyt_ has joined #ruby
dionysus70 has joined #ruby
jud has joined #ruby
jud has quit [Changing host]
jud has joined #ruby
silverdust has quit [Ping timeout: 264 seconds]
ur5us_ has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has quit [Ping timeout: 264 seconds]
dionysus70 has quit [Remote host closed the connection]
adu has quit [Quit: adu]
dionysus70 has joined #ruby
silverdust has joined #ruby
dionysus70 has quit [Ping timeout: 240 seconds]
Rudd0 has quit [Ping timeout: 260 seconds]
dionysus69 has quit [Ping timeout: 246 seconds]
zenspider has quit [Quit: ZNC 1.6.6+deb1ubuntu0.2 - http://znc.in]
<lmat>
adam12: Ah, with_each_index, yeah, that seems like the way to go. That's better (in this case) than havenwood's solution because it allows me to unify the two routines.
<lmat>
havenwood: My working solution is like yours, but not nearly so nice! ... doc.p split_comments[0] ... split_comments.last(split_comments.length - 1).each do |c|
* lmat
hides
CustosLimen has quit [Ping timeout: 272 seconds]
afisher has quit [Read error: Connection reset by peer]
kevinsjoberg has quit [Read error: Connection reset by peer]
Lewix has quit [Read error: Connection reset by peer]
manveru has quit [Ping timeout: 260 seconds]
clinth has quit [Read error: Connection reset by peer]
<isene>
"å" is two bytes, "\xC3\xA5". I tried to first match against "\xC3" and then "\xA5" but that doesn't work. And I've tried all manners of gymnastics, and Googling and scratching of head. But nothing seems to work.
mozzarella has quit [Read error: Connection reset by peer]
<isene>
So, if I were to copy your code, how would you capture "å"?
mozzarella has joined #ruby
<isene>
wait, your code does capture "å" correctly...
<isene>
no... it doesn't. It actually screws up curses :-/
<burgestrand>
I don't understand, for me it captures å quite well.
<burgestrand>
(and getch behaves properly, too)
<burgestrand>
isene what's your STDIN.external_encoding?
<burgestrand>
Mind you æøå are only two bytes if they're encoded as e.g. UTF-8. If you receive them as e.g. LATIN-1 (also common) they'll be 1 byte each.
<jhass>
isene: it's not "my code" but an example of combining and using read_nonblock. I don't have a ready made solution to your problem at hand, I just meant I could imagine something into this direction to be able to solve it
<isene>
burgestrand: Oh, this is new to me... how to check STDIN.external_encoding? and how to set it?
<burgestrand>
isene you check it by looking at the value of STDIN.external_encoding :)
<isene>
So, should I simply do ' STDIN.external_encoding = "latin-1" ' then? Or something?
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<burgestrand>
isene I'll give you a snippet, hold on
<isene>
"undefined method `external_encoding=' for #<IO:<STDIN>> (NoMethodError)"
<burgestrand>
isene what is your RUBY_VERSION?
<isene>
ruby 2.7.0p0
<burgestrand>
isene ah, nvm, you do `STDIN.set_encoding(Encoding::UTF_8)` or `STDIN.set_encoding(Encoding::ISO8859_1)`
<burgestrand>
isene which one you pick depends on what the rest of your system thinks you should have, e.g. if your å entered into the terminal are 2 bytes then most likely it's supposed to be UTF-8
<isene>
STDIN.set_encoding(Encoding::UTF_8) works as before, while STDIN.set_encoding(Encoding::ISO8859_1) works in an odd way - I get the characters, but reversed and blinking and it doesn't get captured into my command history. But it seems to be a step in the right direction
<burgestrand>
isene this might be a red herring, but making sure the encodings are proper is usually my first go-to whenever there are issues with my åäö :)
<isene>
I also get this when using the character afterwards: incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string) (Encoding::CompatibilityError)
<burgestrand>
isene strings/regex in ruby are tagged with an encoding, and when you e.g. a regex with a string their encodings (string.encoding, regex.encoding) must match or you get that error
<burgestrand>
e.g. `Regexp.new("å".b) === "å"` will raise that error
<isene>
c = STDIN.getch
<isene>
=> "å"
<isene>
puts c.bytesize
<isene>
2
<burgestrand>
isene indeed looks like UTF-8 is what you want :)
<isene>
When I set `STDIN.set_encoding(Encoding::ISO8859_1)` I get: å (blinking, bold, reverse) after hitting "å" just once
<burgestrand>
isene mainly because it's interesting… what happens if you do `STDIN.set_encoding(Encoding::BINARY)`?
<isene>
Same as `STDIN.set_encoding(Encoding::ISO8859_1)`
duckpuppy has quit [Read error: Connection reset by peer]
TCZ has joined #ruby
<burgestrand>
isene unfortunately the file is a bit too much for me to have a thorough look, and I'm not quite sure what you mean with (blinking, bold, reverse)
<burgestrand>
isene I'm assuming the purpose of `getchr` is to read an entire character, wether that be 1 byte (e.g. a), 2 bytes (e.g. å) or more?
<isene>
Yes
<isene>
I tried to add this in the case evaluation (but it didn't capture my beloved "å"):
<isene>
when "\xC3"
<isene>
case $stdin.getc
<isene>
when "\xA5" then chr = "å"
<isene>
end
<isene>
getchr successfully capture all arrow keys/Home/End/Backspace/PgUp etc as well as "\r" and normal characters... but not the cute, little "Å"
<burgestrand>
isene note the .b at the end of the "\xC3" and "\xA5" — without it the encodings won't match up, and the strings won't match
roshanavand has quit [Ping timeout: 264 seconds]
<burgestrand>
String#b will force a string to be binary encoding (no encoding), and comparison will be by bytes
<burgestrand>
Huh, TIL, ruby considers strings of different encodings to be unequal, doesn't matter if their bytes are identical
<isene>
YAY!
<burgestrand>
isene there are two things that make that gist work: input (external) encoding is binary, and the comparison strings are binary
<burgestrand>
isene for an input encoding of binary, STDIN.getc will read each byte of å separately, but if you have an input encoding of UTF-8 it'll read both bytes of å in one g
<burgestrand>
yeah and that's interesting — I'm guessing curses does something to e.g. STDIN.getc to make it read a single character? For me the input is newline-terminated
<isene>
burgestrand: Yes, it may well be a curses issue... but since I do get the characters out (but blinking reversed and not uasble for comparisons etc.) with the Encoding::ISO8859_1, I do believe this is solvable
dionysus69 has joined #ruby
<isene>
The characters are captured somehow, I just need to figure out a way to decode them
vondruch has quit [Ping timeout: 256 seconds]
<burgestrand>
isene it probably is :) if I'm to run your code, what's the best way to test the problem? which characters do I need to enter?
<isene>
You fire up RTFM, then press ":" to get into command mode on the bottom line/window then enter "å" or "æ" or "ø"
<burgestrand>
isene if I put some log output in your code at the end of chr, with an Encoding::UTF_8, then it shows that `chr` is a proper 2 bytes with an UTF-8 encoding
<burgestrand>
isene i.e. it looks like `getchr` is indeed working as it should
<isene>
Except I can't seem to catch the bastard...
<burgestrand>
isene I put that right above `return chr` and the logged output looks OK
<isene>
So how on Earth do I catch it and return the cheeky "å"?
<burgestrand>
isene when I run it locally, the command mode shows a typical "?", i.e. probably only shows the first byte of the character — is that the problem you're having?
batisi[m] has joined #ruby
<isene>
burgestrand: No, it shows nothing when I press "å" once and after pressing it twice I get "┗↑╔" (blinking reversed)
<burgestrand>
isene give `@win_bottom.addstr(chr)` a try
<burgestrand>
isene instead of `addch`
<burgestrand>
isene with Encoding::UTF_8 for your stdin
<isene>
HOLY COW!!
<isene>
That worked :-D
<burgestrand>
mooo
<burgestrand>
isene I'm guessing either getch isn't encoding-aware, or simply doesn't accept more than one byte
<burgestrand>
sorry, not getch, addch
<isene>
You said addch
<isene>
And I changed line 770 to ' @win_bottom.addstr(chr) ' and it was Voilá!
<burgestrand>
\o/
<isene>
Indeed.
<isene>
You've been of great value. If it werent for COVID, I'd give you a big hug right now
<isene>
I still have some matching stuff to iron out, but at least I get the characters now :-)
<burgestrand>
isene IRC hugs are covid-aware and well received :)
<isene>
;-)
<isene>
Since you're still here, how would I best solve this (and similar):
<isene>
/home/geir/bin/rtfm:202:in `match': incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string) (Encoding::CompatibilityError)
<burgestrand>
isene it probably means `@searched` has no encoding, I'd double-check that first by logging `@searched.encoding` on line 201
<burgestrand>
isene give `str.b.match(…)` a try, it might be good enough
<isene>
Then it doesn't crash - but it doesn't match either
<burgestrand>
isene I'm guessing `win_bottom_curstr` is returning binary encoded strings (i.e. `win_bottom_curstr.encoding == Encoding::BINARY`) and that's unfortunate because I guess it's user input?
<burgestrand>
isene ideally you'd do `return str.force_encoding(STDIN.external_encoding)` on line 730 instead — I'm not sure that solves it, but it's assuming that the return value is actually UTF-8 and I'm not sure that's entirely accurate
<isene>
With that I get: /home/geir/bin/rtfm:800:in `gsub!': invalid byte sequence in UTF-8 (ArgumentError)
<isene>
... for a command entered with "Å" and for search:
<isene>
/home/geir/bin/rtfm:202:in `block in list_dir': invalid multibyte character (ArgumentError)
<isene>
... even with the `str.b.match(…)`
vondruch has joined #ruby
akem_ has joined #ruby
akem has quit [Ping timeout: 240 seconds]
<burgestrand>
isene there's a healthy mix of encodings in and out here :) it's possible that anything you get from Curses is binary, and anything you get from STDIN/hard-code is UTF-8 — that's bound to cause issues whenever the two mix
<burgestrand>
isene typically using UTF-8 everywhere is better because that retains some meaning in your strings, e.g. "\xC3\xA5" could be anything without context, in UTF-8 it's `å` and in LATIN-1 it's `Ã¥` — in binary it's neither, just some unknown bytes
<burgestrand>
isene lacking that it might be easier to fall back to binary everywhere, i.e. what I did with "\xC3".b — you might see some issues with string length calculations (e.g. "å".length => 2) or some regex patterns not behaving well (e.g. \p{L} will not properly match å)
burgestrand has quit [Quit: burgestrand]
fandre1986 has joined #ruby
silverdust has joined #ruby
banisterfiend has joined #ruby
burgestrand has joined #ruby
<isene>
burgestrand: I have located the issue (https://github.com/isene/RTFM/blob/main/rtfm#L717) - it is the Curses.inch that reads only the first byte of a character on the screen. And the curses library has no other way to read characters from the screen - which is, well, pretty broken. But, I will work around that by not relying on reding back what the user has written, but rather store the user's typing
<isene>
in a variable back-end. So, it will be solved. Again, thanks for all the help here. I learned a lot.
<burgestrand>
isene that sounds like a good idea, not passing the string through curses :)
dfucci has joined #ruby
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
alexherbo2 has joined #ruby
bsdbandit-01 has joined #ruby
TCZ has quit [Quit: Leaving]
rubydoc has joined #ruby
CrimisoK` has joined #ruby
phaul has joined #ruby
akem_ is now known as akem
rubydoc has quit [Remote host closed the connection]
rubydoc has joined #ruby
CrimisoK` has left #ruby [#ruby]
dfucci_ has joined #ruby
<nakilon>
if I get "No debugging symbols found in /usr/bin/ruby" in gdb that means I can't see backtrace?
<jhass>
no C level backtrace, probably
dfucci has quit [Ping timeout: 268 seconds]
<jhass>
well you can still see it but it's just memory addresses
<nakilon>
okay then
<nakilon>
the actual issue is that ruby processes keep living even if there is `abort` in the very first line
<nakilon>
launched under the cron /bin/sh
<jhass>
mh
<nakilon>
the cron launches 6 processes and near 20% of them stay forever even while the very first line is: abort "too many processes" if 10 < `ps aux | grep ruby | wc -l`.to_i
<jhass>
typical reason would be if the parent process never wait(2)'s on it, but that's unlikely for cron and sh
<jhass>
oh, how exactly do you launch these 6?
dfucci has joined #ruby
TCZ has joined #ruby
<jhass>
via one shell as background tasks or per separate cron entries?
<nakilon>
and not in alpine's htop; maybe I'm noob and don't know what should I press to make zombies appear in it, because they aren't in htop but are in ps aux
<havenwood>
nakilon: yeah, I recalled then spot checked it wasn't in 2.5 to confirm
<adam12>
2.5 did receive improvements to Time but it was about units.
<nakilon>
docs lack an example
<nakilon>
passed the timezone name and then had to find in specs that I have to TimeSpecs::TimezoneWithName.new
<nakilon>
wait, that's a class for specs I guess
<nakilon>
should I use TZInfo::Timezone.get?
<nakilon>
then it's a gem dependency
<havenwood>
nakilon: "A timezone argument must have local_to_utc and utc_to_local methods, and may have name and abbr methods."
<nakilon>
the first time I see an optional argument in stdlib that will start work only after I install a gem
ramfjord has joined #ruby
TomyWork has quit [Remote host closed the connection]
alexherbo2 has joined #ruby
teardown has quit [Ping timeout: 240 seconds]
teardown has joined #ruby
rmnull has quit [Ping timeout: 264 seconds]
rmnull has joined #ruby
TCZ has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hiroaki has joined #ruby
teardown has quit [Ping timeout: 240 seconds]
teardown has joined #ruby
TCZ has quit [Quit: Leaving]
<isene>
havenwood: RTFM is now pretty feature complete. Did a full rewrite of the command/search input to circumvent a broken part of the curses module (it can't read multibyte characters from screen). Next will be to make a 30 sec screencast. Feel free to suggest code improvements (I did the Dir.home change you suggested). Clocked 40 hours coding so far.
Rudd0 has quit [Ping timeout: 240 seconds]
<mcr>
I'm looking help understanding how to use the Google API Client, FCMv1 class. I switched from the "fcm" gem to this, because I need the v1-OAUTH2 authentication mechanism (rather than API_KEY. It's an internal policy issue, PM me if you want to know details). But, I can't seem to get that class to do things, and there are too many layers of indirection in the source code.
vondruch_ has joined #ruby
GodFather has quit [Ping timeout: 272 seconds]
burgestrand has joined #ruby
vondruch has quit [Ping timeout: 256 seconds]
vondruch_ is now known as vondruch
tbisker8 has quit [Ping timeout: 256 seconds]
davispuh has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
GodFather has joined #ruby
TCZ has joined #ruby
teardown has quit [Ping timeout: 240 seconds]
cnsvc has joined #ruby
davispuh has quit [Ping timeout: 240 seconds]
davispuh has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<GuyGomma>
do you have any experience with that as well ?
<apotheon>
To quote the immortal Al Pacino, in the movie Heat, "[You could] get killed walking your doggie!"
<apotheon>
(re: "secure")
<GuyGomma>
what does that mean ?
<GuyGomma>
this channel is very quiety.
ap4y has joined #ruby
<apotheon>
It means that asking whether a piece of software is "secure" in some general, unspecified sense is pretty much a completely pointless thing to do.
<GuyGomma>
are you a dev baweaver
<apotheon>
(especially a piece of software like a compiler, interpreter, runtime)
<GuyGomma>
i have heard ruby can be hacked
<apotheon>
(that is, a complicated piece of software)
<apotheon>
PHP and firewood can get hacked.
<go|dfish>
GuyGomma: this shaman_king is very persistenty.
<GuyGomma>
but php is more mature
ur5us__ has quit [Remote host closed the connection]
ur5us__ has joined #ruby
<apotheon>
"mature"
<jtperreault>
more mature than firewood though? hm i dunno bout that
<apotheon>
One of the most amusing quotes I've encountered about PHP is "The reason PHP looks like a language designed by children is that it was."
<baweaver>
Let's avoid language bashing.
<apotheon>
I was just quoting someone.
<GuyGomma>
who designed ruby ?
<apotheon>
The point is that someone says something negative about *every* language.
<apotheon>
GuyGomma: smart people
<baweaver>
GuyGomma: You're free to google that and look it up yourself.
<GuyGomma>
i think its best to learn different languages
<GuyGomma>
start with grails and move to rails.
GuyGomma was banned on #ruby by baweaver [*!sid470167@gateway/web/irccloud.com/x-nicjyinlbnjebgkb]
GuyGomma was kicked from #ruby by baweaver [Your behavior is not conducive to the desired environment.]
<baweaver>
Bye
<baweaver>
100% convinced now.
<apotheon>
GuyGomma: What would satisfy your question? Do you want a software developer and former infosec professional to exlain to you that the answer to your question is that Ruby is about as safe to use for programming as any other language?
<apotheon>
oh, whoops
<apotheon>
gone now
<baweaver>
Same boring troll with the Grails bit
<baweaver>
It's about 5 messages until extremely racist diatribes
<apotheon>
baweaver: I was indistinguishably close to 100% sure it was the same person I saw you kick out last time I noticed it.
<baweaver>
adam12 / havenwood: stepping out for a bit, might want to +r
<baweaver>
Went ahead and set it for the moment.
<baweaver>
DMs afterwards pretty well confirm it. Anyways, as you all were.