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!
sylario has quit [Quit: Connection closed for inactivity]
leitz has quit [Quit: Leaving]
AJA4351 has joined #ruby
AJA4350 has quit [Ping timeout: 244 seconds]
AJA4351 is now known as AJA4350
bruce_lee has quit [Remote host closed the connection]
frem has quit [Quit: Connection closed for inactivity]
gix has quit [Ping timeout: 258 seconds]
txdv has quit [Ping timeout: 245 seconds]
drincruz has joined #ruby
k0mpa has joined #ruby
sytherax has joined #ruby
morenoh149 has joined #ruby
k0mpa has quit [Client Quit]
sytherax has quit [Ping timeout: 245 seconds]
morenoh149 has quit [Ping timeout: 244 seconds]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has quit [Ping timeout: 244 seconds]
k0mpa has joined #ruby
drincruz has quit [Ping timeout: 248 seconds]
k0mpa has quit [Client Quit]
jenrzzz has joined #ruby
txdv has joined #ruby
x86sk has quit [Quit: Connection closed for inactivity]
SeepingN has quit [Quit: The system is going down for reboot NOW!]
stryek has quit [Quit: Connection closed for inactivity]
x86sk has joined #ruby
AJA4350 has quit [Ping timeout: 248 seconds]
AJA4350 has joined #ruby
meinside has joined #ruby
GodFather has quit [Ping timeout: 245 seconds]
GodFather_ has quit [Ping timeout: 258 seconds]
AJA4350 has quit [Remote host closed the connection]
bmurt has joined #ruby
drincruz has joined #ruby
bmurt has quit [Quit: Textual IRC Client: www.textualapp.com]
morenoh149 has joined #ruby
jenrzzz has quit [Ping timeout: 272 seconds]
morenoh149 has quit [Ping timeout: 268 seconds]
bambanx has joined #ruby
evdubs has quit [Ping timeout: 264 seconds]
evdubs_ has joined #ruby
ukd1 has joined #ruby
hutch has quit [Ping timeout: 248 seconds]
morenoh149 has joined #ruby
sagax_ has joined #ruby
sagax has quit [Remote host closed the connection]
hutch has joined #ruby
jenrzzz has joined #ruby
kacykurio has joined #ruby
kacykurio has quit [Quit: kacykurio]
greengriminal has joined #ruby
poontangmessiah has quit [Remote host closed the connection]
skryking has joined #ruby
ramfjord has quit [Ping timeout: 245 seconds]
KeyJoo has quit [Quit: KeyJoo]
sytherax has joined #ruby
sytherax has quit [Ping timeout: 245 seconds]
duderonomy has joined #ruby
bambanx has quit [Quit: Leaving]
brool has quit [Ping timeout: 250 seconds]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<qbrd[m]> When in doubt try it again while cursing under your breath...
_whitelogger has joined #ruby
fredolinhares has joined #ruby
SanguineAnomaly has quit [Ping timeout: 248 seconds]
SanguineAnomaly has joined #ruby
morenoh149 has quit [Ping timeout: 248 seconds]
h1r0P0p18 has joined #ruby
h1r0P0p18 has quit [Client Quit]
jmcgnh has quit [Ping timeout: 245 seconds]
x86sk has quit [Quit: Connection closed for inactivity]
jmcgnh has joined #ruby
jmcgnh has quit [Excess Flood]
code_zombie has joined #ruby
duderonomy has joined #ruby
jmcgnh has joined #ruby
duderonomy has quit [Client Quit]
howdoi has joined #ruby
hutch has quit [Ping timeout: 258 seconds]
duderonomy has joined #ruby
duderonomy has quit [Client Quit]
jenrzzz has quit [Ping timeout: 248 seconds]
code_zombie has quit [Read error: Connection reset by peer]
code_zombie has joined #ruby
jenrzzz has joined #ruby
greengriminal has quit [Quit: This computer has gone to sleep]
houhouli_ has quit [Remote host closed the connection]
fredolinhares has quit [Quit: WeeChat 1.9.1]
ukd1 has quit [Ping timeout: 258 seconds]
Mrgoose8 has joined #ruby
morenoh149 has joined #ruby
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
donofrio has joined #ruby
tsujp has joined #ruby
ur5us has quit [Ping timeout: 268 seconds]
Mrgoose8 has quit [Quit: The Lounge - https://thelounge.chat]
Mrgoose8 has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
ascarter has joined #ruby
ascarter has quit [Client Quit]
duderonomy has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Rush has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
glosoli has joined #ruby
duderonomy has joined #ruby
duderonomy has quit [Client Quit]
jenrzzz has joined #ruby
fphilipe_ has joined #ruby
dellavg has joined #ruby
glosoli has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
za1b1tsu has joined #ruby
glosoli has joined #ruby
ramfjord has joined #ruby
fphilipe_ has quit [Ping timeout: 264 seconds]
ramfjord has quit [Ping timeout: 248 seconds]
glosoli has quit [Ping timeout: 268 seconds]
sytherax has joined #ruby
za1b1tsu has quit [Remote host closed the connection]
za1b1tsu has joined #ruby
code_zombie has quit [Quit: Leaving]
sytherax has quit [Ping timeout: 245 seconds]
lxsameer has joined #ruby
<al2o3-cr> &>> require 'fiddle'; Fiddle::Pointer[TrueClass.__id__ * 2][0,64] = Fiddle::Pointer[FalseClass.__id__ * 2][0,64]; [false == false, true == true, 0 == 0]
<rubydoc> # => [false, false, false] (https://carc.in/#/r/7dcu)
sylario has joined #ruby
<al2o3-cr> just how much fun can we have with this today ;)
fphilipe_ has joined #ruby
duderonomy has joined #ruby
TomyWork has joined #ruby
za1b1tsu_ has joined #ruby
<al2o3-cr> &>> require 'fiddle'; include Fiddle; sc = Function.new Handle['sincos'], [TYPE_DOUBLE, *[TYPE_VOIDP] * 2], TYPE_VOID; s = [0].pack ?d; c = [0].pack ?d; sc.(34.5, s, c); [s,c].map { |v| v.unpack1 ?d }
<rubydoc> # => [0.057487478104924564, -0.9983462274487422] (https://carc.in/#/r/7dd0)
za1b1tsu has quit [Ping timeout: 246 seconds]
duderonomy has quit [Client Quit]
corellian has joined #ruby
glosoli has joined #ruby
deepredsky has joined #ruby
aupadhye has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
fphilipe_ has quit [Ping timeout: 264 seconds]
Nicmavr has joined #ruby
gigetoo has quit [Ping timeout: 245 seconds]
morenoh149 has quit [Ping timeout: 272 seconds]
drnerdius has quit [Ping timeout: 268 seconds]
kyrylo has joined #ruby
tdy has quit [Ping timeout: 272 seconds]
za1b1tsu_ has quit [Ping timeout: 245 seconds]
duderonomy has joined #ruby
glosoli has quit [Read error: Connection reset by peer]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gigetoo has joined #ruby
za1b1tsu_ has joined #ruby
irdr has quit [Remote host closed the connection]
morenoh149 has joined #ruby
morenoh149 has quit [Ping timeout: 248 seconds]
mikecmpbll has joined #ruby
cd has quit [Quit: cd]
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
bruce_lee has joined #ruby
mat_bug has joined #ruby
fphilipe_ has joined #ruby
galaxie has quit [Remote host closed the connection]
lalitmee has joined #ruby
tsujp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
howdoi has quit [Quit: Connection closed for inactivity]
za1b1tsu_ has quit [Remote host closed the connection]
morenoh149 has joined #ruby
howdoi has joined #ruby
morenoh149 has quit [Ping timeout: 248 seconds]
deepredsky has quit [Ping timeout: 246 seconds]
leitz has joined #ruby
_whitelogger has joined #ruby
deepredsky has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
drnerdius has joined #ruby
kyrylo has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
<leitz> Lines 66-68 are the catch for hitting EOF with data. Is there a way to put that in the block above? https://github.com/LeamHall/resume/blob/master/bin/parse_jobs.rb#L66-L68
sagax_ is now known as sagax
drnerdius has quit [Quit: Konversation terminated!]
drnerdius has joined #ruby
deepredsky has quit [Ping timeout: 244 seconds]
RougeRR has joined #ruby
<RougeRR> hello, i need some assistance with open3, anyone got experience?
mat_bug_ has joined #ruby
<RougeRR> this is the code im working with https://dpaste.de/j438
mat_bug has quit [Ping timeout: 252 seconds]
<RougeRR> when reading a file with large amounts of stderror/stdout
<RougeRR> it hangs
<RougeRR> and i know its to do with the buffer being overwhelmed
deepredsky has joined #ruby
deepredsky has quit [Ping timeout: 268 seconds]
<leitz> RougeRR, what is the output if you just run the command?
<RougeRR> leitz, i get a huge amount of output to stderror
<RougeRR> and stdout
<RougeRR> its a bit of edge case behaviour
<RougeRR> i cant provide the source im working with unfortunately as its sensitive
<leitz> Understood on the "sensitive".
<leitz> Is stdout and stderr line based? That is, could you read it a line at a time?
<RougeRR> that is a thought ive had
<RougeRR> seems you would want to buffer it
<RougeRR> ill give that a go
<RougeRR> i tried spawning each one in a new thread
<RougeRR> but it didnt seem to do work
<leitz> It will likely hit IO heavy, but it might let you filter as you go, if you don't need all of it.
<RougeRR> i dont need msot of it no
<RougeRR> its mostly noise that isnt going to be needed for the program
<leitz> Do you really need an object for this?
involans has joined #ruby
Fraeon has quit [Ping timeout: 268 seconds]
deepredsky has joined #ruby
<havenwood> RougeRR: lines 21 and 23 are a good case for a lonely person operator: stdout&.read
<RougeRR> havenwood, but they arnt causing exceptions by stdout being nil?
<RougeRR> leitz, i should mention. this is not my code.
<RougeRR> im trying to fix a gem which im using
<havenwood> &>> nil&.read
<rubydoc> # => nil (https://carc.in/#/r/7dee)
deepredsky has quit [Ping timeout: 244 seconds]
<RougeRR> seems like my same issue
* leitz wonders what havenwood is doing up this late.
<havenwood> leitz: Can shorten line 4 a bit now that there's __dir__: $LOAD_PATH << File.expand_path('../lib/', __dir__)
kyrylo has quit [Read error: Connection reset by peer]
<havenwood> leitz: Not that it matters here, since the process ending closes the file descriptor, but the block form of File.open auto-closes on end.
kyrylo has joined #ruby
<havenwood> leitz: it's faster to parse Array literal `[]` instead of Array.new.
<havenwood> jobs = []
<leitz> havenwood, I've used the block for now and again. This is proof of concept for me, I've been stumped on how to parse the file for a long time. And it seems having a current resume is good. :)
<havenwood> leitz: Normally I'd suggest extracting your Regexp to a constant. Creating it in a method causes object churn.
<leitz> I tend to use "Array.new" or Hash.new so I can search for it in the files. Unix grep often chokes on special character strings like []
<havenwood> leitz: I'd recommend replacing `return start_date, end_date` with: [start_date, end_date]
<leitz> And I'm newbie enough to have to find how I figured something out before. :)
<havenwood> leitz: I'd probably one-line the if statements, like: return date if dates[0] == "present"
<havenwood> leitz: #size to me signals a lazily calculated size, where #count often actually iterates to count.
<RougeRR> found a solution
<havenwood> leitz: you can put `year =` outside the if statement, and only do it once
<RougeRR> im just working out how it works and why now
<havenwood> leitz: I like: data.positive?
ramfjord has joined #ruby
Fraeon has joined #ruby
drincruz has quit [Read error: Connection reset by peer]
drincruz has joined #ruby
ramfjord has quit [Ping timeout: 248 seconds]
<leitz> havenwood, is there a better solution for lines 66-68? They are there to catch the last job in the file.
* leitz has to makes notes. When the "get to work" chime rings he has to magically transform into a perl guy. :(
<RougeRR> ahh okay
<leitz> RougeRR, have you figured out how that works?
deepredsky has joined #ruby
<RougeRR> leitz, so its to do with STDOUT not flushing the bugger
<RougeRR> buffer
<RougeRR> if the process is being called from another process
<RougeRR> rather than the shell
<RougeRR> then this buffer is never sent
<RougeRR> so by using a psuedoterminal, we can work around this.
<RougeRR> by emulating a shell within the program, the stdout stream is sent in real time
<RougeRR> rather than buffering and never being sent
<RougeRR> that was poorly explained. the stackoverflow answer says it better
drincruz has quit [Ping timeout: 245 seconds]
<leitz> An unflushed buffer can be a bugger. :)
nerdius has joined #ruby
<RougeRR> haha yeah
drnerdius has quit [Read error: No route to host]
teardown has quit [Ping timeout: 245 seconds]
jackholmes has joined #ruby
jackholmes has left #ruby [#ruby]
AJA4350 has joined #ruby
nerdius has quit [Read error: Connection reset by peer]
drnerdius has joined #ruby
Tuor has joined #ruby
jenrzzz has quit [Ping timeout: 272 seconds]
<RougeRR> leitz,
<RougeRR> hmmm
<RougeRR> another method ive found works
<RougeRR> i think the issue is popen3
<RougeRR> as that spawns a new process
jenrzzz has joined #ruby
drnerdius has quit [Read error: No route to host]
drnerdius has joined #ruby
mat_bug_ has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 246 seconds]
tsujp has joined #ruby
ellcs has joined #ruby
<leitz> RougeRR, I'm mostly a Ruby newbie, and not as familiar with the Ruby process stuff. Glad that you're enjoying figuring it out!
<RougeRR> Yeah, been using ruby 2 years. Still a noob at any other language/programming stuff.
<RougeRR> nice to learn process stuff etc yeah
deepredsky has quit [Ping timeout: 272 seconds]
deepredsky has joined #ruby
tsujp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tsujp has joined #ruby
involans has quit [Ping timeout: 244 seconds]
jenrzzz has joined #ruby
basic has joined #ruby
<basic> how does one tell rubocop to parse like it's 2017 (ruby 2.5)
<havenwood> basic: TargetRubyVersion: 2.5
mat_bug has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
<basic> havenwood: does rubocop try to find this configuration file?
kyrylo has quit [Read error: Connection reset by peer]
<basic> like inside the filetree strcutre
<basic> wow, compiling ruby is quick
<basic> which would be my next question, do i need ruby 2.5+ installed for rubocop to work? or does it use it's parsers?
kyrylo has joined #ruby
<havenwood> basic: you can use whatever version of Ruby you want
<havenwood> basic: Ruby 2.6.3 is the latest version.
<basic> hm, doesn't seem to work
tsujp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood> basic: what doesn't work
AJA4350 has quit [Ping timeout: 246 seconds]
<basic> i have the config file in the root directory of the project
<havenwood> what seems to be the problem?
<basic> and rescue blocks (implicit begin...end) that will be shown as errors on my linter
<basic> (i use ALE for vim)
<basic> does that maybe ignore the rubocop config?
<havenwood> ¯\_(ツ)_/¯
<basic> undefined method `[]' for 2.5:Float
<basic> :o
<basic> (if i call rubocop manually)
<basic> do i have to specify it as string?
kyrylo has quit [Read error: Connection reset by peer]
<havenwood> basic: Without knowing what you've done, it's hard to say.
<havenwood> basic: Here's an example .rubocop.yml: https://github.com/rubocop-hq/rubocop/blob/master/.rubocop.yml
<basic> Warning: unrecognized cop TargetRubyVersion found in .rubocop.yml
<havenwood> basic: If you share your config, and the command you're running, I'm sure someone here can point out what's gone wrong.
<basic> ah, i get it, one sec
kyrylo has joined #ruby
<basic> holy shit rubocop hates my code
<havenwood> basic: have it fix it: rubocop -a
<basic> well it's still doing 2.3
<havenwood> basic: what version is your Ruby?: ruby -v
<basic> it's 2.4 right now
<basic> 2.4.6 to be exact
<havenwood> basic: do you have RuboCop installed on the current version of Ruby?: gem which rubocop
<basic> but my project runs in docker, which is 2.5.3
<basic> yes
<basic> i only have that ruby version
<havenwood> basic: If the project runs on 2.5, I'd suggest using 2.5 locally
<havenwood> basic: it's common for Ruby developers to install many versions of Ruby, and switch between them for various projects
<basic> havenwood: poor fools
<havenwood> basic: what OS/distro are you on locally?
<basic> gentoo
lightstalker has quit [Remote host closed the connection]
<havenwood> basic: it looks like there's a portage package for Ruby 2.5
<basic> yeah i installed 2.6 right now
<basic> hm, looks like ALE uses the installed ruby version not rubocop at all
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
* basic wonders how it uses ruby as integrated linter
stryek has joined #ruby
mat_bug has quit []
mat_bug has joined #ruby
GodFather has joined #ruby
GodFather_ has joined #ruby
leitz has quit [Quit: Leaving]
mat_bug_ has joined #ruby
mat_bug has quit [Ping timeout: 244 seconds]
sytherax has joined #ruby
drnerdius has quit [Ping timeout: 245 seconds]
lalitmee has quit [Ping timeout: 244 seconds]
jenrzzz has joined #ruby
deepredsky has quit [Ping timeout: 248 seconds]
deepredsky has joined #ruby
mat_bug_ has quit []
mat_bug has joined #ruby
AJA4350 has joined #ruby
drnerdius has joined #ruby
lucasb has joined #ruby
chalkmonster has joined #ruby
RougeRR has quit [Ping timeout: 244 seconds]
drincruz has joined #ruby
Swyper has quit [Remote host closed the connection]
poontangmessiah has joined #ruby
dellavg has quit [Ping timeout: 248 seconds]
Swyper has joined #ruby
h1r0P0p18 has joined #ruby
h1r0P0p18 has quit [Client Quit]
leitz has joined #ruby
greengriminal has joined #ruby
jenrzzz has quit [Ping timeout: 258 seconds]
greengriminal has quit [Client Quit]
snapcase has quit [Quit: Lost terminal]
bmurt has joined #ruby
snapcase has joined #ruby
snapcase has quit [Quit: leaving]
sytherax has quit [Ping timeout: 248 seconds]
mat_bug has quit []
jenrzzz has joined #ruby
lalitmee has joined #ruby
hutch has joined #ruby
redlegion has quit [Remote host closed the connection]
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
redlegion has joined #ruby
duderonomy has joined #ruby
AJA4350 has quit [Ping timeout: 245 seconds]
tdy has joined #ruby
drnerdius has quit [Remote host closed the connection]
drnerdius has joined #ruby
drnerdius has quit [Read error: No route to host]
jenrzzz has quit [Ping timeout: 258 seconds]
GodFather has quit [Ping timeout: 258 seconds]
GodFather_ has quit [Ping timeout: 272 seconds]
lalitmee has quit [Quit: Leaving]
wallace_mu has joined #ruby
<havenwood> If Perl 6 is renaming to "Camelia," does that mean Ruby 3 is free to rename to "Perl 6?"
deepredsky has quit [Ping timeout: 246 seconds]
Tuor has quit [Quit: Konversation terminated!]
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
aupadhye has quit [Remote host closed the connection]
deepredsky has joined #ruby
snapcase has joined #ruby
suukim has joined #ruby
<leitz> havenwood, have you had too many energy drinks?
<havenwood> leitz: that reminds me... coffee time!
code_zombie has joined #ruby
<adam12> lol
<leitz> havenwood, when you get back, I'll go back to the "Lines 86-88" question. If there was an answer I missed it in the reboot. I did add your comments so I can track them.
tsujp has joined #ruby
<havenwood> leitz: I think I missed the question.
<havenwood> leitz: What's the issue you're running into?
<leitz> Yup. Lines 66-68 seem klugy. They previous block triggers an object build on the *next* new section, which means the last section in the file doesn't get created.
<leitz> Now lines 84-86.
<leitz> I added notes. :)
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
jenrzzz has joined #ruby
<havenwood> leitz: An alternative to using a block with #open is to just: File.foreach(filename) do |line|
<havenwood> leitz: I'd recommend `next if line.empty?` here: https://github.com/LeamHall/resume/blob/master/bin/parse_jobs.rb#L62
deepredsky has quit [Ping timeout: 272 seconds]
rippa has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.5]
Huck777 has quit [Quit: Textual IRC Client: www.textualapp.com]
<havenwood> leitz: Instead of `data.count > 0` you can say `data.any?`.
<leitz> havenwood, there's only one data file for this.
<havenwood> leitz: File.foreach('input/leamhall_jobs.txt') do |line|
<havenwood> leitz: I'd put this `data` inside the if statement, since there's no need to create a new Hash if it's empty.
<leitz> havenwood, ah, gotcha. The foreach is the line, not the file.
<leitz> havenwood, I should just clear the hash in line 67. It gets repopulated for each job.
corellian has quit [Quit: leaving]
Huck777 has joined #ruby
<leitz> I'm still in the transition from "Apprentice Generic Programmer" to "Apprentice Ruby Programmer".
<havenwood> jobs << Job.new(data) if data.any?
<havenwood> jobs << Job.new(data) unless data.empty?
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cd has joined #ruby
<havenwood> leitz: This makes me feel like you should be creating the Array literal directly with these values: https://github.com/LeamHall/resume/blob/master/bin/parse_jobs.rb#L72-L75
<havenwood> leitz: Can you switch to Symbol values?
<havenwood> leitz: data = {start_date: start_date, end_date: end_date, title: title, employer: employer}
<leitz> havenwood, symbols should work. The end state is either a JSON or text file that can get loaded, and then use whatever "format" the particular resume needs to be in. The lines starting at L88 are the basis of what a format would be.
<leitz> Symbols work. Implementing some other things.
<leitz> :w
deepredsky has joined #ruby
deepredsky has quit [Ping timeout: 245 seconds]
ellcs has quit [Ping timeout: 245 seconds]
ellcs has joined #ruby
SeepingN has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
AJA4350 has joined #ruby
salerace has joined #ruby
sytherax has joined #ruby
wallace_mu has quit []
sytherax has quit [Ping timeout: 245 seconds]
basic has quit [Ping timeout: 258 seconds]
ellcs has quit [Ping timeout: 268 seconds]
tdy has quit [Ping timeout: 248 seconds]
Ryctolagus has joined #ruby
bruce_lee has quit [Ping timeout: 268 seconds]
matheusmoreira has joined #ruby
jenrzzz has joined #ruby
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
bruce_lee has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
frem has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
TomyWork has quit [Ping timeout: 246 seconds]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
ukd1 has joined #ruby
Ryctolagus has quit [Read error: Connection reset by peer]
eddof13 has joined #ruby
salerace has quit [Quit: salerace]
jenrzzz has quit [Ping timeout: 258 seconds]
AJA4350 has quit [Ping timeout: 245 seconds]
kyrylo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bruce_lee has quit [Ping timeout: 246 seconds]
bruce_lee has joined #ruby
sytherax has joined #ruby
sytherax has quit [Client Quit]
duderonomy has joined #ruby
cow[moo] has quit [Read error: Connection reset by peer]
<jokke> hey there
<havenwood> jokke: hi
<jokke> i'm trying to figure out how to write c bindings for ruby
<jokke> i'm struggling a bit with methods
<jokke> so from the docs i gathered that the function i pass to the rb_define_method function will be called with the ruby instance of the object the method was called on
<jokke> the question is, how can i get the initializer to store a pointer to the instance on c level.
<jokke> and how can i access that pointer from the function i pass to rb_define_method
<jokke> what i'm actually trying to do is write something in crystal and use it from ruby
<jokke> crystal too is object oriented so i'd need to call methods on an instance of the corresponding crystal class
<jokke> what i'm struggling with is how to associate the crystal instance with the ruby instance
<havenwood> jokke: You can create a gem with a Crystal extension then embed MRuby in your Crystal code.
<havenwood> For... reasons.
howdoi has quit [Quit: Connection closed for inactivity]
Ryctolagus has joined #ruby
<havenwood> jokke: Have you tried Fiddle and Fiddle::Importer?
<jokke> havenwood: ah no, i don't mean it that way
<jokke> i want to be able to use my crystal classes from ruby
<jokke> havenwood: no, haven't heard of fiddle
jenrzzz has joined #ruby
<jokke> mmh
<havenwood> jokke: You can also do fun stuff within Ruby with Fiddle: https://gist.github.com/havenwood/0aa75f0c896a6dda0e56da5f21ed9fbd
kyrylo has joined #ruby
<havenwood> jokke: Gems like Typhoeus use FFI to interface with libcurl.
<jokke> yeah but FFI is meh
<havenwood> jokke: it seems a lot nicer to me than the C-ext interface
<havenwood> Fiddle is a bit nicer yet.
<havenwood> jokke: It'd be interesting if Crystal could generate dynamic libraries, but alas: https://github.com/crystal-lang/crystal/issues/921
<jokke> yeah
codefriar has joined #ruby
SeepingN has quit [Quit: The system is going down for reboot NOW!]
wildtrees has joined #ruby
wildtrees has quit [Remote host closed the connection]
wildtrees has joined #ruby
Swyper has quit [Remote host closed the connection]
wildtrees has quit [Remote host closed the connection]
wildtrees has joined #ruby
ukd1 has quit [Ping timeout: 245 seconds]
wildtrees has quit [Remote host closed the connection]
fphilipe_ has quit [Ping timeout: 272 seconds]
_Joes_ has joined #ruby
ukd1 has joined #ruby
_Joes_ has quit [Ping timeout: 245 seconds]
ukd1 has quit [Ping timeout: 246 seconds]
SuperL4g is now known as SuperLag
Nicmavr has quit [Read error: Connection reset by peer]
ukd1 has joined #ruby
Nicmavr has joined #ruby
ramfjord has joined #ruby
suukim has quit [Quit: Konversation terminated!]
bmurt has joined #ruby
Xiti` has joined #ruby
Xiti has quit [Ping timeout: 268 seconds]
poontangmessiah has quit [Remote host closed the connection]
Xiti` is now known as Xiti
jenrzzz has quit [Ping timeout: 244 seconds]
bmurt has quit [Ping timeout: 276 seconds]
fphilipe_ has joined #ruby
gix has joined #ruby
s2013 has joined #ruby
kyrylo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eddof13 has quit [Quit: eddof13]
Huck777 has quit [Ping timeout: 245 seconds]
jenrzzz has joined #ruby
tdy has joined #ruby
tdy1 has joined #ruby
eddof13 has joined #ruby
tdy has quit [Ping timeout: 268 seconds]
teardown has joined #ruby
SuperLag has quit [Quit: reboot]
frem has quit [Quit: Connection closed for inactivity]
GodFather_ has joined #ruby
GodFather has joined #ruby
SuperLag has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
<jidar> Can somebody tell me what exception catch I can write to catch only things found in net/smtp? I'm using the following code: https://gist.github.com/227c23a3cc478c65ce1af50a1f8eeb62 but it's catching errors further up the stack and causing the application to bomb abnormally
<jidar> it looks like there's a few Net::SMTP<something>Errors to catch?
morenoh149 has joined #ruby
fphilipe_ has quit [Ping timeout: 276 seconds]
jenrzzz has joined #ruby
eddof13 has quit [Quit: eddof13]
<havenwood> jidar: Net::SMTPError is mixed into all the other SMTP error classes, so you can just rescue it.
<havenwood> jidar: It's almost always a bad idea to: rescue Exception
<havenwood> jidar: A plain `rescue` is implicitly `rescue StandardError`.
<havenwood> jidar: rescue Net::SMTPError
<havenwood> jidar: You can omit `=> e` if you're not using `e`.
fphilipe_ has joined #ruby
jcalla has quit [Ping timeout: 245 seconds]
<jidar> groovy thanks havenwood
tdy1 has quit [Ping timeout: 246 seconds]
AJA4350 has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
bmurt has joined #ruby
<Retr0Punk> hey all, i am looking into adding templating to my program, that is, not HTML templating, but a template for the command line. for example, i'd like to have a config file where someone can input something like #{track} - #{title} - #{artist} and have the program output the correct data to the terminal. where could i start to look into doing this?
<darix> Retr0Punk: for that kind of stuff you dont even need a templating library
unixcat_ has joined #ruby
<Norrin> sounds like homework
<Retr0Punk> lol
<Norrin> or an interview question
<Retr0Punk> it's not homework, i'm working on my project trying to learn ruby https://gitlab.com/DomenicF/track_list/tree/master
unixcat has quit [Quit: ZNC - https://znc.in]
<Retr0Punk> havenwood: that is HTML templating though, could i use ERB in the same fashion for templating on the command line?
<Norrin> Nice
<havenwood> Retr0Punk: I don't think "templating" is really what you want, after reading what you've said.
<havenwood> Retr0Punk: Folk often use a serialization format, like YAML, for config files.
jenrzzz has joined #ruby
<Retr0Punk> yeah i was thinking YAML, ok i will look into including that in my project, maybe read from a file or user input on the command line with YAML
<Retr0Punk> thank you :)
eddof13 has joined #ruby
<leftylink> so. would it work if you just made them enter a string like '%<title>s' and then you just use % to format it?
<leftylink> &>> '%<title>s' % {title: :arghhh}
<rubydoc> stderr: playpen: timeout triggered! (https://carc.in/#/r/7dls)
<leftylink> then no library is needed, just the default capabilities of the language
<leftylink> &>> '%<title>s' % {title: :arghhh}
<rubydoc> # => "arghhh" (https://carc.in/#/r/7dlt)
chalkmonster has joined #ruby
unixcat_ is now known as unixcat
ellcs has joined #ruby
<leftylink> if you're really set on not making them remember the exact format of %<title>s, maybe they think the angle brackets and the s are TOO BURDENSOME or something, then maybe you can just make them do <title> and you insert the % and s yourself
<Retr0Punk> leftylink: that is exactly what i need
<Retr0Punk> right now, i made a config file in my home directory including: output: "%TRACK%. %TITLE% (%LENGTH)"
<leftylink> also in case you ever came across a suggestion `eval ?" + template + ?"`, I highly recommend against :) since someone will set `template = '"; puts :pwned; "'`
<Retr0Punk> i then use YAML.load to load this into Ruby, but i am wondering if what you did with %<title> is some built in Ruby thing?
SeepingN has joined #ruby
<leftylink> please see the documentation for String#%
<leftylink> &ri String#%
beanie__ has joined #ruby
<Retr0Punk> i don't see any angle brackets on this page :/ it's ok though, i can look into it more if it's really basic lol
tpanarch1st_ has quit [Ping timeout: 272 seconds]
matheusmoreira has quit [Quit: leaving]
<leftylink> although it is surely the case that the snippet of code `'%<title>s' % {title: :arghhh}` was indeed using String#%, there is no question about that. so the logical place to start looking at documentation is String#%
<leftylink> if it is so the case that the documentation for String#% asks one to look at other documentation, so too should that documentation be looked at.
ur5us has joined #ruby
<Retr0Punk> yes, i don't want to be a bother, i will look into it more. thank you
<leftylink> I can also add as a general point. sometimes it can be hard to tell whether a question would be a bother or not. it would be a shame if a person became too afraid to ask questions. but that is usually okay. people probably notice what I do. there are certain questions to which my answers take the form of "here are general rules that will help a person to know where to find the answer for oneself"
galaxie has joined #ruby
<leftylink> and it is that way because 1. (hopefully) it is helpful whether the asker was a vampire or not, and if they were a vampire I need to give that kind of answer for my own sake anyway. and 2. if I just tell them the answer they learn nothing
<leftylink> my general philosophy is nothing is magic though, so I hope to help allow people to see that it is not magic
<Retr0Punk> no i understand that, i am aware that what i am asking is pretty rudimentary stuff, and honestly i am not proud to need to ask these questions, as a professional developer, it just feels like Ruby is a completely new ecosystem to me and things aren't clicking in my brain as easy as i'd like them to. but i do not fault you for pointing me in the right direction, you have been very helpful
poontangmessiah has joined #ruby
morenoh149 has quit [Ping timeout: 245 seconds]
queip has quit [Ping timeout: 272 seconds]
s2013 has joined #ruby
Ryctolagus has quit [Quit: Leaving]
tdy1 has joined #ruby
queip has joined #ruby
lxsameer has quit [Ping timeout: 246 seconds]
chalkmonster has quit [Quit: WeeChat 2.5]
ukd1 has quit [Ping timeout: 246 seconds]
ukd1 has joined #ruby
elated has quit [Ping timeout: 245 seconds]
ellcs has quit [Ping timeout: 248 seconds]
mynameisdebian has joined #ruby
<mynameisdebian> I have an Apache script serving a CGI script that responds to Slack events. Apache always takes several seconds to respond with "200 OK", and because of it Slack is throwing a message. How do I respond with 200 and send it right away with Ruby?
<bougyman> make it faster
<bougyman> This is a vague question, I can only give a vague answer.
gix has quit [Remote host closed the connection]
gix has joined #ruby
AJA4351 has joined #ruby
poontangmessiah_ has joined #ruby
AJA4350 has quit [Ping timeout: 246 seconds]
AJA4351 is now known as AJA4350
poontangmessiah has quit [Ping timeout: 245 seconds]
<baweaver> bougyman: be nice.
<baweaver> Instead, ask mynameisdebian for more details that help clarify the question
<baweaver> Such as what the script is, what code it has, if they've tested where the bottleneck is..
morenoh149 has joined #ruby
<mynameisdebian> I have an Apache server running a Ruby CGI script. The CGI script receives a message from Slack, responds to Slack with "HTTP OK", then does a bunch of other stuff. It seems like the Apache server does not send 200 until the CGI script completes. Is there any way to make Apache return 200 without waiting for the script to complete?
beanie__ has quit [Ping timeout: 272 seconds]
tpanarch1st_ has joined #ruby
drincruz has quit [Ping timeout: 268 seconds]
<SeepingN> yes. Fork the meat of your app in a 2nd script.
<SeepingN> then return 200 and either wait for child to finish or just let it go unattached
phenom has joined #ruby
<mynameisdebian> SeepingN: Thank you for the reply. Is that a common solution, and this a common problem? Can you elaborate on "wait for child to finish or just let it go unattached"? What do you mean by those two options there?
<mynameisdebian> If I call the child script from the parent, won't the parent still take a long time to finish, and I'll still get the timeout error?
<SeepingN> not if you fire in the background. non-blocking.
wildtrees has joined #ruby
<SeepingN> system “#{RAILS_ROOT}/script/runner Project.my_method >/dev/null 2>&1
<SeepingN> &”
<rubydoc> parser error at position 0 around `”'
<havenwood> SeepingN: smart quotes?
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<mynameisdebian> SleepingN, I just want to make sure because I am almost sleeping myself, is there any reason this solution would not work on Ruby without Rails?
akem-hp_ has joined #ruby
akem-hp has quit [Ping timeout: 245 seconds]
<havenwood> mynameisdebian: Forking from the CGI process to do the background work should suffice.
<havenwood> mynameisdebian: It's certainly popular to use Rack for such things.
<havenwood> mynameisdebian: Rails is one of many Rack frameworks, but you don't need to use a framework with Rack at all.
<havenwood> mynameisdebian: https://rack.github.io/
<havenwood> mynameisdebian: if you wanted to be fancy, you could use Rack with a Redis-backed worker queue like Sidekiq.
<havenwood> Or Resque.
<havenwood> Or just something Thread-backed, like Suckerpunch.
<SeepingN> never knew what you wanted could get some complicated, eh
<havenwood> or just fork :P
ukd1 has quit [Ping timeout: 244 seconds]
ukd1 has joined #ruby
<mynameisdebian> havenwood, I just need a way to send the 200 response and still run some code. Having a second script seems ok, but I'm trying to understand rack. Do you have a second to kind of explain those short examples on that page for me?
<havenwood> mynameisdebian: In CGI, by forking from your process or sending a task to a worker queue you can let the CGI script spin down so Apache sends the response.
<havenwood> mynameisdebian: Rack is an alternative, where you run a more sophisticated Ruby webserver that stays up between requests, unlike GCI which spins up a fresh Ruby process for each request.
<havenwood> mynameisdebian: By convention, you launch a Rack app from a config.ru file.
<havenwood> mynameisdebian: This line, for example, creates a simple Rack app in a single config.ru file:
<havenwood> echo "run -> _env { [200, {}, ['Hello World']] }" > config.ru
<havenwood> mynameisdebian: You can then run that ^ app with the command: rackup
<havenwood> mynameisdebian: Just install Rack, and usually you'll also want to install a Rack webserver like Puma too, rather than using the default.
<havenwood> mynameisdebian: gem install rack puma
<havenwood> mynameisdebian: Try creating that ^ config.ru, and running it with: rack
<havenwood> mynameisdebian: The `200` is the response code.
<havenwood> mynameisdebian: The empty Hash `{}` is for any Headers you want to set.
<havenwood> mynameisdebian: And the third argument is the body of the response.
<havenwood> mynameisdebian: You could spin up a thread, fork, use a worker queue, etc. to do some background work.
<havenwood> mynameisdebian: Does that make any sense? I'd suggest just playing with Rack a bit to get a feel for a simple Rack app.
<mynameisdebian> Does the Rack app contain the other code I want to run?
<havenwood> mynameisdebian: Yes, you can trigger that other code running from your Rack app. If you find you want to respond to more than one verb, routes, etc, consider using Roda on top of Rack: http://roda.jeremyevans.net/
<havenwood> mynameisdebian: It add a routing tree, for easy routing, and optional plugins.
<mynameisdebian> so, all I'm doing here is receiving a JSON message from Slack and responding with 200 OK, then taking information from that message and using it to place a call to another API. That API returns some data that is used to generate a Slack-formatted message, and then that message is posted back to a Slack endpoint
<havenwood> mynameisdebian: Here's an example of a Rack app that responds to all requests with 200 immediately, then five seconds laters logs "did work!":
<havenwood> echo "run -> _env { Thread.new { sleep 5; puts 'did work!' }; [200, {}, ['Hello World']] }" > config.ru
<havenwood> mynameisdebian: Run ^ that config.ru file with: rackup
<havenwood> mynameisdebian: Try it in the browser at: localhost:9292
<havenwood> mynameisdebian: You'll see an immediate response, then five seconds later a log entry.
<havenwood> mynameisdebian: Try doing the same with Roda.
<havenwood> mynameisdebian: gem install roda
<havenwood> mynameisdebian: It'll handle a ton more requests than CGI, fwiw.
<havenwood> mynameisdebian: If you see a config.ru file, you've spotted a Rack app.
<havenwood> mynameisdebian: Rails, Sinatra, Hanami, Roda, etc will all have a config.ru (Rack Up) file.
ukd1 has quit [Ping timeout: 272 seconds]
<havenwood> The default Rack webserver for Rails is Puma.
<havenwood> I
<mynameisdebian> havenwood, I'm confusing myself a little bit here. In this scenario is my Apache server still running on the server, serving the config.ru file?
<havenwood> I'd recommend Puma as a solid choice for whatever Rack app you're using.
<havenwood> mynameisdebian: You could serve Puma straight up on port 80, or 443, or you could reverse proxy from Apache to the port or socket that Puma is running on.
<havenwood> mynameisdebian: It's a very common setup to reverse proxy from Apache to Puma.
ukd1 has joined #ruby
<havenwood> mynameisdebian: I prefer the Nginx setup.
<havenwood> mynameisdebian: Falcon is a newer webserver than Puma that's meant to be run without Apache or Nginx.
<mynameisdebian> and in this case the Ruby webserver is always running, or does it have to be run on demand?
<havenwood> mynameisdebian: It would be always running.
<havenwood> mynameisdebian: Typically people just start Puma with systemd, which keeps it running.
<mynameisdebian> oh I see
<havenwood> mynameisdebian: Falcon has great performance served directly on port 443, fwiw: https://github.com/socketry/falcon
eddof13 has quit [Quit: eddof13]
<havenwood> mynameisdebian: Puma is a more mainstream webserver.
<havenwood> mynameisdebian: You can swap a Rack app's webserver very easily between Puma, Passenger, Unicorn, Falcon, etc.
<mynameisdebian> It's a company webserver and I have to go through some admins to get anything done. I'm thinking it might be less complex in this case to have first script return 200 and make a system call to the other
<havenwood> mynameisdebian: There are a bunch of battle tested, high quality web server options.
<mynameisdebian> havenwood, I appreciate your time
<mynameisdebian> I'm going to re-read what you said and try to get a better grasp of it later on
<havenwood> mynameisdebian: please come back and inquire further if things come up
<havenwood> mynameisdebian: good luck!
<mynameisdebian> havenwood, thank you
phenom has quit [Ping timeout: 248 seconds]
morenoh149 has quit [Ping timeout: 258 seconds]
mynameisdebian has quit [Ping timeout: 248 seconds]
morenoh149 has joined #ruby
lucasb has quit [Quit: Connection closed for inactivity]
sylario has quit [Quit: Connection closed for inactivity]
cyclonis has joined #ruby
phenom has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]