baweaver changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.5.1, 2.4.4, 2.3.7, 2.6.0-preview2: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.de/ and select ruby as the language | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first!
JamJam_kid has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
JamJam_kid has quit [Quit: Leaving]
ace91 has quit [Remote host closed the connection]
bmurt has joined #ruby
AJA4350 has quit [Quit: AJA4350]
bmurt has quit [Read error: Connection reset by peer]
bmurt has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dbz has quit [Remote host closed the connection]
dbz has joined #ruby
Azure has quit [Read error: Connection reset by peer]
dbz has quit [Remote host closed the connection]
Azure has joined #ruby
dbz has joined #ruby
dbz has quit [Remote host closed the connection]
sameerynho has quit [Ping timeout: 244 seconds]
jenenliu has quit [Ping timeout: 245 seconds]
tdy has joined #ruby
orbyt_ has quit [Quit: Textual IRC Client: www.textualapp.com]
jp has quit [Ping timeout: 240 seconds]
apeiros has quit [Ping timeout: 245 seconds]
Rootsudo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
apeiros has joined #ruby
nicesignal has quit [Remote host closed the connection]
nicesignal has joined #ruby
arescorpio has joined #ruby
dviola has quit [Quit: WeeChat 2.2]
jp has joined #ruby
eckhardt has joined #ruby
psmolen has quit [Ping timeout: 240 seconds]
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenenliu has joined #ruby
jenenliu has quit [Quit: Leaving]
arescorpio has quit [Quit: Leaving.]
dbz has joined #ruby
eckhardt has joined #ruby
cadillac_ has quit [Quit: I quit]
dbz has quit [Ping timeout: 272 seconds]
jenenliu has joined #ruby
braincrash has quit [Quit: bye bye]
braincrash has joined #ruby
blobsson has joined #ruby
<blobsson> in ruby on rails I have a problem where I have 2 threads running code at the same time. Is there a way to block other instances / check if an instance is already running in the same code
dellavg_ has joined #ruby
paraxial has quit [Read error: Connection reset by peer]
paraxial has joined #ruby
<woodruffw> sounds like a mutex is what you want? https://ruby-doc.org/core-2.5.1/Mutex.html
samort7 has quit [Read error: Connection reset by peer]
baweaver is now known as baweaver_away
knight33 has joined #ruby
knight33 has quit [Max SendQ exceeded]
donofrio_ has quit [Remote host closed the connection]
tdy has quit [Ping timeout: 272 seconds]
paraxial has quit [Ping timeout: 252 seconds]
eckhardt has quit [Quit: Textual IRC Client: www.textualapp.com]
paraxial has joined #ruby
paraxial has quit [Ping timeout: 245 seconds]
paraxial has joined #ruby
paraxial has quit [Ping timeout: 252 seconds]
paraxial has joined #ruby
dellavg_ has quit [Ping timeout: 245 seconds]
jjman has left #ruby ["WeeChat 1.6"]
dbz has joined #ruby
cgfbee has joined #ruby
dbz has quit [Ping timeout: 246 seconds]
dbz has joined #ruby
paraxial has quit [Ping timeout: 252 seconds]
paraxial has joined #ruby
paraxial has quit [Read error: Connection reset by peer]
paraxial has joined #ruby
Inline has quit [Quit: Leaving]
MoritaShinobu has joined #ruby
esrse has joined #ruby
dbz has quit [Remote host closed the connection]
dbz has joined #ruby
doubledup has joined #ruby
paraxial has quit [Ping timeout: 246 seconds]
paraxial has joined #ruby
madhatter has joined #ruby
_whitelogger has joined #ruby
MoritaShinobu has quit [Remote host closed the connection]
MoritaShinobu has joined #ruby
DTZUZO has quit [Ping timeout: 244 seconds]
eddof13 has quit [Ping timeout: 240 seconds]
paraxial has quit [Read error: Connection reset by peer]
paraxial has joined #ruby
paraxial has quit [Ping timeout: 245 seconds]
paraxial has joined #ruby
paraxial has quit [Ping timeout: 245 seconds]
paraxial has joined #ruby
reber has joined #ruby
snickers has joined #ruby
dionysus69 has joined #ruby
paraxial has quit [Ping timeout: 252 seconds]
paraxial has joined #ruby
jenenliu_ has joined #ruby
jenenliu_ has quit [Remote host closed the connection]
jenenliu has quit [Ping timeout: 246 seconds]
MoritaShinobu has quit [Ping timeout: 252 seconds]
blobsson has quit [Read error: Connection reset by peer]
paraxial has quit [Ping timeout: 252 seconds]
paraxial has joined #ruby
paraxial has quit [Ping timeout: 252 seconds]
MoritaShinobu has joined #ruby
LACampbell has left #ruby ["WeeChat 2.0.1"]
paraxial has joined #ruby
d^sh has quit [Ping timeout: 240 seconds]
aufi has joined #ruby
d^sh has joined #ruby
jokke__ has joined #ruby
ineb has joined #ruby
kapil___ has joined #ruby
aupadhye has joined #ruby
clorisu has quit [Remote host closed the connection]
yohji has joined #ruby
aupadhye has quit [Quit: Leaving]
mikecmpbll has joined #ruby
aupadhye has joined #ruby
aupadhye has quit [Client Quit]
mikecmpbll has quit [Quit: inabit. zz.]
clemens3 has joined #ruby
alex``` has joined #ruby
<alex```> Hi
<alex```> What is the best practise to tweak a value with a control flow?
<alex```> data = get
aupadhye has joined #ruby
<alex```> if options[:pretty]
<alex```> data[:a] = ...
<alex```> data[:b] = data[:b].to_human_size
<alex```> ...
<alex```> tap is recommended?
<alex```> get.tap do |data|
<alex```> if options[:pretty]
<alex```> data[:a] = data[:a].to_human_size
<alex```> ...
<alex```> end
<alex```> end
doubledup has quit [Quit: Leaving]
clorisu has joined #ruby
tristanp has joined #ruby
tristanp has quit [Remote host closed the connection]
azerin has joined #ruby
<azerin> Hi
mikecmpbll has joined #ruby
sysvalve has joined #ruby
<ineb> alex```: it doesnt really matter, but you can write data[:a] = data[:a].to_human_size if options[:pretty]
azerin has quit [Ping timeout: 246 seconds]
azerin has joined #ruby
<apeiros> alex```: dude, gist
Quiz has joined #ruby
clorisu has quit [Quit: Leaving]
lxsameer has joined #ruby
Quiz has quit [Quit: Page closed]
azerin__ has joined #ruby
azerin has quit [Ping timeout: 252 seconds]
azerin__ is now known as azerin
MoritaShinobu has quit [Ping timeout: 246 seconds]
dbz has quit [Remote host closed the connection]
dbz has joined #ruby
pwnd_nsfw has joined #ruby
dbz has quit [Ping timeout: 245 seconds]
desperek has joined #ruby
tristanp has joined #ruby
MoritaShinobu has joined #ruby
Beams has joined #ruby
tristanp has quit [Ping timeout: 252 seconds]
roshanavand has joined #ruby
paraxial has quit [Read error: Connection reset by peer]
paraxial has joined #ruby
roshanavand has quit [Quit: leaving]
roshanavand has joined #ruby
mike11 has joined #ruby
Puffball has quit [Read error: Connection reset by peer]
n13z has quit [Quit: leaving]
aufi has quit [Ping timeout: 244 seconds]
mike11 has quit [Ping timeout: 240 seconds]
clorisu has joined #ruby
MoritaShinobu has quit [Ping timeout: 250 seconds]
paraxial has quit [Ping timeout: 245 seconds]
azerin has left #ruby ["Bye"]
paraxial has joined #ruby
roshanavand has quit [Quit: leaving]
roshanavand has joined #ruby
esrse has quit [Ping timeout: 245 seconds]
MoritaShinobu has joined #ruby
DTZUZO has joined #ruby
jottr has joined #ruby
clorisu has quit [Remote host closed the connection]
clorisu has joined #ruby
paraxial has quit [Ping timeout: 252 seconds]
paraxial has joined #ruby
AJA4350 has joined #ruby
anikras has joined #ruby
Freshnuts has quit [Quit: Leaving]
dbz has joined #ruby
dbz has quit [Ping timeout: 240 seconds]
aufi has joined #ruby
Guest18202 has quit [Quit: Gateway shutdown]
sysvalve has quit [Ping timeout: 252 seconds]
arekushi has joined #ruby
arekushi is now known as Guest18202
prestorium has joined #ruby
<prestorium> Hi all. Anyone using Net/SSH with Windows' OpenSSH? Not git's SSH, but Windows' SSH. I'm trying to make Net/SSH to recognise ssh-agent running under windows
<prestorium> So far, it is always trying to get pageant (putty's agent)
drale2k_ has joined #ruby
clemens3 has quit [Ping timeout: 252 seconds]
clorisu has quit [Ping timeout: 272 seconds]
kapil___ has quit [Quit: Connection closed for inactivity]
MoritaShinobu has quit [Quit: Leaving]
tristanp has joined #ruby
tristanp has quit [Ping timeout: 244 seconds]
clemens3 has joined #ruby
dionysus69 has quit [Ping timeout: 252 seconds]
paraxial has quit [Ping timeout: 252 seconds]
mikecmpbll has quit [Quit: inabit. zz.]
augcesar has joined #ruby
mikecmpbll has joined #ruby
sysvalve has joined #ruby
paraxial has joined #ruby
jinie has quit [Quit: ZNC 1.6.1 - http://znc.in]
prestorium has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
clemens3 has quit [Ping timeout: 240 seconds]
AJA4350 has quit [Remote host closed the connection]
prestorium has joined #ruby
<prestorium> Hi all. Anyone using Net/SSH with Windows' OpenSSH? Not git's SSH, but Windows' SSH. I'm trying to make Net/SSH to recognise ssh-agent running under windows
<prestorium> So far, it is always trying to get pageant (putty's agent)
mikecmpbll has quit [Read error: Connection reset by peer]
mikecmpbll has joined #ruby
MyMind has joined #ruby
Sembei has quit [Ping timeout: 250 seconds]
aufi has quit [Quit: Leaving]
aufi has joined #ruby
<prestorium> Dumb question: is UNIXSocket defined on windows?
prestorium has quit [Quit: prestorium]
prestorium has joined #ruby
<ineb> prestorium: you mean local sockets AF_UNIX?
<ineb> its available in recent windows releases
<prestorium> ineb I don't know. I'm using Windows 10 and I'm trying to use openssh-ssh-agent named pipe
<ineb> prestorium: regarding your initial question, net/ssh is pure ruby afaik
<prestorium> ineb yes, it is. So I'm trying to monkey patch it so it can work like I want/need :)
<ineb> prestorium: yeah, i looked at the source and they only support pageant from putty
tristanp has joined #ruby
<prestorium> ineb yeah... I saw that. But I, in my naïvety, think it should be pretty easy to make it work using openssh on windows as well. That's what I'm trying to do.
<ineb> prestorium: i would assume so aswell. on windows, i would check if i have UNIXSocket available in ruby, then patch out the win32 checks in https://github.com/duerst/net-ssh/blob/master/lib/net/ssh/authentication/agent/socket.rb
tristanp has quit [Ping timeout: 245 seconds]
<ineb> or just overwrite Net::SSH::Authentication::PLATFORM for a quick hack
<prestorium> ineb this is exactly what I'm doing. :) Except that I'm pretty sure that UNIXSocket is not defined on windows... I took a look at socket/lib/socket.rb, and it requires socket.so. There is no explicit definition of UNIXSocket
<prestorium> So, I'm guessing that socket.so have some #ifdef macro... :(
tty has quit [Quit: tty]
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
prestorium has quit [Quit: prestorium]
prestorium has joined #ruby
prestorium has quit [Client Quit]
prestorium has joined #ruby
prestorium has quit [Client Quit]
prestorium has joined #ruby
<ineb> prestorium: okay, ssh-agent on windows exposes a named pipe instead of a UNIX Socket, have you looked at that?
<prestorium> ineb yes. But I'm not sure how to use a named pipe with ruby
<prestorium> That's why I was trying to use it as an unix socket
<ineb> prestorium: well, you cant use a UNIX Socket either if ssh-agent does not creates one
<ineb> or talks to one
<prestorium> ineb well... if a named pipe were a socket... haha
<prestorium> that was my train of thought: "I will make something like UNIXSocket.open("\\.\pipe\openssh-ssh-agen") and call it a day"
<prestorium> I saw win32-pipe... But it has been 2 years since the last update. So I think it is not being used anymore. Perhaps because there is an alternative
darix has quit [Quit: may the packets be with you...]
<ineb> prestorium: you just need something that does #read #send and #close to a named pipe
<ineb> prestorium: and provide your custom socket factory to Net::SSH::Authentication::Agent#connect!
<ineb> looks like you does not need to patch anything that way
<prestorium> ineb yeah... you're right
anikras has quit [Quit: Ex-Chat]
snickers has quit [Ping timeout: 252 seconds]
drale2k_ has joined #ruby
darix has joined #ruby
redlegion has quit [Ping timeout: 250 seconds]
rippa has joined #ruby
redlegion has joined #ruby
bmurt has joined #ruby
conta2 has joined #ruby
MoritaShinobu has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cek has joined #ruby
prestorium has quit [Quit: prestorium]
darix has quit [Quit: may the packets be with you...]
prestorium has joined #ruby
Inline has joined #ruby
Inline has quit [Read error: Connection reset by peer]
prestorium has quit [Quit: prestorium]
hays has quit [Ping timeout: 246 seconds]
prestorium has joined #ruby
darix has joined #ruby
aufi has quit [Ping timeout: 246 seconds]
wildermind has joined #ruby
aupadhye has quit [Ping timeout: 272 seconds]
hays has joined #ruby
teej has joined #ruby
yohji has quit [Ping timeout: 252 seconds]
tristanp has joined #ruby
conta2 has quit [Quit: conta2]
sysvalve has quit [Quit: Leaving]
lomex has joined #ruby
tristanp has quit [Ping timeout: 246 seconds]
prestorium has quit [Quit: prestorium]
hays has quit [Quit: No Ping reply in 180 seconds.]
hays_ has joined #ruby
nowhere_man has quit [Remote host closed the connection]
nowhere_man has joined #ruby
psmolen has joined #ruby
eddof13 has joined #ruby
lxsameer has quit [Ping timeout: 252 seconds]
hays_ has quit [Ping timeout: 246 seconds]
lxsameer has joined #ruby
Dbugger has joined #ruby
hays has joined #ruby
lxsameer has quit [Ping timeout: 244 seconds]
lxsameer has joined #ruby
lxsameer has quit [Ping timeout: 240 seconds]
lxsameer has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
Zaab1t has joined #ruby
SuperLag has quit [Quit: leaving]
lxsameer has quit [Ping timeout: 240 seconds]
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lxsameer has joined #ruby
lomex has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
thejs has joined #ruby
dionysus69 has joined #ruby
samort7 has joined #ruby
<samort7> Can anyone tell me why .map! isn't working here?
Beams has quit [Quit: .]
<samort7> `Line 43: in `block in max_increase_keeping_skyline': undefined method `map!' for #<Enumerator: [3, 0, 8, 4]:each_with_index> (NoMethodError)`
lxsameer has quit [Ping timeout: 272 seconds]
<apeiros> samort7: because your expression returns an Enumerator, and Enumerator does not define map!, only map.
<apeiros> I don't know why you use map anyway there
<samort7> apeiros: I am not sure I understand
<apeiros> I'm sure you don't understand :)
<apeiros> what do you expect the map! to do there?
<samort7> apeiros: I was googling how to change an array as you iterate through it and all the stack overflow answers said to use map
doubledup has joined #ruby
<apeiros> how to change an *array*. you don't have an array there.
<apeiros> row <-- array, row.each_with_index <-- not an array
Nicmavr has quit [Read error: Connection reset by peer]
<samort7> oh, right. That makes sense
<samort7> So how do I change the values as I iterate through them?
lxsameer has joined #ruby
<apeiros> >> a = [1,2,3]; a.map!.each_with_index do |e,idx| e*idx end; a
<apeiros> eval.in dead again :(
<apeiros> # => [0,2,6]
Nicmavr has joined #ruby
<samort7> ooooh
<samort7> so the problem was where i was calling .map!
<samort7> apeiros: I think I was thrown off by this question where he calls map __after__ .each_with_index
lxsameer has quit [Ping timeout: 272 seconds]
<apeiros> with map, that works. with map!, it doesn't.
<apeiros> since as said, the return value of each_with_index is Enumerator, not Array. and there's no Enumerator#map!
<samort7> aah, interesting
RougeR has joined #ruby
<RougeR> sim using minitest and my test will pass intermittently
<RougeR> sometimes i get Uninitalized constant FooClass
<samort7> apeiros: I guess I need to read up on what an enumerator is
<RougeR> sometimes i get full passing
<RougeR> any ideas
<RougeR> NameError: uninitialized constant CopyFileFromS3
<RougeR> Where CopyFileFrom S3 is a class that is being initialized fine when i run the tests again
<RougeR> i know tests run in randomized orders, but im not sure why this is happening
lxsameer has joined #ruby
AJA4350 has joined #ruby
<RougeR> >NameError: uninitialized constant CopyFileFromS3
SuperLag has joined #ruby
lxsameer has quit [Ping timeout: 252 seconds]
EvilJStoker has quit [Ping timeout: 252 seconds]
cek has left #ruby [#ruby]
lxsameer has joined #ruby
EvilJStoker has joined #ruby
lxsameer has quit [Ping timeout: 240 seconds]
SuperLag has quit [Quit: leaving]
lxsameer has joined #ruby
dellavg_ has joined #ruby
lxsameer has quit [Ping timeout: 244 seconds]
akem has quit [Read error: Connection reset by peer]
akem__ has joined #ruby
lxsameer has joined #ruby
RougeR has quit [Ping timeout: 252 seconds]
thejs has quit [Read error: Connection reset by peer]
nikivi has quit [Quit: ZNC is awesome]
SuperLag has joined #ruby
lxsameer has quit [Ping timeout: 246 seconds]
<pyrmont> samort7: I was looking for information about Enumerators the other day and found this article (https://medium.com/@farsi_mehdi/the-enumerable-module-in-ruby-part-i-745d561cfebf) and its sequel helpful.
paraxial has quit [Ping timeout: 252 seconds]
lxsameer has joined #ruby
nikivi has joined #ruby
lxsameer has quit [Ping timeout: 240 seconds]
MoritaShinobu has quit [Quit: Leaving]
nowhere_man has quit [Ping timeout: 252 seconds]
jottr has quit [Ping timeout: 246 seconds]
lxsameer has joined #ruby
thejs has joined #ruby
lxsameer has quit [Ping timeout: 240 seconds]
tristanp has joined #ruby
redlegion has quit [Ping timeout: 250 seconds]
lxsameer has joined #ruby
redlegion has joined #ruby
tristanp has quit [Ping timeout: 252 seconds]
lxsameer has quit [Ping timeout: 272 seconds]
lxsameer has joined #ruby
mroutis has joined #ruby
lxsameer has quit [Ping timeout: 244 seconds]
lxsameer has joined #ruby
lxsameer has quit [Ping timeout: 240 seconds]
Zaab1t has quit [Quit: Zaab1t]
lxsameer has joined #ruby
dbz has joined #ruby
mroutis has quit [Ping timeout: 244 seconds]
lxsameer has quit [Ping timeout: 252 seconds]
lxsameer has joined #ruby
psmolen has quit [Ping timeout: 245 seconds]
lxsameer has quit [Ping timeout: 245 seconds]
dionysus70 has joined #ruby
kennethd has quit [Ping timeout: 245 seconds]
dionysus69 has quit [Ping timeout: 252 seconds]
dionysus70 is now known as dionysus69
lxsameer has joined #ruby
thejs has quit [Ping timeout: 240 seconds]
psmolen has joined #ruby
lxsameer has quit [Ping timeout: 252 seconds]
psmolen has quit [Read error: Connection reset by peer]
lxsameer has joined #ruby
psmolen has joined #ruby
lxsameer has quit [Ping timeout: 240 seconds]
Lloyd has quit [*.net *.split]
mattwc has quit [*.net *.split]
oblique has quit [*.net *.split]
TheMoonMaster has quit [*.net *.split]
mrsolo has quit [*.net *.split]
charles81_ has quit [*.net *.split]
danzilio has quit [*.net *.split]
rfv has quit [*.net *.split]
pizzaops has quit [*.net *.split]
Fenhl has quit [*.net *.split]
deimos has quit [*.net *.split]
podman has quit [*.net *.split]
lesce has quit [*.net *.split]
ircmaxell has quit [*.net *.split]
Yonk__ has quit [*.net *.split]
Diabolik has quit [*.net *.split]
chromis has quit [*.net *.split]
jxf has quit [*.net *.split]
dmnd has quit [*.net *.split]
HalcyonicStorm__ has quit [*.net *.split]
manveru has quit [*.net *.split]
colstrom has quit [*.net *.split]
micalexander has quit [*.net *.split]
boxrick has quit [*.net *.split]
AndyWojo has quit [*.net *.split]
pyrmont has quit [*.net *.split]
justizin has quit [*.net *.split]
noodle has quit [*.net *.split]
kke has quit [*.net *.split]
cyberjames has quit [*.net *.split]
Sp4rKy has quit [*.net *.split]
redlegion has quit [*.net *.split]
Sp4rKy has joined #ruby
TheMoonMaster_ has joined #ruby
redlegion has joined #ruby
HansPeterIngo has joined #ruby
kapil___ has joined #ruby
noodle has joined #ruby
DTZUZO has quit [Ping timeout: 240 seconds]
dbz has quit [Remote host closed the connection]
psmolen has quit [Ping timeout: 252 seconds]
psmolen has joined #ruby
lenqbit has joined #ruby
<HansPeterIngo> I have been trying to follow the rubocop styling rules for the 3rd time. But I cannot get my head around how splitting up methods like these could be a good idea. https://gist.github.com/HansPeterIngo/6d2116b0d18e2559f53c463e38524937
dionysus69 has quit [Ping timeout: 252 seconds]
<HansPeterIngo> It would be propably the easiest to just use some plain sql-statement in a string. But aren't then those dsl / builder gems always against the ruby style guide? Because they lead in my experience to long methods.
psmolen has quit [Ping timeout: 252 seconds]
lenqbit has quit [Ping timeout: 246 seconds]
Inline has joined #ruby
RougeR has joined #ruby
Inline has quit [Read error: Connection reset by peer]
psmolen has joined #ruby
Inline has joined #ruby
dbz has joined #ruby
HansPeterIngo has quit [Quit: WeeChat 1.9.1]
jp has quit [Ping timeout: 252 seconds]
dbz has quit [Remote host closed the connection]
dbz has joined #ruby
DTZUZO has joined #ruby
thejs has joined #ruby
sameerynho has joined #ruby
dbz has quit [Remote host closed the connection]
jp has joined #ruby
c0ncealed2 has quit [Remote host closed the connection]
c0ncealed2 has joined #ruby
dbz has joined #ruby
dbz has quit [Remote host closed the connection]
dbz has joined #ruby
Dbugger has quit [Ping timeout: 240 seconds]
augcesar has quit [Quit: Connection closed for inactivity]
clorisu has joined #ruby
<JJonah> automatically for every method. That is, every method would get wrapped by a memoizer. But I can't find a good meta-programming technique to accomplish this (other than creating a class method like `def_memoized` that I'd use every time instead of `def` -- a solution I'm not crazy about). Any ideas?
<JJonah> Consider an immutable value object with lazy, memoized methods for derived attributes: https://eval.in/1053602. It's tedious to create the memoizations like `@some_attr ||= ...` for every single method, especially when I know beforehand (since the object is immutable) that I want *every* method to work like that. Ideally I could just `extend ValueObject` as the first line under the class definition, and this would happen
dbz has quit [Remote host closed the connection]
lenqbit has joined #ruby
dbz has joined #ruby
dellavg_ has quit [Ping timeout: 244 seconds]
danguita has quit [Ping timeout: 260 seconds]
danguita has joined #ruby
clorisu has quit [Remote host closed the connection]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
psmolen has quit [Ping timeout: 245 seconds]
<apeiros> JJonah: there are gems out there providing memoization for methods, you should probably take a look
<apeiros> personally, if I'd implement that, I'd use a prefixed method: `memoized def foo; complex_calc; end`
<apeiros> and the impl. would be to have a prepended module.
lenqbit has quit [Ping timeout: 246 seconds]
orbyt_ has joined #ruby
<JJonah> apeiros: how would that work syntactically? (ie, `memoized def foo`) Googling "prefixed ruby method" isn't turning up anything. What it suggests is exactly what I want (meaning I want to treat an ordinary `def` defined method as a first-class object, and then either wrap it or alter it to provide the memoization functionality. But I thought ruby wasn't capable of this...
<apeiros> memoized is a class method, def foo returns :foo, that's passed to memoized as argument
<apeiros> prepended module would mean wrapping (via inheritance chain)
<apeiros> basically: `def memoized(method_name); class_eval("def method_name(*args); @_#{method_name} ||= super"; end); end`
Guest58115 has joined #ruby
<JJonah> apeiros: TIL `def` returns a symbol... Ok what you did makes sense. I guess the part that screwed with me is I want to be able to address the method as an object (like a `Proc`ish) at the class level, but the concepts of `UnboundMethod` only makes sense in ruby at the instance level. Which (related to my question last night) seems like an arbitrary, unnecessary restriction.
<apeiros> no, UnboundMethod doesn't only make sense at an instance level. quite the opposite.
<apeiros> only a bound method (Method) makes only sense at an instance level.
<apeiros> that's why UnboundMethod#bind exists
Guest58115 has quit [Ping timeout: 240 seconds]
<JJonah> apeiros: sorry, that was confusing. I meant that you can't (or I can't figure out how to :) to take an UnboundMethod, alter it (eg, by wrapping it with a memoizer) and then "re-attach" at the class level to its original class. This kind of thing, eg, would be trivial in JS.
psmolen has joined #ruby
reber has quit [Remote host closed the connection]
<apeiros> I don't think altering functions is trivial in JS. I'm curious about that technique.
<JJonah> (other than using `class_eval` as you did, ofc). But that requires manipulation via strings.
<apeiros> define_method takes an UnboundMethod, but doesn't let you alter it.
<JJonah> apeiros: in JS you can just wrap it. and then put it back on the object
<apeiros> wrap isn't alter.
<apeiros> wrapping is trivial in ruby too.
<JJonah> apeiros: So can you do what you did without "eval", but using actual Proc or UnboundMethod objects? That's essentially what I'm asking (and saying is easy in JS)
<apeiros> basically: `def memoized(method_name); ubm = instance_method(method_name); define_method(method_name) do |*args, &block| ubm.bind(self).call(*args, &block); end; end`
<apeiros> essentially the same you'd have to do in JS too (apply/call =~ bind().call())
<apeiros> though if I'd want to do it stringless, I'd do:
<baweaver_away> Oi oi oi, that's a lot of code talk
<lupine> FWIW, we looked at this kind of memoization magic in our codebase, and ran a mile. We just `include Utils::StrongMemoize` and do def x ; strong_memoize { ... } ; end` instead
roshanavand has quit [Ping timeout: 250 seconds]
* baweaver_away starts reading through the back traces
<lupine> just because you can, does not mean you should
<apeiros> `def memoized(method_name); define_method(method_name) do instance_variable_get(:"@_#{method_name}") || "instance_variable_set(:"@_#{method_name}", super); end; end`
<apeiros> lupine: yeah, told them to look at gems :)
<lupine> but yes, it's traditional(ish) OO, not prototypes
<apeiros> all my methods btw. don't give a crap about methods which have valid nil/false results
<JJonah> apeiros: i know about the gems. i'm trying to understand it myself and understand the options. also i'm not crazy about the gem interfaces i've looked at.
<lupine> you can emulate javascript behaviour in ruby quite easily by disdaining classes and using hashes everywhere
<baweaver_away> dangit IRC, gimme my nick
<lupine> you can even add prototypes with the `Hash.new {|h,k| h[k] = ... }` idiom
* apeiros nicks baweaver's irc
<lupine> or, you know, you could just write in javascript. nodejs exists for people who like to do that
<JJonah> lupine: "by disdaining classes and using hashes everywhere" . I have no desire to do that :)
<lupine> right, so it's not surprising that some things are different
<apeiros> yeah, and you can rebuild ruby's class/module infrastructure in JS (even with JS before ES6)
<lupine> you wouldn't want to though :D
<apeiros> I still did, though. and it was fun. and useful.
<baweaver_away> Fine fine....
<lupine> here's an alternative. How about a Memoizer class that acts as a facade around an object and memoizes methods going through it?
baweaver_away is now known as lemur
<apeiros> lupine: indiscriminately memoize all methods?
<JJonah> "so it's not surprising that some things are different"... my issue isn't that "thing are different". it's that i wasn't able to do something i thought i should be able to do. but apeiros last replies are basically the answer i was looking for.
<apeiros> seems wasteful
<JJonah> "indiscriminately memoize all methods" not if you're in the context of an immutable value object which was the jumping off point of the discussion.
<apeiros> would work for the given parameters, though (immutable objects - though memoization basically breaks that)
<lemur> Ah.
<lemur> Decorators
<JJonah> "immutable objects - though memoization basically breaks that" -- it does not.
<lemur> They're hell on inheritance chains though
<apeiros> the moment you store the memoized value in the object, yes, yes, you do :)
<JJonah> only in a technical sense, not in a conceptual sense
<lupine> apeiros: one could optionally implement a list of memoable methods
<JJonah> because you are guaranteed that a pure function on immutable params will always return the same value
<apeiros> lupine: yeah, that'll be rather close to my suggestion of `memoized` using a prepended module.
dbz has quit [Remote host closed the connection]
<JJonah> the object is still immutable in every meaningful way. the "memoizatoin" mutation is purely a caching strategy
<apeiros> just that you create the list by prepending `memoized` to the method def :)
<lemur> If that's what you're going for, there are ways to make it "pure"
<lemur> Though it's insanely pedantic in Ruby to insist on absolute purity
dbz has joined #ruby
<apeiros> Puby!
<apeiros> that's either ruby in puberty, or pure ruby.
<lemur> referential purity, sure. If the outside caller doesn't know you're doing something impure it matters very little.
dbz has quit [Remote host closed the connection]
<JJonah> lemur: i don't want you mean by that. but immutable value objects are very useful in ruby. i don't see any pedantry about them
<apeiros> my point mostly being: you can't use .freeze to ensure the immutability of memoizing objects if you use those objects as the storage for the memoized values.
<lemur> consider this implementation of count_by: def count_by(list, &fn) list.reduce(Hash.new(0)) { |h,v| h[fn[v]] += 1; h } end
<JJonah> "referential purity, sure. If the outside caller doesn't know you're doing something impure it matters very little." exactly
<lemur> It mutates, but it doesn't really matter
<apeiros> and personally, I tend to actually freeze my immutable objects to get early and loud explosions.
<lemur> because the outside caller has no idea it did anything, so you get hybrid FP with some speed gains in Ruby.
kapil___ has quit [Quit: Connection closed for inactivity]
<JJonah> apeiros: that breaks lazy evaluation which is a very good thing and what i'm after here.
sameerynho has quit [Ping timeout: 245 seconds]
<apeiros> JJonah: it doesn't. it just puts restrictions on your available toolset.
<lupine> looks a bit like https://gitlab.com/snippets/1750773
<lupine> 'though ISTR you should implement responds_to or something as well
<JJonah> apeiros: how do you get lazy evaluation out of truly frozen object?
<lemur> Now then, the proposed memo solution looks pure, but technically is not. Question is do we want to be pedantic about that detail, or relish in the fact that it still follows the contract of idempotency?
<JJonah> (lazy evaluation and caching i should say)
<apeiros> JJonah: you don't store the result in the frozen object.
<lupine> heh, my solution works for that
<apeiros> see WeakHash
<JJonah> lemur: "relish in the fact that it still follows the contract of idempotency" i want to relish
* lemur wants a hot dog now
* apeiros is already full, thank you for your consideration
<lemur> apeiros: what was that hackery where you could do this nice long block before a method and it'd redefine the next one to "decorate" it?
<lemur> Api Pie does it everywhere: https://github.com/Apipie/apipie-rails
jjman has joined #ruby
<apeiros> lemur: I'd assume they use method_added
<lemur> Aha!
<JJonah> apeiros: I want the object to cache its own values. The pattern of my original paste is exactly what I want, I just want to avoid the repeated `||=` boilerplate.
<apeiros> at least iirc that's how rake does it
<apeiros> (desc + task)
<jjman> What's a good book to learn ruby these days?
<lemur> jjman: what's your skill level?
<apeiros> JJonah: @memoized={} in initialize
<apeiros> remember, freeze ain't deep
<lemur> and what goals do you have?
<lemur> Also see the books list in the channel topic
<apeiros> JJonah: though I see zero reason for that requirement. seems rather arbitrary.
<JJonah> apeiros: sure, but that's just an implementation detail. i fail to see how that's fundamentally different from the pattern i posted.
<apeiros> which pattern did you post?
<apeiros> you mean @foo ||=?
<JJonah> "for that requirement. seems rather arbitrary." -- which requirement. i meant this pattern: https://eval.in/1053602
<apeiros> "I want the object to cache its own values"
<apeiros> this requirement
<jjman> lemur: have solid compsci foundations I guess, my goal is Rails ;) to create a server-side-rendered html web app in a short time
<apeiros> why do you bother where the cache is?
<apeiros> it's an implementation detail
<apeiros> (unless you fuck up, of course :D)
<JJonah> apeiros: yes, i think we're crossing wires. if the internal hash is doing it, it's still "the object caching its own values"
<lemur> jjman: Start around "Eloquent Ruby"
<JJonah> the only POV we're considering is the object's contract from the outside
<apeiros> JJonah: I see no issue with an external weakhash storing it either
<lemur> It teaches Ruby from a perspective of already knowing programming
<apeiros> both variants allow you to freeze your object
<apeiros> allowing you to enforce the immutability contract
desperek has quit [Quit: xoxo]
<JJonah> apeiros: external to the object itself? that would be bad imo. an internal hash, that's fine.
<apeiros> maintaining your requirement of caching/lazy evaluation
<jjman> lemur: Ok, will check out it, have you read the pickaxe boo? seems appropiate too
<jjman> s/boo/book/
<lemur> It's a bit basic
<apeiros> define external. the only things internal to an object are variables. never objects.
<apeiros> so IMO that notion is pointless.
<JJonah> apeiros: we're just using the word differently
<jjman> lemur: ok yeah, I like details
<lemur> Books: https://goo.gl/wpGhoQ
<lemur> I wrote this list a while back
<lemur> give it a look.
<lemur> There's a Rails one too
<lemur> Rails Book List: http://goo.gl/SGklzh
<apeiros> JJonah: I see that differently. but well, it's bed time for me.
<JJonah> i mean the client of the object should not have to deal with the object AND a 2nd object that does the caching
<apeiros> JJonah: why do you think the client would have to?
<apeiros> as said, it's an implementation detail
<JJonah> apeiros: i am like 95% sure we're agreeing
<lupine> note that `@foo ||=` doesn't work well if hte result is `false` or `nil`, yet still expensive to compute
<jjman> lemur: yeah, got the pickaxe book from your first link, thanks
<JJonah> lupine: yes, that's a good point. you can get around that if need be though.
<lupine> aye, it's easily forgotten is all
<lupine> I still like mine. the internal vs. external question is by the by - ruby doesn't store data like that
tty has joined #ruby
<lupine> all we're asking is whether the memozied class holds a reference to its memoizer or not
<JJonah> lupine: yours being the method_missing version?
<lupine> ja
<JJonah> and yes, i agree that is an implementation detail
dbz has joined #ruby
<JJonah> to me the question of `||=` vs a private hash is of little import.
<lupine> it can be useful to hold such a reference - for instance, you might want to clear memoized values based on some interaction or another. but you can always include the reference if you need it
<JJonah> lupine: sure
thejs has quit [Ping timeout: 244 seconds]
bomb has joined #ruby
dbz has quit [Ping timeout: 240 seconds]
jp has quit [Ping timeout: 245 seconds]
<JJonah> lupine: the only thing i don't like about the method_missing snippet you posted is that I have to create my object and then wrap it. I can't just issue the directive at the class level. Or have I misunderstood?
<jjman> lemur: the rails guide seem pretty good I guess? why are they not on your list?
<lemur> Probably forgot
<lemur> Throw a comment up with a link to it
<lemur> It's not unusual that I miss one or two good ones :P
<jjman> ok
<bomb> hi i'm learning ruby
<jjman> bomb: me too!
<lemur> It's the bomb :D
<jjman> ;)
<bomb> \o/
<lemur> bomb: What's your skillset? What do you want to make?
<lemur> See the booklist in the channel topic
<bomb> mobile and desktop GUI lemur. but first i need to learn ruby well. it's a little different than what i knew
<bomb> thanks
<lemur> Eloquent Ruby is a good start
lemur is now known as baweaver
<baweaver> Aha! Got my nick back
<baweaver> There we go.
<bomb> hehe
<JJonah> lemur: do you use your Mf gem often in your own work? I found it a few weeks after write a similar gem (https://github.com/jonahx/pretty_ruby) and thought it was quite clever.
<JJonah> baweaver: ^^
<baweaver> lemur === baweaver
<baweaver> Sometimes
<bomb> Eloquent Ruby alright
<baweaver> I use Xf and Qo a ton
<baweaver> Xf is real danged handy for Swagger JSON debugging, Jira responses, and other such things
jp has joined #ruby
<baweaver> Qo for a lot of ETL type tasks to trim down some real nasty logic
<lupine> JJonah: one option would be to override the `new` method to return an always-memoized instance
<baweaver> I used Mf to get around having to monkey patch anything
<lupine> or to add a `build_memoized` class method that does the smae
<lupine> lots of ways to do this
<bomb> do you know what's the reasoning behind this quote? "Ruby is designed to make programmers happy."
<JJonah> baweaver: i want to alias it to X though so i can do `map {&X + 5}` etc... :)
<baweaver> Nothing stopping you from `X = Mf` :)
<JJonah> bomb: the language is intended to be fun to write and pretty to read.
<baweaver> All the one letter names were taken
<baweaver> I ended up getting a hold of Any too
<baweaver> Any is an always true match
<baweaver> For Qo you can do this: [1, 's', 3.0, 4].select(&Qo[Integer, 1..4])
mroutis has joined #ruby
<bomb> JJonah: hmm sounds cool. is it really fun in practice?
<baweaver> If you had tuples or objects it gets real handy
<baweaver> people.select(&Qo[name: Any, age: 20..30])
<baweaver> Though it'll hard require that key to exist
<baweaver> #ruby-offtopic is a fun join if you want to see shenanigans outside of just Ruby in Ruby.
<JJonah> baweaver: nice.
<baweaver> Anyone else going to RubyConf this year?
<baweaver> If you are you get to see me making lemur voices on stage :D
Nicmavr has quit [Ping timeout: 245 seconds]
clorisu has joined #ruby
mikecmpbll has joined #ruby
<JJonah> bomb: that's a hard question to answer. the short is: it's a nice language, but not perfect.
clorisu has quit [Read error: Connection reset by peer]
<baweaver> I certainly have fun
<baweaver> http://rubyconf.org/program#session-716 - Lemur talk! :D
thejs has joined #ruby
Nicmavr has joined #ruby
<JJonah> baweaver: "They're hell on inheritance chains though"... just scrolled up to copy something and noticed this. Don't you mean "inheritcance chains are hell in themselves"?
<baweaver> method_added
<bomb> JJonah: fair. hopefully it brings the fun back, because i'll be using Ruby for non-serious projects :)
<JJonah> bomb: what do you program in now?
<bomb> JJonah: i mostly do java and python professionally. got some free time now, wanted to try Ruby for some small mobile and desktop apps
<bomb> i'll be using rubymotion and shoes
<JJonah> bomb: i personally think ruby is more fun than both of those languages, especially java. though tbh it's not _that_ different from python.
<bomb> JJonah: speaking of java, does jruby work well? it doesn't hurt to have an access to an ocean of libraries
<JJonah> bomb: haven't use it much myself, but i think it's fairly mature.
<lupine> I've got production experience of jruby. it's pretty solid
<lupine> sometimes surprising things happen, and the gap between jruby and cruby is a lot narrower now than it was back then. I probably wouldn't use it again
<baweaver> TruffleRuby is the new kid on the block there.
<bomb> oh glad to hear. JavaFX + JRuby with Shoes-esque interface might be fun
<bomb> TruffleRuby is that new Graal thing?
<baweaver> yep
pabs has joined #ruby
duderonomy has quit [Ping timeout: 246 seconds]
doubledup has quit [Quit: Leaving]
nowhere_man has joined #ruby
Nicmavr has quit [Quit: ZNC 1.7.0 - https://znc.in]
Nicmavr has joined #ruby
dbz has joined #ruby
<bomb> interesting. RPG Maker XP uses Ruby for scripting. LibGDX + JRuby also works, apparently. and there is also Gosu
<baweaver> RMXP and one of the later versions
<baweaver> it uses JS now.
AJA4351 has joined #ruby
<baweaver> Though it was also some variant of 1.9.2
<baweaver> and was pretty sketch
<bomb> yeah, i have the MV version. i wish XP was on sale
AJA4350 has quit [Ping timeout: 240 seconds]
AJA4351 is now known as AJA4350
<baweaver> I used to hang around a lot of RPG maker forums as lemur forever ago.
<bomb> was it fun?
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<baweaver> Yep. Some good times way back then.
<baweaver> KobrasRealm, RpgRpgRevolution, and a few others
<baweaver> Some DreamInCode too, but that was more generic.
<bomb> i heard many people still use XP because of the existing Ruby scripts
RougeR has quit [Ping timeout: 246 seconds]
clorisu has joined #ruby
apeiros has quit [Ping timeout: 246 seconds]
psmolen has quit [Ping timeout: 272 seconds]
psmolen has joined #ruby
Guest58115 has joined #ruby
nowhere_man has quit [Ping timeout: 245 seconds]
Guest58115 has quit [Ping timeout: 244 seconds]
apeiros has joined #ruby
jackrandom has quit [Quit: ZNC - https://znc.in]
LiftLeft3 has joined #ruby
LiftLeft has quit [Remote host closed the connection]
jackrandom has joined #ruby
Nicmavr has quit [Quit: ZNC 1.7.0 - https://znc.in]
clorisu has quit [Ping timeout: 245 seconds]
orbyt_ has joined #ruby
clorisu has joined #ruby
thejs has quit [Remote host closed the connection]
dviola has joined #ruby
DTZUZO has quit [Ping timeout: 240 seconds]
clorisu has quit [Quit: Leaving]
eblip is now known as eb0t_
Freshnuts has joined #ruby
johnny56 has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]