havenwood changed the topic of #ruby to: Ruby 3.2.2, 3.1.4, 3.3.0-preview1: https://www.ruby-lang.org | Rules: https://ruby-community.com | Logs: https://libera.irclog.whitequark.org/ruby
<eam> does ruby have anything simliar to perl's source filter? Like a preprocessor?
eddof13 has joined #ruby
eddof13 has quit [Client Quit]
grenierm has quit [Ping timeout: 246 seconds]
<ox1eef_> I don't think so. Nothing I know of that lets you modify the AST on the fly, which is kind of what Perl is doing ? But there's ruby_parser, ripper, and the option to compile Ruby to byte code.
<ox1eef_> In theory you could modify any of what those three produce, and produce a new script based on it.
<johnjaye> hmm how do i print unicode chars
<johnjaye> i can do puts("\u2665") but I'm not sure how to get there from the number
<eam> perl's is just a cheap preprocessor hack, nothing as fancy as modifying the AST. It's a gsub in a precompliation block like BEGIN
<ox1eef_> I think it should be \u{2665} no?
<ox1eef_> >> "\u{2665}"
<ruby[bot]> ox1eef_: # => "♥" (https://carc.in/#/r/fpow)
<johnjaye> force_encoding doesn't seem to work either
<eam> ox1eef_: ripper might be exactly what I'm looking for
<johnjaye> ox1eef_: i mean what if i have the raw number
<ox1eef_> I haven't heard of anything like that, but there's probably the tooling to do something like that.
<johnjaye> like 169
<adam12> eam: You can modify ruby AST but nothing Ruby "encourages" you to do. Kevin Newton did a talk on it. https://github.com/kddnewton/compiling-ruby
<ox1eef_> Try 169.chr
<eam> ah great. Yeah this is squarely in silly stunt territory
<johnjaye> i did. it gives me some kind of error
<johnjaye> well no it just gives a blank output
<johnjaye> puts 169.chr.force_encoding("UTF-8")
<ox1eef_> Works for me. What's "foo".encoding return ?
<johnjaye> UTF-8
<eam> I made this in perl earlier today and was going to try to reproduce in ruby too https://gist.github.com/eam/e88093628fe305590674c5fccfd97b9b
<johnjaye> you get the copyright symbol for that?
<ox1eef_> No
<ox1eef_> I get f.
<ox1eef_> Oh wait, I did 102.chr
<weaksauc_> that doesn't look valid
<weaksauc_> what's going on there eam
<johnjaye> well as you said there's probably some way to do it
<ox1eef_> Yeah, I'm not sure, \u{} can work but I don't know what it is parsing those numbers as.
<ox1eef_> h
<ox1eef_> Ah*
<ox1eef_> Try ths
<ox1eef_> >> [169].pack('U')
<ruby[bot]> ox1eef_: # => "©" (https://carc.in/#/r/fpox)
<ox1eef_> Hard to determine what that actually is on my screen, maybe copyright symbol.
<johnjaye> oh wow. yeah it is
<johnjaye> that's pretty cool. i have no idea how it works though. but it does
<weaksauc_> that isn't quite right is it?
<johnjaye> i thought pack was related to bits and bit shifting
<weaksauc_> [2665].pack('U') spits out something else
<johnjaye> idk. it prints the right symbols on my terminal
<weaksauc_> not the heart i'd expect
<johnjaye> it doesn't make a heart?
<johnjaye> oh that's the hex value
<johnjaye> you want 9829
<weaksauc_> oh
<ox1eef_> \u{2665} does.
<johnjaye> yes it's implicit hex for the \u syntax
<ox1eef_> >> ["\u{2665}".pack("U")].unpack("U")
<ruby[bot]> ox1eef_: # => undefined method `pack' for "♥":String ...check link for more (https://carc.in/#/r/fpoy)
<weaksauc_> yeah makes sense
eddof13 has joined #ruby
<ox1eef_> Well, TIL.
<johnjaye> i stumbled onto this while trying to investigate determining if a string is a digit
<weaksauc_> what do you mean a digit?
<johnjaye> in C you would do '0' < x and x < '9'.
eddof13 has quit [Client Quit]
<weaksauc_> ah
<johnjaye> surprisingly ruby is smart about < and you can write the same code. even though it's semantically different
<johnjaye> i would hazard a guess that any unicode char range would work
<johnjaye> but i don't know enough about how < works with strings
<ox1eef_> isdigit, isdigit_l
<ox1eef_> (in C)
konsolebox has quit [Ping timeout: 246 seconds]
<weaksauc_> johnjaye you could do it by just doing Float("somestring") and rescuing the error
<weaksauc_> unless you are trying some performance thing
<johnjaye> rescue is ruby's exception handling, right?
<weaksauc_> yeah
<johnjaye> why would converting to float do it
duderonomy has quit [Quit: Textual IRC Client: www.textualapp.com]
<johnjaye> oh you mean for is a digit
<weaksauc_> oh you mean you want to know if it is a single digit?
<johnjaye> right
<johnjaye> i wanted a way different than using a regex
<ox1eef_> isdigit_l is libc, you can most likely interface to it via fiddle.
<weaksauc_> well you could do Integer("somestring") and rescue
<johnjaye> kind of crazy there's all these ways to do such a simple task
<weaksauc_> and check < >
<johnjaye> that's a good point!
<weaksauc_> though it might fail if passed in "1.2"
<weaksauc_> so you'd have to check string length too
<johnjaye> oh good point
<weaksauc_> actually no it will error
yosafbridge has quit [Quit: Leaving]
yziquel has quit [Ping timeout: 246 seconds]
<ox1eef_> Integer("foo", exception: false)
<ox1eef_> You can use it this way to return nil instead
<ox1eef_> But these are boring solutions, try interface with isdigit_l
<weaksauc_> yeah good point
<johnjaye> ah ok. i prefer not to abuse exceptions though unless there's no other way
<weaksauc_> yeah i forgot about that fact
neshpion has quit [Quit: neshpion]
<weaksauc_> that's the beauty of ruby though
<weaksauc_> so many ways
<johnjaye> yes. i like the philosophy a lot more than python
<johnjaye> and ruby often seems like it picks "the right things" from lisp or smalltalk or what not
<johnjaye> i assume all these $- variables are from perl
<ox1eef_> Yep. But tbh they're not appreciated by a large portion of the Ruby community.
<weaksauc_> great for golf but terrible for readability
<johnjaye> i was going to read minitest and prime for some examples
<ox1eef_> Regxp.last_match is often preferred over $1-9.
<johnjaye> try to get the feel of ruby 'style'. but i guess a lot of that would be in rails
<johnjaye> see i would say the opposite. $1 would be one of the more recognizable ones to me
<ox1eef_> rubocop would disagree.
<ox1eef_> But that's the thing, there's style nazis.
<ox1eef_> That's why I prefer to live and let live.
<weaksauc_> johnjaye https://rubystyle.guide/ and the book eloquent ruby
<johnjaye> if you don't mind me asking, do either of you use ruby for your jobs
<johnjaye> if so is it like rails stuff
<ox1eef_> Yep. Rails.
<weaksauc_> i have in the past and it was rails yes
<ox1eef_> I have had a few jobs where it wasn't rails, from webmachine-ruby to a VPN client.
<johnjaye> webmachine...?
<johnjaye> is that like wasm?
<ox1eef_> Nope. Port of a erlang idea to Ruby.
<johnjaye> ah ok. well tbh i am learning ruby for personal use and because it looks fun. not sure i want a webdev type job with rails
<ox1eef_> You have the right idea.
<weaksauc_> it's a great language and has a few big projects that aren't web
<weaksauc_> vagrant, chef, puppet, homebrew, etc
<weaksauc_> metasploit is web adjacent but not really web
<ox1eef_> Also, keep in mind, rubystyle.guide is not official, and is pedantic to the core. It takes the fun out of Ruby. I truly hate it.
dalan038228 has quit [Quit: dalan038228]
<weaksauc_> of course it's pedantic that's the purpose
<weaksauc_> but yeah pick and choose
<ox1eef_> standard is a more easy going alternative that doesn't micro manage the tiniest details and force it down your throat.
dalan038228 has joined #ruby
yosafbridge has joined #ruby
<johnjaye> not saying web is bad or anything. it's just not my area rn
<adam12> Wow. Webmachine. Haven't heard that name in ages.
<johnjaye> it sounds like a brand of ice cream somehow
<adam12> I've been doing Ruby fulltime without Rails since ~ 2014.
<adam12> (Ruby fulltime before that, but WITH Rails)
<johnjaye> ah ok. how would you compare them. is it similar work environment and project style
<adam12> Well, if you're not using Rails, you're using Padrino, Sinatra, plain Rack, Roda, Hanami, etc.
<adam12> Rails definitely "ate the world". Sometimes when I am doing web but _not_ using Rails I feel like I am swimming upstream.
<adam12> Padrino was out of box batteries included like Rails, but nobody on core team seemed to be using it when I started contributing. I had to move on.
<adam12> Sinatra has been around forever. Still maintained. Almost zero batteries (vs Rails). Some people joke you end up re-creating a crappy version of Rails in large Sinatra projects... I might be inclined to believe it.
<adam12> I'd put Rack/Roda/Hobbit/everything else micro in that camp.
<adam12> Hanami is interesting and I've been contributing/trying to contribute to it. Very big goals. Some choices I don't particularly care for but there's a huge lift to learn some of the pieces.
<johnjaye> ah i see
<adam12> I've built a lot of stuff on Roda+Sequel successfully. Lately I've been doing my own "Framework" which is Hanami-Router+Sequel(optional)+some glue code. I like it more than the others, but that is natural for things you build yourself.
<adam12> Roda's routing tree trips up too many people on teams I've found. And I miss real objects/classes where I can extract method and use traditional Ruby programming techniques.
<johnjaye> you sound like you appreciate the web frameworks a lot. makes sense
<adam12> Well, it makes me the money.. so I have no choice. LOL.
<johnjaye> that's odd... you don't use classes when ruby is inherently object based?
<adam12> I'd much rather be doing something backend.
<adam12> Sure, but in Roda, it's basically one giant `if` statement in a single class by default.
<adam12> You need to go out of your way to break it into smaller classes since it wasn't designed that way.
<johnjaye> that's surprising. someone told me ruby is the most oo language they know aside from smalltalk
<adam12> It is.
<adam12> (at least, I think it is)
<johnjaye> i mean. even integers are objects. when you're treating integers as the same as classes you know you are far down the rabbit hole
<ox1eef_> Roda and Sinatra make for good routers, but I'm doubtful about them for web applications. They have a block spaghetti problem.
<johnjaye> in web frameworks, sometimes they don't use the elegant ruby features?
<adam12> ox1eef_: I think hanami-router has done the best with this so far. And if you adopt Hanami proper, you get something akin to Action-domain-responder vs "MVC"
<adam12> I've had a ton of fun with my "framework"
<ox1eef_> What does hanami do differently ?
<adam12> I cribbed the plugin feature from Sequel/Roda/Jeremys's book and have been building all functionality in it. Been nice to "home grow" it in a real app and then extract it up to the framework.
<ox1eef_> Compared to say Rails
<adam12> ox1eef_: #1 is no monkey patching. Except one tiny one around `.html_safe?`.
<ox1eef_> Hrm interesting.
<adam12> ox1eef_: Second one is SRP for controller actions. An action has one public method and it only handles one type of request (vs a Rails controller that handles a bunch of request types around a single domain)
<adam12> Third, which is huge, is the data layer is essentially ROM
<adam12> Which is fantastic, but a huge lift for me from Sequel which I've crawled over every last line of code these last few years :P
<adam12> (and ActiveRecord, which I could personally leave if I had to)
<adam12> It's a really well done framework.
<adam12> Oooh, my net-http PR from 2021 is getting some action.
<ox1eef_> Success :))
<johnjaye> well, it's a bit interesting. i know nothing of frameworks.
<johnjaye> so hearing you guys talk about it just goes ove rmy head
<adam12> johnjaye: I think starting with a framework is nice to keep the bikeshedding to a minimum.
<adam12> but in reality, my favourite projects have been the ones where each piece is independently upgraded. No large Rails upgrades in my recent lifetime.
<ox1eef_> That's kind of the problem. No one keeps it simple. All these ideas (especially ROM) are inherently complex.
<adam12> Yes. That's a huge issue.
<adam12> You can poke through my "framework" if you want. I think it's fairly approachable, but it's missing lots. And it's not fit for public consumption.
<ox1eef_> Bookmarked :)
<johnjaye> i got tired of using github. so i just wrote a bash command to download git repos
<adam12> I'm actually using it for non-web stuff too. So that's kind of interesting.
<johnjaye> it's like 'got adam12/framework-2'
<johnjaye> plus it's faster to search with grep than the web tool
<ox1eef_> Good approach.
<adam12> Nothing wrong with that. I use a tool called ghq for it.
<adam12> Because I would drown in git repos :|
<ox1eef_> xD
<adam12> Apply some sanity to my git cloning.
meimei_ has joined #ruby
meimei has quit [Ping timeout: 246 seconds]
<ox1eef_> Nice
meimei_ is now known as meimei
<ox1eef_> Even if I don't use the tool that's a good pattern.
<adam12> Yep, exactly.
eddof13 has joined #ruby
eddof13 has quit [Client Quit]
<johnjaye> this ghq tool is pretty interesting
<johnjaye> it looks like one of those handy tools you pick up while doing a thing
<adam12> It's one of those weird things you find in a dotfiles repo years ago and carry it with you
ur5us has joined #ruby
<ox1eef_> I reorganized my git repos according to that approach, before it was ~/git/<username> where username could be from github, gitlab, etc. Much nicer this way.
<adam12> Any users of asdf? If so, thoughts?
<johnjaye> is that another framework?
<adam12> johnjaye: Tool for managing installed tools (ruby, node, postgres, etc)
vls has joined #ruby
<ox1eef_> I thought you meant https://rubygems.org/gems/asdf
<adam12> No... but interesting that it's written by Yehuda. LOL
<adam12> I actually just linked to a Yehuda video today. https://youtu.be/4iv3Gk95-v0?si=NDJlfDSPChvDJRFs
lucartc has quit [Remote host closed the connection]
<adam12> I'm eyeballing this instead of asdf. https://github.com/jdx/rtx
<adam12> Have it replace ruby-build, chruby, and maybe arkade for me.
<ox1eef_> I'm not sure I'm sold on the approach. I believe in one tool doing one job well, and I see this tool trying to do that for multiple jobs.
<johnjaye> my biggest fear in getting into web frameworks is rattling off a long list of projects and words
<johnjaye> and i have no idea what any of them are.
<johnjaye> lol
<ox1eef_> Gives me RVM vibes.
<johnjaye> it's like the individual words are english. but they mean something else completely
grenierm has joined #ruby
eddof13 has joined #ruby
eddof13 has quit [Client Quit]
brokkoli_origin has quit [Ping timeout: 246 seconds]
brokkoli_origin has joined #ruby
Ashutosh has joined #ruby
Ashutosh has quit [Client Quit]
f4z4 has quit [Quit: Bye bye…]
f4z4 has joined #ruby
mahlon has quit [Read error: Connection reset by peer]
mahlon has joined #ruby
Vonter has joined #ruby
_ht has joined #ruby
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 255 seconds]
desnudopenguino1 is now known as desnudopenguino
konsolebox has joined #ruby
ur5us has quit [Ping timeout: 246 seconds]
_ht has quit [Remote host closed the connection]
otisolsen70 has joined #ruby
jmjl has quit [Quit: ~nyaa]
otisolsen70 has quit [Remote host closed the connection]
otisolsen70 has joined #ruby
jmjl has joined #ruby
teclator has joined #ruby
willfish has joined #ruby
dviola has quit [Quit: WeeChat 4.0.4]
grenierm has quit [Ping timeout: 246 seconds]
TomyWork has joined #ruby
leon__ has joined #ruby
intelligent_boat has quit [Ping timeout: 240 seconds]
intelligent_boat has joined #ruby
otisolsen70 has quit [Read error: Connection reset by peer]
moo has quit [Quit: moo]
moo has joined #ruby
dviola has joined #ruby
otisolsen70 has joined #ruby
moo has quit [Quit: moo]
moo has joined #ruby
kiwi_36 has joined #ruby
ur5us has joined #ruby
RDMengineer has quit [Ping timeout: 258 seconds]
taupiqueur_shiny has joined #ruby
otisolsen70 has quit [Read error: Connection reset by peer]
infinityfye has joined #ruby
RDMengineer has joined #ruby
taupiqueur_shiny has quit [Ping timeout: 246 seconds]
taupiqueur_shiny has joined #ruby
konsolebox has quit [Ping timeout: 245 seconds]
thelounge18 has joined #ruby
konsolebox has joined #ruby
otisolsen70_ has joined #ruby
reset has quit [Quit: reset]
constxqt_ has joined #ruby
otisolsen70_ has quit [Quit: Leaving]
<constxqt_> bros
<constxqt_> is it possible to overload a.x += 4 so that it doesn't just desugar to a.x = a.x + 4
<constxqt_> like def x+=(y) ... end
<ox1eef_> Don't think so. Assignment is not a method call.
ur5us has quit [Ping timeout: 255 seconds]
roshanavand has joined #ruby
leon__ has quit [Remote host closed the connection]
leon__ has joined #ruby
eddof13 has joined #ruby
eddof13 has quit [Client Quit]
eddof13 has joined #ruby
eddof13 has quit [Client Quit]
nkm has joined #ruby
eddof13 has joined #ruby
konsolebox has quit [Quit: Leaving]
Vonter has quit [Ping timeout: 245 seconds]
Vonter has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Vonter has quit [Ping timeout: 246 seconds]
Vonter has joined #ruby
graywolf has joined #ruby
nkm has quit [Quit: Client closed]
Linux_Kerio has joined #ruby
Linux_Kerio has quit [Remote host closed the connection]
Linux_Kerio has joined #ruby
<adam12> good morning
hrberg has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
hrberg has joined #ruby
eddof13 has joined #ruby
gr33n7007h has quit [Quit: WeeChat 4.0.4]
Linux_Kerio has quit [Max SendQ exceeded]
Linux_Kerio has joined #ruby
xmachina has quit [Quit: WeeChat 4.0.4]
gr33n7007h has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
taupiqueur_shiny has joined #ruby
xmachina has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
taupiqueur_shiny has joined #ruby
Vonter has quit [Ping timeout: 248 seconds]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Vonter has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
TomyWork has quit [Quit: Leaving]
_ht has joined #ruby
taupiqueur_shiny has joined #ruby
<miah> moin
<adam12> miah: how goes
graywolf has quit [Quit: WeeChat 4.0.4]
<miah> slowly. my task list is infinite, im working through it. weather is heating up at least. getting cold at night, almost back to 70 though
<adam12> miah: Are you in the southern hemisphere?
<miah> im in michigan
<adam12> Oooh. Yeah, it's been a few cold days hasn't it.
<adam12> (I'm in Ontario)
<miah> ya, my weather station says its been getting down to mid 40's at night :/
<adam12> We had a frost warning for northern Ontario a few days ago. Very untypical _this_ early. I wonder if it's wildfire/smoke related.
<miah> ya, probably
<joto> i just edited config/environments/production.rb. Would this change get picked up immediatly on a running web application or do I have to reload something?
<joto> (rails question btw)
<adam12> joto: Most of the time those files aren't auto-reloaded, so you'll need to restart server.
<joto> okay! now I need to look up how to do that on Heroku without blowing away that file haha
<joto> because they have this ephemeral system
<adam12> joto: Likely not possible. You shoudl be shipping this change in your repository.
<adam12> Or use an ENV value to configure it.
<joto> okay
<adam12> (depending on your needs)
<adam12> I think Rails has a more official configuration mechanism than ENV. It's been some time since I worked with it.
taupiqueur_shiny has quit [Remote host closed the connection]
taupiqueur_shiny has joined #ruby
willfish has quit [Ping timeout: 248 seconds]
otisolsen70 has joined #ruby
gr33n7007h has quit [Read error: Connection reset by peer]
gr33n7007h has joined #ruby
svdasein has joined #ruby
svdasein_ has joined #ruby
willfish has joined #ruby
xmachina has quit [Quit: WeeChat 4.0.4]
xmachina has joined #ruby
szkl has joined #ruby
willfish has quit [Ping timeout: 246 seconds]
constxqt_ has quit [Ping timeout: 248 seconds]
gr33n7007h has quit [Read error: Connection reset by peer]
gr33n7007h has joined #ruby
_ht has quit [Remote host closed the connection]
gr33n7007h has quit [Ping timeout: 240 seconds]
gr33n7007h has joined #ruby
infinityfye has quit [Read error: Connection reset by peer]
infinityfye has joined #ruby
roshanavand has quit [Ping timeout: 245 seconds]
roshanavand has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
rvalue has quit [Ping timeout: 258 seconds]
roshanavand has quit [Remote host closed the connection]
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 248 seconds]
desnudopenguino1 is now known as desnudopenguino
ur5us has joined #ruby
kokoro_ has quit [Ping timeout: 246 seconds]
kokoro has joined #ruby
xmachina has quit [Quit: WeeChat 4.0.4]
rvalue has joined #ruby
szkl has quit [Quit: Connection closed for inactivity]
teclator has quit [Ping timeout: 250 seconds]
Linux_Kerio has quit [Read error: Connection reset by peer]
Linux_Kerio has joined #ruby
crespire has quit [Remote host closed the connection]
duderonomy has joined #ruby
Linux_Kerio has quit [Ping timeout: 248 seconds]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
otisolsen70 has quit [Quit: Leaving]
constxqt_ has joined #ruby
kiwi_36 has quit [Remote host closed the connection]
eddof13 has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xmachina has joined #ruby
eddof13 has joined #ruby
crespire has joined #ruby
havenwood has quit [Quit: The Lounge - https://thelounge.chat]
havenwood has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eddof13 has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xmachina has quit [Quit: WeeChat 4.0.4]
eddof13 has joined #ruby
eddof13 has quit [Client Quit]
John_Ivan has joined #ruby
infinityfye has quit [Quit: Leaving]
xmachina has joined #ruby