havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.6.1, 2.5.3, 2.4.5: 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!
spacesuitdiver has quit [Client Quit]
<bjpenn> any ruby ninja techniques to get it to do what i want? :P
<bjpenn> the reason being, the contents within the heredoc, the "string", is a complex regex expression
<bjpenn> i want to keep the essence of that the way it is copy/pasted
<bjpenn> the only thing that needs changing is "\" being "\\"
<bjpenn> and some fields that will become string interpolated like this: #{blah}
<mozzarella> are you going to create a regex object with said string? is it a valid ruby regex?
<bjpenn> its actuallynot regex
<bjpenn> its a query string for sumologic
<bjpenn> :D
<bjpenn> it contains regex though
<bjpenn> but i prefer the whole thing to be in a heredoc
<bjpenn> without me going to random characters and escaping them manually
<mozzarella> bjpenn: you could do something like this: https://www.honeybadger.io/blog/data-and-end-in-ruby/
<havenwood> bjpenn: how about heredoc with sprintf?
<mozzarella> erb template at the end of the file
<leftylink> a study of https://ruby-doc.org/core-2.5.0/doc/syntax/literals_rdoc.html#label-Here+Documents reveals that IF this is using a literal, the only option is to disable *both* interpolation and escaping, with no option to only disable escaping while keeping interpolation. so the solution will have to be something other than a literla.
<havenwood> bjpenn: <<~'END' % {meaning: 42}
<leftylink> fun
<mozzarella> I think I prefer this way, actually
<bjpenn> looking..
<bjpenn> nice... that might actually work
<bjpenn> im using heredocs as part of an erb template though
* bjpenn crosses fingers
<bjpenn> trying it
ubuntuisloved has joined #ruby
<mozzarella> bjpenn: can't it be its own template, then, and then embedded in the parent template?
<mozzarella> shouldn't be too hard
<bjpenn> yeah i suppose that would work too
ams__ has quit [Quit: Connection closed for inactivity]
nowhereman has joined #ruby
<bjpenn> that ruby magic didnt bode well with the erb
<bjpenn> :/
<bjpenn> thank you all for trying though! :)
<havenwood> fun with ERB templates!
<havenwood> it's interesting that Ruby's JIT uses ERB :)
<havenwood> here's a simple ERB template i meant to do a writeup on to introduce folk to making their own templates: https://gist.github.com/havenwood/4469e3975ce0b597e00a3cf205dea4bb
blackmesa has joined #ruby
crankharder has quit [Ping timeout: 240 seconds]
ubuntuisloved has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
AJA4350 has quit [Ping timeout: 245 seconds]
DeadPixelz01 has quit [Ping timeout: 240 seconds]
AJA4350 has joined #ruby
renich_ has quit [Remote host closed the connection]
DeadPixelz01 has joined #ruby
orbyt_ has joined #ruby
nowhereman has quit [Ping timeout: 252 seconds]
crankharder has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dviola has joined #ruby
conta has joined #ruby
orbyt_ has joined #ruby
conta has quit [Ping timeout: 252 seconds]
Swyper has quit [Remote host closed the connection]
sgen has quit [Ping timeout: 252 seconds]
Swyper has joined #ruby
sidepocket has quit [Remote host closed the connection]
sidepocket has joined #ruby
bambanx has joined #ruby
r29v has quit [Quit: r29v]
Swyper has quit [Ping timeout: 255 seconds]
DeadPixelz01 has quit [Ping timeout: 240 seconds]
crankharder has quit [Ping timeout: 240 seconds]
sidepocket has quit [Ping timeout: 256 seconds]
zachk has quit [Quit: Leaving]
gix has quit [Ping timeout: 240 seconds]
renich has joined #ruby
Averna has joined #ruby
r29v has joined #ruby
r29v has quit [Client Quit]
r29v has joined #ruby
<mjacob> is there a builtin (or shorter / more idiomatic) version of "Enumerator.new do |y| loop do y << f() end end.lazy"?
AJA4350 has quit [Ping timeout: 245 seconds]
mangold has joined #ruby
FastJack has quit [Ping timeout: 264 seconds]
FastJack has joined #ruby
gnufied has quit [Remote host closed the connection]
Swyper has joined #ruby
SeepingN has quit [Quit: The system is going down for reboot NOW!]
sgen has joined #ruby
r29v has quit [Quit: r29v]
sylario has quit [Quit: Connection closed for inactivity]
Swyper has quit [Ping timeout: 240 seconds]
Swyper has joined #ruby
Swyper has quit [Ping timeout: 255 seconds]
Swyper has joined #ruby
Onwarion has joined #ruby
Onwarion_re has quit [Ping timeout: 246 seconds]
Swyper has quit [Ping timeout: 250 seconds]
dviola has quit [Quit: WeeChat 2.4]
<havenwood> mjacob: that reminds me of Elixir's Stream.repeatedly/1, which you can implement just like you showed: https://github.com/havenwood/elixir.rb/blob/master/lib/elixir/stream.rb#L29-L35
<mjacob> i agree that we all should use (better) functional languages, but i don't really have a choice ;)
<havenwood> mjacob: You could make a helper method like ^ and then: repeatedly { foo }.lazy
sacomo has quit [Ping timeout: 264 seconds]
crankharder has joined #ruby
ozzloy has joined #ruby
ozzloy has quit [Changing host]
ozzloy has joined #ruby
sacomo has joined #ruby
Swyper has joined #ruby
cthulchu has quit [Ping timeout: 255 seconds]
hightower2 has quit [Ping timeout: 240 seconds]
v01d4lph4 has joined #ruby
renich_ has joined #ruby
renich has quit [Ping timeout: 245 seconds]
sgen has quit [Ping timeout: 252 seconds]
tau has joined #ruby
code_zombie has quit [Quit: Leaving]
cd has quit [Remote host closed the connection]
aqd has quit [Remote host closed the connection]
aqd_ has joined #ruby
Tempesta_ has joined #ruby
Tempesta has quit [Ping timeout: 245 seconds]
miah has quit [Ping timeout: 264 seconds]
miah has joined #ruby
orbyt_ has quit [Ping timeout: 245 seconds]
cd has joined #ruby
Tempesta_ has left #ruby ["Closing Channel, bye."]
Tempesta has joined #ruby
Qiong|AFK is now known as Qiong
Qiong is now known as Qiong|Eat
dubuc has quit [Quit: Textual IRC Client: www.textualapp.com]
tau has quit [Remote host closed the connection]
Qiong|Eat is now known as Qiong|HalfFull
fluxAeon has quit [Quit: Textual IRC Client: www.textualapp.com]
crankharder has quit [Ping timeout: 255 seconds]
duderonomy has quit [Ping timeout: 240 seconds]
duderonomy has joined #ruby
fluxAeon has joined #ruby
DTZUZO has joined #ruby
v01d4lph4 has quit [Remote host closed the connection]
v01d4lph4 has joined #ruby
braincrash has quit [Quit: bye bye]
blackmesa has quit [Ping timeout: 257 seconds]
braincrash has joined #ruby
crankharder has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
meinside has quit [Quit: Connection closed for inactivity]
Nicmavr has joined #ruby
BTRE has quit [Ping timeout: 255 seconds]
Swyper has quit [Remote host closed the connection]
BTRE has joined #ruby
aqd_ has quit [Ping timeout: 240 seconds]
agent_white has quit [Quit: bbl]
Swyper has joined #ruby
xrexeon has quit [Ping timeout: 240 seconds]
v01d4lph4 has quit [Remote host closed the connection]
ur5us has quit [Remote host closed the connection]
Swyper has quit [Remote host closed the connection]
ur5us has joined #ruby
govg has quit [Ping timeout: 245 seconds]
v01d4lph4 has joined #ruby
ur5us has quit [Ping timeout: 240 seconds]
crankharder has quit [Ping timeout: 244 seconds]
DeadPixelz01 has joined #ruby
DaRock has quit [Ping timeout: 250 seconds]
sgen has joined #ruby
Fusl has quit [Remote host closed the connection]
Fusl has joined #ruby
RiPuk has joined #ruby
crankharder has joined #ruby
jud has joined #ruby
jud has joined #ruby
jud has quit [Changing host]
crankharder has quit [Ping timeout: 255 seconds]
crankharder has joined #ruby
Calinou has quit [Remote host closed the connection]
jmcgnh has quit [Ping timeout: 252 seconds]
Calinou has joined #ruby
rippa has joined #ruby
jmcgnh_ has joined #ruby
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
aqd has joined #ruby
sgen has quit [Ping timeout: 252 seconds]
SeepingN has joined #ruby
evdubs_ has joined #ruby
evdubs has quit [Ping timeout: 240 seconds]
renich has joined #ruby
renich_ has quit [Ping timeout: 245 seconds]
bambanx has quit [Read error: Connection reset by peer]
bambanx has joined #ruby
Swyper has quit [Remote host closed the connection]
conta has joined #ruby
crankharder has quit [Ping timeout: 252 seconds]
Inline has quit [Quit: Leaving]
crankharder has joined #ruby
jcarl43 has quit [Quit: WeeChat 2.4]
cd has quit [Quit: cd]
aufi has joined #ruby
tdy has joined #ruby
DeadPixelz01 has quit [Quit: Leaving]
jane_booty_doe has quit [Remote host closed the connection]
reber has joined #ruby
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #ruby
eightfold has joined #ruby
crankharder has quit [Ping timeout: 245 seconds]
qual has joined #ruby
<sagax> hi all!
skryking has quit [Ping timeout: 245 seconds]
<sagax> who use vim - what the best colorscheme for ruby?
skryking has joined #ruby
fluxAeon has quit [Ping timeout: 252 seconds]
jane_booty_doe has joined #ruby
eightfold has quit [Quit: eightfold]
fluxAeon has joined #ruby
crankharder has joined #ruby
t0xik has joined #ruby
fluxAeon has quit [Ping timeout: 240 seconds]
emilford has quit [Ping timeout: 255 seconds]
DaRock has joined #ruby
crankharder has quit [Ping timeout: 252 seconds]
<bambanx> hi sagax ! i use vim
hahuang6| has quit [Ping timeout: 264 seconds]
hahuang6- has joined #ruby
ur5us has joined #ruby
Xiti has quit [Ping timeout: 245 seconds]
ur5us has quit [Client Quit]
Xiti has joined #ruby
tag has quit [Quit: Connection closed for inactivity]
jinie has quit [Quit: ZNC 1.6.1 - http://znc.in]
emilford has joined #ruby
jinie has joined #ruby
clemens3 has joined #ruby
schleppel has joined #ruby
<bambanx> i use vim-gotham is nice sagax
emilford has quit [Ping timeout: 245 seconds]
qual is now known as qual[away]
emilford has joined #ruby
sauvin has joined #ruby
emilford has quit [Ping timeout: 255 seconds]
emilford has joined #ruby
evdubs_ has quit [Remote host closed the connection]
lxsameer has joined #ruby
keden has joined #ruby
KeyJoo has joined #ruby
KeyJoo has quit [Max SendQ exceeded]
KeyJoo has joined #ruby
evdubs_ has joined #ruby
keden has quit [Ping timeout: 240 seconds]
tdy1 has joined #ruby
qual[away] has quit [Ping timeout: 240 seconds]
<sagax> thanks
tdy has quit [Ping timeout: 245 seconds]
<sagax> i will try this
KeyJoo has quit [Remote host closed the connection]
KeyJoo has joined #ruby
renich has quit [Quit: renich]
suukim has joined #ruby
cnsvc has joined #ruby
suukim has quit [Remote host closed the connection]
bambanx has quit [Quit: Leaving]
suukim has joined #ruby
themsay has quit [Ping timeout: 245 seconds]
keden has joined #ruby
keden has quit [Ping timeout: 255 seconds]
eightfold has joined #ruby
ellcs1 has joined #ruby
eightfold_ has joined #ruby
jane_booty_doe has quit [Quit: The Lounge - https://thelounge.chat]
eightfold has quit [Ping timeout: 268 seconds]
eightfold_ has quit [Ping timeout: 268 seconds]
aupadhye has joined #ruby
eightfold has joined #ruby
qual has joined #ruby
cnsvc has quit [Ping timeout: 256 seconds]
jane_booty_doe has joined #ruby
eightfold has quit [Client Quit]
qual is now known as qual[away]
sylario has joined #ruby
hightower2 has joined #ruby
ellcs1 has quit [Ping timeout: 240 seconds]
qual[away] has quit [Ping timeout: 250 seconds]
hightower2 has quit [Changing host]
hightower2 has joined #ruby
themsay has joined #ruby
ellcs1 has joined #ruby
evdubs_ has quit [Remote host closed the connection]
meinside has joined #ruby
DaRock has quit [Read error: Connection reset by peer]
evdubs_ has joined #ruby
gloscombe has joined #ruby
ellcs1 has quit [Ping timeout: 240 seconds]
keden has joined #ruby
KeyJoo has quit [Remote host closed the connection]
eightfold has joined #ruby
eightfold_ has joined #ruby
eightfold has quit [Ping timeout: 268 seconds]
eightfold_ is now known as eightfold
bjpenn has quit [Ping timeout: 252 seconds]
KeyJoo has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Qiong|HalfFull has quit [Remote host closed the connection]
neo has joined #ruby
neo has left #ruby [#ruby]
bruce_lee has joined #ruby
bruce_lee has quit [Client Quit]
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
bruce_lee has joined #ruby
claudiuinberlin has joined #ruby
DTZUZO has quit [Ping timeout: 255 seconds]
sriehl has quit [Read error: Connection reset by peer]
sriehl has joined #ruby
dinfuehr_ is now known as dinfuehr
KeyJoo has quit [Quit: KeyJoo]
claudiuinberlin has quit [Ping timeout: 240 seconds]
DTZUZO has joined #ruby
KeyJoo has joined #ruby
themsay has quit [Ping timeout: 240 seconds]
themsay has joined #ruby
ferr has joined #ruby
eightfold_ has joined #ruby
eightfold has quit [Ping timeout: 268 seconds]
eightfold_ is now known as eightfold
qual has joined #ruby
mikecmpbll has joined #ruby
eightfold has quit [Quit: eightfold]
aqd has quit [Quit: Leaving]
sinanislekdemir has joined #ruby
jane_booty_doe has quit [Quit: The Lounge - https://thelounge.chat]
jane_booty_doe has joined #ruby
alem0lars has joined #ruby
conta has quit [Ping timeout: 244 seconds]
aqd has joined #ruby
beaky has quit [Read error: Connection reset by peer]
beaky has joined #ruby
ldnunes has joined #ruby
Ai9zO5AP has joined #ruby
qual is now known as qual[away]
conta has joined #ruby
alem0lars has quit [Ping timeout: 245 seconds]
alem0lars has joined #ruby
alem0lars has quit [Read error: Connection reset by peer]
eightfold has joined #ruby
keden has quit [Ping timeout: 245 seconds]
v01d4lph4 has quit [Remote host closed the connection]
keden has joined #ruby
qual[away] has quit [Quit: qual[away]]
DaRock has joined #ruby
keden has quit [Ping timeout: 255 seconds]
keden has joined #ruby
mangold has quit [Ping timeout: 252 seconds]
mangold_ has joined #ruby
v01d4lph4 has joined #ruby
<kke> solarized dark for everything
DTZUZO has quit [Ping timeout: 252 seconds]
v01d4lph4 has quit [Remote host closed the connection]
ray479 has joined #ruby
<ray479> hello im trying regex with Ruby
ubuntuisloved has joined #ruby
<ray479> is there a gem to valid email in ruby ?
<ray479> i mean check valid email
za1b1tsu has joined #ruby
ray479 has quit [Quit: Page closed]
eightfold has quit [Quit: eightfold]
keden has quit [Ping timeout: 246 seconds]
keden has joined #ruby
eightfold has joined #ruby
<ytti> regexp is poor way to validate email, if it needs to be absolutely right
<ytti> you'd need proper parser with lexer and tokenizer
<ytti> if it needs to be just approximately right then it's not really worth a gem
ubuntuisloved has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ubuntuisloved has joined #ruby
ljarvis_ has joined #ruby
ljarvis has quit []
ljarvis_ is now known as ljarvis
<TheBrayn> what are even usecases for 100% validating an email address?
stryek has joined #ruby
Fusl has quit [Remote host closed the connection]
fluxAeon has joined #ruby
Fusl has joined #ruby
crankharder has joined #ruby
<ytti> not losing customer who couldn't sign up because you wouldn't accept their email
<ytti> seems odd question to ask
<ytti> because then question rises, well, how correct must it be?
<ytti> i have trouble signing in with email addres from domain @0b.fi
<ytti> many validators expect domain not to start with number
<ytti> many validators expect domain to be longer than two characters
helpa has quit [Remote host closed the connection]
helpa-bot has joined #ruby
chromis has joined #ruby
jane_booty_doe has quit [Remote host closed the connection]
ljarvis_ has joined #ruby
helpa-bot has quit [Remote host closed the connection]
helpa has joined #ruby
ljarvis has quit [Ping timeout: 246 seconds]
ljarvis_ is now known as ljarvis
cyberarm_ has joined #ruby
cyberarm has quit [Ping timeout: 255 seconds]
sinanislekdemir has quit [Quit: rcirc on GNU Emacs 27.0.50]
ljarvis has quit [Ping timeout: 240 seconds]
lucasb has joined #ruby
Inline has joined #ruby
jcalla has joined #ruby
stan has joined #ruby
Swyper has joined #ruby
aupadhye has quit [Ping timeout: 245 seconds]
Swyper has quit [Remote host closed the connection]
p0s1x has joined #ruby
Swyper has joined #ruby
conta has quit [Ping timeout: 245 seconds]
p0s1x has quit [Read error: Connection reset by peer]
Fusl has quit [Ping timeout: 256 seconds]
Fusl has joined #ruby
stan has quit [Remote host closed the connection]
Rapture has joined #ruby
apparition has joined #ruby
stan has joined #ruby
stan_ has joined #ruby
mikecmpb_ has joined #ruby
stan has quit [Ping timeout: 240 seconds]
al2o3-cr has quit [Read error: Connection reset by peer]
mikecmpbll has quit [Ping timeout: 240 seconds]
polishdub has joined #ruby
al2o3-cr has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
AJA4350 has joined #ruby
Swyper has quit [Remote host closed the connection]
conta has joined #ruby
gnufied has joined #ruby
Swyper has joined #ruby
conta has quit [Ping timeout: 250 seconds]
conta has joined #ruby
DaRock has quit [Ping timeout: 255 seconds]
apparition has quit [Quit: Bye]
conta has quit [Ping timeout: 252 seconds]
zleap has joined #ruby
zleap has quit [Changing host]
zleap has joined #ruby
DTZUZO has joined #ruby
v01d4lph4 has joined #ruby
t0xik has quit [Quit: Connection closed for inactivity]
eightfold has quit [Quit: eightfold]
tau has joined #ruby
AJA4351 has joined #ruby
AJA4350 has quit [Ping timeout: 252 seconds]
AJA4351 is now known as AJA4350
aufi has quit [Remote host closed the connection]
conta has joined #ruby
robotcars1 has joined #ruby
sriehl has quit [Quit: ZNC 1.7.2 - https://znc.in]
Rapture has quit [Quit: Textual IRC Client: www.textualapp.com]
robotcars has quit [Ping timeout: 244 seconds]
conta has quit [Client Quit]
dante has quit [Read error: Connection reset by peer]
dante has joined #ruby
clemens3 has quit [Ping timeout: 252 seconds]
emilford has quit [Ping timeout: 240 seconds]
[Butch] has joined #ruby
robotcars has joined #ruby
emilford has joined #ruby
duderonomy has joined #ruby
robotcars1 has quit [Ping timeout: 250 seconds]
conta has joined #ruby
conta has quit [Ping timeout: 255 seconds]
ubuntuisloved has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Swyper has quit [Remote host closed the connection]
marcoecc has joined #ruby
VladGh has joined #ruby
ubuntuisloved has joined #ruby
VladGh has quit [Remote host closed the connection]
VladGh has joined #ruby
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
cthulchu has joined #ruby
za1b1tsu has quit [Remote host closed the connection]
mikecmpb_ has quit [Quit: inabit. zz.]
emilford has quit [Ping timeout: 240 seconds]
lxsameer has quit [Ping timeout: 268 seconds]
emilford has joined #ruby
mikecmpbll has joined #ruby
KeyJoo has quit [Ping timeout: 250 seconds]
zleap has quit [Quit: WeeChat 2.4]
ljarvis_ has joined #ruby
Swyper has quit [Remote host closed the connection]
ljarvis_ is now known as ljarvis
v01d4lph4 has quit [Remote host closed the connection]
mikecmpbll has quit [Quit: inabit. zz.]
emilford has quit [Ping timeout: 255 seconds]
emilford has joined #ruby
robotcars1 has joined #ruby
robotcars2 has joined #ruby
roychri has joined #ruby
robotcars has quit [Ping timeout: 250 seconds]
AJA4350 has quit [Ping timeout: 245 seconds]
robotcars1 has quit [Ping timeout: 245 seconds]
szulak_ has joined #ruby
roychri has left #ruby [#ruby]
marcoecc has quit [Ping timeout: 250 seconds]
sgen has joined #ruby
robotcars has joined #ruby
robotcars1 has joined #ruby
robotcars1 has quit [Client Quit]
robotcars1 has joined #ruby
robotcars2 has quit [Ping timeout: 240 seconds]
robotcars1 has quit [Client Quit]
robotcars has quit [Ping timeout: 252 seconds]
zleap has joined #ruby
zleap has quit [Changing host]
zleap has joined #ruby
jack479 has joined #ruby
<jack479> Hello guys
eightfold has joined #ruby
<zleap> hello
<jack479> How can i match string that can contain [a-z] [0-9] and a '-' ( provided that it is not the first or last character) ?
<zleap> not sure
<jack479> i tried string =~ /[a-zA-Z\-]/ ; doesn't works
<jack479> anyone have an idea ?
<jack479> thank's!
keden has quit [Ping timeout: 250 seconds]
eightfold has quit [Quit: eightfold]
szulak_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
crankharder has quit [Ping timeout: 246 seconds]
amil has joined #ruby
crankharder has joined #ruby
v01d4lph4 has joined #ruby
amil has quit [Remote host closed the connection]
<leftylink> jack479: there are probably two parts to your question but if I assume that we are focusing on how to include a hyphen inside a character class, then https://www.regular-expressions.info/charclass.html is probably helpful
<jack479> leftylink: oh thank you ! :)
v01d4lph4 has quit [Ping timeout: 246 seconds]
<leftylink> one thing to note is that the escaping you did (with a backslash) does indeed cause the hyphen to be included in the character class
robotcars has joined #ruby
<leftylink> if instead we focus on a different part of the question (how to express "- can't be the first or last character"), though there might be multiple ways to express this, one way that comes to mind is to say, well, the valid characters for the first/last character are the characters other than hyphen, and the valid chars for those in the middle are including hyphen
<ljarvis> jack479: [a-z0-9][a-z0-9-][a-z0-9] ? :)
<ljarvis> add a + after the second char class
jcarl43 has joined #ruby
lucasb has quit [Quit: Connection closed for inactivity]
<leftylink> hm. thinking about ranges has got me thinking
<leftylink> if you have a range that is "unusual" what happens...
<leftylink> &>> /[A-z]/ =~ (?A.ord + 28).chr; $~
<rubydoc> # => #<MatchData "]"> (https://carc.in/#/r/6gai)
<leftylink> okay
<ljarvis> A-z isn't really unusual
<leftylink> thought it might have been something like that
zachk has joined #ruby
<ljarvis> well, i guess it is unusual, just not really something i'd expect to fail
<leftylink> well
<leftylink> hopefully anyone who uses it is okay with it matching the 6 chars in between
<ljarvis> i was thinking you meant a-9 or something, which would raise an error (i think)
<leftylink> hmm
<leftylink> &>> /[a-9]/
<rubydoc> stderr: -e:2: empty range in char class: /[a-9]/ (https://carc.in/#/r/6gaj)
<leftylink> I see
<leftylink> &>> (0..255).select { |c| /[9-a]/.match?(c.chr) }.minmax
<rubydoc> # => [57, 97] (https://carc.in/#/r/6gak)
<leftylink> okay
eightfold has joined #ruby
snk has joined #ruby
<snk> hello
v01d4lph4 has joined #ruby
mangold_ has quit [Quit: This computer has gone to sleep]
v01d4lph4 has quit [Ping timeout: 240 seconds]
ravenousmoose has joined #ruby
ravenousmoose has quit [Ping timeout: 258 seconds]
zachk has quit [Changing host]
zachk has joined #ruby
<leftylink> to be fair I didn't check that the range is continuous
bjpenn has joined #ruby
sphenxes has joined #ruby
eightfold has quit [Quit: eightfold]
gloscombe has quit [Quit: gloscombe]
aqd has quit [Remote host closed the connection]
sphenxes has quit [Remote host closed the connection]
sameerynho has joined #ruby
paraxial has quit [Quit: The Lounge - https://thelounge.chat]
v01d4lph4 has joined #ruby
[Butch] has quit [Quit: Textual IRC Client: www.textualapp.com]
DTZUZO has quit [Ping timeout: 250 seconds]
[Butch] has joined #ruby
DTZUZO has joined #ruby
yqt has joined #ruby
aqd has joined #ruby
fluxAeon has quit [Ping timeout: 245 seconds]
mikecmpbll has joined #ruby
renich has joined #ruby
<jack479> ok, will try on my side
<jack479> get back to you guys
<jack479> thank's
themsay has quit [Ping timeout: 250 seconds]
jack479 has quit [Ping timeout: 256 seconds]
zachk has quit [Ping timeout: 250 seconds]
Swyper has joined #ruby
sauvin has quit [Read error: Connection reset by peer]
millerti has joined #ruby
orbyt_ has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
orbyt_ has quit [Ping timeout: 245 seconds]
sphenxes has joined #ruby
ravenousmoose has joined #ruby
Swyper has quit [Remote host closed the connection]
orbyt_ has joined #ruby
Swyper has joined #ruby
tdy1 is now known as tdy
hightower3 has joined #ruby
hightower2 has quit [Ping timeout: 250 seconds]
naught-fowl has joined #ruby
v01d4lph4 has quit [Read error: Connection reset by peer]
v01d4lph4 has joined #ruby
dinfuehr_ has joined #ruby
dinfuehr has quit [Ping timeout: 244 seconds]
zachk has joined #ruby
zachk has quit [Changing host]
zachk has joined #ruby
v01d4lph4 has quit [Ping timeout: 240 seconds]
nwradio has joined #ruby
suukim has quit [Quit: Konversation terminated!]
Swyper has quit [Remote host closed the connection]
_mak has joined #ruby
<_mak> hi there
<nwradio> sup my guy
<_mak> is there a way to convert: {"key1"=>"value1"} into {key1: "value1"}?
<sagax> hi all!
<nwradio> unfortunately i'm pretty new to ruby so i cannot help you at the moment
<sagax> how to right catch/throw ?
Swyper has joined #ruby
<sagax> i am not about begin/rescue
tau is now known as el-bigodon
<_mak> ah
<_mak> :)
Dbugger has joined #ruby
<_mak> what's the name of this `{key1: "value1"}?
<_mak> it is not json right, because on json the key is between quotes
<snk> that's ruby 1.9+ hash syntax
<_mak> but when I convert my {"key1"=>"value1"} into hash I get the same thing
arooni_team_b is now known as arooni
<snk> pre 1.9 hash syntax is still valid
<snk> the latter example there is slightly different, in that the key will be a symbol instead of a string
<_mak> in it possible to convert it?
<_mak> found it!
<naught-fowl> Hash[ somehash.map {|k,v| [k.to_sym, v]} ]
<_mak> with your 'symbol' keyword
<_mak> hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
<_mak> nice thanks!
sphenxes has quit [Quit: Leaving]
<snk> rubocop can do it... though i'd be careful in any places where you rely on the key being a string?
<_mak> didn't work :(
<_mak> not all levels of the hash have been converted into symbols
yqt has quit [Ping timeout: 240 seconds]
zleap has quit [Quit: WeeChat 2.4]
go|dfish has quit [Ping timeout: 246 seconds]
<naught-fowl> right
AJA4350 has joined #ruby
nowhereman has joined #ruby
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Swyper has quit [Remote host closed the connection]
nowhereman has quit [Ping timeout: 245 seconds]
go|dfish has joined #ruby
hiroaki_ has quit [Ping timeout: 255 seconds]
n13z has joined #ruby
Swyper has joined #ruby
szulak_ has joined #ruby
SeepingN has joined #ruby
orbyt_ has quit [Quit: Textual IRC Client: www.textualapp.com]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
gix has joined #ruby
ldnunes has quit [Quit: Leaving]
Fernando-Basso has joined #ruby
tiogrand_ has joined #ruby
naught-fowl has quit [Quit: This computer has gone to sleep]
szulak_ has quit [Quit: Textual IRC Client: www.textualapp.com]
ua has quit [Ping timeout: 255 seconds]
noobineer has quit [Ping timeout: 245 seconds]
FastJack has quit [Ping timeout: 264 seconds]
naught-fowl has joined #ruby
FastJack has joined #ruby
ua has joined #ruby
BTRE has quit [Remote host closed the connection]
AJA4350 has quit [Ping timeout: 245 seconds]
noobineer has joined #ruby
BTRE has joined #ruby
<mkroman> what's an efficient way to generate a sha256 digest for a file in Ruby?
<mkroman> any gems?
<havenwood> mkroman: it's in the stdlib under Digest
<mkroman> for files?
<havenwood> for anything
<mkroman> unless the API lets me do it directly from IO it's gonna be slow as balls in Ruby
dviola has joined #ruby
<havenwood> &ri Digest::SHA256.file
<rubydoc> parser error at position 0 around `r'
<havenwood> &ri Digest::SHA256::file
<rubydoc> parser error at position 0 around `r'
<havenwood> mkroman: anyhow, you can use Digest::SHA2 with IO
dellavg__ has quit [Ping timeout: 245 seconds]
<mkroman> damnit, so I can…
<mkroman> thanks! and sorry for bothering you, kinda should've looked it up myself :p
redmedic has joined #ruby
<redmedic> cross posting from the #cinch channel but its pretty inactive. Im using cinch to try and make an irc bot that can use memoserv and Im not seeing anything in the gem to interact with it.
<mkroman> memoserv should just be a reserved user on the network that you talk to, any commands you want to send to it you can do through privmsg's
ravenousmoose has quit [Ping timeout: 264 seconds]
tiogrand_ has quit [Ping timeout: 250 seconds]
<sagax> but i don't understand - right way to use throw/catch
hightower3 has quit [Changing host]
hightower3 has joined #ruby
<sagax> catch :foo do throw :foo end - it's strange
Dbugger has quit [Ping timeout: 240 seconds]
<mkroman> havenwood: https://gist.github.com/mkroman/f9b1673721bcdeb8e6daf25129d87190 in case you were curious
<mkroman> (and yes, I know it depends heavily on the system cache and the fact that it's on a tmpfs, but there's still a significant difference)
<mkroman> and the overhead might be entirely in the process spawning
AJA4350 has joined #ruby
<mkroman> sagax: are you asking as a beginner or are you looking to optimize code?
Swyper has quit [Remote host closed the connection]
<sagax> i want understand catch/throw
<baweaver> sagax: Use begin / rescue
<mkroman> honestly, I've never seen catch/throw used in real life
<sagax> no,
<sagax> i need catch/throw
<leftylink> I forgot catch / throw exists
naught-fowl has quit [Quit: This computer has gone to sleep]
<mkroman> sagax: from what I gather the difference is that catch/throw won't have *any* stack information, backtrace log, error type or message
<ytti> afaik it is 'goto'
<ytti> i have no idea of what the application might be
<ytti> i suspect more idiomatic solution exists to most or all problems
<mkroman> whereas rescue/raise will create a whole object, reverse the stack and store the backtrace in it just to give you more information
<mkroman> if you need exceptions to be performant, you're doing something wrong.
<sagax> catch/throw can return result
<leftylink> that is interesting.
<sagax> and catch/throw can stop block
<sagax> just stop
<sagax> without exception
<sagax> stop and return something
<leftylink> &>> catch(:hello) { 1.step { |n| throw :hello, n if Math.log(Math.log(n)) >= Math::E } }
<rubydoc> # => 3814280 (https://carc.in/#/r/6gci)
<leftylink> so, I could do that, if I felt like
<leftylink> but I wuld rather use 1.step.find in this instance
<baweaver> sagax: Use begin / rescue, you'll have a lot easier time.
<leftylink> or I would use a function and return frmo it maybe?
<baweaver> What code do you _need_ it for?
<baweaver> begin / rescue can also return a result.
<sagax> begin/rescue it's about exceptions,
<baweaver> Very often when one thinks they _need_ a language feature that's not entirely accurate. It depends heavily on context, and sometimes we're bent on shoehorning our problem to match.
<sagax> but i don't need it
<baweaver> What problem are you trying to solve?
<baweaver> because it sounds a lot like `break` or `next`
<mkroman> ^
<sagax> i need just stop function and return something
<baweaver> You're fixating on try/catch, not your actual problem.
<sagax> all this can do catch/throw
<baweaver> Do you have a code example?
<baweaver> You can use `return` for that as well.
<leftylink> if you want to stop a function and return something, then it sounds like you want `return`, not try/catch
<leftylink> ... beaten to the punch
<sagax> no, return it's ugle
<sagax> it's like as switch/case
<sagax> or if/else/if/else/if/else
<baweaver> Can you show us some example code?: https://dpaste.de
reber has quit [Remote host closed the connection]
<baweaver> What if we said that try/catch is ugly?
schleppel has quit [Quit: Konversation terminated!]
<sagax> ok, i show,
<baweaver> If you're bent on using it, use it.
<sagax> on paste
mochiyoda has joined #ruby
SuperL4g has joined #ruby
AJA4351 has joined #ruby
SuperLag has quit [Ping timeout: 245 seconds]
polishdub has quit [Remote host closed the connection]
AJA4350 has quit [Ping timeout: 240 seconds]
AJA4351 is now known as AJA4350
<mkroman> sagax: if your code is proliferated with if else if else, you might want to use if guards
nowhereman has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<sagax> it's simple examples
<baweaver> Yeah, just use `return`.
<sagax> no
<sagax> if i use return i need if/else/if/else/if/else
<sagax> throw i can call in any place
<baweaver> You're not gaining any clarity there.
<baweaver> If anything you're trying to ad-hoc on pattern matching
<sagax> return "something" if some - it's not what i need
<baweaver> It's an approximation of an Either type.
<baweaver> You're using throw/catch as a psuedo-either type to pass additional context with returns
<baweaver> It's more commonly known as Railway Oriented Programming: https://fsharpforfunandprofit.com/rop/
<sagax> i use throw to stop function
<sagax> or block
<baweaver> I'm not really sure what you want here.
<baweaver> You're fixated on one solution, so just use it.
<baweaver> Just be warned it's not very common and will likely confuse other programmers.
Swyper has joined #ruby
<phaul> ah. 256 is not allowed in class namesin my parser. sorry havenwood I fix it
<phaul> &ri Digest::SHA
<rubydoc> Found no entry that matches class Digest::SHA
<phaul> &ri Digest::SHA256
<rubydoc> parser error at position 0 around `r'
<phaul> ruby syntax rules are super complex :)
Swyper has quit [Remote host closed the connection]
rafadc has quit [Quit: ZNC 1.7.1 - https://znc.in]
Autolycus has joined #ruby
gigetoo has quit [Ping timeout: 245 seconds]
gigetoo has joined #ruby
Swyper has joined #ruby
rafadc has joined #ruby
tdy1 has joined #ruby
tdy has quit [Ping timeout: 244 seconds]
Swyper has quit [Remote host closed the connection]
cnsvc has joined #ruby
AJA4351 has joined #ruby
uplime is now known as darth_uplime