<AstrallyForged>
.hg …yep, optparse does indeed do that. The part I was missing was to actually call `parse!`, and get the positional arguments directly from `ARGV` afterwards. Thanks!
<gr33n7007h>
AstrallyForged: flagged options get destructed after being consumed, leaving positional options in ARGV
<gr33n7007h>
sam113101: there might be something already implemented in matrix lib for get all diagonals.
ur5us has quit [Ping timeout: 244 seconds]
John_Ivan__ has joined #ruby
mahlon has joined #ruby
jpn has quit [Ping timeout: 268 seconds]
ccapndave has joined #ruby
<ccapndave>
Hey everyone. I know very little about Ruby and Bundler, but I find myself having to use them for something. Is there a way to install a `gem` from the command line, but specifying a git repository and branch? Or alternatively, is there a way to put something in the Gemfile that won't install by default with `bundle install` but only if I do `bundle config set --local with `?
jetchisel has joined #ruby
<rapha>
Hardly an expert but the only way I know how to manually install a gem from a git repo is to clone said repo. Why are you having to embark on such non-standard usages? Like, what's the goal here and what's the non-goal?
<ccapndave>
I have a website built in Jekyll and it uses some dependency called eventmachine for local development. The version in gem doesn't work with my machine (maybe cos its M1?) so I need to install it from master. However, the site itself is build by a Github Action and I need that to ignore eventmachine totally otherwise the build fails ther.
<ccapndave>
So 1) the gem has to come from a master branch on git and 2) I want this gem to install on my local machine for development, but not in the Github action (which uses helaili/jekyll-action@v2)
<ccapndave>
It seems to work! Weirdly, when I ran `bundle install` it said that it had downgraded eventmachine back to the non-master version but somehow it still runs without an error.
<ccapndave>
Thanks very much for your help
<rapha>
Ah yes, the secrets of bundler's decisions. Glad it's working for you now!
nasshund has joined #ruby
<nasshund>
hola
nasshund has quit [Client Quit]
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
angely has joined #ruby
angely_ has joined #ruby
<angely_>
Hi, i dont kow if i have find some kind of bug
jpn has joined #ruby
<marahin>
angely_, who would know, if not you? :)
<gr33n7007h>
ccapndave: `gem i specific_install` then you can use it as such: gem specific_install -l github-url branch
<angely_>
I have a method with two variables wich equal each other at the begining and then after appliying some enumerables to one of them both are changed at the end
_ht has joined #ruby
<adam12>
angely_: This can happen, because the variable might be a _reference_ to something. You could try calling `dup` before you start mutating.
<adam12>
angely_: Share some code and we can advise further.
<adam12>
gr33n7007h: Never heard of specific_install. Neat.
<gr33n7007h>
adam12: it really is! i think havenwood recomended it to me, if i remember correctly
<adam12>
Where do people like to position their class-level methods inside a class? I've always habitually stuck them at the bottom, near `private`, but I've seen them at the top lately and it feels like a better location.
<angely_>
adam12: How do I send you the code?
<adam12>
angely_: gist.github.com
fercell has joined #ruby
<rapha>
I almost never have to use private for anything adam12 but at the top sounds nicer than at the bottom ... because "class level" and close to "def class" ... just a feeling tho.
<adam12>
rapha: I kind of agree. A lot of my class-level methods are constructors anyways. It's always fun trying to break 20 years of habit tho.
* rapha
also, in his entire 18 year ruby life, has never had to use a @@ class variable despite of how funny it looks
* rapha
intriguedly googles Doctrine of Useful Objects
<rapha>
ooooooh
<rapha>
hey! i do that!!
<rapha>
just never knew it has a _name_
<adam12>
angely_: Looking, but I don't see how it's mutating the same reference value.
<rapha>
wait ... "no dependencies of an object should ever be allowed to be unitialized" ... by dependency of an object they mean anything that can happen only after said object has been initialized, right?
<adam12>
angely_: What is the value of @code and check? And how are you determining it?
<adam12>
rapha: It means that if you have a dependency, it either has a working implementation, or is a substitute or null object.
<adam12>
rapha: It's never nil.
<rapha>
i still don't understand. is a "dependency of an object" something outside of the class the object is an instance of? or inside?
<adam12>
angely_: Is there any way your code is updating the same array's in exactly the same way?
<adam12>
rapha: Hmm, I'm not sure I follow. It's referring to collaborator objects, afaik.
<rapha>
ouch
<rapha>
i'm out of my depth then here
<rapha>
i read "An object must be useful immediately upon instantiation of the object" and thought that's what i'm doing myself (using #initialize) but this seems to be much more advanced than that
<angely_>
These lines of code are the only ones where these two variables intervine
<adam12>
angely_: What about this line? `check[turn]= @code[turn]`
<adam12>
angely_: I'm guessing that's your issue.
<rapha>
eventide looks interesting though ... i think it might be fun to base a small minimalistic SmartHome on it
<adam12>
rapha: It's a beautiful way of building code.
<adam12>
Doctrine. I havent' used Eventide.
<rapha>
is there any explanation of it a simpler person, such as me, could understand? i.e. a bit more hand-holding where each concept is explained with a brief example?
<angely_>
adam12: thats the begining where I put the same values on both, after that one of them is modified but it has to start with the same values
<rapha>
because i love beautiful ways of building code :)
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
angely has quit [Quit: Leaving]
angely_ is now known as angely
dionysus69 has quit [Ping timeout: 244 seconds]
dionysus69 has joined #ruby
<angely>
adam12: if thats the problem how I make them be the same value at that moment? when you equals a variable to other variable it should be saved in that exact moment and after that ypu should be able to change one of them without altering the other, am I right?🤔️
dionysus69 has quit [Read error: Connection reset by peer]
dionysus69 has joined #ruby
<angely>
Unless ruby asigns the same memory space to both?
<adam12>
angely: It's hard to say without running the code. If that's your intent, then that's what the code does.
<adam12>
angely: But if they are the same at the end, then that assignment is probably doing it. Which means the logic is wrong, somewhere.
<angely>
adam12: But it changes before finishing the main loop and after doing the two enumerables
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
<adam12>
angely: If you can make it runnable for me, I'll look closer. But I don't see anything wrong at this point.
<angely>
this one is the game almost complete. It will show you how check and code evolves throught the enumerables
<adam12>
angely: It runs, but I can't seem to see the issue you're having.
<ruralscientist>
Hi there, on a Debian 11.4, I installed ruby with apt-get, and then did $ gem install jekyll bundler. Starting jekyll I got https://pastebin.com/A2LF3V6a . What is the problem here?
<ruby[bot]>
ruralscientist: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
<adam12>
angely: I added A:, B:, and C: to your `p` statements, so I knew which one was what.
<adam12>
ruralscientist: Try `bundle exec jekyll` instead of plain `jekyll`
<ruralscientist>
adam12, thanks
<rapha>
adam12: am I seeing correctly that the Eventide project is where TDoUO originated? Noone else seems to be writing about it.
<adam12>
angely: I'd try decomposing the `play` method down a bit more. You have probably at least `prompt`, and `compare` in there. Maybe that will help narrow down your issue.
<adam12>
rapha: Yes. That's correct.
<rapha>
Alright
<rapha>
They have some videos on YouTube ... perhaps that's a good way to learn about it, I'll watch tonight after babysitting
<angely>
adam12: Thank you for your time, It seems very simple but I can not guess why it vhanges both
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<adam12>
angely: I don't follow some of your design choices so I am unsure what the issue is. The only line that sticks out is the `check[turn] = @code[turn]`.
<adam12>
angely: ie. I'm not sure why you create a fixed Array at the top. And I'm not sure the purpose of `.`, `+`, and `-` are.
<angely>
'.''-' and'+' are simbols to indicate if it is incorrect guess, correct but in bad position and correct and correct position respectively
<adam12>
angely: Ah. Interesting.
<angely>
the fixed array is not necessary
<adam12>
angely: What if you dup this array? `check[turn]= @code[turn].dup`
<adam12>
It's actually a String, looking at it. But what if you dup it anyways...
<angely>
its an arry of one char stings
<adam12>
Oh right. It is split on that same line.
<angely>
I didnt know dup
<adam12>
I'd still try duping it.
eddof13 has joined #ruby
<angely>
adam12: So dup makes a copy without affecting the original.
<angely>
It works
<adam12>
angely: Ah, great.
<angely>
but Then
<angely>
It is a bug?
<angely>
🙃️
<adam12>
angely: No. It's working as designed.
<angely>
So when you equals two variables they update each time one of then is updated?
<adam12>
angely: Not exactly. The variables are independent, but their contents might be connected by a reference.
finsternis has joined #ruby
<adam12>
angely: This is true for Arrays and Hashes, and sometimes for Strings. It's not true for primitives like true, false, 1, 2, 3, etc.
<angely>
And in this case how are connected?
<adam12>
angely: If you go `code = [1, 2, 3]`, and then `check = code`, and said `p code.object_id; p check.object_id`, you'd see they are referring to the same object, internally, as they both have the same reference.
<angely>
Maybe is because they are in the same method?
<angely>
or is it always like that in arrays and hashes?
<adam12>
It's always like this for Arrays and Hashes. You're passing around a reference to the same Array, as that's generally the intent most of the time.
<adam12>
The issue comes when you mutate an Array that is referenced in mulitple places.
<adam12>
But it's more common than not where that's not the case.
<angely>
I have learn something important today
<angely>
thank you for your time
<adam12>
angely: yw!
Sankalp has quit [Ping timeout: 264 seconds]
Sankalp has joined #ruby
skuntee4 has joined #ruby
skuntee4 has quit [Client Quit]
nirvdrum has joined #ruby
fercell has joined #ruby
ross has joined #ruby
fercell has quit [Ping timeout: 250 seconds]
<ross>
hey! found myself in a situation where I want multiple inheritance, which obvs isn't possible. The classes I want to inherit from are both in a gem, so I can't edit them to e.g. refactor those methods into modules. They don't share an inheritance tree (although they both inherit from the same parent class), although logically I know that these specific classes won't be incompatible if both inherited from. As a result I know that I can just copy-paste the
<ross>
methods from one class and inherit from the other, but that feels like a really bad way of doing things. Is there a better way?
<ross>
I've tried e.g. looping over methods from one class like below, but ruby rejects the binding because the classes aren't in an inheritance chain
<ruby[bot]>
ross: we in #ruby do not like irccloud.com, it has no syntax highlighting, distracting formatting and loads slowly for most. Please use https://gist.github.com
dviola has joined #ruby
c10l has quit [Ping timeout: 252 seconds]
c10l has joined #ruby
angely has quit [Quit: angely]
<leah2>
ross: i can only think of a hack
<leah2>
ross: require 'a'; B = A; require 'b'
<ross>
leah2: I'm down for hacks - anything beats copy-pasting! I'll give this a go, thank you!
<leah2>
this will make 'class B' effectively 'class A'
<ross>
that's fine so long as it's constrained to this one file and not all instances of class B elsewhere
protektwar has quit [Ping timeout: 264 seconds]
nirvdrum has quit [Ping timeout: 265 seconds]
plujon has joined #ruby
nirvdrum has joined #ruby
<adam12>
ross: Maybe a new object with delegators to instances of the other objects? idk.
<ross>
my only real reservation about that approach was having to set up all the method redirects, but TIL about Forwardable and delegators
<adam12>
If you need equality for class, you'll have to define your own method for that, but it's not that bad.
<adam12>
Technically you could cheat and use method_missing, but I like the expressiveness of the delegators.
<ross>
I'll cheat if I must, but will diligently avoid it until then
<adam12>
def method_missing(meth, args, &block); return @a.send(meth, args, &block) if @a.respond_to?(meth); return @b.send(meth, args, &block) if @b.respond_to?(:meth); super; end
<ross>
I'm afraid I'm not familiar with the term 'equality for class' except in the context of social hierarchy lmao
<adam12>
You'd need another method for method_missing implementation. respond_to_method or something. I'd have to look it up.
<ross>
ok that's pretty clever
<adam12>
equality for class is basically C.is_a?(A). Which would be false by default, obviously, but that doesn't have to be the case. For multiple inheritance, I think C.is_a?(A) would be truthy.
<adam12>
With ducktyping, I wouldn't reach for class equality immediately.
<ross>
ah, I see - thanks for the tip! hopefully I won't need that
dionysus69 has quit [Ping timeout: 265 seconds]
polishdub has quit [Remote host closed the connection]
lagash has quit [Ping timeout: 248 seconds]
Guest4041 has joined #ruby
polishdub has joined #ruby
<Guest4041>
So I've written a backend using sequel and sinatra. it's restful JSON and it has a handful of endopoints exposing CRUD functionality plus a filter/search and list.
<adam12>
Guest4041: Nice.
<Guest4041>
My question is: Is it common to handle multiple queries to the backend CRUD endpoints to correlate data stored in several DB tables, in the javascritpt frontend? Or should I implement endpoints at the backend to perform SQL joins before passing that data to the frontend
nirvdrum has joined #ruby
<Guest4041>
Thanks Adam12. You suggested I use Sequel a few weeks back, I love it
<adam12>
Guest4041: You can do both. Some people think that it should be done in the frontend. I disagree, and it's kind of how GraphQL came to be.
<adam12>
Guest4041: I'm in the build-specific APIs for the frontend camp.
<Guest4041>
Ok, that makes sense. Just wanted get a sense for what is commonly done to screen out glaring anti-patterns
<adam12>
I think people are all over the place, and there's no consistency.
<Guest4041>
Yeah, I think it makes more sense to design the backend to prepare data for consumption by the frontend
<adam12>
I actually punt on this as much as I can, and just server-side render and use Unpoly.
<adam12>
Because the bikeshedding is real.
<Guest4041>
Nice, you're way ahead of me - I'll google those terms to figure out what you mean.
<Guest4041>
I just want a clean separation of backend json/rest and frontend interface
<adam12>
Guest4041: What are you using for Frontend?
nirvdrum has quit [Ping timeout: 268 seconds]
<Guest4041>
I'm using bootstrap with jquery and working on updating the backend to use longpolling, but struggling to find the clean way to update (on the frontend) entries in-place
<adam12>
You could use generic endpoints, but I wouldn't be afraid to make some internal, page specific ones, especially where they might be heavy.
<adam12>
You could also look how someone like Stripe does it; where part of the query says to expand certain nested associations.
<adam12>
That's recreating GraphQL in some ways but is conceptually simpler to rationalize.
<adam12>
Definitely checkout Unpoly; tho it doesn't use JSON over the wire. It uses HTML. But it can make your app feel single-page like.
<Guest4041>
Awesome. I'll take a look at Unpoly for sure. Thanks for the recommendations, this really helps me navigate the way forward, I appreciate it adam12!
<adam12>
Guest4041: Cheers.
fercell has joined #ruby
fercell has quit [Ping timeout: 268 seconds]
Guest4041 has quit [Quit: Client closed]
jpn has quit [Ping timeout: 265 seconds]
ruralscientist has quit [Ping timeout: 250 seconds]
lagash has joined #ruby
ruralscientist has joined #ruby
jpn has joined #ruby
RougeR has joined #ruby
RougeR has quit [Client Quit]
jpn has quit [Client Quit]
RougeRT480 has joined #ruby
RougeRRT480 has joined #ruby
<adam12>
Currently storing documentation for 12358 gems in 204.2 gigabytes.
<adam12>
Wow.
RougeRRT480 has quit [Client Quit]
RougeRT480 has quit [Client Quit]
RougeRT480 has joined #ruby
RougeRT480 has quit [Quit: Leaving]
RougeRT480 has joined #ruby
RougeR has joined #ruby
nirvdrum has joined #ruby
RougeRT480 has quit [Quit: Leaving]
nirvdrum has quit [Ping timeout: 244 seconds]
jpn has joined #ruby
<weaksauce>
dang adam12++
<ross>
adam12: just finished up with my multiple inheritance - your delegation solution has worked perfectly. thank you!!
<adam12>
ross: Ah sweet.
reset has joined #ruby
RougeR has quit [Quit: Leaving]
jpn has quit [Ping timeout: 268 seconds]
jpn has joined #ruby
nirvdrum has joined #ruby
jpn has quit [Ping timeout: 265 seconds]
nirvdrum has quit [Ping timeout: 268 seconds]
Linux_Kerio has quit [Quit: Konversation terminated!]
_ht has quit [Quit: _ht]
Starfoxxes has quit [Read error: Connection reset by peer]
jpn has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nirvdrum has joined #ruby
Starfoxxes has joined #ruby
touta has joined #ruby
touta has quit [Remote host closed the connection]
jpn has quit [Quit: Lost terminal]
touta has joined #ruby
nirvdrum has quit [Read error: Connection reset by peer]
nirvdrum has joined #ruby
eddof13 has joined #ruby
<adam12>
I kind of expected StringIO#gets to block and not return nil. Seems like such a strange omission for something that acts like an IO object.
nirvdrum has quit [Quit: nirvdrum]
nirvdrum has joined #ruby
reset has quit [Ping timeout: 268 seconds]
<adam12>
Ended up using UNIXSocket.pair, which works more realistically.
John_Ivan__ has quit [Quit: Phantom of the future.]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
skuntee4 has joined #ruby
<libsys>
hello people... question... how can I change the context (binding) of a proc to be executed as if it were executed inside the instance of an object?
<libsys>
like... obj = MyClass.new; obj.instance_exec(proc) do |proc_on_obj_context| proc_on_obj_context.call end
<libsys>
that of course does not work... proc is executed in the context where it was written
<gr33n7007h>
libsys: just `obj.instance_exec(&proc)` should be enough
eddof13 has joined #ruby
moldorcoder7_ has quit [Ping timeout: 268 seconds]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
fercell has joined #ruby
fercell has quit [Ping timeout: 268 seconds]
perrierjouet has quit [Quit: WeeChat 3.6]
<sam113101>
how can I change the stack level limit
<gr33n7007h>
sam113101: use the RUBY_THREAD_VM_STACK_SIZE environment variable