baweaver changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.5.1, 2.4.4, 2.3.7, 2.6.0-preview2: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.de/ and select ruby as the language | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first!
robin has quit [Ping timeout: 260 seconds]
aeontech has quit [Ping timeout: 240 seconds]
gnufied has quit [Ping timeout: 268 seconds]
aeontech has joined #ruby
thy0 has joined #ruby
sticaz has quit [Quit: My name Heff]
SeepingN has quit [Quit: The system is going down for reboot NOW!]
sameerynho has joined #ruby
nicesignal has quit [Remote host closed the connection]
nicesignal has joined #ruby
mroutis has joined #ruby
cliluw has quit [Read error: Connection reset by peer]
lytol_ has quit [Remote host closed the connection]
cliluw has joined #ruby
yokel has quit [Ping timeout: 244 seconds]
mroutis has quit [Read error: Connection reset by peer]
yokel has joined #ruby
mroutis has joined #ruby
cliluw has quit [Read error: Connection reset by peer]
eckhardt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
samort7 has quit [Quit: Leaving]
orbyt_ has quit [Ping timeout: 256 seconds]
orbyt_ has joined #ruby
jcarl43 has quit [Quit: WeeChat 2.2]
aeontech has quit [Quit: aeontech]
cliluw has joined #ruby
s2013 has joined #ruby
DarthGandalf has quit [Remote host closed the connection]
code_zombie has quit [Quit: Leaving]
j0bk has joined #ruby
DarthGandalf has joined #ruby
j0bk has quit [Ping timeout: 260 seconds]
jqpl has quit [Quit: .]
GodFather has quit [Ping timeout: 268 seconds]
za1b1tsu_ has joined #ruby
mroutis has quit [Remote host closed the connection]
za1b1tsu_ has quit [Ping timeout: 260 seconds]
cadillac_ has quit [Ping timeout: 240 seconds]
thy0 has quit [Quit: TTFN]
jdawgaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
s2013 has joined #ruby
za1b1tsu_ has joined #ruby
za1b1tsu_ has quit [Ping timeout: 240 seconds]
GodFather has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
s2013 has joined #ruby
sameerynho has quit [Ping timeout: 244 seconds]
Freshnuts has quit [Quit: Leaving]
faitswulff has joined #ruby
DTZUZO has quit [Read error: No route to host]
DTZUZO has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jdawgaz has joined #ruby
za1b1tsu_ has joined #ruby
za1b1tsu has quit [Ping timeout: 240 seconds]
za1b1tsu_ has quit [Ping timeout: 244 seconds]
t0xik has joined #ruby
booboy has quit [Quit: ZNC - https://znc.in]
booboy has joined #ruby
jdawgaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jdawgaz has joined #ruby
mrush has quit [Ping timeout: 240 seconds]
cthulchu_ has quit [Ping timeout: 260 seconds]
faitswulff has quit [Remote host closed the connection]
cadillac_ has joined #ruby
Nightmare_ has joined #ruby
faitswulff has joined #ruby
faitswulff has quit [Ping timeout: 255 seconds]
faitswulff has joined #ruby
cadillac_ has quit [Quit: I quit]
cadillac_ has joined #ruby
sspreitz has quit [Ping timeout: 240 seconds]
faitswulff has quit [Remote host closed the connection]
dviola has joined #ruby
sspreitz has joined #ruby
gix has quit [Disconnected by services]
braincrash has quit [Quit: bye bye]
za1b1tsu_ has joined #ruby
faitswulff has joined #ruby
cjkinni has joined #ruby
braincras has joined #ruby
za1b1tsu_ has quit [Ping timeout: 260 seconds]
faitswulff has quit [Remote host closed the connection]
faitswulff has joined #ruby
faitswulff has quit [Ping timeout: 265 seconds]
arescorpio has quit [Quit: Leaving.]
AJA4350 has quit [Quit: AJA4350]
faitswulff has joined #ruby
faitswulff has quit [Remote host closed the connection]
agent_white has quit [Quit: bbl]
faitswulff has joined #ruby
j0bk has joined #ruby
patr0clus has joined #ruby
patr0clus has quit [Quit: WeeChat 2.1]
faitswulff has quit [Remote host closed the connection]
patr0clus has joined #ruby
faitswulff has joined #ruby
za1b1tsu_ has joined #ruby
kryptoz has quit [Remote host closed the connection]
za1b1tsu_ has quit [Ping timeout: 240 seconds]
faitswulff has quit [Ping timeout: 260 seconds]
kryptoz has joined #ruby
Freshnuts has joined #ruby
kryptoz has quit [Remote host closed the connection]
kryptoz has joined #ruby
kryptoz has quit [Remote host closed the connection]
kryptoz has joined #ruby
kryptoz has quit [Remote host closed the connection]
kryptoz has joined #ruby
kryptoz has quit [Remote host closed the connection]
kryptoz has joined #ruby
kryptoz has quit [Remote host closed the connection]
za1b1tsu_ has joined #ruby
za1b1tsu_ has quit [Ping timeout: 244 seconds]
dellavg has joined #ruby
kapil___ has joined #ruby
armyriad has quit [Quit: Leaving]
armyriad has joined #ruby
za1b1tsu_ has joined #ruby
dviola has quit [Quit: WeeChat 2.2]
faitswulff has joined #ruby
faitswulff has quit [Ping timeout: 260 seconds]
Furai has quit [Quit: WeeChat 2.2]
jdawgaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jdawgaz has joined #ruby
jdawgaz has quit [Client Quit]
segy has quit [Quit: ZNC - http://znc.in]
Furai has joined #ruby
patr0clus has quit [Quit: WeeChat 2.1]
graphene has quit [Remote host closed the connection]
segy has joined #ruby
graphene has joined #ruby
segy has quit [Client Quit]
reber has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
segy has joined #ruby
s2013 has joined #ruby
s2013 has quit [Client Quit]
tdy has joined #ruby
armyriad has quit [Quit: Leaving]
SegFaultAX has quit [Ping timeout: 240 seconds]
armyriad has joined #ruby
SegFaultAX has joined #ruby
apeiros has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
faitswulff has joined #ruby
faitswulff has quit [Ping timeout: 260 seconds]
orbyt_ has joined #ruby
jottr has joined #ruby
t0xik has quit [Quit: Connection closed for inactivity]
orbyt_ has quit [Ping timeout: 272 seconds]
jottr has quit [Ping timeout: 260 seconds]
za1b1tsu_ has quit [Ping timeout: 272 seconds]
Dbugger has joined #ruby
kapil___ has quit [Quit: Connection closed for inactivity]
DarthGandalf has quit [Remote host closed the connection]
xuanrui has joined #ruby
DarthGandalf has joined #ruby
duderonomy has quit [Quit: Textual IRC Client: www.textualapp.com]
sauvin has joined #ruby
snickers has joined #ruby
clemens3 has joined #ruby
za1b1tsu has joined #ruby
xuanrui has quit [Remote host closed the connection]
Freshnuts has quit [Quit: Leaving]
DTZUZO has quit [Ping timeout: 272 seconds]
za1b1tsu_ has joined #ruby
za1b1tsu has quit [Ping timeout: 240 seconds]
Alina-malina has quit [Ping timeout: 272 seconds]
pabs has quit [Ping timeout: 260 seconds]
sameerynho has joined #ruby
za1b1tsu has joined #ruby
za1b1tsu_ has quit [Ping timeout: 256 seconds]
nowhereman_ has joined #ruby
tristanp has joined #ruby
MarcWeber has joined #ruby
<MarcWeber> Which library to parse date differences like '2 days' ?
tristanp has quit [Ping timeout: 272 seconds]
postmodern has quit [Quit: Leaving]
dionysus69 has joined #ruby
xuanrui has joined #ruby
xuanrui has quit [Read error: Connection reset by peer]
drbrain has quit [Ping timeout: 272 seconds]
<MarcWeber> Which library to parse date differences like '2 days' ?
<MarcWeber> 
<ArahaelPi> MarcWeber: I saw your first question, and I still don't know.
<ArahaelPi> MarcWeber: Someone might, but re-posting doesn't help.
kevinsjoberg has joined #ruby
wolfshappen has quit [Ping timeout: 244 seconds]
<MarcWeber> I did repost because Irssi showed 'joined' after me having send the message, so I was uncertain whether it showed up at al.l
<MarcWeber> I thought its a very common issue, eg PHP has a DateDiff class which gets it done perfectly. I could just wirte a 3line PHP script .. it sucks but works.
wolfshappen has joined #ruby
<ArahaelPi> Well, do that, and if someone response, apply the improved version.
reber has quit [Remote host closed the connection]
<apeiros> MarcWeber: not sure whether chronic also handles duration
<apeiros> it's the only one I remember which handles natural language dates, though
<apeiros> if the format is fixed and simple enough, you can build something on your own relatively easily, though. regex + factor lookup table
t0xik has joined #ruby
venmx has joined #ruby
t0xik is now known as t0x
<alex``> What is the more clear between:
<alex``> (in a case / when)
<alex``> until ARGV.empty?
<alex``> parameters[:arguments] << ARGV.shift
<alex``> end
<alex``> and
<alex``> parameters[:arguments].append(*ARGV)
<alex``> ARGV.clear
<alex``> MarcWeber: Hey o/
<alex``> Looong time not seeing you, hdy?
kapil___ has joined #ruby
TheBloke has quit [Ping timeout: 256 seconds]
duderonomy has joined #ruby
Alina-malina has joined #ruby
jottr has joined #ruby
TheBloke has joined #ruby
nowhereman_ has quit [Ping timeout: 240 seconds]
nicesignal has quit [Remote host closed the connection]
nicesignal has joined #ruby
venmx has quit [Ping timeout: 272 seconds]
wolfshappen has quit [Ping timeout: 244 seconds]
<apeiros> alex``: use concat, not append/push with splat
<apeiros> and I'd go with concat+clear. it's faster and rather obvious in intent.
tristanp has joined #ruby
Hobbyboy|BNC has joined #ruby
jottr has quit [Ping timeout: 272 seconds]
Hobbyboy has quit [Read error: Connection reset by peer]
tristanp has quit [Ping timeout: 272 seconds]
Hobbyboy|BNC is now known as Hobbyboy
jottr has joined #ruby
DTZUZO has joined #ruby
faitswulff has joined #ruby
Kug3lis has joined #ruby
jottr has quit [Quit: WeeChat 2.2]
jdawgaz has joined #ruby
jottr has joined #ruby
dionysus70 has joined #ruby
dionysus69 has quit [Ping timeout: 260 seconds]
dionysus70 is now known as dionysus69
d^sh has quit [Ping timeout: 268 seconds]
d^sh has joined #ruby
AJA4350 has joined #ruby
dionysus69 has quit [Ping timeout: 240 seconds]
jottr has quit [Ping timeout: 268 seconds]
dionysus69 has joined #ruby
faitswulff has quit [Remote host closed the connection]
faitswulff has joined #ruby
tristanp has joined #ruby
tristanp has quit [Ping timeout: 272 seconds]
GodFather has quit [Ping timeout: 260 seconds]
faitswulff has quit [Remote host closed the connection]
GodFather has joined #ruby
pabs has joined #ruby
jottr has joined #ruby
apparition has joined #ruby
jottr has quit [Ping timeout: 268 seconds]
savolla has joined #ruby
herbmillerjr has quit [Quit: Konversation terminated!]
faitswulff has joined #ruby
faitswulff has quit [Ping timeout: 255 seconds]
jottr has joined #ruby
savolla has quit [Ping timeout: 244 seconds]
jottr has quit [Ping timeout: 244 seconds]
DTZUZO has quit [Quit: WeeChat 2.0]
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
jtperreault has joined #ruby
t0x has quit [Quit: Connection closed for inactivity]
reber has joined #ruby
sticaz has joined #ruby
dionysus69 has quit [Ping timeout: 240 seconds]
DLSteve has joined #ruby
savolla has joined #ruby
faitswulff has joined #ruby
graphene has quit [Read error: Connection reset by peer]
graphene has joined #ruby
Inline has quit [Remote host closed the connection]
mikecmpbll has joined #ruby
tristanp has joined #ruby
faitswulff has quit [Remote host closed the connection]
faitswulff has joined #ruby
jdawgaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tristanp has quit [Ping timeout: 272 seconds]
IanMalcolm has joined #ruby
xlegoman has joined #ruby
Inline has joined #ruby
alex`` has quit [Remote host closed the connection]
gnufied has joined #ruby
gnufied has quit [Remote host closed the connection]
alex`` has joined #ruby
nicesignal has quit [Remote host closed the connection]
nicesignal has joined #ruby
thy0 has joined #ruby
<alex``> How to merge 2 arrays (superpose) like hash?
<alex``> [nil, '%{foo}', "\n"] and ['http://foo.bar', '%{bar}']
<alex``> => ['http://foo.bar', '%{bar}', "\n"]
kapil___ has quit [Quit: Connection closed for inactivity]
cadillac_ has quit [Ping timeout: 256 seconds]
cadillac_ has joined #ruby
savolla has quit [Remote host closed the connection]
Kug3lis is now known as Kug3lis_off
<al2o3-cr> alex``: a1 | a2 if you want to remove dups
<havenwood> alex``: Or alternatively consider using a Set.
<apeiros> where did the nil go?
<apeiros> or actually - what kind of "merge" is that? based on length?
savolla has joined #ruby
<havenwood> The case of the whistling bagpiper and the missing nil.
danguita has joined #ruby
<al2o3-cr> it just returns the last array in alex`` way.
<al2o3-cr> hang on no.
Kug3lis_off is now known as Kug3lis
<apeiros> >> a = [nil, '%{foo}', "\n"]; b = ['http://foo.bar', '%{bar}']; a[0,b.size] = b; a
<ruby[bot]> apeiros: # => ["http://foo.bar", "%{bar}", "\n"] (https://eval.in/1048755)
<al2o3-cr> ah.
<apeiros> that would fit your description alex``. but then again, why do I even bother, didn't even get any kind of response to when I last wrote something.
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kapil___ has joined #ruby
danguita has quit [Client Quit]
<havenwood> alex``: Is that ^ what you meant when you said "merge 2 arrays (superpose) like hash)"?
<alex``> apeiros: Awesome
<alex``> havenwood: Yep
<alex``> I was going with zip or to_h, but apeiros lot much clear in intent
laekur has joined #ruby
<alex``> A.zip(B).map { |pack| pack.compact.last }
graphene has quit [Remote host closed the connection]
laekur has quit [Remote host closed the connection]
<alex``> apeiros: Is there a functional way as simple as your solution?
graphene has joined #ruby
<alex``> without relying on modifying a
<alex``> in-place
<apeiros> c = a.size > b.size ? b+a[b.size..-1] : b
<havenwood> alex``: Do you know which Array the `nil`s will be in? One or both? Always up front?
<alex``> Can be both
Kug3lis has joined #ruby
<apeiros> shorter but more expensive: c = b + (a[b.size..-1] || [])
<alex``> I write a command-line wrapper around positional arguments
<alex``> to pass to a function
<havenwood> alex``: Can you just share what you're really doing. We can probably give you better suggestions with context.
<apeiros> unless you know that b.size is guaranteed to be <= a.size, then you can just do: c = b + a[b.size..-1]
danguita has joined #ruby
<alex``> [nil, 'default-value', 'another-default'].zip(['user-input-one', 'second']).collect { |pack| pack.compact.last }
dviola has joined #ruby
<alex``> havenwood: ^
<alex``> apeiros: b would be ARGV or something
<apeiros> alex``: doesn't matter. what matters is knowledge of length
<alex``> XD
<apeiros> but with ARGV it's a given that oyu don't know.
<apeiros> *you
<apeiros> (never trust user input)
<apeiros> .collect { |pack| pack.compact.last } -> .map { |a,b| b || a }
<havenwood> alex``: Consider option flags?
<alex``> havenwood: What is option flags?
<alex``> apeiros: Thanks again :p
<havenwood> alex``: I meant to show context zoomed out from this line. I was considering doing a writeup on some modern option parsing stuff but only got as far as this little gist: https://gist.github.com/havenwood/02123198a79447543a3ea053e7e592fd
guardian has quit [Remote host closed the connection]
<havenwood> alex``: If you show us what info you're trying to get at, maybe we can suggest a better way to get it from the command line. When you have multiple arguments you want to pass, it can be really nice to pass them coupled by name rather than position.
<havenwood> alex``: Arguments are of course by position. Options are by name.
danguita has quit [Client Quit]
<alex``> havenwood: where ARGV.options is from ?
<havenwood> alex``: It gets defined when you: require 'optionparser'
<havenwood> alex``: Alternatively you can: OptionParser.new do ...
mikecmpbll has quit [Quit: inabit.]
sagax has joined #ruby
<sagax> hi all!
<havenwood> sagax: g'mornin'!
<sagax> it's http://www.ruby2d.com based on SDL?
jottr has joined #ruby
<alex``> havenwood: Thanks for you gist
<havenwood> alex``: You're welcome. This reminds me I need to actually write that article.
<alex``> I would like Ruby supporting -flag
mzo has joined #ruby
<alex``> instead of --flag
danguita has joined #ruby
jottr has quit [Ping timeout: 268 seconds]
<havenwood> sagax: Yes, SDL. Here's a talk that gives an overview: http://www.blacktm.com/rubyconf/
<sagax> thanks!
<havenwood> sagax: More specifically, it uses: https://github.com/simple2d/simple2d
<havenwood> Which uses SDL.
<alex``> havenwood: Do you mind making yr gist public so I can still see it back from time to time from my Stars?
<alex``> It actually listed in my Stars é_é
<havenwood> alex``: done
<alex``> Thanks :p
<havenwood> alex``: I'll put a link to the article on the gist, when I get around to writing it.
<havenwood> alex``: Ruby stdlib has another option parser called GetoptLong, but I prefer OptionParser: https://docs.ruby-lang.org/en/2.5.0/GetoptLong.html
<havenwood> alex``: Honorable mention to the Slop gem, for a nice interface: https://github.com/leejarvis/slop#slop
<alex``> option.accept is smart
<alex``> havenwood: I get right the prototypes?
<alex``> accept(class, regex-to-pass-string-option, &block-to-transform-string-option)
za1b1tsu has quit [Read error: Connection reset by peer]
za1b1tsu has joined #ruby
thejs has joined #ruby
<alex``> "1" with accept(Integer) would do Integer("1") ?
<alex``> or it requires, accept(Integer, Integer) { |string| string.to_i }
<alex``> havenwood: I was using Thor, but it’s quite too much for the need of the tool I write
savolla has quit [Ping timeout: 256 seconds]
nikivi has joined #ruby
<nikivi> when you require a relative file
<nikivi> is it possible to use the methods as stated in the file as if they were written in the file you are requiring from?
dviola has quit [Quit: WeeChat 2.2]
LenPayne has quit [Quit: ZNC 1.7.0 - https://znc.in]
LenPayne has joined #ruby
<nikivi> for example I have method 'def shell()' in file karabiner.rb
<nikivi> and inside config.rb in the same dir that karabiner.rb is, I do 'require_relative 'karabiner.rb''
<nikivi> but then I can't just call the methods from karabiner.rb bare like 'shell()'
<nikivi> is it possible to make that happen?
<havenwood> nikivi: Could you gist the two files? You totally can define a method at top level in a file, require that file, then call the method.
<havenwood> nikivi: I'm not sure why your example isn't working, since what you describes works. It'd be helpful to see your code.
<nikivi> check karabiner.rb which has many methods
<nikivi> and config.rb where I try to call them
sarna has joined #ruby
Dbugger has quit [Ping timeout: 265 seconds]
<havenwood> nikivi: You're trying to call them with a different receiver than `main` at top level.
<nikivi> what does that mean?
<havenwood> nikivi: derr
<havenwood> nikivi: You should go ahead and just use Modules.
<havenwood> nikivi: I meant, *err
<nikivi> not too familiar with modules, reading it now
<nikivi> do I have to wrap all my methods as module?
<havenwood> nikivi: Sec, I'll gist and example
<havenwood> nikivi: A module with module_function is a really nice way to namespace.
<nikivi> is there no way to just require the thing and use its methods as if they are in the same file
<havenwood> yes, you can do just that
<sarna> hey, is "The Ruby Programming Language" still relevant? it's from 2008
<havenwood> nikivi: that's why i'm a bit confused why your example isn't working, but this is enough code it's hard to see the minimal reproducible case
<havenwood> sarna: That's still a good book. It's pretty easy to catchup on the last ten years if you understand that book.
<nikivi> config.rb:14:in `main': undefined method `simkeys' for main:Object (NoMethodError)
<nikivi> from config.rb:34:in `<main>'
<nikivi> I get this error trying to call rb on config.rb
<nikivi> ruby*
<havenwood> nikivi: You define simkeys in that same file, 20 lines later.
<nikivi> ohh
<nikivi> I think its due to main
<nikivi> it has to be at the bottom
<havenwood> nikivi: It's a good example of why to use a Module and module_function.
<nikivi> okay I think it works now
<nikivi> I just though I could call main right after def main
<nikivi> and still do def's after main call
<havenwood> nikivi: You can, but you haven't defined the other methods yet.
<sarna> havenwood: thanks
<nikivi> yeah makes sense
<nikivi> just in JS you can do that
<nikivi> declare stuff at end of files and use it earlier
<havenwood> nikivi: Use a module. Sec, I'll gist something for you.
mzo has quit [Ping timeout: 260 seconds]
<nikivi> thanks havenwood
<nikivi> but it seems I dont need modules in this case
<nikivi> it seems to work like I want
<havenwood> nikivi: you don't *need* them, but it's a good idea and will save you from issues like what bit you
<havenwood> nikivi: the modules are to make our lives better, not for the machines
<havenwood> nikivi: no prob, any time
<alex``> havenwood: Slop is awesome :)
dionysus69 has joined #ruby
<havenwood> alex``: Thank ljarvis :-)
IanMalcolm has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
impermanence has quit [Remote host closed the connection]
<alex``> I like it doesn’t have assumption upon how CLI should be
<alex``> there is no -h --help, etc.
<alex``> or GNU long option forced
sspreitz has quit [Ping timeout: 265 seconds]
d1rewolf has joined #ruby
<d1rewolf> all, I'm confused. I would expect: Regexp.new('(\S*)').match("ruby is great") to return three groups (ruby, is, and great). however, it only returns one
<d1rewolf> although testing on rubular, it seems to return three. what am I overlooking?
jdawgaz has joined #ruby
sspreitz has joined #ruby
<d1rewolf> I'd like to split a string on a pattern, but store what matches the pattern to split as well. So, if I had "x===a".split(/=*/)
<d1rewolf> i'd get "x", "===", and "a". is there a method which does this?
sarna has quit [Quit: Quit]
leah2 has quit [Ping timeout: 240 seconds]
<elomatreb> d1rewolf: match only gets you the first match (if any) by design, you probably want String#scan
<apeiros> >> "x===a".split(/(=*)/)
<ruby[bot]> apeiros: # => ["x", "===", "a"] (https://eval.in/1048765)
<apeiros> d1rewolf: ^
riclima has joined #ruby
IanMalcolm has joined #ruby
<d1rewolf> apeiros: that works nicely. thx
leah2 has joined #ruby
<apeiros> note that * as a quantifier will split everywhere, since * allows the empty string as well.
<apeiros> >> "x===abc".split(/(=*)/)
<ruby[bot]> apeiros: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<apeiros> >> "x===abc".split(/(=*)/)
<ruby[bot]> apeiros: # => ["x", "===", "a", "", "b", "", "c"] (https://eval.in/1048767)
fmcgeough has joined #ruby
thejs has quit [Ping timeout: 260 seconds]
jdawgaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Nicmavr has quit [Read error: Connection reset by peer]
jdawgaz has joined #ruby
Nicmavr has joined #ruby
code_zombie has joined #ruby
DLSteve has quit [Quit: All rise, the honorable DLSteve has left the channel.]
jdawgaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
faitswulff has quit [Remote host closed the connection]
herbmillerjr has joined #ruby
thejs has joined #ruby
Mikel_ has joined #ruby
galeido has quit [Remote host closed the connection]
s2013 has joined #ruby
jottr has joined #ruby
jottr has quit [Ping timeout: 276 seconds]
xlegoman has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
apparition has quit [Quit: Bye]
dionysus69 has quit [Ping timeout: 276 seconds]
galeido has joined #ruby
faitswulff has joined #ruby
faitswulff has quit [Remote host closed the connection]
faitswulff has joined #ruby
bsamorim has joined #ruby
faitswulff has quit [Remote host closed the connection]
graphene has quit [Remote host closed the connection]
<bsamorim> Hi! I'm having trouble installing ruby from source: I followed the instructions from the ruby website. The installation itself succeded but, when I tried running `gem install bundler`, I got the error "Unable to require openssl, install OpenSSL and rebuild Ruby (preferred) or use non-HTTPS sources"
graphene has joined #ruby
<bsamorim> Is this a known issue?
xlegoman has joined #ruby
dionysus69 has joined #ruby
xlegoman has quit [Client Quit]
<bsamorim> The only oddity about my installation is that I'm running every command as the root user.
<bsamorim> Could this be the cause of the issue?
<bsamorim> I have openssl installed, by the way
code_zombie has quit [Quit: Leaving]
fmcgeough has quit [Quit: fmcgeough]
darkhanb has joined #ruby
nowhereman_ has joined #ruby
theRealGent has joined #ruby
<apeiros> bsamorim: I think ruby detects openssl, if it can't find it, it builds without. and then that kind of things happen.
<bsamorim> But I'm installing it before ruby
<apeiros> bsamorim: as far as I'm aware, the best way to build ruby yourself atm is using ruby-install https://github.com/postmodern/ruby-install
<bsamorim> apeiros: thanks a lot for the tip! Is it thinner than rvm?
<apeiros> I think rvm uses that for building ruby (and some other version managers too I think)
<bsamorim> ok, thanks!
IanMalcolm has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
Zaab1t has joined #ruby
tristanp has joined #ruby
tristanp has quit [Ping timeout: 256 seconds]
graphene has quit [Remote host closed the connection]
graphene has joined #ruby
riclima has quit [Ping timeout: 244 seconds]
nowhereman_ has quit [Ping timeout: 276 seconds]
IanMalcolm has joined #ruby
reber has quit [Read error: Connection reset by peer]
drbrain has joined #ruby
faitswulff has joined #ruby
faitswulff has quit [Ping timeout: 276 seconds]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
johnny56 has quit [Read error: Connection reset by peer]
riclima has joined #ruby
s2013 has joined #ruby
nowhereman_ has joined #ruby
johnny56 has joined #ruby
sauvin has quit [Remote host closed the connection]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tpendragon has quit [Remote host closed the connection]
sarna has joined #ruby
Freshnuts has joined #ruby
jottr has joined #ruby
<riclima> Hello
<apeiros> hi riclima, welcome to #ruby
jottr has quit [Ping timeout: 276 seconds]
<riclima> I'm a Python developer learning Ruby. I'm trying to get a grip on the Ruby development workflow
<riclima> What's the Ruby equivalent for virtualenv?
<riclima> And/or is it even needed?
<apeiros> as far as I understood what virtualenv does, I'd say rvm or rbenv
<apeiros> those are for ruby versions
<apeiros> bundler for the libraries
<riclima> Right
<riclima> So from my understanding
<apeiros> i.e. you put a .ruby-version and a Gemfile into your projects and you should be settled.
<riclima> I use bundler to make my gems, and that's the basics?
<apeiros> uh, you can use bundler to create a skeleton for a new gem too, yes
<apeiros> the more common use of it is to enforce specific versions of your dependencies in your projects
<riclima> cool, so bundler also manages dependencies?
<apeiros> in a way. the part it does is enforcing of versions.
<apeiros> I'm not sure how much it does and how much of the work it delegates to rubygems.
<riclima> apeiros: alright, thanks for the help. I'll jump in on the bundler documentation and go from there.
<riclima> Cheers
<apeiros> if you make a gem, your Gemfile will usually be mostly empty and just reference the *.gemspec file of your gem.
<elomatreb> One difference to Python might be that bundler and friends don't do the "environment changing" that virtualenv does, you need to prefix commands or use explicit stubs to *force* it to use your specified versions
<apeiros> oh, I think I forget about that because rvm does it. I never prefix `bundle exec`
<apeiros> but good point
<elomatreb> Does it actually apply bundler constraints or is it just a side effect of isolating the installed gems?
<apeiros> I don't use gemsets if you refer to that
* apeiros just realized that he's oblivious about the actual mechanics of this
<elomatreb> The fallback behavior from what I remember if you don't prefix bundle exec is to use the latest installed version of a gem
<apeiros> I guess I should fix that one day :D
<apeiros> no, it is run via bundler
<apeiros> otherwise it wouldn't abort if stuff is checked out in the wrong version (git stuff in Gemfile) or not updated/installed.
<elomatreb> In short, Rubygems: Gemfile goes in -> *magic* -> something is executed
sarna has quit [Quit: Leaving]
druonysus has joined #ruby
t0x has joined #ruby
dionysus69 has quit [Ping timeout: 272 seconds]
s2013 has joined #ruby
Zaab1t has quit [Quit: Zaab1t]
DTZUZO has joined #ruby
IanMalcolm has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
s2013 has joined #ruby
dellavg has quit [Ping timeout: 240 seconds]
savolla has joined #ruby
qolq3 has joined #ruby
Xiti` has joined #ruby
IanMalcolm has joined #ruby
Freshnuts has quit [Remote host closed the connection]
Freshnuts has joined #ruby
Tempesta has quit [Ping timeout: 272 seconds]
thy0 has quit [Ping timeout: 240 seconds]
qolq has quit [Ping timeout: 272 seconds]
qolq3 is now known as qolq
Xiti has quit [Ping timeout: 272 seconds]
dionysus69 has joined #ruby
nowhereman_ has quit [Ping timeout: 272 seconds]
tpendragon has joined #ruby
IanMalcolm has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
kapil___ has quit [Quit: Connection closed for inactivity]
JoshS has joined #ruby
IanMalcolm has joined #ruby
orbyt_ has joined #ruby
thy0 has joined #ruby
dviola has joined #ruby
Fr4n has quit [Remote host closed the connection]
IanMalcolm has quit [Ping timeout: 256 seconds]
IanMalcolm has joined #ruby
thejs has quit [Remote host closed the connection]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
riclima has quit [Ping timeout: 244 seconds]
s2013 has joined #ruby
IanMalcolm has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
graphene has quit [Read error: Connection reset by peer]
graphene has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
s2013 has joined #ruby
RedNifre has joined #ruby
<RedNifre> hey there!
<apeiros> hallo erfinder
<RedNifre> schnell geblickt!
<apeiros> well, I've seen you a couple of times
<RedNifre> jedenfalls, I was wondering how to sort of do a command line stream script in ruby and how to get a result from it.
<RedNifre> :)
<RedNifre> Yeah, I tend to come back here... and to other channels.
jdawgaz has joined #ruby
<RedNifre> Anyway, I thought I should try out the old unix tools sed, awk, etc. but I'm not sure it's worth it.
<apeiros> $stdout.sync = true or $stdout.flush after you write
<RedNifre> What I have right now is something that preprocesses a log on the fly, but I need to do some accumulation on it... i guess with ruby I would just pipe to the ruby script which would read from stdin... but since this is sorta infinite, where should I access the accumulated results?
<apeiros> I guess that depends a lot on when you want to have access to accumulated results
<apeiros> and in what form
jottr has joined #ruby
<apeiros> and what other information you want to get out of that script
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<RedNifre> Say the log looks like "Bob bought 23 green bananas for $10,00 from you." and I already trimmed it down to "Bob 23 green bananas 10.00"... I want to accumulate the money for each purchase per item...
<RedNifre> Oh, wait, maybe I'm just thinking to complex here...
s2013 has joined #ruby
<RedNifre> I guess I'll just print the whole state of the script on every purchase so I'll always see the latest state when I look at the terminal window.
<RedNifre> That way, there is no "end" result.
<apeiros> that could be a viable approach, yes. printing running totals.
jdawgaz has quit [Client Quit]
<apeiros> I'm not sure logfiles are the right place for things like this, though.
<apeiros> that's the domain of databases.
<RedNifre> It's just a toy project from a game.
<RedNifre> I thought about this, too, but a database might be overkill.
<apeiros> eh, sqlite is easy to add.
<RedNifre> Sure, but hear me out.
<RedNifre> This is the situation: There is a game, in that game you can open virtual shops and you get chat messages when people buy or sell to your shop. The game logs the chat to a txt file.
<apeiros> there's a big chance other approaches will end up with you having to do a lot more than if you just add a dependency and throw each purchase into a table. summing is trivial from there.
<RedNifre> So my idea is to count what's in my shop when I log in, tell it to the script, and the script reads the chat log to keep the inventory tally updated.
<RedNifre> I considered it and my plan right now is to actually do both.
<RedNifre> however, the nature of the game makes all this very transient.
jottr has quit [Ping timeout: 244 seconds]
<RedNifre> i.e. when i log off people will still interact with the shop, which means the inventory count will diverge
<apeiros> you don't get offline messages?
<RedNifre> so what really matters is the inventory count when i log in plus all following chat messages
<RedNifre> right
<RedNifre> it's not a serious professional system, it's just a tiny game that isn't even about shops
<RedNifre> I want to put all the messages in a sqlitedb anyway so i can easily figure out who my most frequent customers are etc. but the immediate goal is more transient.
<RedNifre> ...but that might get a bit too far off topic now... I guess I'll try piping the sed output into a ruby script and have it process it... it's just `gets`, right? For one line of stdin?
<RedNifre> (it's been a while since i last used ruby)
<apeiros> yes
postmodern has joined #ruby
<RedNifre> Thanks, I'll see what happens...
<apeiros> Kernel#gets reads from ARGF, which without values in ARGV is just $stdin.gets.
jdawgaz has joined #ruby
<apeiros> if you strictly want to read from stdin, you should do $stdin.gets, though. people get confused about "why does ruby say 'no such file `foobar`'?" when they invoke their script as `somescript foobar`.
graphene has quit [Read error: Connection reset by peer]
graphene has joined #ruby
dionysus69 has quit [Ping timeout: 268 seconds]
<RedNifre> well, i tried `some sed stuff | ruby myscriptrb` and `gets` seems to return empty strings.
<apeiros> that'd mean you got empty lines as input.
<RedNifre> I'm not familiar with the "different" stdin... where in the ruby script do the 5000 lines that get emitted by the sed stuff appear?
<RedNifre> To keep it simple I tried to write an echo command in ruby, just while true do line = gets; puts "got #{line}"; end, nothing too fancy.
<apeiros> stuff piped ends up on $stdin and waits there until you read it
<apeiros> "where in the ruby script" - wherever you read from $stdin.
<apeiros> echo -e "hello\nworld\nthis\nis\nnice." | ruby -e 'while line = $stdin.gets; puts line.upcase; end'
<apeiros> `$stdin.each_line do |line|` will work fine too.
<al2o3-cr> ruby -ne 'puts $_.upcase'
<apeiros> yes, if you want to write short shell oneliners, -n and -p are nice
<apeiros> ruby -e '20.times do |i| puts i; $stdout.flush; sleep 1; end' | ruby -e '$stdin.each_line do |line| puts line.upcase; end' # to test "streaming"
<apeiros> e.g. ^ could just write `| ruby -pe '$_.upcase!'`
<al2o3-cr> aye
<apeiros> pillow time for me. gn8 y'all.
<al2o3-cr> gn apeiros o/
za1b1tsu has quit [Ping timeout: 240 seconds]
bsamorim has quit [Ping timeout: 256 seconds]
DTZUZO has quit [Ping timeout: 276 seconds]
nadir has joined #ruby
DTZUZO has joined #ruby
<RedNifre> good night!
<RedNifre> and thanks for the help!
apeiros has quit [Remote host closed the connection]
apeiros has joined #ruby
duderonomy has quit [Ping timeout: 256 seconds]
apeiros has quit [Ping timeout: 260 seconds]
dviola has quit [Quit: WeeChat 2.2]
apeiros has joined #ruby
tdy1 has joined #ruby
tdy has quit [Ping timeout: 240 seconds]
alex`` has quit [Ping timeout: 276 seconds]
apeiros has quit [Ping timeout: 240 seconds]
<RedNifre> hm, is there a decimal datatype? something for two decimal places?
<elomatreb> RedNifre: What do you mean? There is Float for machine floating point numbers, or Rational if you need precision
<weaksauce> BigDecimal is one option if you need precision
<RedNifre> I need something for decimal numbers with two places, e.g. 10.00
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<weaksauce> a general solution to that is to use integers and convert it to two decimal places when needed
<weaksauce> floats are not accurate for money
<elomatreb> Or anything else for that matter :)
<weaksauce> indeed
<weaksauce> but bigdecimal is
Dark_Arc has quit [Quit: ZNC 1.6.5 - http://znc.in]
<weaksauce> but i wouldn't use it for that. i would store it as an integer and convert when needed
za1b1tsu has joined #ruby
<RedNifre> well, it's just for a game and precision is not that important... if i add 7000 numbers as floats, do I still have 2 decimals precision?
<RedNifre> (i'm pretty much clueless about numerics and accumulated errors...)
Dark_Arc has joined #ruby
<weaksauce> there are some values that floats simply cannot handle and round. it really depends.
<weaksauce> you can see why in that first example
<weaksauce> er second example
<elomatreb> Floats are often the source of bugs or weird behaviors in games, e.g. if you use them for coordinates your points become more spaced out if you go far from the center
reber has joined #ruby
<elomatreb> It depends on the numbers
<elomatreb> >> 0.1 + 0.1 + 0.1
<ruby[bot]> elomatreb: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<elomatreb> #=> 0.30000000000000004
s2013 has joined #ruby
apeiros has joined #ruby
<RedNifre> yeah, but if i round to 2 places it's still correct
<weaksauce> it can be
<weaksauce> if it's just for a game without precision worries you can get away with it
<RedNifre> okay, another thing, how do I do a hash where every entry kinda already exists with value 0.00 ? so I can just do myhash[some_previously_unknown_key] += some_amount ?
<elomatreb> Hash.new(0.0)
<RedNifre> ruby sure is simple :)
<elomatreb> There is a caveat with this if you want to use it with "complicated" objects instead of the "primitives" like numbers, reading the docs of Hash#new is worthwhile
apeiros has quit [Ping timeout: 240 seconds]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
sticaz has quit [Quit: My name Heff]
darkhanb has quit [Quit: Textual IRC Client: www.textualapp.com]
<RedNifre> well, it seems to work... is there a simple list to turn this into an ordered high score list like [["key34", 1000.00], ["key90", 980.00]...] ?
apeiros has joined #ruby
<RedNifre> sleepwalking?
<RedNifre> never mind, I'll figure it out...
fmcgeough has joined #ruby
<elomatreb> RedNifre: Enumerable#
<elomatreb> ignore that, sorry
<elomatreb> Enumerable#sort_by will help you and was what I meant to say
apeiros has quit [Ping timeout: 276 seconds]
<RedNifre> well, I did hashmap.to_a.sort { |a, b| a[1] <=> b[1] } instead
<elomatreb> Hashes are ordered and implement Enumerable, so the to_a step is not necesssary fwiw
alex`` has joined #ruby
gix has joined #ruby
jshjsh has joined #ruby
moei has quit [Ping timeout: 272 seconds]
k0mpa has joined #ruby
apeiros has joined #ruby
JoshS has quit [Ping timeout: 272 seconds]
sticaz has joined #ruby
apeiros has quit [Ping timeout: 244 seconds]
za1b1tsu has quit [Ping timeout: 276 seconds]
apeiros has joined #ruby
Dark_Arc has quit [Quit: ZNC 1.6.5 - http://znc.in]
apeiros has quit [Ping timeout: 260 seconds]
Dark_Arc has joined #ruby
alex`` has quit [Quit: WeeChat 2.2]
moei has joined #ruby
apeiros has joined #ruby
apeiros has quit [Ping timeout: 244 seconds]
<weaksauce> RedNifre what are you actually trying to accomplish?
<weaksauce> oh nevermind.
jottr has joined #ruby
apeiros has joined #ruby
jottr has quit [Ping timeout: 240 seconds]
za1b1tsu has joined #ruby
apeiros has quit [Ping timeout: 272 seconds]
theRealGent has quit [Remote host closed the connection]
za1b1tsu has quit [Ping timeout: 240 seconds]
<RedNifre> huh?
<RedNifre> weaksauce I finished it, I'm just writing some simple analytics script for a silly game.
<weaksauce> oh i just misread your question
<RedNifre> it's a game where you can build a shop and now I have a high score list of which player bought how much.
apeiros has joined #ruby
<weaksauce> glad it's working!
wolfshappen has joined #ruby
apeiros has quit [Ping timeout: 260 seconds]
apeiros has joined #ruby