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]
<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…]
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?
<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
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']
<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']...
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
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)
<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]