<adam12>
johnjay: It can stand in for a lot of pieces of make. I don't think it's necessarily better than Make or CMake, but if you're in a Ruby project it's nice to use a tool that is also written in Ruby.
<adam12>
johnjay: There's no integration between autotools and rake, so most C projects likely would never use it.
Sankalp has quit [Ping timeout: 256 seconds]
roadie has joined #ruby
roadie has quit [Ping timeout: 248 seconds]
<johnjay>
ah ok
<johnjay>
i meant in the sense of that yes, using it for non-ruby projects
roadie has joined #ruby
roadie has quit [Ping timeout: 248 seconds]
roadie has joined #ruby
Sankalp has joined #ruby
roadie has quit [Remote host closed the connection]
roadie has joined #ruby
CrazyEddy has joined #ruby
roadie has quit [Ping timeout: 248 seconds]
John_Ivan has joined #ruby
<ox1eef_>
There's the rake-compiler gem that's helpful when building Ruby C extensions.
<johnjay>
question. if i declare a variable inside a loop, can i access it outside the lop
<johnjay>
er loop. e.g. while i < 10 do i += 1; j = 17; end then can I access j
Rudist17 has quit [Ping timeout: 256 seconds]
kokoro has quit [Ping timeout: 248 seconds]
kokoro has joined #ruby
<sphex>
johnjay: in this case yes because "while" doesn't create a block for its body
<ox1eef_>
You can use loop { } to avoid that, or wrap the while body in a proc.
Linux_Kerio has joined #ruby
grenierm has joined #ruby
<johnjay>
proc?
<johnjay>
well i tried wrapping it in {} but it didn't like that
<johnjay>
how do I know if a loop creates a block or not
roadie has joined #ruby
Pixi` has quit [Quit: Leaving]
Pixi has joined #ruby
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
Thiago has quit [Ping timeout: 245 seconds]
johnjay has quit [Remote host closed the connection]
TomyLobo has quit [Ping timeout: 256 seconds]
mexen has joined #ruby
tomtmym has joined #ruby
tomtmym has quit [Changing host]
tomtmym has joined #ruby
teclator has joined #ruby
crespire has quit [Ping timeout: 240 seconds]
crespire has joined #ruby
Linux_Kerio has quit [Quit: Konversation terminated!]
Linux_Kerio has joined #ruby
<leftylink>
too bad. I would have answered that question had they not left
<leftylink>
I remember that back in 2019 we were discussing this, baweaver informed me that in a certain other language they call this the immediately invoked function expression
<leftylink>
the departure of baweaver from this channel was a huge loss
<isene>
After a few hours of coding, I now got a working shell written in Ruby with configurable prompts and aliases. This is fun stuff. Will aim to make this awesome (at least for me)
<Shell>
Nice. Job control next? :)
fat_shinobi has joined #ruby
Bentha has joined #ruby
classi10 has quit [Ping timeout: 260 seconds]
infinityfye has joined #ruby
<rapha>
weaksauc_: thats nice to know. perhaps time i checked it out again.
<rapha>
isene: what are you aiming for? something like fish?
<ox1eef_>
The default rails stack recommends hotwire these days, it is a refreshing approach given the advent of React but I think you will find a lot of Rails shops using React or Vue. So the space is a bit more diverse than before.
<ox1eef_>
And I think it makes sense. React and Rails doesn't make a whole lot of sense. There's little need for actionview anymore, and more often than not you just want controllers that spew JSON.
<rapha>
hmm. having to learn some react at work atm. colleague showed me vue (might be the project i'll be put in after). vue somehow seems more coherent and easier to understand, especially when react is paired with redux. is hotwire another view framework?
unindi27 has joined #ruby
<ox1eef_>
hotwire is somewhat a revert to the classical approach where you have typical actionview views that are rendering HTML, except it is done in a such a way that only the HTML that has changed is sent across the wire.
<rapha>
so... something on top of websockets?
<ox1eef_>
I haven't actually used it, but that's my understanding of it.
<rapha>
k
<ox1eef_>
I have used Vue, and React in my past two jobs and I definitely prefer React.
<rapha>
because on its own its leaner?
Bentha has quit [Ping timeout: 246 seconds]
<ox1eef_>
I like how a component is just a function that returns a JSX element / node.
<ox1eef_>
Simple concept. Not a whole lot to learn in that regard.
<rapha>
html inside of js did feel weird in the beginning but in practice it works well
<ox1eef_>
Agreed.
<ox1eef_>
I think Vue only separates the two at the conceptual level as well. In the end it is still bundled into JavaScript.
Linux_Kerio has joined #ruby
<rapha>
how do you feel about Svelte?
<isene>
rapha: Maybe. But knowing the work Axel put into creating fish, I doubt I'll get that far
<ox1eef_>
I don't know much of anything about Svelte.
<rapha>
me neither
<rapha>
it's just said to be the thing that cleans up the mess created by the current "big 3"
<rapha>
i have my doubts but know nothing, so...
<ox1eef_>
Yeah, that's how I understand it too. Kind of like the merb of the Rails world or something like that.
<isene>
Having a brain fart moment, so please help me out; I have a string STR = "a b c a d" and a hash with the format {"a" => "foo", "b" => "bar"}. I want to replace all occurences of the hash keys with the hash values in STR. The result would be "foo bar c foo d". How do I get this?
<ox1eef_>
While cool in their own right, I don't think I would use them. Too error prone.
<leftylink>
this also needs some care if some replacements are substrings of things not to be replaced
<leftylink>
for example if we want to make a swear filter
<isene>
But - it will also replace occurences of any command inside other commands. So I need a way to have {"ls" => "ls --color -F"} not replace the 'ls' in e.g. "else". So - only replace if it is preceeded by start-of-line or a pipe and proceeded by a space or a pipe.
<ox1eef_>
A killer Ruby shell might be able to understand POSIX shell, so you could copy&paste scripts that already exist.
<mooff>
are you currently trying to handle command aliases?
<mooff>
for instance, "ls" resolving to "ls --color"
<mooff>
are user commands evaluated as Ruby?
<isene>
mooff: yes and yes
<mooff>
in that case, does the user's command invoke an "ls" method in Ruby?
<mooff>
maybe command aliases just override / define a method
<isene>
At the moment, I simply system() everything
<mooff>
from method_missing?
TomyLobo has joined #ruby
<isene>
When I first do @alias.keys.map{|k| "\b#{k}\b"}, I get e.g. {"\bls\b"=>"ls --color -F", "\bl\b"=>"less"}, but when I then do Regexp.union(@alias.keys), the \b changes into \x08 as in /\x08ls\x08|\x08l\x08/ which ends up not matching anything (while the expected result /\bls\b|\bl\b/ would match as intended) - How would I go around preserving the \b with the Union or otherwise?
<leftylink>
it's because "\b#{k}\b" is a string, whereas it should be a regex instead
Cork has quit [Ping timeout: 240 seconds]
<isene>
OK, but the keys are strings, so where would I interject a command to make it a regex (as union takes strings to transform into a regex)?
<isene>
Right, but I cannot have regex objects as keys, so my beautiful construct does not work: a = @alias.transform_keys {|k| "\b#{k}\b"}; cmd.gsub(Regexp.union(a.keys), a)
<leftylink>
13:52:59 < leftylink> it's because "\b#{k}\b" is a string, whereas it should be a regex instead
<leftylink>
well, clearly a can't be the replacement arg to gsub
<leftylink>
since the replacement needs strings
<leftylink>
but the arg to Regexp.union should absolutely be Regexps, each starting and ending with \b
<mooff>
try "\\b#{k}\\b"
<mooff>
\b means something different in string literals, it's the ancient ASCII "backspace" haracter
unders has joined #ruby
<mooff>
so you gotta escape it
<isene>
mooff: That doesn't work as the Regexp.union(a.keys) then becomes /\\bls\\b|\\bl\\b/
<isene>
Seems a step in the right direction - but here's a weird twist: Regexp.union([/\bls\b/, /\bl\b/]) -> /(?-mix:\bls\b)|(?-mix:\bl\b)/
<isene>
If that would have worked, I would have the whole solution wrapped like this: a = @alias.transform_keys {|k| "\\b#{k}\\b"} ; cmd.gsub!(Regexp.union(a.keys.map{|k| Regexp.new(k)), a)
teclator has joined #ruby
<isene>
but nope, the Union of regexp objects seems not to like that
<leftylink>
feel free to use the block form to debug. for example have it print out "I MATCHED {_1}"
<leftylink>
I always forget the # huh
<leftylink>
"I MATCHED #{_1}"
<leftylink>
been doing that a lot lately
<leftylink>
I don't see why there is reason to be concerned about the union
unders has quit [Quit: Best CPUs can count to infinity twice without being bugged out by zero division errors or whatnot.]
<isene>
With @alias = {"ls"=>"ls --color -F", "l"=>"less"} and cmd = "ls less", the code `a = @alias.transform_keys {|k| "\\b#{k}\\b"} ; cmd.gsub!(Regexp.union(a.keys.map{|k| Regexp.new(k)), a)` leaves cmd as " else"
<leftylink>
well of course. because the key doesn't exist in the hash (a)
<leftylink>
when you, as I instructed, change the gsub to a { "MATCHED #{_1}" }, you see it says "MATCHED ls". and now we ask, does ls exist in a? no it doesn't. a contains \bls\b, not ls. therefore, replaces with nothing.
<isene>
So, how would you go about resolving that?
<leftylink>
theh hash passed to gsub needs to have ls as a key, not \bls\b. luckily, you already have one handy that does have ls as a key.
<mooff>
>> h = {"ls" => "yay", "l", "also yay"}; r = h.transform_keys { |k| Regexp.new("\\b#{k}\\b") }; "ls && l".gsub(r)
<mooff>
also note that leftylink provided all the clues!
perrierjouet has quit [Ping timeout: 240 seconds]
perrierjouet has joined #ruby
Cork has joined #ruby
nmollerup has joined #ruby
c10l has joined #ruby
___nick___ has quit [Ping timeout: 268 seconds]
cek has quit [Quit: Connection closed for inactivity]
Guest26nakilon has joined #ruby
<Guest26nakilon>
how do I wait until there is a newline-ending string in a socket?
<Guest26nakilon>
p(@socket.wait_readable(1)) and @socket.gets(chomp: true) -- prints "#<TCPSocket:fd 15, AF_INET, 192.168.1.68, 58734>" but then raises Connection reset by peer @ io_fillbuf - fd:15 (Errno::ECONNRESET)
<Guest26nakilon>
refactoring the irb bot for 100th time
<Guest26nakilon>
*irc
<Guest26nakilon>
it always was with #select but I thought the wait_readable is what it should be replaced with today
<Guest26nakilon>
was I wrong?
<Guest26nakilon>
I wanted to rewrite because with select it was raising the error in the same place in some rare cases, like if select said that there is something but then the following gets could not read that anyway
<Guest26nakilon>
or is the exception in gets inavoidable?
<Guest26nakilon>
can't easily share the full code, it's huge
<Guest26nakilon>
"but select can't indicate when one is there" -- I need something to indicate
<mooff>
ah
<mooff>
gets returns the next line in the stream, or nil, if there isn't one
<mooff>
presumably your buffer doesn't contain a "\n" yet when it's putting nil
teclator has joined #ruby
<Guest26nakilon>
do you mean there is some text but jut without newline?
<mooff>
yeah, that's the guess
<Guest26nakilon>
fuck twitch, it looks wrong
<Guest26nakilon>
let's see...
<Guest26nakilon>
socket.read_nonblock(100) throws: end of file reached (EOFError)
<mooff>
are you printing everything you send and receive?
<mooff>
if so, what does the exchange look like
<mooff>
maybe Twitch doesn't like your registration messages and closes the connection
<mooff>
have you got a cleartext tunnel to ircs://irc.chat.twitch.tv or something?
<Guest26nakilon>
heh, if I use `read` instead of `read_nonblock` it steals data from the following gets and the program can't reach the moment when my issues starts (only after a few seconds of data transfer)
<Guest26nakilon>
mooff I always printed only after gets
<Guest26nakilon>
yeah maybe it it closes connection telling me some slurs but without \n
<mooff>
read / read_nonblock will advance the cursor, so both should 'steal' data from being visible to gets
<Guest26nakilon>
mooff never heard about this link you gave
<mooff>
ircs:// is just the scheme for IRC over TLS
<mooff>
probably will end up needing something like that
<Guest26nakilon>
I just have to expire my token and since they've made some API changes now the third party service people user to obtain oauth token demands client-secret so I decided to generate token on my own and it appears that it expires often so I have to add the access token refresh to the irc bot, and that's what I'm now trying to handle
<Guest26nakilon>
first, before doing the refresh-token routine I need to figure out the loop I get
<mooff>
fwiw, i don't think i've had to change my bot's PASS token in ~3 years
<Guest26nakilon>
I didn't either
<mooff>
what's changed?
<Guest26nakilon>
but I forgot the password, and now tokens are expiring
<mooff>
oh God
* mooff
shudders in OAuth
<mooff>
preserve your sanity and switch to simple readline() loop if you can
<mooff>
until you're sure it works
<Guest26nakilon>
first you get the "auth code", then get the auth token and refresh token, and you can't specify the expiration -- after hours the auth code is expired and when auth token is expired you have to get new via refresh one
<mooff>
ffs, so you have to do OAuth in your bot to get an IRC password?
<Guest26nakilon>
yes )
<mooff>
i should hold on to my existing token for dear life
aesthetikx has joined #ruby
<Guest26nakilon>
where is io#readline doc?
<mooff>
pandabot: ri IO.readline
<Guest26nakilon>
ah I see, it's somehow not in google index
<mooff>
Guest26nakilon: ri IO.readline :D
<Guest26nakilon>
but it's blocking
<mooff>
yes
<Guest26nakilon>
ok maybe I should face the EOF error but somehow retrieve what was on queue before the end
<mooff>
get the auth working before doing non-blocking
<Guest26nakilon>
not sure about that; I want to have a clear view on what's happening first
<Guest26nakilon>
because I had some infinite and fast loop when I alt+tabbed to it today
<Guest26nakilon>
should better recognize when my auth is broken and not loop
<Guest26nakilon>
I imagine I should do #select, then #read to a some StringIO and then gets from it
<mooff>
you definitely want some additional buffer, i think
<mooff>
expect keeps any unused data in a buffer for next time, if the timeout expires
<Guest26nakilon>
but wait, if the connection was closed as we presume, it would not loop like it's seen in my gist (it loops for many pages until I stop it) so the connection is still on; and no matter if I make a kludge with StringIO or use the IO#expect I'll can't use my wanted "\n" delimeter there it won't reach it
<Guest26nakilon>
omg, "I'll can't" -- sorry for my english
<Guest26nakilon>
rarely use it in last months
<Guest26nakilon>
yeah looks like I have to make a buffer or I'll never know what's stuck there
<Guest26nakilon>
but bad thing is that it loops through the first line like insane when it's nothing to read; but the #select did the same, I don't know why
<Guest26nakilon>
so this is what is weird about i all; https://dpaste.org/fyvAt/slim -- for several seconds the #select is rightfully stuck returning nil but then it returns the socket while in fact there is nothing to read from it
<Guest26nakilon>
i.e. .read is "" and .nread is 0, but .select isn't nil
<weaksauc_>
Guest26nakilon I think there's a typo on your summary... it should probably be non-heuristic instead of non-eursitic
<Guest26nakilon>
weaksauc_ thank you!
<weaksauc_>
np
<weaksauc_>
i see you made a random csgo map
<weaksauc_>
that's neat
<weaksauc_>
did you see the rouge like one that someone did?
<Guest26nakilon>
yeah but guys with weak PCs said it's lagging; I suppose the engine optimizes the static obstacles but props that can be moved consume more rendering power
<weaksauc_>
ah
<isene>
Can I redefine what "\b" includes or not?
_ht has quit [Remote host closed the connection]
<isene>
I need "-l" not to be treated as "l" when doing "\bl\b"
<Guest26nakilon>
you probably can't recompile the BSP on fly so while the usual map is only rendering what you, you have to render all the dynamic stuff, even if it's not all visible
<Guest26nakilon>
none of those videos have a credit to my one, that AFAIK was the first in csgo ..P
<weaksauc_>
ha lame
tomtmym has quit [Quit: Gone.]
ox1eef_ has quit [*.net *.split]
gr33n7001 is now known as gr33n7007h
ox1eef_ has joined #ruby
Linux_Kerio has joined #ruby
infinityfye has quit [Quit: Leaving]
<mooff>
isene: can't refine \b, but could use a different pattern in place of \b
windfa83 has joined #ruby
dionysus69 has joined #ruby
windfa83 has quit [Client Quit]
roadie has quit [Ping timeout: 248 seconds]
<isene>
While I have full control of regex in vimscript, I'm not quite there in Ruby. How do I do a "match 'l' but not if its preceeded by '-' or followed by '+' "?
<weaksauc_>
negative lookbehind probably
roadie has joined #ruby
<weaksauc_>
((?<!-)\|(?!+))
<weaksauc_>
i haven't tried that but it should work i think