<isene>
Ideas to check, points to debug or potential research?
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
pwnd_sfw has joined #ruby
<adam12>
isene: What's the issue?
<isene>
Here's the sweet and short. Relevant code: https://github.com/isene/RTFM/blob/main/rtfm#L624 (to get rid of the next line of code). I am using @selected_safe as the shellescaped version of the image file name. This does work for showing images in terminal via w3mimgdisplay - but not when the file names includes spaces. But - if I did like before - send the file name enclosed in 'image.png' to the
<isene>
bash script then all files are displayed. Sending file names enclosed in '' to the Open3 command results in no images shown. What I need is to be able to show images with spaces in the file names.
<isene>
The program /usr/lib/w3m/w3mimgdisplay takes a certain string from the command line/stdin and the Open3 seems to serve that quite well - except for files with spaces in the file names
<isene>
adam12: ^^
<adam12>
isene: What's the stdin look like with a filename with a space? can you get a real sample? Just curious.
dionysus69 has quit [Remote host closed the connection]
<leftylink>
if the claim is that the now-commented line 625 works if uncommented, then the road should be as follows. see what `echo $w3m_command` produces in imgw3m.sh, and reproduce that exactly on line 624 in rtfm. it should quickly become obvious what the difference is
<leftylink>
I skipped a few steps
bmurt has joined #ruby
<leftylink>
see what `echo $w3m_command` produces in imgw3m.sh, without piping it to w3mimgdisplay. compare it against the argument to stdin_data on line 624. resolve any discrepancies
<isene>
The problem is I cannot for the love of tomatoes seem to get the quoting of the variables and the full command issued to w3mimgdisplay correct
<leftylink>
I thought the claim is that you've already gotten it correct in imgw3m.sh
dionysus69 has quit [Ping timeout: 272 seconds]
<leftylink>
if someone has already gotten it correct in one place, it's less work to move it from one place to another than it is to be forced to figure it out from scratch
<adam12>
isene: I can't run w3imgdisplay locally so best I could do is help you compare pipe output
<adam12>
isene: Why `echo -e` is used is a mystery to me (there's no backslashes in there that need escaping), and maybe that's the clue.
<leftylink>
I think I didn't attack the heart of the issue when I made my assertion at 21:54... I should state a revised assertion
<leftylink>
it would be very unbelievable to me if w3mimgdisplay used a shell to parse the contents of its standard input. the fact that imgw3m.sh works, given its current contents, https://github.com/isene/RTFM/blob/main/imgw3m.sh, is more evidence that it does not.
<isene>
adam12: There would be backslashes in image file names that has escaped characters...
<isene>
leftylink: I first tried to do it all inside RTFM, in Ruby, gave up because I couldn't escape everything correctly, did it via that bash script and it turned out to work nicely :-/
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Macrobiotic has joined #ruby
TCZ has joined #ruby
TCZ has quit [Remote host closed the connection]
<leftylink>
if it all works nicely with the bash script, then that's a great starting point to get it working in pure Ruby. we can even take it in steps
<leftylink>
that would be a first incremental step that can be taken
<isene>
leftylink: I need someone to hold my hand on this apparently - but it's 2:18 am here and I need to get up in 5 hours ...
<isene>
Let me try that before I faint from lack of sleep. 1 min
<leftylink>
and then, once that is confirmed, then what we would want to do is is compare what imgw3m.sh is outputting vs what's currently there in 624 and resolve the differences (which will become pretty obvious on inspection. as mentioned before, w3mimgdisplay is seemingly not using a shell to interpret its stdin (and why would it?)
klaas_ has joined #ruby
klaas has quit [Read error: Connection reset by peer]
<isene>
The weird thing is that I get an error when inputting an image file name with a space in it - even if I enclose the file name in " " or in ' ' - BUT when I call that from RTFM when it's working - it DOES work when I enclose the file names in " " even when there are spaces in there
<leftylink>
so that would tell you that while it's good hygiene to fix the error, fixing it won't fix the main problem currently being dealt with
<leftylink>
now, the error is from [. even though it looks like [ doesn't have a manual page... `man test` is it.
<leftylink>
... I suppose its manual page isn't really all that helpful for this particular one though
<leftylink>
hmm, so how to explain this one
<leftylink>
that shells don't try to be smat about anything and just interpolate? eh, no, that's not helpful in this context
<leftylink>
I guess the least ambiguous way I would have to explain that would be by an example I guess
<leftylink>
echo 'echo you gave me $1 and $2' > a.sh; echo 'sh a.sh $1' > b.sh; sh b.sh '1 2 3'
<leftylink>
no, that doesn't really help either
<leftylink>
huh, this ain't easy to explain
* leftylink
scratches head
<isene>
leftylink: I really appreciate your help. Really, really. But I'm fainting from lack of sleep. Need to pick this up tomorrow :-/
orbyt_ has joined #ruby
<leftylink>
well, perhaps that will give me time to reflect on how to explain what's happening
<isene>
:-)
<isene>
good night
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bmurt has joined #ruby
fippy__ is now known as fippy
howdoi has quit [Quit: Connection closed for inactivity]
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
elcontrastador has joined #ruby
tpanarch1st has quit [Ping timeout: 260 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cfjk6 has joined #ruby
Black has joined #ruby
c0san0stra has quit [Ping timeout: 256 seconds]
miah has quit [Ping timeout: 256 seconds]
miah has joined #ruby
kenichi has quit [Ping timeout: 256 seconds]
Cork has quit [Ping timeout: 256 seconds]
go|dfish has quit [Ping timeout: 256 seconds]
Benett has quit [Ping timeout: 256 seconds]
cfjk has quit [Ping timeout: 256 seconds]
cfjk6 is now known as cfjk
bmurt has joined #ruby
kenichi has joined #ruby
lucasb has quit [Quit: Connection closed for inactivity]
<naftilos76>
hi i have been struggling to use ruby logger in a daemonized script without success. If i remove the block that daemonizes the code the logger works fine but as a daemon i get the following errors: log shifting failed. closed stream\nlog writing failed. closed stream
<naftilos76>
In order to try i am using minimal code
<isene>
leftylink: havenwood Fixed it! The culprit was indeed the "-e" in "echo -e". Open3 is buggy, so the final code became simple and oldfashioned: https://github.com/isene/RTFM/blob/main/rtfm#L623
johnny56 has joined #ruby
imode has quit [Quit: WeeChat 2.9]
gigetoo has joined #ruby
<havenwood>
naftilos76: Instantiate the Logger inside the #run_proc block.
BSaboia has joined #ruby
<leftylink>
that is a weighty accusation, but I am not personally harmed enough by the accusation that I feel the need to contradict it
<leftylink>
I would however urge the need to revisit the accusation for personal learning purposes
imode has joined #ruby
<leftylink>
as follows.
<leftylink>
I hope we can agree to use cat as a demonstration
<leftylink>
oh, no, that insufficiently demonstrates what needs to be demonstrated... I will have to retract and revisit if I get a working example
<leftylink>
or it could just mean I was just wrong, in which case the fact that I was an asshole about it didn't pay off at all
<leftylink>
if I was an asshole but was right, then at least I was right. but if I was an asshole and was wrong, then I was an asshole for no good reason
<leftylink>
so I should never be an asshole if there's even the slightest chance of me being wrong
<leftylink>
damn. in that case, I apologise for being an asshole
Jnco has joined #ruby
burgestrand has quit [Quit: burgestrand]
cnsvc has quit [Ping timeout: 240 seconds]
j416 has joined #ruby
supercoven has joined #ruby
<leftylink>
ruby -rshellwords -e 'image = Shellwords.escape("a b c d"); puts `echo hello #{image} bye | cat`'
<leftylink>
ruby -rshellwords -ropen3 -e 'image = Shellwords.escape("a b c d"); puts Open3.capture2("cat", stdin_data: "hello #{image} bye")[0]'
<leftylink>
ruby -ropen3 -e 'image = "a b c d"; puts Open3.capture2("cat", stdin_data: "hello #{image} bye")[0]'
<leftylink>
one of these three is not like the other two.
<leftylink>
understanding why is important, instead of throwing around accusations against Open3
<Jnco>
hey .. I'm the founder of Occupi.us, we're changing the way people see homes by integrating self-showings into listing platforms. We could really use some help on the product side, obviously we are a ruby shop, if anyone is has bandwidth and interested please PM me, cheers. xD
cloud69 has quit [Quit: Connection closed for inactivity]
j416 has quit [Ping timeout: 256 seconds]
j416 has joined #ruby
burgestrand has joined #ruby
akem has joined #ruby
ur5us has joined #ruby
<naftilos76>
havenwood: thanks it worked
imode has quit [Ping timeout: 256 seconds]
ur5us has quit [Ping timeout: 264 seconds]
dionysus69 has joined #ruby
cloud69 has joined #ruby
dionysus69 has quit [Ping timeout: 256 seconds]
fercell has joined #ruby
fandre1986 has joined #ruby
<isene>
leftylink: The reason I know that it is buggy is this: I issue the very same command - as it stands in backticks in RTFM now and the same with Open3. It does work - most of the time. It /sometimes/ does not (leaves terminal blank instead of showing the image) - it also seems slower than the backticks variant. It's not like I need to send time diving into Open3 - but would leave it at that.
naftilos76 has quit [Quit: Leaving]
<isene>
havenwood: So, rtfm is now what I could call on a plateau of feature completeness. If you wanna look at the code and spank me, feel free to do so.
burgestrand has quit [Quit: burgestrand]
extrowerk has quit [Ping timeout: 256 seconds]
TCZ has joined #ruby
gix has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
gix has quit [Ping timeout: 256 seconds]
extrowerk has joined #ruby
extrowerk has quit [Client Quit]
extrowerk has joined #ruby
gix has joined #ruby
gix has quit [Disconnected by services]
fandre1986 has quit [Quit: Connection closed]
extrowerk has quit [Quit: Bye!]
extrowerk has joined #ruby
gix has joined #ruby
BSaboia has joined #ruby
BSaboia has quit [Client Quit]
ruurd has quit [Quit: bye folks]
burgestrand has joined #ruby
BSaboia has joined #ruby
Rudd0 has quit [Ping timeout: 240 seconds]
BSaboia has quit [Quit: This computer has gone to sleep]
TCZ has quit [Quit: Leaving]
fercell has quit [Ping timeout: 272 seconds]
dionysus69 has joined #ruby
BSaboia has joined #ruby
dionysus70 has joined #ruby
dionysus69 has quit [Ping timeout: 246 seconds]
dionysus70 is now known as dionysus69
BSaboia has quit [Quit: This computer has gone to sleep]
ruurd has joined #ruby
derpadmin has joined #ruby
BSaboia has joined #ruby
BSaboia has quit [Client Quit]
BSaboia has joined #ruby
dviola has quit [Quit: WeeChat 2.9]
silverdust has joined #ruby
BSaboia has quit [Client Quit]
dka has quit [Quit: My Ex-Girlfriend once told me: I'm not a slut, I'm just popular]
silverdust has quit [Ping timeout: 246 seconds]
BSaboia has joined #ruby
BSaboia has quit [Client Quit]
chouhoulis has joined #ruby
chouhoulis has quit [Ping timeout: 260 seconds]
Retropikzel has quit [Quit: Vision[0.10.3]: i've been blurred!]
BSaboia has joined #ruby
Retropikzel has joined #ruby
weaksauce has quit [Ping timeout: 240 seconds]
BSaboia has quit [Client Quit]
Milos has quit [Ping timeout: 240 seconds]
BSaboia has joined #ruby
BSaboia has quit [Client Quit]
Milos has joined #ruby
silverdust has joined #ruby
cloud69 has quit [Quit: Connection closed for inactivity]
BSaboia has joined #ruby
BSaboia has quit [Read error: Connection reset by peer]
akem_ has joined #ruby
akem has quit [Ping timeout: 246 seconds]
trigcode has joined #ruby
dionysus69 has quit [Ping timeout: 260 seconds]
dka has joined #ruby
ChmEarl has joined #ruby
bmurt has joined #ruby
BrianWGray has quit [Quit: Give a man a phish, you might get his credentials. Teach a man to phish, he'll get someone elses.]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
TCZ has joined #ruby
rippa has joined #ruby
cd has joined #ruby
trigcode has left #ruby [#ruby]
Inoperable has quit [Quit: All your buffer are belong to us!]
burgestrand has quit [Quit: burgestrand]
Rudd0 has joined #ruby
Inoperable has joined #ruby
dka has quit [Quit: My Ex-Girlfriend once told me: I'm not a slut, I'm just popular]
TCZ has quit [Quit: Leaving]
TCZ has joined #ruby
cthulchu has joined #ruby
chouhoulis has joined #ruby
dka has joined #ruby
TCZ has quit [Quit: Leaving]
elcontrastador has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
weaksauce has joined #ruby
Black has joined #ruby
Benett has quit [Ping timeout: 240 seconds]
Glumetu has quit [Quit: Glumetu]
Black is now known as Benett
Ediz has quit [Read error: Connection reset by peer]
orbyt_ has joined #ruby
bmurt has joined #ruby
howdoi has joined #ruby
gix has quit [Quit: Client exiting]
gix has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<nakilon>
there is a gem and there is an attribute there that can be nil by default so there is `def ylabel_length ; ylabel&.length || 0 ; end`
<nakilon>
isn't it the same as `ylabel.length if ylabel` but more cryptic?
<nakilon>
I don't see how &. makes Ruby better...
<nakilon>
oh, not the same, but... ylabel ? ylabel : 0
<nakilon>
(forgot .length, oh, I'm so used to chats with editable messages)
<fippy>
<nakilon> Yes, there is
<fippy>
andand
cloud69 has joined #ruby
bmurt has joined #ruby
imode has joined #ruby
bocaneri has quit [Remote host closed the connection]
cliluw has joined #ruby
gray_-_wolf has joined #ruby
titanbiscuit has joined #ruby
ur5us has joined #ruby
pwnd_sfw has quit [Read error: Connection reset by peer]
pwnd_sfw9 has joined #ruby
mohsen_in has joined #ruby
mohsen_in has quit [Remote host closed the connection]
cliluw has quit [Ping timeout: 256 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ellcs has joined #ruby
ellcs has quit [Ping timeout: 260 seconds]
donofrio has joined #ruby
zofrex has joined #ruby
<zofrex>
rubocop is (rightfully) complaining that I have defined constants inside `describe` blocks (Minitest). They get hoisted to global scope from there, even though a describe block creates a class
<zofrex>
what's a good alternate way to define constant test data that's re-used in many tests?
<adam12>
zofrex: What's the contstant you're creating? Is it pure or does it have side effects?
<zofrex>
it's pure, adam12
hiroaki_ has quit [Ping timeout: 256 seconds]
<zofrex>
an example: [0, 0, 0].pack('w*').freeze
<adam12>
zofrex: iirc, minitest recommends something like SETUP = begin; YOUR_CONST = ...; end. I wonder what Rubocop thinks about that.
<adam12>
zofrex: (outside of a describe block, naturally).
<adam12>
zofrex: If you really feels like it fits in the describe block more naturally, a local is likely more relevant (ie. let() or something).
akem_ has quit [Ping timeout: 240 seconds]
<adam12>
zofrex: If neither of those seem suitable, minitest-hooks.
<havenwood>
zofrex: You could alternatively extract a test helper module and put constants there.
<havenwood>
TestHelper::FOO #=> "\x00\x00\x00"
<zofrex>
adam12: Rubocop also objects to the SETUP = ... construction. I wonder how that gets disambiguated if you have more than one in a single context...
<zofrex>
I forgot that Minitest also has let(), that seems like a good option here
<zofrex>
thank you :)
<havenwood>
zofrex: #let is the standard go to :)
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood>
An aside, but I really like #prove_it! for Minitest :)
<zofrex>
havenwood: if I do that, then I have to change the top-level `describe` to an explicit class, at which point I can use consts, or use inheritance to share code with the describe blocks. which isn't a bad option! but I was trying to stick to using describes for consistency :)
<zofrex>
(do that = helper module)
<havenwood>
zofrex: I don't get why the helper module means you need an explicit describe class.
<zofrex>
oh, can you include modules in a describe block?
<havenwood>
zofrex: I just mean create a separate helper file with a module containing constants that you use in the describe block explicitly.
<havenwood>
zofrex: An include would get you back to top level constants, I think.
<zofrex>
oh I see what you mean
<zofrex>
yeah that woudl also work :)
<zofrex>
btw if you have two SETUP constants in different describe blocks, you get a warning: warning: already initialized constant RuneterraCardsSpec::SETUP
<zofrex>
and I'm not 100% confident it will actually do the right thing behaviour-wise, there. that's fun
orbyt_ has joined #ruby
<adam12>
Interesting, but not surprising I guess.
<adam12>
havenwood: I enjoy that you've done spec/assert style in that project.
<adam12>
I've gone completely back to test-unit style, because minitest-sprint can run the names of tests _much_ easier, at least that I can tell.
hiroaki has quit [Ping timeout: 256 seconds]
hiroaki has joined #ruby
hiroaki has quit [Ping timeout: 265 seconds]
<cloud69>
for scrapers and such in a rails app, wouldn't it be better to have them as rake tasks as opposed to incorporating them into models and controllers?
<cloud69>
seems a bit overkill imho
hiroaki has joined #ruby
<havenwood>
cloud69: It depends. Rake task run as Active Job jobs is common.
<adam12>
cloud69: I'd personally make sure it's encompassed in a class or module and then just make the rake task invoke it (or trigger the active job for it).
<adam12>
cloud69: Since testing rake tests is neigh impossible with any type of nicety.
<cloud69>
adam12: class or module inside the rake task right?
<adam12>
cloud69: I'd maybe be inclined to put it in lib/
<adam12>
cloud69: lib/your_app_name/scrapers or something
<adam12>
cloud69: I don't remember the semantics for reloading in lib/ for Rails tho, so you'll need to see what needs to happen for that.
<adam12>
You don't necessarily need the your_app_name namespace either. It's just an example.
<cloud69>
great
hiroaki has quit [Ping timeout: 246 seconds]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<cloud69>
so yeah you guys were right my ecommerce affiliates do offer live json feeds
<cloud69>
for my reddit clone im planning to scrape reddit and it seems they offer a live feed as well, how convenient
<nakilon>
lol
<nakilon>
there is already some service that consumes reddit, you won't be able to scrape it all
<nakilon>
and more important, their API is the crappiest API you can find in web
<cloud69>
nakilon: what do you mean? i have to use nokogiri and .css() instead?
<cloud69>
ah i see
<nakilon>
they can suddenly return HTML for .json url
<cloud69>
bastards
<nakilon>
they can return error code but still return the page, and vise versa, or return one code saying it's another one
<cloud69>
they do that just to f with people?
<nakilon>
their .rss link is actually giving .atom, and it includes 5-10 RFC implementation errors, and they don't fix them
<cloud69>
hehe
<nakilon>
they switched to this broken atom implementation silently and all consumers, like feedly, etc. had to adapt to it
<nakilon>
all the best practices of python
<nakilon>
also they ban in /r/bugs for reporting bugs, lol, I mean you'll do git commit -m "Reddit is ****" a lot if you try to automate anything around it
chouhoulis has quit [Remote host closed the connection]
<cloud69>
lol
<nakilon>
ah, also about feeds -- they can suddenly put a bunch 10 years old posts onto /new, so you should not even expect the feed and ids to be ordered
<cloud69>
should maybe make a function then to be like "ERROR: HTML has likely changed. Exiting..."
ecuanaso has joined #ruby
pwnd_sfw9 has quit [Ping timeout: 264 seconds]
<nakilon>
their API changes without a changelog, ENUMs are undocumented, they don't respond to users, and they always try to reduce your abilities to use the API (that makes no sense, right? I know) -- direct links can become dead or lead to a post page at any moment
hiroaki has joined #ruby
<cloud69>
sounds like the scraper has to act like a human then? like delays, stumbling around like an idiot, clicking links all over the place, going back and forth
<apotheon>
20:38 < nakilon> all the best practices of python
<apotheon>
Do Python devs often do that kind of thing?
<apotheon>
I hadn't noticed.
<cloud69>
hey there apotheon !
<cloud69>
(if im scraping the html with nokogiri that is)
<apotheon>
hi
<apotheon>
I'm glad I've never had to use any reddit APIs or feeds.
<cloud69>
im also thinking about making something like this - https://www.reddit.com/r/EEW/wiki/index (from the ##covid-19 channel) - to get the latest corona news from twitter tags
* nakilon
just has several reddit bots running
<apotheon>
I mostly just try to avoid spending time on reddit. I succeed for months at a time.
<cloud69>
nakilon: that makes sense. i'd love to know more
<cloud69>
apotheon: hehe
<nakilon>
I try too, that's why I made smart RSS filters that reads all my subscriptions but emits only N posts per day/week
chouhoulis has joined #ruby
<apotheon>
That's less avoid-reddit-success than I'd want.
<crashoverride>
I am following a somewhat old tutorial, and it mentions "rvm wrapper $stuff"
<crashoverride>
now, rvm wrapper does not work that way anymore.
<apotheon>
nakilon: Only the part about never receiving reddit links seems ideal.
<crashoverride>
any idea how to create wrappers with ruby 2.7.2 and rvm 1.29.10?
<crashoverride>
according to the usage, rvm wrapper is only for REgenerating the wrappers.
<crashoverride>
oh wait, now it needs the full path, apparently.
mustmodify has joined #ruby
<mustmodify>
I'm trying to write a unit test for a meta bit of code. If I create an anonymous class (ie var = Class.new(ancestor)), can I fake class.name easily?
<mustmodify>
in a way that won't break ruby?
<mustmodify>
:)
<adam12>
mustmodify: def var.name; "Foobar"; end ?
<mustmodify>
Ohhhhh let me try.
<adam12>
mustmodify: If you can show some of what you've already done/tried, maybe a better answer can be curated for you.
<zofrex>
what are the pros/cons of declaring development dependencies for a gem in the gemspec vs the gemfile
<adam12>
zofrex: Pros for gemspec: Reverse Dependency on Rubygems. Cons (IMHO) I never remember the construct for `gem install dependency --with-dev-dependencies`.
<zofrex>
ah, hadn't considered the dependency info :)
Emmanuel_Chanel has quit [Ping timeout: 272 seconds]
Emmanuel_Chanel has joined #ruby
cnsvc has quit [Remote host closed the connection]
cnsvc has joined #ruby
al2o3-cr has joined #ruby
ivz_hh has quit [Remote host closed the connection]
ivz_hh has joined #ruby
ivz_hh has quit [Remote host closed the connection]
ruurd has quit [Ping timeout: 258 seconds]
ivz_hh has joined #ruby
ecuanaso has joined #ruby
TCZ has joined #ruby
ecuanaso has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ecuanaso has joined #ruby
<crashoverride>
oh, I forgot to leave
crashoverride has left #ruby [#ruby]
mustmodify has left #ruby [#ruby]
ruurd has joined #ruby
ur5us has quit [Ping timeout: 264 seconds]
ecuanaso has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]