havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.6.0, 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!
cschneid has quit [Ping timeout: 246 seconds]
elphe has joined #ruby
agent_white has quit [Quit: later on]
tdy has joined #ruby
cschneid has joined #ruby
<cthu|> weird. I don't know why I'm getting this error
<cthu|> I do temp_event = {} and then:
<cthu|> temp_event.key?("screen_name") ? screen_name = temp_event["screen_name"] : screen_name = ""
<cthu|> it says my temp_event is undefined
<cthu|> nil class doesn't have the .key? method
cschneid has quit [Ping timeout: 250 seconds]
<phaul> &>> temp_event = {} ; temp_event.key?("screen_name") ? screen_name = temp_event["screen_name"] : screen_name = ""
<rubydoc> # => "" (https://carc.in/#/r/5v7o)
<cthu|> wtf
gix has quit [Ping timeout: 245 seconds]
<phaul> cthu|: without understanding that what;s happening in that case, Hash#fetch would do what you are doing in a more elegant way
<phaul> screen_name = temp_event.fetch("screen_name", "")
<al2o3-cr> or screen_name = temp_event['screen_name'] || ''
<cthu|> thank you
<cthu|> but still
<cthu|> I want to know what's wrong with my object
<al2o3-cr> but fetch is more elegant.
<cthu|> I will use fetch
<cthu|> what
<cthu|> we can do it like in JS?
<cthu|> I was sure we couldn't
<cthu|> &>> qwe = asd["asd"] || "foo"
<rubydoc> # => undefined local variable or method `asd' for main:Object (NameError) (https://carc.in/#/r/5v7p)
<cthu|> yeah, we can't
<al2o3-cr> sure, you can.
<cthu|> ^
cschneid has joined #ruby
kapil____ has joined #ruby
<al2o3-cr> &>> h = {}; h[:foo] || 'nah'
<rubydoc> # => "nah" (https://carc.in/#/r/5v7q)
<cthu|> bleh
<al2o3-cr> &>> h = {foo: 42}; h[:foo] || 'nah'
<rubydoc> # => 42 (https://carc.in/#/r/5v7r)
<cthu|> I'm not familiar with :
<cthu|> no idea what it does
<cthu|> throws me NoMethodError: undefined method `key?' for nil:NilClass
<cthu|> on line 8
<cthu|> al2o3-cr, I think it works cuz you use symbolic links. I don't use them. I just do => cuz it feels more fair.
tdy has quit [Read error: error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac]
tdy has joined #ruby
<cthu|> lol
<cthu|> same error with fetch
<cthu|> omfg
<cthu|> why?!
<cthu|> oh
<cthu|> I think I know
<cthu|> it's cuz blocks don't have access to this
<cthu|> which is stupid af
<cthu|> I think I had this issue before
mikecmpbll has quit [Quit: inabit. zz.]
cschneid has quit [Ping timeout: 246 seconds]
orbyt_ has joined #ruby
<cthu|> I wonder if blocks that use do end can use the context.
JoeA2552 has joined #ruby
Guest44017 has joined #ruby
<cthu|> now I have to have an ugly temp_event = temp_event || {} in each iteration because of the fact that I don't have the context. that's sad. Can I add arbitrary arguments to blocks? Like f.each_line { |line, temp_event={}|
Guest44017 has quit [Ping timeout: 252 seconds]
tdy has quit [Ping timeout: 244 seconds]
<cthu|> omfg
<cthu|> I don't have match?
<cthu|> no string.match? no regex.match?
ByronJohnson has joined #ruby
<cthu|> okay, I'm gonna use the ugliest ===
<cthu|> cuz 2.2
davidw has quit [Ping timeout: 244 seconds]
cschneid has joined #ruby
elphe has quit [Ping timeout: 240 seconds]
cschneid has quit [Ping timeout: 245 seconds]
JoeA2552 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
JoeA2552 has joined #ruby
\void has quit [Quit: So long, and thanks for all the fish.]
JoeA2552 has quit [Client Quit]
D4rK51D3 has joined #ruby
AJA4350 has quit [Remote host closed the connection]
<D4rK51D3> hi everybody
r29v has joined #ruby
<havenwood> D4rK51D3: hi
<D4rK51D3> i just have a simple question, i dont know if maybe somebody can help, i just want to make a facebook autoposter in ruby, to work maybe in localhost as a webpage, or maybe just as a executable, is ruby the right language to do this?
jcalla has quit [Ping timeout: 246 seconds]
<D4rK51D3> autoposter (MULTI-poster, post a single post but in many different groups at the same time with a simple click
<D4rK51D3> is this possible in ruby? is it the right language for this? anybody ? :|
JoeA2552 has joined #ruby
<cthu|> why Ruby?
JoeA2552 has quit [Client Quit]
<cthu|> it makes sense to use JS in this case
<cthu|> locally in browser
<cthu|> unless heavy backend is involved
<cthu|> also, D4rK51D3 I believe there are many solutions that can be easily employed. Generally, it's either you hack and make it hard for FB to know that it's automated or you use its API. In the latter case you don't care about the language. In the former, however, you wanna use JS
sarink has joined #ruby
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<D4rK51D3> i dont know, ive just enrolled in a ruby course and i think it is much easier than python
<cthu|> oh, if you're a student, you probably don't wanna start messing with a task like this. Unless you feel confident with APIs
<D4rK51D3> but i really dont have an idea
<cthu|> also I wouldn't say Python is more complex or easier than Ruby. They're different, but have approximately the same level
masterasia has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<D4rK51D3> so you mean in ruby this task would be much harder? or more difficult?
<havenwood> D4rK51D3: Pretty much any modern language is perfectly fine for making an HTTP API client. Ruby is a fine choice.
JoeA2552 has joined #ruby
sarink has quit [Ping timeout: 246 seconds]
<D4rK51D3> i definitely would use facebook API
<D4rK51D3> i need to pull lot of info from facebook so i will need the API, nothing about spamming, facebook has rules about multiposting, since you respect those rules no problem
<havenwood> D4rK51D3: Maybe check out the Koala gem: https://github.com/arsduo/koala#readme
jcalla has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<D4rK51D3> koala?
JoeA2552 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
esrse has joined #ruby
<D4rK51D3> Koala is a Facebook library for Ruby, supporting the Graph API (including the batch requests and photo uploads), the Marketing API, the Atlas API, realtime updates, test users, and OAuth validation
<D4rK51D3> WOW
davidw has joined #ruby
connermcd has joined #ruby
<D4rK51D3> so my idea wouold be to make a "website" hosted in localhost, and from there manage my multipostings, receibe feedback from the facebook API, how about that?
JoeA2552 has joined #ruby
<D4rK51D3> is that a good/bad idea?, what is your expert opinion?
<hays> is there anything like the pickaxe book that is up to date
davidw has quit [Ping timeout: 246 seconds]
JoeA2552 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
D4rK51D3 has left #ruby ["Leaving"]
JoeA2552 has joined #ruby
<comet23> rate my clean code out of 10
lambarena has quit [Quit: Ping timeout (120 seconds)]
b6b has quit [Ping timeout: 246 seconds]
lambarena has joined #ruby
nomoney4u has quit [Ping timeout: 246 seconds]
cthu| has quit [Ping timeout: 250 seconds]
b6b has joined #ruby
tdy has joined #ruby
FrankD has joined #ruby
hutch has joined #ruby
kapil____ has quit [Quit: Connection closed for inactivity]
orbyt_ has joined #ruby
tdy has quit [Read error: Connection reset by peer]
tdy has joined #ruby
tag has quit [Quit: Connection closed for inactivity]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kapil____ has joined #ruby
orbyt_ has joined #ruby
Milos has quit [Quit: ZNC 1.7.1 - https://znc.in]
sgen_ has quit [Ping timeout: 250 seconds]
hutch has quit [Ping timeout: 245 seconds]
Milos has joined #ruby
code_zombie has quit [Quit: Leaving]
<hays> should i read the manning book?
<hays> seems to be the most recent that is actually about ruby
hutch has joined #ruby
elphe has joined #ruby
<comet23> manning is a terrible publisher
<comet23> you wanna learn ruby?
<comet23> look up app academy online it's free
<comet23> full full stack developer course at your own pace
connermcd has quit [Quit: WeeChat 2.3]
hutch has quit [Ping timeout: 268 seconds]
<hays> looking for a deeper understanding of the language
<hays> dont really care about being a full stack dev
<hays> industry seems to be moving away from this anyway
elphe has quit [Ping timeout: 268 seconds]
<hays> articles online about ruby are of pretty inconsistent quality
davidw has joined #ruby
r29v has quit [Quit: r29v]
hutch has joined #ruby
ogres has joined #ruby
<baweaver> hays: What're you trying to learn?
<hays> well, ive been spending some time reading about the ruby object model
<hays> watched a dave thomas video
<baweaver> Want to see some Ruby black magic? :D
<hays> but really would like to just get a good overview
hutch has quit [Ping timeout: 240 seconds]
JoeA2552 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hutch has joined #ruby
braincrash has quit [Quit: bye bye]
braincrash has joined #ruby
sgen_ has joined #ruby
masterasia has joined #ruby
darkhanb has joined #ruby
cschneid has joined #ruby
<hays> heh
<hays> i see you have a new article out :)
davidw has quit [Ping timeout: 272 seconds]
ansraliant has joined #ruby
KeyJoo has joined #ruby
sauvin has joined #ruby
davidw_ has joined #ruby
quipa_ has quit [Remote host closed the connection]
armyriad has quit [Ping timeout: 250 seconds]
tdy has quit [Ping timeout: 272 seconds]
sarink has joined #ruby
davidw_ has quit [Ping timeout: 250 seconds]
sarink has quit [Ping timeout: 250 seconds]
<zenspider> rawr
jtdowney has quit [Ping timeout: 268 seconds]
_whitelogger has joined #ruby
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ogres has quit [Quit: Connection closed for inactivity]
sgen_ has quit [Ping timeout: 250 seconds]
laaron has joined #ruby
hutch has quit [Ping timeout: 272 seconds]
JoeA2552 has joined #ruby
cthu| has joined #ruby
_whitelogger has joined #ruby
za1b1tsu has joined #ruby
_whitelogger has joined #ruby
laaron- has joined #ruby
laaron has quit [Remote host closed the connection]
marz_d`ghostman has quit [Quit: Page closed]
jthomas1 has joined #ruby
_whitelogger has joined #ruby
JoeA2552 has joined #ruby
jthomas1 has quit [Ping timeout: 244 seconds]
cschneid has joined #ruby
lightstalker has quit [Ping timeout: 240 seconds]
lightstalker has joined #ruby
JoeA2552 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
neuraload has joined #ruby
JoeA2552 has joined #ruby
kapil____ has quit [Quit: Connection closed for inactivity]
roshanavand has joined #ruby
cnsvc has joined #ruby
laaron has joined #ruby
laaron- has quit [Remote host closed the connection]
cschneid has quit [Ping timeout: 244 seconds]
cthu| has quit [Ping timeout: 268 seconds]
cthu| has joined #ruby
_whitelogger has joined #ruby
cnsvc has quit [Ping timeout: 256 seconds]
BH23 has quit [Ping timeout: 245 seconds]
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Mike11 has joined #ruby
BH23 has joined #ruby
neuraload has quit [Quit: Leaving]
conta has joined #ruby
ansraliant has quit [Quit: My planet needs me]
tiff has joined #ruby
reber has joined #ruby
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
laaron has quit [Remote host closed the connection]
elphe has joined #ruby
neuraload has joined #ruby
gix has joined #ruby
neuraload has quit [Ping timeout: 240 seconds]
esrse has quit [Quit: happy new year]
kapil____ has joined #ruby
lxsameer has joined #ruby
sameerynho has quit [Ping timeout: 246 seconds]
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
marz_d`ghostman has joined #ruby
<marz_d`ghostman> I've created a /config/initializers/production.rb & test.rb . . . to initialize things. However, how do I select which one should be included when I run it in production and test?
elphe has quit [Ping timeout: 272 seconds]
mikecmpbll has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
laaron has joined #ruby
roshanavand has joined #ruby
marz_d`ghostman has quit [Quit: Page closed]
FrankD has quit [Read error: Connection reset by peer]
powerbit has quit [Ping timeout: 250 seconds]
BH23 has quit [Ping timeout: 250 seconds]
powerbit has joined #ruby
powerbit has quit [Excess Flood]
elphe has joined #ruby
powerbit has joined #ruby
powerbit has quit [Excess Flood]
elphe has quit [Ping timeout: 268 seconds]
powerbit has joined #ruby
elphe has joined #ruby
roshanavand has quit [Remote host closed the connection]
roshanavand has joined #ruby
JoeA2552 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
keden has joined #ruby
ur5us has joined #ruby
yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
quipa has joined #ruby
elphe has quit [Ping timeout: 272 seconds]
quipa has quit [Max SendQ exceeded]
quipa has joined #ruby
laaron- has joined #ruby
laaron has quit [Remote host closed the connection]
elphe has joined #ruby
KeyJoo has quit [Quit: KeyJoo]
rubydoc has quit [Ping timeout: 246 seconds]
yxhuvud has joined #ruby
phaul has quit [Ping timeout: 244 seconds]
KeyJoo has joined #ruby
phaul has joined #ruby
rubydoc has joined #ruby
cd has quit [Quit: cd]
elphe has quit [Ping timeout: 272 seconds]
elphe has joined #ruby
laaron- has quit [Remote host closed the connection]
laaron has joined #ruby
bobthebutcher has joined #ruby
Mike11 has quit [Ping timeout: 250 seconds]
cschneid has joined #ruby
ur5us has quit [Remote host closed the connection]
elphe has quit [Ping timeout: 250 seconds]
elphe has joined #ruby
bobthebutcher has quit [Quit: WeeChat 1.9.1]
patteh_ has joined #ruby
donofrio has quit [Remote host closed the connection]
<hays> i am thinking i should just read the pickaxe book
<hays> and then just read the changelogs of ruby from 1.9
cschneid has quit [Ping timeout: 245 seconds]
mostlybadfly has joined #ruby
<al2o3-cr> hays: look @ /topic for book references.
lucasb has joined #ruby
neuraload has joined #ruby
elphe has quit [Quit: leaving]
AJA4350 has joined #ruby
keden has quit [Ping timeout: 246 seconds]
keden has joined #ruby
agent_white has joined #ruby
KeyJoo has quit [Quit: KeyJoo]
dviola has joined #ruby
s2013 has joined #ruby
reber has quit [Remote host closed the connection]
larissa has quit [Ping timeout: 252 seconds]
larissa has joined #ruby
szulak_ has joined #ruby
laaron has quit [Remote host closed the connection]
laaron has joined #ruby
jcalla has quit [Ping timeout: 272 seconds]
comet23 has joined #ruby
jcalla has joined #ruby
<comet23> how do you wrap values around?
<al2o3-cr> say what?
<comet23> like i have an array
<al2o3-cr> yes.
<comet23> ['a','b','c']
<al2o3-cr> ok.
<comet23> i want a counter to keep going back to a when it reaches c
<comet23> not get nil
donofrio has joined #ruby
<al2o3-cr> comet23: can you paste an example of input/output? (with comments)
<comet23> i don't have any code i just wanted to know for future reference
<al2o3-cr> you don't need a counter.
<phaul> class Array; def infinitie_each(&block); (1..).map { each }.inject(:+); end; end # :)
<al2o3-cr> &>> %w(a b c).cycle.to_a 5
<rubydoc> # => ["a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c"] (https://carc.in/#/r/5va1)
mikecmpbll has joined #ruby
donofrio has quit [Ping timeout: 246 seconds]
<al2o3-cr> comet23: not sure what you mean otherwise.
dviola has quit [Quit: WeeChat 2.3]
Mike11 has joined #ruby
<hays> why doesn't this work? [1,2,3].reduce([]) { |sum, n| sum.push(n) if n.odd? }
<phaul> &>> [1,2,3].reduce([]) { |sum, n| sum.push(n) if n.odd? }
<rubydoc> # => undefined method `push' for nil:NilClass (NoMethodError) (https://carc.in/#/r/5va5)
<al2o3-cr> hays: use each_with_object
<hays> yeah, i know, but why doesn't that work?
<szulak_> &>> [1,2,3].reduce([])
<rubydoc> # => [] is not a symbol nor a string (TypeError) (https://carc.in/#/r/5va6)
<phaul> if n is even then the block is nil
<phaul> then nil is assigned to sum
<al2o3-cr> no
<phaul> &>> [1,2,3].reduce([]) { |sum, n| x = sum.push(n) if n.odd? ; p x }
<rubydoc> # => [1] ...check link for more (https://carc.in/#/r/5vab)
bmurt has joined #ruby
<phaul> so yes.
<al2o3-cr> hays: don't use reduce/inject like that.
<al2o3-cr> phaul: not to your answer ;)
<phaul> ah. :) nm
<hays> phaul: ah, yes
<hays> [1,2,3].reduce(Array.new) { |sum,n| n.odd? ? sum.push(n) : sum }
<hays> and that Array.new could be p[
<hays> erm. []
<hays> al2o3-cr: yeah i know i can use select, or each_with_object
<bougyman> i was about to mention each_with_object
<bougyman> [1,2,3].each_with_object([]) { |n, sum| sum.push(n) if n.odd? }
<bougyman> => [1, 3]
<al2o3-cr> yeah select the very method for it ;)
<al2o3-cr> &>> [1,2,3].select &:odd?
<rubydoc> # => [1, 3] (https://carc.in/#/r/5vag)
<bougyman> but yeah, select is better
<hays> " reduce is so powerful that every other Enumerable function could be written using it."
<hays> i was just playing with that idea
<bougyman> haha, it's true.
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<al2o3-cr> &>> ["Enumerable"].inject Object, :const_get
<rubydoc> # => Enumerable (https://carc.in/#/r/5vah)
bmurt has joined #ruby
<bougyman> just cause it can doesn't mean it should, though
<bougyman> [1,2,3].inject(0) { |sum, n| n.odd? ? sum += n : sum }
<bougyman> => 4
<al2o3-cr> &>> (1..10).inject :lcm
<rubydoc> # => 2520 (https://carc.in/#/r/5vaj)
bmurt has quit [Client Quit]
laaron has quit [Remote host closed the connection]
<hays> do rubyists like inject over reduce i guess?
<al2o3-cr> &>> "loud".each_byte.with_object("") { |b, s| s << b ^= 32 }
<rubydoc> # => "LOUD" (https://carc.in/#/r/5vaq)
<lupine> I don't like either
cschneid has joined #ruby
venmx has joined #ruby
clemens3 has joined #ruby
<al2o3-cr> hays: no, each to their own.
<al2o3-cr> hays: ask baweaver about reduce, he'll teach you loads of wizardry ;)
laaron has joined #ruby
LichenStaff has joined #ruby
szulak_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
polishdub has joined #ruby
LichenStaff has quit [Quit: Leaving]
<al2o3-cr> hays: the reason i like (inject) is for method injection as the name suggests.
<al2o3-cr> i.e
<al2o3-cr> &>> (1..4).inject :fdiv
<rubydoc> # => 0.041666666666666664 (https://carc.in/#/r/5vaw)
<al2o3-cr> is the same as
<al2o3-cr> &>> 1.fdiv(2).fdiv(3).fdiv(4)
<rubydoc> # => 0.041666666666666664 (https://carc.in/#/r/5vax)
laaron has quit [Remote host closed the connection]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
laaron has joined #ruby
<al2o3-cr> and never do [1,2,3].inject &:+, use :+ is a direct method call without creating a proc
<al2o3-cr> you'd hardly ever need inject/reduce if you used the Enumerable methods provided.
<hays> shouldn't there be @ on the functions in ratio? https://github.com/skmetz/poodr2/blob/master/2_10.rb
Rapture has joined #ruby
Guest44017 has joined #ruby
<al2o3-cr> hays: no, because there is a setter method ofr chainring
<al2o3-cr> *getter
<hays> ahh
<hays> and than can be simplified to : class Gear < Struct.new(:chainring, :cog) I think
<al2o3-cr> hays: yes.
roshanavand has quit [Ping timeout: 250 seconds]
roshanavand1 has joined #ruby
BTRE has quit [Ping timeout: 268 seconds]
roshanavand1 is now known as roshanavand
<al2o3-cr> but i'd use Gear = Struct.new ....
<al2o3-cr> otherwise you'll have an anonymous class in the ancestory
<al2o3-cr> &>> Gear = Struct.new(:chainring, :cog) { def ratio; chainring / cog.to_f; end }; Gear.new(52, 11).ratio
<rubydoc> # => 4.7272727272727275 (https://carc.in/#/r/5vb4)
davidw_ has joined #ruby
RiPuk has quit [Quit: ZNC 1.7.1 - https://znc.in]
BTRE has joined #ruby
RiPuk has joined #ruby
<hays> collect also seems to be the same as map
<al2o3-cr> hays: it is an alias, yes.
chouhoulis has joined #ruby
<al2o3-cr> hays: there is many aliases ;)
<al2o3-cr> *is/are
<hays> also map.with_index seems like magic
tdy has joined #ruby
<al2o3-cr> hays: why?
<al2o3-cr> it's a method on Enumertor class
cschneid has quit [Ping timeout: 268 seconds]
<al2o3-cr> hays: Enumerator#with_index is so you can have an index other 0
clemens3 has quit [Ping timeout: 272 seconds]
clemens3_ has joined #ruby
<hays> yeah, so .map returns an Enumerator, which still contains enough information to create an index
roshanavand has quit [Read error: Connection reset by peer]
roshanavand has joined #ruby
<al2o3-cr> "which still contains enough information to create an index" ?
conta has quit [Quit: conta]
<al2o3-cr> hays: what does that mean?
<al2o3-cr> &>> Enumerator.instance_methods(false)
<rubydoc> # => [:each_with_index, :with_index, :with_object, :next_values, :each_with_object, :peek, :feed, :peek_v ...check link for more (https://carc.in/#/r/5vb5)
<hays> just trying to say that the Enumerator still has access to the array, so it can provide indices. I wasn't thinking of .map returning anything, which doesn't make sense
donofrio has joined #ruby
<phaul> hays, when those methods return an Enumerator they don't actually run the iteration yet (at the point of return). Enumerator just encapsulates a reference to them, and can call them later when they have a block. It's lazy.
sgen_ has joined #ruby
<hays> yes
<al2o3-cr> hays: simalar to generators in python.
kapil____ has quit [Quit: Connection closed for inactivity]
sgen_ has quit [Remote host closed the connection]
<al2o3-cr> eg hays
<al2o3-cr> &>> e = (1..10).to_enum; [e.take(3), e.next]
<rubydoc> # => [[1, 2, 3], 1] (https://carc.in/#/r/5vb6)
donofrio has quit [Ping timeout: 272 seconds]
connermcd has joined #ruby
<al2o3-cr> in 2.6 Numeric#step & Range#step returns an Enumerator::ArithmeticSequence class
<al2o3-cr> weird.
<al2o3-cr> must be something to do with endless ranges.
cschneid has joined #ruby
<phaul> this aborts :( 2.step(by: 3).include? 7
<al2o3-cr> &>> Array.module_eval { def to_ruby() pack 'C*' end }; [82, 85, 66, 89].to_ruby * 3
<rubydoc> # => "RUBYRUBYRUBY" (https://carc.in/#/r/5vbh)
<al2o3-cr> phaul: how?
<phaul> its infinite loop
garyserj has joined #ruby
<phaul> ArithmeticSequence#include? could have been just simple modulo arithmetics
<phaul> but apparently not
<al2o3-cr> phaul: show me what you tested with
lightstalker has quit [Ping timeout: 250 seconds]
<phaul> ruby-2.6.0-rc2
<al2o3-cr> code i mean.
Puffball has quit [Remote host closed the connection]
<al2o3-cr> nvm lol
davidw_ has quit [Ping timeout: 246 seconds]
<al2o3-cr> phaul: yeah it fucks up.
kaleido has quit [Quit: out]
<al2o3-cr> yeah, with the :to keyword space happens.
<al2o3-cr> phaul: file a bug my brother
armyriad has joined #ruby
<al2o3-cr> phaul: wouldn't modulo be off by 1?
<al2o3-cr> :D
kaleido has joined #ruby
<phaul> I don't know the purpose of that class, it doesn't seem to implement anything itself.
<al2o3-cr> phaul: it implements #last
<phaul> someone just added #sum
<al2o3-cr> nice ;_)
tdy has quit [Ping timeout: 245 seconds]
<al2o3-cr> ruby devs are gods!
<al2o3-cr> phaul: anymore?
<phaul> that's all I got :)
<al2o3-cr> that one got past me ;)
davidw_ has joined #ruby
lucasb has quit [Quit: Connection closed for inactivity]
chouhoulis has quit [Remote host closed the connection]
<al2o3-cr> phaul: this is a nice addition: RubyVM.resolve_feature_path
<al2o3-cr> RubyVM.resolve_feature_path #=> [:so, "/home/gr33n7007h/.rubies/ruby-2.6.0/lib/ruby/2.6.0/x86_64-linux/objspace.so"]
hutch has joined #ruby
<phaul> what is it for?
<al2o3-cr> phaul: it resolves paths from require 'blah'
<al2o3-cr> first is ext /rb|so/ then path.
<al2o3-cr> trust me this is a good feature.
<phaul> I take your word for it :)
\void has joined #ruby
garyserj has quit [Quit: garyserj]
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<al2o3-cr> &>> require'fiddle';include Fiddle;x = Struct.new(:foo, :bar).new(:blah, :nah); 0.step(24,8).zip([8].cycle).map { |b| Pointer[Pointer[dlwrap x][*b].unpack1('Q')].to_value }
<rubydoc> # => [8196, #<Class:0x000055da179cdcd0>, :blah, :nah] (https://carc.in/#/r/5vbo)
agent_white has quit [Remote host closed the connection]
<al2o3-cr> &>> require'fiddle';include Fiddle;x = Struct.new(:foo, :bar).new(:blah, :nah); 0.step(24,8).zip([8].cycle).map { |b| Pointer[Pointer[dlwrap x].ref[*b].unpack1('Q')].to_value }
<rubydoc> # => [#<struct foo=:blah, bar=:nah>, false, false, false] (https://carc.in/#/r/5vbp)
garyserj has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
cschneid has quit [Ping timeout: 268 seconds]
hahuang6- has quit [Ping timeout: 250 seconds]
garyserj is now known as rogerroger
comet23 has quit [Quit: Connection closed for inactivity]
roshanavand has quit [Remote host closed the connection]
agent_white has joined #ruby
clemens3_ has quit [Ping timeout: 240 seconds]
kapil____ has joined #ruby
<al2o3-cr> phaul: this is infinite loop
<al2o3-cr> 0.step(8,0) ....
<phaul> that's a cute one.
keden has quit [Quit: WeeChat 2.3]
laaron has quit [Remote host closed the connection]
<phaul> tbh I would expect it to raise ArgumentError
clemens31 has joined #ruby
<phaul> &>> 0.step(to: 8, by: 0)
<rubydoc> # => #<Enumerator: 0:step({:to=>8, :by=>0})> (https://carc.in/#/r/5vbw)
<phaul> &>> 0.step(to: 8, by: 0).entries
<rubydoc> # => (https://carc.in/#/r/5vbx)
hays_ has joined #ruby
hays has quit [Ping timeout: 240 seconds]
<al2o3-cr> &>> (1..8).step 0
<rubydoc> # => #<Enumerator: 1..8:step(0)> (https://carc.in/#/r/5vby)
<al2o3-cr> &>> (1..8).step(0).entries
<rubydoc> # => step can't be 0 (ArgumentError) (https://carc.in/#/r/5vbz)
sameerynho has joined #ruby
sanscoeur has joined #ruby
lxsameer has quit [Ping timeout: 272 seconds]
nchambers has joined #ruby
Fusl has quit [Remote host closed the connection]
cschneid has joined #ruby
Madmanden has joined #ruby
darkhanb has joined #ruby
roshanavand has joined #ruby
clemens3 has joined #ruby
clemens31 has quit [Ping timeout: 250 seconds]
Mike11 has quit [Quit: Leaving.]
Fusl has joined #ruby
hays_ has quit [Remote host closed the connection]
clemens3_ has joined #ruby
clemens3 has quit [Ping timeout: 250 seconds]
Madmanden has quit [Quit: Leaving]
orbyt_ has joined #ruby
hays_ has joined #ruby
hutch has quit [Ping timeout: 246 seconds]
cschneid has quit [Ping timeout: 268 seconds]
rogerroger has quit [Quit: rogerroger]
neuraload has quit [Quit: This computer has gone to sleep]
hutch has joined #ruby
<havenwood> &>> ((0..0) % 0).size
<rubydoc> # => undefined method `%' for 0..0:Range (NoMethodError) (https://carc.in/#/r/5vc3)
<havenwood> #=> Infinity
hays_ has quit [Ping timeout: 250 seconds]
garyserj has joined #ruby
<al2o3-cr> ((0..1) % 0).size #=> Inf
blockchan has joined #ruby
<al2o3-cr> ;)
<al2o3-cr> had a good xmas havenwood
<havenwood> al2o3-cr: got a brand new Ruby as a present! \o/
<nchambers> havenwood: i really liked that infinite range operator (article). can't wait to use ruby 2.6!
<havenwood> nchambers: yay!
<al2o3-cr> havenwood: i got that early :)
<havenwood> al2o3-cr: ruby 2.7.0dev ;)
neuraload has joined #ruby
<al2o3-cr> havenwood: hehe ;)
thejs has joined #ruby
<blockchan> Hello everyone. I was wondering if anyone encountered this weird error with eventmachine I have. UDP socket does not receive packets from network, but when I send something from localhost it suddenly starts receiving packets from network correctly
thejs has quit [Client Quit]
polishdub has quit [Remote host closed the connection]
masterasia has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
clemens3_ has quit [Ping timeout: 250 seconds]
clemens3 has joined #ruby
za1b1tsu has quit [Quit: Leaving]
hays_ has joined #ruby
ellcs has joined #ruby
za1b1tsu has joined #ruby
Flaghacker has joined #ruby
garyserj has quit [Quit: garyserj]
Flaghacker has quit [Client Quit]
blockchan has quit [Quit: Page closed]
blockchan has joined #ruby
ellcs has quit [Ping timeout: 250 seconds]
lightstalker has joined #ruby
masterasia has joined #ruby
polishdub has joined #ruby
blockchan has quit [Quit: Page closed]
Rapture has quit [Ping timeout: 268 seconds]
<al2o3-cr> &>> "yipppee ki yay".reverse
<rubydoc> # => "yay ik eepppiy" (https://carc.in/#/r/5vc5)
<nchambers> yippee kayak other buckets
<al2o3-cr> nchambers: :)
<nchambers> :}
<nchambers> i've been watching too much brooklyn 99
<mspo> blockchan: your program worked for me
<al2o3-cr> been drikning to much poish potato wine :D
<nchambers> :D
clemens3 has quit [Ping timeout: 250 seconds]
segy has quit [Ping timeout: 240 seconds]
clemens3_ has joined #ruby
cthulchu_ has joined #ruby
tdy has joined #ruby
cthu| has quit [Ping timeout: 250 seconds]
za1b1tsu has quit [Read error: Connection reset by peer]
JoeA2552 has joined #ruby
tdy has quit [Ping timeout: 240 seconds]
<al2o3-cr> &>> ENV
<rubydoc> # => {"PATH"=>"/usr/local/bin:/usr/bin:/bin", "HOME"=>"/home/ruby", "USER"=>"ruby", "LOGNAME"=>"ruby"} (https://carc.in/#/r/5vc7)
neuraload has quit [Quit: Leaving]
<al2o3-cr> &&> $(ls)
sauvin has quit [Read error: Connection reset by peer]
<al2o3-cr> $>> `w`
<cthulchu_> actually I was wrong yesterday
<cthulchu_> blocks do have normal access to this
<cthulchu_> it's just in that particular case it didn't work
<cthulchu_> I fixed it, but I still don't know what was wrong with that code
<cthulchu_> if anyone can clarify it for me, it would be awesome
<cthulchu_> (and my fix is ugly, I don't like it)
quipa has quit [Remote host closed the connection]
quipa has joined #ruby
quipa has quit [Max SendQ exceeded]
quipa has joined #ruby
lightstalker has quit [Ping timeout: 250 seconds]
nchambers is now known as uplime
donofrio has joined #ruby
quipa has quit [Remote host closed the connection]
quipa has joined #ruby
mostlybadfly has quit [Quit: Connection closed for inactivity]
<uplime> cthulchu_: where was the code though
donofrio has quit [Read error: Connection reset by peer]
<cthulchu_> uplime, https://paste.ofcode.org/35MJgEypkzBg9m8PVHB2LUf throws me NoMethodError: undefined method `key?' for nil:NilClass on line 8
donofrio has joined #ruby
<uplime> ah
<cthulchu_> I had to do ugly temp_event = temp_event || {} in there to fix it
<uplime> i can see why you would want something a bit cleaner :D
<cthulchu_> yeah :)
quipa has quit [Max SendQ exceeded]
quipa has joined #ruby
<cthulchu_> also, I have a different question. I have a hash and an array with hashes. I need to make sure that all the fields in this hash are present in each hash of the array. I'm gonna do this using two nested .each in one .select. It's three nested loops. I mean, I don't expect them to be too large, but the code becomes hard to read.
<cthulchu_> maybe there are hacks like hash.includes(hash)
reber has joined #ruby
<cthulchu_> although I need it to do regex inclusion
<cthulchu_> so I guess not
<cthulchu_> anyhow, will write a method for this
JoeA2552 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
donofrio has quit [Ping timeout: 245 seconds]
quipa has quit [Max SendQ exceeded]
quipa has joined #ruby
laaron has joined #ruby
quipa has quit [Max SendQ exceeded]
Emmanuel_Chanel has joined #ruby
quipa has joined #ruby
quipa has quit [Remote host closed the connection]
quipa has joined #ruby
<al2o3-cr> cthulchu_: deffo not json?
quipa has quit [Read error: Connection reset by peer]
<cthulchu_> hm?
<cthulchu_> crap
<cthulchu_> I think sometimes I do : instead of =>
<al2o3-cr> ffs
<cthulchu_> but in that case everything is =>
<cthulchu_> ah, right, I do json when I need to pretty print
<cthulchu_> anyhow, I don't think it relates
JoeA2552 has joined #ruby
<al2o3-cr> ok, good.
laaron- has joined #ruby
laaron has quit [Remote host closed the connection]
cthu| has joined #ruby
cthulchu_ has quit [Ping timeout: 250 seconds]
<cthu|> I kinda hesitate to do nested selects
<cthu|> they have a weirdass syntax
<cthu|> hm
<cthu|> okay, select is not the way to go
<cthu|> I guess I'll just do the old good each and select them manually
<cthu|> really, some of these blocks are just lame. don't know how you use them freely when they are so limited
garyserj has joined #ruby
SeepingN has joined #ruby
clemens3_ has quit [Ping timeout: 245 seconds]
clemens3_ has joined #ruby
<cthu|> wtf
<cthu|> there's arr.each that passes the object and there's arr.each_index that passes the index. Where's the one that passes both like hash.each?
<cthu|> ot I guess once we have an index, we don't need the val cuz we can get it pretty quickly?
<cthu|> guys, am I alone here?
<lupine> each_with_index
<cthu|> errr
<cthu|> I don't see it
<cthu|> oh, maybe it's cuz I use 2.2
<lupine> >> [6,1,2,3].each_with_index { |a,b| puts "#{a} #{b}" }
<ruby[bot]> lupine: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<cthu|> see
<cthu|> I told you!
<lupine> >> puts [6,1,2,3].each_with_index { |a,b| puts "#{a} #{b}" }
<ruby[bot]> lupine: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<cthu|> read the error
<lupine> works fine locally, anyway, and rings a bell from 1.8.
<phaul> lupine: &>>
<lupine> &>> [6,1,2,3].each_with_index { |a,b| puts "#{a} #{b}" }
<rubydoc> # => 6 0 ...check link for more (https://carc.in/#/r/5vci)
<lupine> woo
SantaKline is now known as fountainpuppy
<lupine> also consider more words per line, and fewer imprecations per minute
<cthu|> I'm kinda almost alone here
clemens3 has joined #ruby
<cthu|> also don't like to use methods that are not in the doc. maybe you wrote yours locally
<lupine> 🎻
clemens3_ has quit [Ping timeout: 268 seconds]
tag has joined #ruby
cschneid has joined #ruby
roshanavand has quit [Remote host closed the connection]
roshanavand has joined #ruby
hays has joined #ruby
hays_ has quit [Ping timeout: 250 seconds]
hutch has quit [Ping timeout: 246 seconds]
<cthu|> If I have nested each, will break break me out of one or will it apply to all layers?
<cthu|> I presume it's the former
BH23 has joined #ruby
reber has quit [Remote host closed the connection]
connermcd has quit [Quit: WeeChat 2.3]
<cthu|> okay
<cthu|> just made this function: https://paste.ofcode.org/ZBj6J6WSpeLNAkxvgmkFEX Can you take a look at it and criticize?
<uplime> (asking as a beginner) why do you use .size == 0 instead of .empty?
<cthu|> a habit, but thanks
<cthu|> empty is cooler
<uplime> ah
<uplime> ruby might be the only language where i don't use .size == 0
<cthu|> yeah, that's the thing. If you get used to ruby's sugar, it may be problematic when you switch
<uplime> yeah, i don't blame you
<cthu|> so it may be a good idea to do it in the traditional
garyserj has quit [Quit: garyserj]
kapil____ has quit [Quit: Connection closed for inactivity]
Renich has joined #ruby
dellavg_ has quit [Ping timeout: 250 seconds]
Guest44017 has quit [Ping timeout: 252 seconds]
Guest44017 has joined #ruby
hutch has joined #ruby
laaron has joined #ruby
JoeA2552 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
laaron- has quit [Remote host closed the connection]
roshanavand has quit [Remote host closed the connection]
lucasb has joined #ruby
roshanavand has joined #ruby
sarink has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Renich has quit [Ping timeout: 268 seconds]
jottr has joined #ruby
Nicmavr has joined #ruby
segy has joined #ruby
Rapture has joined #ruby
TvL2386 has quit [Ping timeout: 244 seconds]
planigan has quit [Ping timeout: 244 seconds]
mistergibson has joined #ruby
tdy has joined #ruby
planigan has joined #ruby
cschneid has quit [Remote host closed the connection]
laaron- has joined #ruby
cd has joined #ruby
laaron has quit [Remote host closed the connection]
SeepingN has quit [Disconnected by services]
SeepingN_ has joined #ruby
uplime has quit [Ping timeout: 250 seconds]
tdy has quit [Read error: error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac]
tdy has joined #ruby
code_zombie has joined #ruby
uplime has joined #ruby
sarink has quit [Remote host closed the connection]
sarink has joined #ruby
BH23 has quit [Ping timeout: 246 seconds]
<cthu|> ruuuubyyyy! why are you so silent, ruby!
sarink has quit [Ping timeout: 244 seconds]
<cthu|> oh, it's probably Christmas
hutch has quit [Ping timeout: 240 seconds]
cschneid has joined #ruby
hutch has joined #ruby
<cthu|> folks, help me with this thingy
<cthu|> a["test"] << {"qwerty"=>"qwe"}
<cthu|> a is {}
<cthu|> << can't create an object
<cthu|> I hoped it would make an array
<uplime> a = Hash.new []
<cthu|> nah
<cthu|> I'm doing it in loop
<uplime> what does that have to do with anything?
<cthu|> cuz I would create a new [] in each iteration
<cthu|> wouldn't I?
<cthu|> I need to append to it instead
<uplime> it creates a new hash with the default value of []
<uplime> its no different than a = {}, except you're giving a default value
<cthu|> okay, I don't wanna do it explicitly
<uplime> why not?
<cthu|> I look for something that would append object to existing key or create the key and an array
<uplime> so, Hash.new []
jottr has quit [Ping timeout: 250 seconds]
<uplime> for every key created, it creates an array
<cthu|> again, I'm not gonna do that in a loop
<cthu|> I don't need keys
<cthu|> I need one key
<cthu|> and one array
<cthu|> my iterations should append to an array
<cthu|> there is a chance that they won't need to append and then I don't need the key
<cthu|> see?
<cthu|> so I don't wanna create it outside
<uplime> no, i have no idea what you're talking about
<cthu|> uh
<cthu|> why would I even do Hash.new []
<cthu|> I can do a["test"] = []
<uplime> sure
<cthu|> which I don't want
<uplime> you said you would hope a["test"] << ... would make an array
<uplime> it won't
<uplime> the hash will have to return an array for << to work
<cthu|> crap
<uplime> you're already doing a = {}. i'm not sure what the issue is with replacing it with a = Hash.new []
<cthu|> cuz I always need a
<cthu|> but not always the []
<uplime> k, good luck i guess
<cthu|> in that loop I do testing. a["test"] has failed cases. if nothing fails, I don't need it
<cthu|> but it there is more than one failure, I need to append
<uplime> you can't append if there is not already an array there
<cthu|> I feel like it's a trivial issue and there should be a trivial solution
<cthu|> well I know that
<cthu|> but I hoped there was some hack
<cthu|> like a = a || ""
<cthu|> yes!!!!!!!!
<cthu|> (foo ||= []) << :element
<cthu|> ha
<cthu|> fuckyeah
tiff has joined #ruby
<cthu|> (object["cds_not_found"] ||= []) << val
<cthu|> looks gorgeous
sarink has joined #ruby
clemens3 has quit [Ping timeout: 268 seconds]
<phaul> &>> a = Hash.new []; a['uplime'] = true; a['phaul']
<rubydoc> # => [] (https://carc.in/#/r/5vd6)
<phaul> &>> a = Hash.new []; a['uplime'] << true; a['phaul']
<rubydoc> # => [true] (https://carc.in/#/r/5vd7)
<phaul> I messed up my example first time
<uplime> so im wrong
<phaul> with block it would work
<uplime> how do you create a hash with an Array being the d... ah thats what I was thinking of
<phaul> &>> a = Hash.new { [] }; a['uplime'] << true; a['phaul']
<rubydoc> # => [] (https://carc.in/#/r/5vd9)
<uplime> yep, my bad
<leftylink> unfortunately, you see that a thing has happened.
<leftylink> &>> a = Hash.new { [] }; a['uplime'] << true; a
<rubydoc> # => {} (https://carc.in/#/r/5vda)
<leftylink> the hash doesn't even contain anything at all
<leftylink> &>> a = Hash.new { |h, k| h[k] = [] }; a['test'] << true; a
<rubydoc> # => {"test"=>[true]} (https://carc.in/#/r/5vdb)
<leftylink> "It is the block's responsibility to store the value in the hash if required"
<phaul> fair point leftylink
<uplime> thanks leftylink
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
laaron has joined #ruby
cschneid has quit [Ping timeout: 245 seconds]
laaron- has quit [Remote host closed the connection]
sarink has quit [Remote host closed the connection]
dionysus69 has quit [Quit: ZNC 1.7.1+deb2+b1 - https://znc.in]
hutch has quit [Ping timeout: 246 seconds]
agent_white has quit [Quit: brb]
<cthu|> this feeling when you finished a large piece of new functionality, but haven't yet run the code. And you try it and... it works just as you expect...
<cthu|> this feeling of "now I have to look to find where it fails" :(
hutch has joined #ruby
<justache> is this a welcoming channel
jottr has joined #ruby
<cthu|> yes
<cthu|> it is
<justache> oh nice
Rapture has quit [Quit: Textual IRC Client: www.textualapp.com]
davidw_ has quit [Ping timeout: 245 seconds]
jottr has quit [Ping timeout: 240 seconds]
polishdub has quit [Quit: leaving]
reber has joined #ruby
jottr has joined #ruby
johnny56_ has joined #ruby
johnny56 has quit [Ping timeout: 272 seconds]
venmx has quit [Ping timeout: 250 seconds]
JoeA2552 has joined #ruby
reber has quit [Remote host closed the connection]
laaron- has joined #ruby
laaron has quit [Remote host closed the connection]
kapil____ has joined #ruby
ellcs has joined #ruby
paraxial has quit [Quit: The Lounge - https://thelounge.github.io]
paraxial has joined #ruby
horribleprogram has joined #ruby
<horribleprogram> Fuck all of you
JoeA2552 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
powerbit has quit [Ping timeout: 268 seconds]
powerbit has joined #ruby
powerbit has quit [Excess Flood]
powerbit has joined #ruby
lucasb has quit [Quit: Connection closed for inactivity]
ellcs has quit [Ping timeout: 268 seconds]