havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.6.3, 2.5.5, 2.7.0-preview1: 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!
AJA4350 has quit [Quit: AJA4350]
lucasb has quit [Quit: Connection closed for inactivity]
ramfjord has quit [Ping timeout: 252 seconds]
ramfjord has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ramfjord has quit [Ping timeout: 252 seconds]
duderonomy has joined #ruby
duderonomy has quit [Client Quit]
r3m has quit [Quit: WeeChat 2.6-dev]
r3m has joined #ruby
duderonomy has joined #ruby
r3m has quit [Client Quit]
r3m has joined #ruby
r3m has quit [Client Quit]
r3m has joined #ruby
duderonomy has quit [Client Quit]
bambanx has joined #ruby
mrpropa has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
duderonomy has joined #ruby
duderonomy has quit [Client Quit]
ramfjord has joined #ruby
duderonomy has joined #ruby
duderonomy has quit [Client Quit]
ramfjord has quit [Ping timeout: 245 seconds]
sarink has joined #ruby
bambanx has quit [Quit: Leaving]
sarink has quit [Ping timeout: 246 seconds]
ramfjord has joined #ruby
codefriar has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
yokel has quit [Read error: Connection reset by peer]
yokel has joined #ruby
Esa_ has quit []
wilywizard has quit [Remote host closed the connection]
Swyper has joined #ruby
BTRE has quit [Remote host closed the connection]
BTRE has joined #ruby
Fernando-Basso has quit [Remote host closed the connection]
Swyper has quit [Remote host closed the connection]
tranch has joined #ruby
hightower2 has quit [Ping timeout: 244 seconds]
duderonomy has joined #ruby
duderonomy has quit [Client Quit]
duderonomy has joined #ruby
ramfjord has quit [Ping timeout: 252 seconds]
duderonomy has quit [Client Quit]
tranch has quit [Quit: tranch]
mrpropa has joined #ruby
tranch has joined #ruby
ghostlines has joined #ruby
codefriar has joined #ruby
duderonomy has joined #ruby
ghostlines has quit [Client Quit]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
leah2 has quit [Ping timeout: 246 seconds]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Inline has quit [Ping timeout: 250 seconds]
oncall-pokemon has joined #ruby
leah2 has joined #ruby
gnufied has quit [Quit: Leaving]
sarink has joined #ruby
sarink has quit [Ping timeout: 244 seconds]
GodFather has quit [Read error: No route to host]
orbyt_ has joined #ruby
ellcs has quit [Ping timeout: 252 seconds]
scp has quit [Quit: Konversation terminated!]
braincrash has quit [Quit: bye bye]
duderonomy has joined #ruby
podlech has joined #ruby
codefriar has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
code_zombie has quit [Quit: Leaving]
code_zombie has joined #ruby
braincrash has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ellcs has joined #ruby
duderonomy has joined #ruby
csaunders has joined #ruby
duderonomy has quit [Client Quit]
Net has quit [Read error: Connection reset by peer]
Net has joined #ruby
m_antis_ has quit [Ping timeout: 246 seconds]
ramfjord has joined #ruby
m_antis has joined #ruby
ramfjord has quit [Ping timeout: 246 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
podlech has quit [Quit: WeeChat 2.5-dev]
crankharder has quit [Ping timeout: 245 seconds]
sarink has joined #ruby
cd has quit [Remote host closed the connection]
cd has joined #ruby
Technodrome has joined #ruby
<Technodrome> Good day
RiPuk has quit [Quit: ZNC 1.7.3 - https://znc.in]
RiPuk has joined #ruby
donofrio has quit [Remote host closed the connection]
sarink has quit [Remote host closed the connection]
duderonomy has joined #ruby
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
oncall-pokemon has quit [Quit: Connection closed for inactivity]
m_antis_ has joined #ruby
staticx has joined #ruby
m_antis has quit [Ping timeout: 246 seconds]
staticx has quit [Read error: Connection reset by peer]
exmortus has quit [Ping timeout: 258 seconds]
staticx has joined #ruby
tranch has quit [Quit: tranch]
SeepingN has joined #ruby
tranch has joined #ruby
m_antis_ has quit [Ping timeout: 258 seconds]
cschneid has joined #ruby
houhoulis has quit [Remote host closed the connection]
zxq2 has quit [Remote host closed the connection]
cgfbee has joined #ruby
tranch has quit [Quit: tranch]
tranch has joined #ruby
BTRE has quit [Read error: Connection reset by peer]
themsay has joined #ruby
za1b1tsu has joined #ruby
conta has joined #ruby
BTRE has joined #ruby
m_antis_ has joined #ruby
tranch has quit [Ping timeout: 268 seconds]
cschneid has quit [Ping timeout: 258 seconds]
m_antis_ has quit [Ping timeout: 272 seconds]
cthu| has joined #ruby
sauvin has joined #ruby
tranch has joined #ruby
BTRE has quit [Ping timeout: 268 seconds]
m_antis has joined #ruby
teardown has joined #ruby
teardown_ has joined #ruby
teardown is now known as Guest79354
teardown_ is now known as teardown
m_antis_ has joined #ruby
m_antis has quit [Ping timeout: 272 seconds]
yokel has quit [Read error: Connection reset by peer]
yokel has joined #ruby
Guest79354 has quit [Quit: leaving]
schne1der has joined #ruby
SeepingN has quit [Quit: The system is going down for reboot NOW!]
<r3m> hi, is there an equivalent to %r but without interpolation, like %q for %Q, %w for %W? or the only way I have is to use Regexp.new('...')
<leftylink> shit shit shit wrong channel so sorry
schne1der has quit [Ping timeout: 252 seconds]
cschneid has joined #ruby
m_antis has joined #ruby
<ytti> it looks like i could be kpop singer
<ytti> i think i could lip sync better, or maybe the video/audio sync is just bad
m_antis_ has quit [Ping timeout: 252 seconds]
reber has joined #ruby
mayurvpatil has joined #ruby
mayurvpatil has quit [Max SendQ exceeded]
<havenwood> r3m: No, there isn't a %R or equivalent.
<r3m> havenwood: thanks
<r3m> I was just curious since %w %q and %x have an uppercase version
<havenwood> &>> '#{}'.match? /#{Regexp.escape('#{}')}/
<rubydoc> # => true (https://carc.in/#/r/74lu)
clemens3 has joined #ruby
<r3m> nice thanks
nolanv has quit [Read error: Connection reset by peer]
<r3m> otherwise Regexp.new with single quote works too
<havenwood> yeah, that's a good way 👍🏽
code_zombie has quit [Quit: Leaving]
mayurvpatil has joined #ruby
mayurvpatil has quit [Max SendQ exceeded]
mayurvpatil has joined #ruby
mayurvpatil has quit [Remote host closed the connection]
mayurvpatil has joined #ruby
hiroaki has quit [Ping timeout: 272 seconds]
nolanv has joined #ruby
cd has quit [Quit: cd]
lxsameer has joined #ruby
BTRE has joined #ruby
cschneid has quit [Ping timeout: 272 seconds]
lxsameer has left #ruby ["in"]
sandstrom has joined #ruby
TomyWork has joined #ruby
schne1der has joined #ruby
aupadhye has joined #ruby
deepreds1 has joined #ruby
donofrio has joined #ruby
deepreds1 has quit [Ping timeout: 252 seconds]
za1b1tsu has quit [Ping timeout: 245 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mikecmpbll has quit [Quit: inabit. zz.]
za1b1tsu has joined #ruby
AndreYuhai has quit [Remote host closed the connection]
AndreYuhai has joined #ruby
alem0lars has joined #ruby
deepreds1 has joined #ruby
crankharder has joined #ruby
cschneid has joined #ruby
alem0lars has quit [Ping timeout: 252 seconds]
m_antis has quit [Quit: m_antis]
conta has quit [Ping timeout: 248 seconds]
m_antis has joined #ruby
mayurvpatil has quit [Ping timeout: 245 seconds]
conta has joined #ruby
m_antis has quit [Ping timeout: 248 seconds]
cschneid has quit [Ping timeout: 258 seconds]
m_antis has joined #ruby
gigetoo has quit [Ping timeout: 258 seconds]
m_antis has quit [Ping timeout: 258 seconds]
gigetoo has joined #ruby
matheusmoreira has quit [Quit: rebooting]
sagax has quit [Ping timeout: 245 seconds]
themsay has quit [Ping timeout: 252 seconds]
matheusmoreira has joined #ruby
mayurvpatil has joined #ruby
m_antis has joined #ruby
cthu| has quit [Read error: Connection reset by peer]
miah has quit [Remote host closed the connection]
m_antis has quit [Ping timeout: 272 seconds]
DTZUZO has quit [Ping timeout: 245 seconds]
csaunders has quit [Quit: later tater]
themsay has joined #ruby
galaxie has quit [Remote host closed the connection]
galaxie has joined #ruby
themsay has quit [Ping timeout: 252 seconds]
themsay has joined #ruby
tranch has quit [Ping timeout: 246 seconds]
tranch has joined #ruby
conta has quit [Ping timeout: 252 seconds]
sagax has joined #ruby
matheusmoreira has quit [Ping timeout: 245 seconds]
matheusmoreira has joined #ruby
yokel has quit [Read error: Connection reset by peer]
yokel has joined #ruby
conta has joined #ruby
ramfjord has joined #ruby
doodlebug has quit [Remote host closed the connection]
ramfjord has quit [Ping timeout: 258 seconds]
mayurvpatil has quit [Quit: This computer has gone to sleep]
Technodrome has joined #ruby
mayurvpatil has joined #ruby
tranch has quit [Ping timeout: 272 seconds]
tranch has joined #ruby
leah2 has quit [Ping timeout: 248 seconds]
alem0lars has joined #ruby
tranch has quit [Ping timeout: 248 seconds]
tranch has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tranch has quit [Client Quit]
leah2 has joined #ruby
imadper is now known as imAdPER|wORkinG
za1b1tsu has quit [Remote host closed the connection]
AJA4350 has joined #ruby
mayurvpatil has quit [Quit: This computer has gone to sleep]
alem0lars has quit [Ping timeout: 272 seconds]
mjacob has joined #ruby
<mjacob> when calling `each` on a array of arrays, the inner array gets expanded. when i pass a proc to each, it doesn't. what would be the most "idiomatic" way to let the inner arrays get expanded before they are passed to the proc?
mikecmpbll has joined #ruby
AndreYuhaii has joined #ruby
<ytti> i'm not sure what you mean, but if oyu call [[1,2],[3,4]].each you are getting [1,2] and [3,4] not 1,2,4,5
<ytti> so the way i understand 'expanded', that is not happening at all
<ytti> you could call Array#collapse to make it single dimensional, if that is what you need
<ytti> s/collapse/flatten/
<ytti> i wonder which language i was thinking
<mjacob> ytti: `[[1,2],[3,4]].each do |a, b| ... end` works
<mjacob> although (naively speaking) the block takes two params, but each passes only one arg
AndreYuhai has quit [Ping timeout: 248 seconds]
<ytti> mjacob, that's beacuse you're desructuring it with |a,b|
DTZUZO has joined #ruby
mniip has joined #ruby
<mjacob> so basically i want to pass it a proc, but in a way that a,b gets destructured
<ytti> can you show simple example what is happening and what you want to happen
mayurvpatil has joined #ruby
alem0lars has joined #ruby
<mjacob> ytti: `[[1,2],[3,4]].each(&lambda do |a, b| puts a + b end)` "should" print 3 and 7, but fails with "ArgumentError (wrong number of arguments (given 1, expected 2))"
<ytti> works for me
<ytti> [1] pry(main)> [[1,2],[3,4]].each(&lambda do |a, b| puts a + b end);RUBY_VERSION
<ytti> 3
<ytti> 7
<ytti> => "2.3.7"
<ytti> mjacob, ithnk you need (a,b) in 1.8 and older
<ytti> i don't have 1.8 at hand
<ytti> mjacob, |(a,b)| instead of |a,b|
<mjacob> i'm on 2.5.3
themsay has quit [Read error: Connection reset by peer]
<ytti> mjacob, does parenthesis fix the problem)
themsay has joined #ruby
<mjacob> yes, but the proc i want to pass is already there; i can't simply add the parens
queip has joined #ruby
<ytti> k = lambda{|(a,b)|puts a+b};[[1,2],[3,4]].each(&k)
<ytti> wont work?
<ytti> or you can't do it
<ytti> because lambda is defined elsewhere
<ytti> and you cannot change it?
<phaul> &25>> [[[1,2],[3,4]].map(&lambda do |a, b| a + b end), RUBY_VERSION]
<rubydoc> # => [[3, 7], "2.5.3"] (https://carc.in/#/r/74po)
leah2 has quit [Ping timeout: 272 seconds]
<ytti> [13] pry(main)> lambda{|a,b|puts a+b}.arity
<ytti> => 2
<ytti> [14] pry(main)> lambda{|(a,b)|puts a+b}.arity
<ytti> => 1
<ytti> it is what it is
<ytti> the first one takes two arguments, the second one takes one and destructures them
<ytti> and your each is decidedly passing single argument
<ytti> if you can't change the lambda, change the call: k = lambda{|a,b|puts a+b};[[1,2],[3,4]].each{|a,b|k.call(a,b)}
kyrylo has joined #ruby
cpruitt has joined #ruby
Cthulu201 has quit [Quit: Nowhere special. I always wanted to go there.]
leah2 has joined #ruby
yokel has quit [Read error: Connection reset by peer]
yokel has joined #ruby
TomyWork has quit [Remote host closed the connection]
TomyWork has joined #ruby
Cthulu201 has joined #ruby
AndreYuhaii has quit [Read error: Connection reset by peer]
AndreYuhaiii has joined #ruby
ramfjord has joined #ruby
ramfjord has quit [Ping timeout: 245 seconds]
conta has quit [Ping timeout: 245 seconds]
cschneid has joined #ruby
Swyper has joined #ruby
crankharder has quit [Ping timeout: 272 seconds]
AndreYuhaii has joined #ruby
Swyper has quit [Remote host closed the connection]
crankharder has joined #ruby
AndreYuhaiii has quit [Ping timeout: 245 seconds]
sarink has joined #ruby
conta has joined #ruby
sarink has quit [Ping timeout: 268 seconds]
Swyper has joined #ruby
sarink has joined #ruby
Rudd0 has quit [Ping timeout: 248 seconds]
Rudd0^ has quit [Ping timeout: 248 seconds]
Sina has quit [Quit: Connection closed for inactivity]
codefriar has joined #ruby
cschneid has quit [Ping timeout: 246 seconds]
<mjacob> ytti: sorry for the late answers
<mjacob> ytti: yes, something like {|a,b|k.call(a,b)} would work
<mjacob> but it would be nice to know how to solve this in a general way
crankharder has quit [Ping timeout: 244 seconds]
Rudd0 has joined #ruby
mayurvpatil has quit [Quit: This computer has gone to sleep]
Swyper has quit [Remote host closed the connection]
Rapture has joined #ruby
waheedi has joined #ruby
sarink has quit [Remote host closed the connection]
crankharder has joined #ruby
mayurvpatil has joined #ruby
<mjacob> i.e. i look for a function X that takes function A with (in the example) two parameters and returns function B with one array parameter
Fernando-Basso has joined #ruby
mayurvpatil has quit [Client Quit]
Inline has joined #ruby
mn3m has joined #ruby
schne1der has quit [Ping timeout: 244 seconds]
conta has quit [Ping timeout: 245 seconds]
yokel has quit [Read error: Connection reset by peer]
yokel has joined #ruby
flux__aeon has joined #ruby
spiette has quit [Quit: ZNC 1.7.3 - https://znc.in]
spiette has joined #ruby
aupadhye has quit [Quit: Leaving]
aupadhye has joined #ruby
TomyWork has quit [Ping timeout: 246 seconds]
cschneid has joined #ruby
queip has quit [Ping timeout: 272 seconds]
AndreYuhaii has quit [Remote host closed the connection]
AndreYuhaii has joined #ruby
schneider has joined #ruby
mynameisdebian has joined #ruby
queip has joined #ruby
mynameisdebian has quit [Ping timeout: 244 seconds]
aupadhye has quit [Remote host closed the connection]
ropeney has quit [Quit: ZNC 1.6.5+deb1+deb9u1 - http://znc.in]
Technodrome has joined #ruby
Rapture has quit [Quit: Textual IRC Client: www.textualapp.com]
wrkrcoop has joined #ruby
wrkrcoop has quit [Client Quit]
Rapture has joined #ruby
conta has joined #ruby
ropeney has joined #ruby
cschneid has quit [Ping timeout: 268 seconds]
<leftylink> oh
<leftylink> that looks like either curry or uncurry but I can never remember which :)
deepreds1 has quit [Ping timeout: 252 seconds]
<leftylink> I see that Proc#curry exists but not Proc#uncurry. so if this operation is actually uncurry then WE'RE OUT OF LUCK
cschneid has joined #ruby
ropeney has quit [Client Quit]
AndreYuhaii has quit [Remote host closed the connection]
ropeney has joined #ruby
ropeney has quit [Remote host closed the connection]
AndreYuhaii has joined #ruby
<leftylink> (or you just have to write your own)
ropeney has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lucasb has joined #ruby
AndreYuhaii has quit [Remote host closed the connection]
AndreYuhaii has joined #ruby
yokel has quit [Read error: Connection reset by peer]
yokel has joined #ruby
<leftylink> yeah
<leftylink> &>> def uncurry(f) ->(a) { f[*a] } end; f = ->(a, b) { puts a + b }; mjacob = uncurry(f)[[1, 2]]
<rubydoc> # => 3 (https://carc.in/#/r/74qt)
<leftylink> since Proc#uncurry doesn't exist I guess we just have to write our own. unless there's something I missed.
<leftylink> enjoy
<leftylink> by the way if someone has any mnemonic for remember which direction is curry vs uncurry I would gladly receive
<mjacob> leftylink: i think curry / uncurry is an unrelated concept
<leftylink> I see. I thought uncurry is exactly what you are asking for. but if you think it is unrelated, I will trust your judgment and yield the floor to the person who knows the correct answeer to your question
<leftylink> with my apologies for giving you an incorrect answer
xco has joined #ruby
cschneid has quit [Ping timeout: 252 seconds]
ropeney has quit [Ping timeout: 248 seconds]
conta has quit [Ping timeout: 246 seconds]
mynameisdebian has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ropeney has joined #ruby
conta has joined #ruby
<mynameisdebian> Has anyone here ever built a Slack app in Ruby? I am trying to do an unfurl. Here is my code: https://dpaste.de/F6mW I am testing on my local machine running Apache and ngrok. When I receive the verification challenge event it runs the first condition and I ngrok tells me it is sending a 200 response. However, when I receive an unfurl it runs the second conditional and it tells me it is sending a 500 Internal Server Error. Even if I only run the
<mynameisdebian> line "puts 'HTTP/1.0 200 OK'" ngrok is still sending a 500 Internal Server Error. I fumbled around to handle the challenge token and I don't know any way to "respond" with 200 OK other than printing it. Can anyone help me with this?
AJA4351 has joined #ruby
AJA4350 has quit [Ping timeout: 252 seconds]
AJA4351 is now known as AJA4350
gigetoo has quit [Remote host closed the connection]
ropeney has quit [Client Quit]
ropeney has joined #ruby
ropeney has quit [Client Quit]
ropeney has joined #ruby
mrpropa has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gigetoo has joined #ruby
Technodrome has joined #ruby
sandstrom has quit [Quit: My computer has gone to sleep.]
thegeekinside has joined #ruby
conta has quit [Ping timeout: 268 seconds]
alem0lars has quit [Ping timeout: 258 seconds]
conta has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ropeney has quit [Quit: ZNC 1.7.4 - https://znc.in]
fphilipe_ has quit [Ping timeout: 268 seconds]
ropeney has joined #ruby
ropeney has quit [Remote host closed the connection]
ropeney has joined #ruby
ropeney has quit [Quit: ZNC 1.7.4 - https://znc.in]
Fernando-Basso has quit [Remote host closed the connection]
ropeney has joined #ruby
ropeney has quit [Client Quit]
ropeney has joined #ruby
clemens3 has quit [Quit: WeeChat 1.6]
yokel has quit [Read error: Connection reset by peer]
yokel has joined #ruby
<mynameisdebian> How can I simply make a Ruby CGI script (with "cgi" gem) respond to a request with HTTP 200?
aupadhye has joined #ruby
mrpropa has joined #ruby
Technodrome has joined #ruby
deepreds1 has joined #ruby
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
za1b1tsu has joined #ruby
rippa has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
aupadhye has quit [Quit: Leaving]
AndreYuhaii has quit [Quit: Leaving]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Exagone313 has quit [Quit: see ya!]
za1b1tsu has quit [Remote host closed the connection]
evdubs_ has quit [Ping timeout: 250 seconds]
Exagone313 has joined #ruby
Technodrome has joined #ruby
sandstrom has joined #ruby
conta has quit [Ping timeout: 272 seconds]
conta has joined #ruby
Swyper has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Technodrome has joined #ruby
englishm has quit [Excess Flood]
englishm has joined #ruby
<adam12> mynameisdebian: The CGI library in stdlib is _somewhat_ clunky. What's your overall goal of this project? Do you care if you have any dependencies?
Rapture has quit [Quit: Textual IRC Client: www.textualapp.com]
<mynameisdebian> adam12: I just want it to be simple. I'm trying to write a Slack app. I get an event in JSON and I'm supposed to immediately respond with HTTP 200, then POST some data to an API endpoint. At this point I would just be happy to figure out how to generate the HTTP 200 response
<ytti> you are getting POST/GET just make route for it
<adam12> mynameisdebian: This is a cgi script right?
<ytti> and by responding to the route, you'll send 200
<mynameisdebian> ytti: is that a Rails thing?
<ytti> mynameisdebian, i would recommend sinatra, but anything goes
<ytti> same result everywhere, if you actually catch the POST/GET, the infra will respond with 200
<adam12> mynameisdebian: I'm not sure that "HTTP/1.0 200 OK" is the correct header for a CGI script, tho it's been a number of years. What about `Status: 200 OK` instead?
<adam12> mynameisdebian: IMHO, I'd bring in rack as a dependency and use the rack CGI handler... with the caveat that sometimes it's not perfect.
<ytti> nah HTTP/1.1 200 OK is definitely fine
<ytti> anyhow you need not know this
<ytti> unless you're writing the low level stuff
yokel has quit [Read error: Connection reset by peer]
<ytti> and you shouldn't based on questions you're asking
<ytti> you just need to have route for what ever their POSTing/GETing
yokel has joined #ruby
<adam12> mynameisdebian: I'm not sure if it helps at all, but I made a URL shortener using Rack as a CGI script. It's open source. Maybe it will give you some clues. If possible, I'd opt to use Rack instead of cgi in stdlib, but I guess that's personal preference. https://github.com/adam12/shorturl
_whitelogger has joined #ruby
<ytti> but on sinatra :)
<ytti> the magid for adam is here:
<ytti> this catches the GET request
<ytti> and the return array tells what it reports back
<ytti> in my case it is get and post lines creating the route
mrpropa has quit [Ping timeout: 252 seconds]
duderonomy has joined #ruby
crankharder has quit [Ping timeout: 245 seconds]
mn3m has quit [Quit: mn3m]
fuzzface has joined #ruby
thunderbirdtr has joined #ruby
redlegion has quit [Quit: The Lounge - https://thelounge.chat]
code_zombie has joined #ruby
redlegion has joined #ruby
deepredsky has joined #ruby
cschneid has joined #ruby
deepreds1 has quit [Ping timeout: 258 seconds]
jefffrails35 has joined #ruby
ramfjord has joined #ruby
mynameisdebian has quit [Remote host closed the connection]
schneider has quit [Ping timeout: 248 seconds]
yokel has quit [Read error: Connection reset by peer]
reber_ has joined #ruby
yokel has joined #ruby
leah2 has quit [Ping timeout: 258 seconds]
rippa has quit [Ping timeout: 248 seconds]
rippa has joined #ruby
cschneid has quit [Ping timeout: 246 seconds]
AJA4350 has quit [Ping timeout: 245 seconds]
schneider has joined #ruby
leah2 has joined #ruby
kyrylo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
riotjone_ has joined #ruby
dviola has joined #ruby
sauvin has quit [Ping timeout: 258 seconds]
beanholez has joined #ruby
<beanholez> I have a problem I'm struggling with a clean solution for. I have been given a hash that can be nested to arbitrary depth. I also have a string that is the path to some data in that hash: "user.name.last.keyword"
themsay has quit [Read error: Connection reset by peer]
<beanholez> Given that string, I want to look in the hash like: h['user']['name']['last']
themsay has joined #ruby
<havenwood> beanholez: h.dig('user', 'name', 'last')
<beanholez> However, the hash is structured in such a way that the value can exist in one of two keys: h['user']['properties'||'fields']['name']['properties'||'fields']['first']...
<havenwood> &>> "user.name.last.keyword".split('.').reverse.reduce({}) { |acc, key| {key => acc} }
<rubydoc> # => {"user"=>{"name"=>{"last"=>{"keyword"=>{}}}}} (https://carc.in/#/r/74sq)
<beanholez> Thank you, I needed to see reduce
conta has quit [Remote host closed the connection]
<ytti> my solution, which also supports arrays eg user.name[2].foo.bar
troulouliou_dev has quit [Ping timeout: 245 seconds]
<beanholez> I am fortunately guaranteed a hash in this case, but I do like that solution
<havenwood> beanholez: So you're looking for a kinda multi-option #dig?
<beanholez> havenwood exactly
<leftylink> hmm
<beanholez> Reducing over the input string, passing the hash to search as the initial acc value works
<leftylink> that sounds like what I'd do
waheedi has quit [Ping timeout: 248 seconds]
waheedi has joined #ruby
yokel has quit [Read error: Connection reset by peer]
yokel has joined #ruby
conta has joined #ruby
queip has quit [Ping timeout: 244 seconds]
riotjone_ has quit [Ping timeout: 258 seconds]
queip has joined #ruby
gix has joined #ruby
Inline has quit [Ping timeout: 252 seconds]
troulouliou_dev has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<beanholez> My solution ended up being reasonable: path.split('.').reduce(hash) {|acc, key| return nil if acc.nil?; acc.dig(:properties, key) || acc.dig(:fields, key) || acc }
<havenwood> beanholez: nice
<havenwood> beanholez: I usually just `return` instead of explicit `return nil`.
cthulchu_ has joined #ruby
Inline has joined #ruby
waheedi has quit [Ping timeout: 246 seconds]
tdy1 has joined #ruby
waheedi has joined #ruby
cpruitt has quit []
tdy has quit [Ping timeout: 248 seconds]
nfsnobody has quit [*.net *.split]
nfsnobody has joined #ruby
tdy1 has quit [Remote host closed the connection]
yokel has quit [Read error: Connection reset by peer]
yokel has joined #ruby
tdy has joined #ruby
leah2 has quit [Ping timeout: 268 seconds]
sandstrom has quit [Quit: My computer has gone to sleep.]
Wolland has joined #ruby
conta has quit [Quit: conta]
leah2 has joined #ruby
dbugger has joined #ruby
dbugger has quit [Remote host closed the connection]
reber_ has quit [Remote host closed the connection]
reber has quit [Remote host closed the connection]
Rapture has joined #ruby
cschneid has joined #ruby
dellavg_ has joined #ruby
cschneid has quit [Remote host closed the connection]
Wolland has quit [Quit: Mutter: www.mutterirc.com]
cschneid has joined #ruby
cschneid has quit [Remote host closed the connection]
dellavg_ has quit [Ping timeout: 248 seconds]
CCDelivery has joined #ruby
duleja has joined #ruby
<duleja> hello
<havenwood> duleja: hi
<duleja> hi havenwood :)
<duleja> how are you? :) still recovering from the previous discussion on rails chat? :)
retromode has joined #ruby
yokel has quit [Remote host closed the connection]
<duleja> can you suggest some strategies on opening a large json file in ruby? I would like to open a json file from url that is ~15 mb
<havenwood> Just launched a Ruby SDK into beta :) https://developer.squareup.com/blog/announcing-square's-new-ruby-sdk/
yokel has joined #ruby
thegeekinside has quit [Ping timeout: 252 seconds]
<duleja> hah :)
<duleja> well I just need something for a certain situation it is read only once per day
<duleja> some kind of a sync in the background
<havenwood> duleja: 15 MB seems small? Read it into memory and parse it?
<duleja> well I am doing that
<retromode> if i have a list_a = List(ObjectA) where ObjectA has some id, and a list_b = [1 => x, 2 => y, 3 => z] where x, y, z are different ObjectA IDs, whats the best way to sort list_a by those keys/indexes of list_b?
<havenwood> what's the current problem?
<duleja> but I do get timeout if I dont set some big timeout
<retromode> or i guess a better question, how can i sort list_a on the key/value pairs from list_b
<havenwood> retromode: Show an example of what you have and an example of what you want?
<retromode> sure, one sec
<havenwood> duleja: Are you timing out on the download or on the JSON parsing?
<duleja> download
<havenwood> And it's already a background worker job?
<duleja> I am trying to download file first to my machine or server and then parse it
<duleja> nono I haven't even there yet :)
<duleja> but yes it will have some delayed job
<duleja> or sidekiq
<retromode> list_a = [123, 353, 567]; list_b = [{1 => 353}, {2 => 567}, {3 => 123}]. so id like to 'intersect'? list_a and list_b to get [353, 567, 123] as the order based on list_b's keys in the hashes
duleja has quit [Remote host closed the connection]
<havenwood> Are you streaming the download? I'd suggest getting that working robustly first. I don't anticipate JSON parse speed issues with a file that small.
<Vaevictus> too bad b isn't indexed the other way
<retromode> it can be, i own it. just wasnt sure of the best way to do it :)
<retromode> so you think, just pass in the id and give back the value/order and then place in list based on that?
<Vaevictus> well, if b was a has of sort order values
<Vaevictus> hash
<retromode> as in, {123 => 3} instead of the other way around?
<Vaevictus> it's something like a.sort {|x,y| b[x] <=> b[y] } i think
duleja has joined #ruby
<havenwood> list_b.invert
<duleja> my laptop just crashed...
<havenwood> I mean: list_b.map(&:invert)
<duleja> havenwood sorry if I missed anything you wrote
<Vaevictus> i've been using a lot of different languages lately so my code might be very off
<havenwood> duleja: Are you streaming the download? I'd suggest getting that working robustly first. I don't anticipate JSON parse speed issues with a file that small.
<havenwood> retromode: Where is that Array of Hashes coming from? Can you use a simpler structure, like just an Array?
<duleja> if I just use standard library like this open(url) I get timeout
<bougyman> list_a & list_b.map { |k| k.to_a.first.last }
<duleja> file is minified maybe that is the problem
<havenwood> duleja: You can stream downloads with Net::HTTP but you have to manually.
<duleja> but if I pass read_timeout like so open(url, :read_timeout => 300) and these are seconds it runs ok
<havenwood> duleja: It's more straightforward with a gem like http.
<havenwood> duleja: Stream the download, then parsing should be no trouble.
<duleja> I have no issues with parsing later from the file
<havenwood> right
<bougyman> [18] pry(main)> list_b.map { |k| k.to_a.first.last } & list_a
<bougyman> => [353, 567, 123]
<duleja> never used this gem before... I will test it now!
<retromode> bougyman: will try that! i can probably also fiddle with my list_b so that sort looks a bit cleaner
<havenwood> retromode: list_b.map(&:invert).map(&:first).map(&:first) & list_a
<havenwood> retromode: Just make list_b be: [353, 567, 123]
<havenwood> retromode: Then you can: list_b & list_a
<havenwood> retromode: (Order by Array index is fine.)
phaul has quit [Quit: :wq]
<havenwood> &[{1=>353}, {2=>567}, {3=>123}].map(&:invert).map(&:first).map(&:first)
<rubydoc> parser error at position 0 around `['
<havenwood> #=> [353, 567, 123]
<havenwood> retromode: Is that Array of Hashes your making or that's what you must be dealing with?
<havenwood> (It's an awkward structure.)
phaul has joined #ruby
<retromode> havenwood: its an array of hashes mostly because im new to ruby coming from scala. is there a way to flatten it?
<havenwood> duleja: Maybe just use that down gem. :) Or it's pretty simple with HTTP.rb.
<retromode> i.e. x.toMap
<retromode> in scala
<havenwood> retromode: An Array is ordered.
<havenwood> retromode: So is a Hash for that matter, but an Array suffices here.
<havenwood> retromode: [353, 567, 123]
<retromode> gotchya
<havenwood> Indexes 0, 1 and 2
<retromode> yep
<havenwood> &>> [353, 567, 123].each.with_index(1).to_h { |n, i| [i, n] }
<rubydoc> stderr: playpen: timeout triggered! (https://carc.in/#/r/74tl)
<havenwood> #=> {1=>353, 2=>567, 3=>123}
waheedi has quit [Ping timeout: 272 seconds]
ur5us has joined #ruby
<retromode> havenwood: thanks! just made my structures easier to work with and that was much more understandable :)
<duleja> havenwood
<duleja> I get Net::ReadTimeout: Net::ReadTimeout again
<duleja> with tempfile = Down.download(url)
jeremycw has joined #ruby
<duleja> same as with open but this gem is actually using net/http
<havenwood> duleja: open-uri is a wrapper around net/http
<havenwood> duleja: You could increase the timeouts or save chunks.
<duleja> I did that before I came here but not sure if that is ok
<havenwood> duleja: going afk, but HTTP.rb is quite nice.
<duleja> file is 15mb...
<havenwood> that's not large
<havenwood> don't timeout?
<havenwood> bbl
<duleja> not sure if I should add huge timeout for 15mb
<duleja> thanks for the info anyway
beanholez has quit [Ping timeout: 260 seconds]
<duleja> I will figure out something to read it without setting big read_timeout
<duleja> but maybe I can leave it like this but it takes like 3 minutes to create that tempfile...
Rapture has quit [Quit: Textual IRC Client: www.textualapp.com]
schneider has quit [Ping timeout: 244 seconds]
codefriar has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
codefriar has joined #ruby
codefriar has quit [Client Quit]
retromode has quit [Ping timeout: 260 seconds]
BH23 has joined #ruby
codefriar has joined #ruby
xco has quit [Ping timeout: 245 seconds]
BH23 has quit [Ping timeout: 258 seconds]
ricer2 has quit [Ping timeout: 258 seconds]
sagax has quit [Write error: Connection reset by peer]
ricer2 has joined #ruby
<havenwood> duleja: How long does it take on average to complete? What's the 90th percentile time? Pick a timeout period that's likely to result in completion.
<duleja> hey havenwood
<duleja> I tried http gem
<duleja> it takes some time but it does get the data
<havenwood> duleja: If you get a timeout where it usually completes, then retries should handle it from there.
<duleja> json data is actually minified
<havenwood> duleja: HTTP.rbb is nice.
<havenwood> duleja: Are you already requesting a gzipped version?
<havenwood> duleja: That can help substantially.
teej has quit [Quit: Connection closed for inactivity]
<duleja> I did managed to open it using just ruby default open(url) but I used it like this open(url, :read_timeout => 300)
<duleja> this will be done once per day
<duleja> so it is ok to have it like this
<duleja> it takes some time to load it
<havenwood> duleja: HTTP.use(:auto_inflate).headers("Accept-Encoding" => "gzip").get("http://example.org/large-file")
<havenwood> duleja: (Request a compressed payload and automatically inflate it on your end.
<havenwood> )
<duleja> just a sec
fphilipe_ has joined #ruby
<duleja> thanks for the help havenwood
<duleja> I am not sure if this is working better now or it is same as before but it seems that http gem is downloading the file faster
<duleja> or I am just very very tired
fphilipe_ has quit [Ping timeout: 244 seconds]
<havenwood> duleja: If you're gzipping JSON now and weren't before, it's likely about twice as fast.
<duleja> nono
<duleja> I am not :)
<duleja> but still it seems that it is faster
<duleja> it was strange to me that timeout was going on with 15mb file
<havenwood> duleja: gzip as well and you should be in business
<havenwood> JSON compresses well
<duleja> I have no power there...
<duleja> Maybe... but more things are involved... but thanks for the input!
flux__aeon has quit [Quit: Textual IRC Client: www.textualapp.com]
<duleja> hmmm
ellcs has quit [Ping timeout: 252 seconds]
<duleja> I would probably save this to a file
<duleja> and parse json from there
<havenwood> *Most* servers are happy to gzip when you request it.
<duleja> yeah
<duleja> it is strange to me that this is not cached like this data is in real time but it is not small not sure how they are providing this json
jeremycw has quit [Ping timeout: 258 seconds]
AJA4350 has joined #ruby
codefriar has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Caerus> Hmm... anyone knows what would be the ruby way of "try"ing an open(url).read while using 'open-uri'. Maybe open(url)&.read ? I don't want to rescue the errors just do nothing if the url is down for whatever reason.
<duleja> havenwood thanks for your input!
<Vaevictus> Caerus: maybe just check if open(url) returned a file or maybe it returns a file object of some sort anyway. hmm
<duleja> shouldn't it return tempfile?
ellcs has joined #ruby
<Vaevictus> it returns a file object, i read that it dl's to memory, not a cache...
duleja has quit [Remote host closed the connection]
codefriar has joined #ruby
jefffrails35 has quit [Remote host closed the connection]
Swyper has quit [Remote host closed the connection]
d^sh has quit [Ping timeout: 272 seconds]
jhass has quit [Ping timeout: 250 seconds]
d^sh has joined #ruby
lucasb has quit [Quit: Connection closed for inactivity]
ramfjord has quit [Ping timeout: 248 seconds]
giraffe has quit [Excess Flood]
jhass has joined #ruby
AndreYuhai has joined #ruby
<AndreYuhai> hey there I am tryinng to scrape aliexpress and there is this slidebar to prevent bots. But even though I can slide it using watir I still get an error. And sometimes I get it even when I try manually, any idea as to why and how to prevent it? https://imgur.com/a/FudHjFW
mn3m has joined #ruby
AJA4350 has quit [Ping timeout: 268 seconds]
_whitelogger has joined #ruby
orbyt_ has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
AndreYuhai has quit [Remote host closed the connection]
mn3m has quit [Remote host closed the connection]
mn3m has joined #ruby
bambanx has joined #ruby
Swyper has joined #ruby
Junaos has quit [Quit: ZNC - http://znc.in]
Swyper has quit [Remote host closed the connection]
mn3m has quit [Ping timeout: 258 seconds]
Junaos has joined #ruby
donofrio has quit [Remote host closed the connection]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
donofrio has joined #ruby