havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.5.3, 2.4.5, 2.3.8, 2.6.0-preview3: 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!
RougeR has joined #ruby
cow[moo] has joined #ruby
blackmesa has quit [Quit: WeeChat 2.3]
<jayjo> does it invoke a particular one, or everything in the directory? how about the db:seed - there's a file called seeds.rb but there's no seed anywhere
<jayjo> or db:setup, I don't see that either
<jayjo> are they defined anywhere? Is there a file or config that says db:seed -> run db/seeds.rb ?
<jayjo> or does it look for files that start with the command?
thinkpad has joined #ruby
whysthatso has quit [Quit: whysthatso]
GodFather has quit [Ping timeout: 244 seconds]
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
beowuff has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
elphe has quit [Ping timeout: 244 seconds]
tdy1 is now known as tdy
bmurt has joined #ruby
elphe has joined #ruby
venmx has quit [Ping timeout: 245 seconds]
impermanence has joined #ruby
bmurt has quit [Read error: Connection reset by peer]
elphe has quit [Ping timeout: 240 seconds]
bak1an has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
despai has joined #ruby
elphe has joined #ruby
AJA4350 has quit [Remote host closed the connection]
aspiers has quit [Quit: ZNC - http://znc.sourceforge.net]
cd has quit [Ping timeout: 256 seconds]
ivanskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cthulchu has quit [Ping timeout: 252 seconds]
alicef has quit [Ping timeout: 246 seconds]
jthomas has quit [Ping timeout: 244 seconds]
queip has quit [Read error: Connection reset by peer]
cd has joined #ruby
queip has joined #ruby
roshanavand has quit [Ping timeout: 252 seconds]
jackrandom has quit [Read error: Connection reset by peer]
za1b1tsu has joined #ruby
alicef has joined #ruby
za1b1tsu has quit [Ping timeout: 246 seconds]
nchambers has joined #ruby
despai has quit [Ping timeout: 240 seconds]
Exuma has quit [Read error: Connection reset by peer]
agit0 has quit [Ping timeout: 272 seconds]
tdy has quit [Ping timeout: 268 seconds]
gix has quit [Ping timeout: 252 seconds]
knight33_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jcarl43 has quit [Quit: WeeChat 2.3]
bmurt has joined #ruby
crankharder has joined #ruby
jcalla has quit [Ping timeout: 246 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jcalla has joined #ruby
alicef has quit [Ping timeout: 246 seconds]
crankharder has quit [Ping timeout: 244 seconds]
awkwords has joined #ruby
ss_much has joined #ruby
tag has quit [Quit: Connection closed for inactivity]
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
crankharder has joined #ruby
crankharder has quit [Ping timeout: 268 seconds]
awkwords has quit [Quit: sleepy time]
jetchisel has quit [Ping timeout: 252 seconds]
jetchisel has joined #ruby
crankharder has joined #ruby
alicef has joined #ruby
crankharder has quit [Ping timeout: 245 seconds]
alicef has quit [Ping timeout: 246 seconds]
tdy has joined #ruby
bmurt has joined #ruby
<Iambchop> jayjo: helpy is a rails app, so rails docs may answer some of your questions. the db:migrate task will load all of the migration files in the directory; on subsequent runs it will skip files it has loaded before. the db:seed task runs the seeds.rb file. those are standard rails conventions. https://guides.rubyonrails.org/active_record_migrations.html
fluxAeon has quit [Ping timeout: 250 seconds]
alicef has joined #ruby
za1b1tsu has joined #ruby
za1b1tsu has quit [Ping timeout: 252 seconds]
darkhanb has joined #ruby
sgen has quit [Ping timeout: 240 seconds]
DTZUZO has quit [Ping timeout: 246 seconds]
alicef has quit [Ping timeout: 246 seconds]
chouhoulis has joined #ruby
kapil____ has joined #ruby
lxsameer has quit [Ping timeout: 272 seconds]
apparition has joined #ruby
RougeR has quit [Ping timeout: 272 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
queip has quit [Read error: Connection reset by peer]
queip has joined #ruby
sgen has joined #ruby
white_lilies has joined #ruby
braincrash has quit [Quit: bye bye]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eckhardt has quit [Quit: Textual IRC Client: www.textualapp.com]
alicef has joined #ruby
braincrash has joined #ruby
dviola has quit [Quit: WeeChat 2.3]
alicef has quit [Ping timeout: 246 seconds]
moei has joined #ruby
eckhardt has joined #ruby
eckhardt has quit [Quit: Textual IRC Client: www.textualapp.com]
za1b1tsu has joined #ruby
eckhardt has joined #ruby
za1b1tsu has quit [Ping timeout: 240 seconds]
lytol has quit [Remote host closed the connection]
alicef has joined #ruby
sgen has quit [Ping timeout: 250 seconds]
NightMonkey has quit [Quit: ZNC - http://znc.in]
queip has quit [Read error: Connection reset by peer]
NightMonkey has joined #ruby
queip has joined #ruby
white_lilies has quit [Quit: WeeChat 2.1]
elphe has quit [Ping timeout: 244 seconds]
arescorpio has joined #ruby
ss_much has quit [Quit: Connection closed for inactivity]
za1b1tsu has joined #ruby
donofrio has quit [Remote host closed the connection]
vonfry has joined #ruby
venmx has joined #ruby
elphe has joined #ruby
MoritaShinobu has joined #ruby
elphe has quit [Ping timeout: 240 seconds]
queip has quit [Read error: Connection reset by peer]
queip has joined #ruby
elphe has joined #ruby
vonfry has quit [Quit: WeeChat 2.2]
aspiers has joined #ruby
sgen has joined #ruby
idiocrash has joined #ruby
chouhoulis has quit [Remote host closed the connection]
za1b1tsu has quit [Quit: WeeChat 2.3]
sgen has quit [Ping timeout: 252 seconds]
kapil____ has quit [Quit: Connection closed for inactivity]
rippa has joined #ruby
arescorpio has quit [Remote host closed the connection]
idiocrash has quit [Read error: Connection reset by peer]
idiocrash has joined #ruby
Dbugger has joined #ruby
venmx has quit [Ping timeout: 246 seconds]
idiocras_ has joined #ruby
kapil____ has joined #ruby
idiocrash has quit [Ping timeout: 268 seconds]
sauvin has joined #ruby
queip has quit [Read error: Connection reset by peer]
queip has joined #ruby
idiocrash has joined #ruby
doubledup has joined #ruby
idiocras_ has quit [Ping timeout: 245 seconds]
idiocra__ has joined #ruby
<baweaver> Started breaking Reducing Enumerable into an illustrated novel of sorts - https://medium.com/@baweaver/reducing-enumerable-part-one-the-journey-begins-ddc1d4108490
<baweaver> It'll take a bit, but should make it easier for everyone to read.
doubledup has quit [Client Quit]
idiocrash has quit [Ping timeout: 244 seconds]
elphe has quit [Ping timeout: 252 seconds]
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
elphe has joined #ruby
elphe has quit [Ping timeout: 245 seconds]
idiocra__ has quit [Ping timeout: 240 seconds]
Exuma has joined #ruby
Exuma has quit [Client Quit]
Exuma has joined #ruby
idiocrash has joined #ruby
elphe has joined #ruby
queip has quit [Read error: Connection reset by peer]
elphe has quit [Ping timeout: 272 seconds]
akaiiro has quit [Remote host closed the connection]
nchambers has quit [Quit: WeeChat 2.2]
queip has joined #ruby
Fernando-Basso has joined #ruby
elphe has joined #ruby
elphe has quit [Ping timeout: 244 seconds]
reber has joined #ruby
kaleido has quit [Read error: Connection reset by peer]
elphe has joined #ruby
venmx has joined #ruby
elphe has quit [Ping timeout: 272 seconds]
idiocrash has quit [Read error: Connection reset by peer]
conta has joined #ruby
venmx has quit [Ping timeout: 252 seconds]
lomex has joined #ruby
rrichardsr3 has joined #ruby
idiocrash has joined #ruby
elphe has joined #ruby
venmx has joined #ruby
lomex has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
idiocrash has quit [Read error: Connection reset by peer]
dellavg_ has joined #ruby
venmx has quit [Ping timeout: 245 seconds]
Puffball has quit [Remote host closed the connection]
Exuma has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
queip has quit [Read error: Connection reset by peer]
Fire-Dragon-DoL has quit [Quit: Quit]
queip has joined #ruby
Puffball has joined #ruby
marz_d`ghostman has joined #ruby
Puffball has quit [Remote host closed the connection]
<marz_d`ghostman> Tried creating a config.rb on my project root to declare some application wide constants. The constants defined in it doesn't seem to be accessible by other parts of my application, specifically under /lib. https://gist.github.com/marzdgzmn/e59587818b0046c4b8911a58a5b5fce9
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
Fire-Dragon-DoL has joined #ruby
<marz_d`ghostman> How do I test File.open in rspec?
marz_d`ghostman has quit [Quit: Page closed]
rrichardsr3 has quit [Remote host closed the connection]
whysthatso has joined #ruby
rrichardsr3 has joined #ruby
ShekharReddy has joined #ruby
elphe has quit [Ping timeout: 244 seconds]
queip has quit [Read error: Connection reset by peer]
queip has joined #ruby
doubledup has joined #ruby
elphe has joined #ruby
phaul has joined #ruby
Mike11 has joined #ruby
queip has quit [Read error: Connection reset by peer]
queip has joined #ruby
apparition has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
jthomas has joined #ruby
elphe has quit [Ping timeout: 272 seconds]
jthomas has quit [Ping timeout: 252 seconds]
elphe has joined #ruby
lxsameer has joined #ruby
al2o3-cr has quit [Quit: WeeChat 2.3]
al2o3-cr has joined #ruby
DTZUZO has joined #ruby
rrichardsr3 has quit [Quit: He who dares .... wins.]
queip has quit [Read error: Connection reset by peer]
queip has joined #ruby
anikras has joined #ruby
anikras has left #ruby [#ruby]
AJA4350 has joined #ruby
ShekharReddy has quit [Quit: Connection closed for inactivity]
apparition has joined #ruby
Mike11 has quit [Ping timeout: 244 seconds]
Dbugger has quit [Remote host closed the connection]
DTZUZO has quit [Ping timeout: 264 seconds]
jaddison_ has joined #ruby
LinuxKnight has quit [Remote host closed the connection]
LinuxKnight has joined #ruby
jaddison has quit [Ping timeout: 268 seconds]
lomex has joined #ruby
KQgt0Cl3 has joined #ruby
smutnysyn has joined #ruby
<KQgt0Cl3> Hello all I got a problem it seems I cannot solve :/
DEac- has quit [Quit: leaving]
<smutnysyn> what is it
DEac- has joined #ruby
queip has quit [Read error: Connection reset by peer]
cd has quit [Quit: cd]
<KQgt0Cl3> Returns
<KQgt0Cl3> ./prices.rb:5:in `price': undefined method `read' for "https://www.bitstamp.net/api/v2/ticker/btceur":String (NoMethodError) from ./prices.rb:10:in `<main>'
queip has joined #ruby
<KQgt0Cl3> before I made this into a method it worked fine.
<KQgt0Cl3> I just want to pass the url as a parameter to the method and use it.
<smutnysyn> because what you're passing is a String and there is no such method as String#read
<al2o3-cr> KQgt0Cl3: content = open url, &:read
<KQgt0Cl3> But i want to pass a string
<smutnysyn> I assume you're going to need to crease some sort of URI object first passing the string as param
<smutnysyn> *create
<al2o3-cr> KQgt0Cl3: ang use JSON to parse it.
fredmorcos has joined #ruby
<KQgt0Cl3> Okay, no errors now!!!
<KQgt0Cl3> @al2o3-cr you are awesome!
<KQgt0Cl3> Okay now I have to read and understand what I wrote :P
<KQgt0Cl3> How would I go now and save the output of the method call to a text file?
<KQgt0Cl3> Actually let me try something first ;)
elphe has quit [Ping timeout: 272 seconds]
<KQgt0Cl3> Ah I am such a noob :P
<KQgt0Cl3> File.write("temporary.txt, btceur")
GodFather has joined #ruby
<KQgt0Cl3> ./prices.rb:13:in `write': wrong number of arguments (given 1, expected 2..3) (ArgumentError) from ./prices.rb:13:in `<main>'
<KQgt0Cl3> I am trying another way, pascal style :D
<KQgt0Cl3> worked! :)
<KQgt0Cl3> temporary = File.new("temporary.txt", "w")
<KQgt0Cl3> temporary.write(btcusd)
<KQgt0Cl3> temporary.close
<KQgt0Cl3> ;)
<KQgt0Cl3> Awesome!
lomex has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pskosinski has joined #ruby
KQgt0Cl3 has quit [Ping timeout: 256 seconds]
kapil____ has quit [Quit: Connection closed for inactivity]
asphyxia has quit [Ping timeout: 272 seconds]
Dbugger has joined #ruby
ss_much has joined #ruby
Fernando-Basso has quit [Remote host closed the connection]
queip has quit [Read error: Connection reset by peer]
queip has joined #ruby
KQgt0Cl3 has joined #ruby
<KQgt0Cl3> How can I rename a file to its' hash?
<KQgt0Cl3> I can't find anything about that.
<al2o3-cr> KQgt0Cl3: ?
<KQgt0Cl3> I have a text file named temporary.txt
<KQgt0Cl3> I would like to rename it to it's contents hash
<al2o3-cr> KQgt0Cl3: how are you hashing the file contents?
<KQgt0Cl3> I am thinking of a whatever hashing algorithm
<KQgt0Cl3> is xxHash an option?
<al2o3-cr> KQgt0Cl3: to rename a file use File.rename
<KQgt0Cl3> Oh okay! :)
<KQgt0Cl3> So I should hash it, store the hash into a variable and then rename the file from the content of the variable I guess.
<KQgt0Cl3> That's quite awesome for what I am building :D
<al2o3-cr> KQgt0Cl3: yeah, that would work.
<KQgt0Cl3> I want to store those hashes to a blockchain everytime there is a new file in the directory (therefore everytime a price changes).
<al2o3-cr> so the file contents will be a price?
akem has joined #ruby
fredmorcos has quit [Remote host closed the connection]
im0nde has joined #ruby
<al2o3-cr> KQgt0Cl3: does it matter what hash algorithm?
<KQgt0Cl3> Not really, just something fast.
<KQgt0Cl3> I tried hash=Hash[*File.read(temporary.txt).split("\t")]puts hash
<KQgt0Cl3> Got ./prices.rb:35:in `<main>': undefined method `txt' for #<File:temporary.txt (closed)> (NoMethodError)
<KQgt0Cl3> do I need a require library?
smutnysyn has quit [Read error: Connection reset by peer]
smutnysyn has joined #ruby
<al2o3-cr> KQgt0Cl3: File.rename 'bot.rb', Digest::SHA512.file('temporary.txt').to_s ?
<al2o3-cr> that is using sha512 hash
<al2o3-cr> bot.rb lol, i was testing.
<KQgt0Cl3> bot.rb?
<al2o3-cr> obviously replace bot with temporary.txt
<KQgt0Cl3> :D
<KQgt0Cl3> Awesooooome! :)
<al2o3-cr> KQgt0Cl3: you will need to require openssl though.
<KQgt0Cl3> Why? it seems to work.
<KQgt0Cl3> You mean for the api read?
<KQgt0Cl3> let me paste all my code so far
<KQgt0Cl3> Here you go: https://dpaste.de/84Tw
<al2o3-cr> KQgt0Cl3: just return JSON.parse(open url, &:read)['last'] from price method
<al2o3-cr> don't parse json like that.
<al2o3-cr> KQgt0Cl3: also, that will hash all file contents if that is what you want?
conta has quit [Ping timeout: 272 seconds]
conta has joined #ruby
<KQgt0Cl3> It's not exactly json though
<al2o3-cr> KQgt0Cl3: what it is then?
KQgt0Cl3 has quit [Ping timeout: 256 seconds]
weird_error has joined #ruby
smutnysyn has quit [Ping timeout: 245 seconds]
smutnysyn has joined #ruby
Exuma has joined #ruby
Dbugger has quit [Ping timeout: 250 seconds]
smutnysyn has quit [Read error: Connection reset by peer]
smutnysyn has joined #ruby
kapil____ has joined #ruby
queip has quit [Read error: Connection reset by peer]
queip has joined #ruby
Dbugger has joined #ruby
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
dbugger_ has joined #ruby
whysthatso_ has joined #ruby
Dbugger has quit [Ping timeout: 264 seconds]
Exuma has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
whysthatso has quit [Ping timeout: 260 seconds]
whysthatso_ is now known as whysthatso
knight33_ has joined #ruby
impermanence has quit [Remote host closed the connection]
apparition has quit [Quit: Bye]
venmx has joined #ruby
leah2 has quit [Ping timeout: 268 seconds]
smutnysyn has quit [Ping timeout: 240 seconds]
doubledup has quit [Quit: Leaving]
Exuma has joined #ruby
leah2 has joined #ruby
Exuma has quit [Ping timeout: 246 seconds]
knight33_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
smutnysyn has joined #ruby
Dbugger has joined #ruby
Exuma has joined #ruby
dbugger_ has quit [Ping timeout: 260 seconds]
FastJack has quit [Ping timeout: 264 seconds]
queip has quit [Read error: Connection reset by peer]
akaiiro has joined #ruby
FastJack has joined #ruby
whysthatso_ has joined #ruby
whysthatso has quit [Ping timeout: 264 seconds]
whysthatso_ is now known as whysthatso
queip has joined #ruby
jrhorn424 has joined #ruby
jrhorn424 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gix has joined #ruby
c0ncealed4 has quit [Remote host closed the connection]
c0ncealed4 has joined #ruby
jetchisel has joined #ruby
venmx has quit [Ping timeout: 246 seconds]
venmx has joined #ruby
conta has quit [Remote host closed the connection]
knight33_ has joined #ruby
venmx has quit [Ping timeout: 268 seconds]
MoritaShinobu has quit [Quit: Leaving]
Inline has quit [Read error: Connection reset by peer]
Inline has joined #ruby
bak1an has joined #ruby
queip has quit [Read error: Connection reset by peer]
elphe has joined #ruby
elphe has quit [Ping timeout: 244 seconds]
queip has joined #ruby
RougeR has joined #ruby
akem has quit [Remote host closed the connection]
akem has joined #ruby
troulouliou_div2 has joined #ruby
sgen has joined #ruby
akem has quit [Remote host closed the connection]
akem has joined #ruby
cow[moo] has joined #ruby
cow[moo] has quit [Client Quit]
cow[moo] has joined #ruby
Exuma has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
knight33_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
queip has quit [Read error: Connection reset by peer]
Exuma has joined #ruby
ule has quit [Ping timeout: 252 seconds]
Exuma has quit [Client Quit]
Exuma has joined #ruby
queip has joined #ruby
conta has joined #ruby
BTRE has quit [Ping timeout: 276 seconds]
jrhorn424 has joined #ruby
smutnysyn has quit [Ping timeout: 240 seconds]
bak1an has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ss_much has quit [Quit: Connection closed for inactivity]
smutnysyn has joined #ruby
hiroaki has joined #ruby
elphe has joined #ruby
jaddison_ has quit [Quit: jaddison_]
queip has quit [Read error: Connection reset by peer]
elphe has quit [Ping timeout: 245 seconds]
jrhorn424 is now known as jrhorn424_away
jrhorn424_away has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
akaiiro has quit [Remote host closed the connection]
queip has joined #ruby
Freshnuts has joined #ruby
conta has quit [Quit: conta]
troulouliou_div2 has quit [Read error: Connection reset by peer]
nchambers has joined #ruby
dviola has joined #ruby
SeepingN has joined #ruby
ivanskie has joined #ruby
leah2 has quit [Ping timeout: 264 seconds]
RougeR has quit [Ping timeout: 252 seconds]
akem has quit [Read error: Connection reset by peer]
leah2 has joined #ruby
houhoulis has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
teardown has joined #ruby
ivanskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jyaworski has quit [Quit: ZNC - http://znc.in]
ivanskie has joined #ruby
hiroaki has quit [Ping timeout: 252 seconds]
Eiam has quit [Ping timeout: 250 seconds]
Dbugger has quit [Ping timeout: 252 seconds]
desperek has joined #ruby
agrecascino has quit [Ping timeout: 245 seconds]
raulp has quit [Quit: raulp]
raulp has joined #ruby
smutnysyn has quit [Ping timeout: 264 seconds]
hiroaki has joined #ruby
elphe has joined #ruby
houhoulis has quit [Ping timeout: 268 seconds]
lomex has joined #ruby
elphe has quit [Ping timeout: 252 seconds]
smutnysyn has joined #ruby
queip has quit [Read error: Connection reset by peer]
knight33_ has joined #ruby
lomex has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
knight33_ has quit [Client Quit]
knight33_ has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
lomex has joined #ruby
queip has joined #ruby
pskosinski has quit [Quit: No Ping reply in 180 seconds.]
pskosinski has joined #ruby
lomex has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lomex has joined #ruby
lomex has quit [Client Quit]
knight33_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Guest24308 has quit [Ping timeout: 252 seconds]
ivanskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
elphe has joined #ruby
hiroaki has quit [Ping timeout: 252 seconds]
elphe has quit [Ping timeout: 252 seconds]
knight33_ has joined #ruby
elphe has joined #ruby
smutnysy1 has joined #ruby
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
smutnysyn has quit [Ping timeout: 246 seconds]
Yxhuvud has joined #ruby
elphe has quit [Ping timeout: 268 seconds]
ua_ has joined #ruby
ua has quit [Ping timeout: 246 seconds]
reber has quit [Remote host closed the connection]
bak1an has joined #ruby
<nchambers> what does the <=> operator do?
<phaul> it's the 3 way compare returns -1, 0, 1 for less than equal or greater than
<phaul> useful to implement Comparable
<phaul> &ri Comparable
<nchambers> ah that makes sense. thanks
<phaul> sometimes you see this trick: [:equal, :greater, :less][5 <=> 3] # => :greater
<phaul> &>> [:equal, :greater, :less][5 <=> 3]
<rubydoc> # => :greater (https://carc.in/#/r/5jtp)
<nchambers> heh
<phaul> it's abusing the -1 index of the array...
<phaul> I saw it on codewars once..
<nchambers> yeah, i like that trick
weaksauce has joined #ruby
asphyxia has joined #ruby
<al2o3-cr> &>> [*0..1_000_000].bsearch_index { |i| i <=> 50_000 }
<rubydoc> # => (https://carc.in/#/r/5juw)
Exuma has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dellavg_ has quit [Ping timeout: 252 seconds]
<al2o3-cr> now revrese that.
Guest24308 has joined #ruby
<al2o3-cr> &>> [*0..1_000_000].bsearch_index { |i| 50_000 <=> i }
<rubydoc> # => (https://carc.in/#/r/5jv0)
<al2o3-cr> binary search (left middle right)
whysthatso has quit [Ping timeout: 252 seconds]
<al2o3-cr> left = -1, middle = 0, right = 1
<al2o3-cr> left = <, middle ==, right = >
elphe has joined #ruby
queip has quit [Read error: Connection reset by peer]
<phaul> &>> [*0..1_000_000].last
<rubydoc> # => (https://carc.in/#/r/5jvo)
<phaul> probably that's as slow as with or without the bsearch :)
kapil____ has quit [Quit: Connection closed for inactivity]
<al2o3-cr> phaul: not a chance.
<phaul> I was just saying the bot times out for all..
<phaul> and that's not bsearch's fault
<al2o3-cr> phaul: probably ram limited.
<al2o3-cr> &>> [*0..1_000].bsearch_index { |i| 345 <=> i }
<rubydoc> # => 345 (https://carc.in/#/r/5jw2)
<al2o3-cr> &>> [*0..1_000].index 345
<rubydoc> # => 345 (https://carc.in/#/r/5jw4)
queip has joined #ruby
<al2o3-cr> i'd say bindex is faster.
samort7 has joined #ruby
<al2o3-cr> probably not by much.
<phaul> binary chpping is faster, I never disputed that, quite the contrary
<al2o3-cr> phaul: there won't be much.
<al2o3-cr> fuck it, i'm gonna say index is faster.
<phaul> yesterday I failed to predict how Hash behaves in terms of perfomance so I'm already losing this game, btw did you see that? I'm still buffled why Hash behaves like the way it does...
lunarkitty7 has quit [Ping timeout: 260 seconds]
<phaul> why is Hash#first signifacntly slower than ~ 1.5x times than pulling the first elem by key?
<phaul> makes 0 sense. but that's the way it does ( did not confirm myself )
<al2o3-cr> phaul: coz more c is goiing on.
<al2o3-cr> phaul: you got pry?
<phaul> I have pry. why?
<al2o3-cr> phaul: check $ Hash#first and $ Hash#[]
Puffball has joined #ruby
<al2o3-cr> phaul: then you will understand.
<al2o3-cr> phaul: install pry-doc
<al2o3-cr> ?pry phaul
<ruby[bot]> phaul: Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (https://pryrepl.org/): gem install pry pry-doc
bmurt has joined #ruby
<phaul> al2o3-cr: I have been using pry, I know it. I prefer gvim with rbtools when I can use it, by also use pry for a repl..
darkhanb has quit [Ping timeout: 244 seconds]
<phaul> this still doesn't explain why Hash works like that, but I guess one would have to profile MRI to get an actual answer
Guest24308 has quit [Ping timeout: 272 seconds]
bmurt has quit [Client Quit]
<phaul> still really counter intuitive to me
<phaul> I know hash has some tricks to make small sizes faster. but the example was like 1000 element Hash. I don't expect 1000 element hash key lookup to beat #first. but still it does.
<phaul> maybe it's just that Enumerable #first is cr*p that Hash is including and creates temporary objects and such
jaddison has joined #ruby
smutnysy1 has quit [Read error: Connection reset by peer]
smutnysy1 has joined #ruby
jrhorn424 has joined #ruby
leitz has joined #ruby
im0nde has quit [Quit: im0nde]
Guest24308 has joined #ruby
Exuma has joined #ruby
|aaron has joined #ruby
Exuma has quit [Client Quit]
jrhorn424 is now known as jrhorn424_away
Exuma has joined #ruby
<|aaron> Is there any different between `if obj['my_attribute']` and `if obj.attribute?('my_attribute')`? Which should I prefer?
<phaul> as far as ruby goes those are completely different things. One does not mean the other would work
<phaul> what library framework are you using
<|aaron> uhh well im writing chef recipes. sorry really new to ruby
desperek has quit [Quit: xoxo]
<|aaron> so is it that the first construct tests if its defined AND isnt nil? and the second only tests if it exists (but could be nil)?
houhoulis has joined #ruby
<phaul> Ruby the language is much more flexible. I don't know anything about chef. the first invokes [] method on obj and thatcould do anything. The second invokes attribute? method on obj and thatcould do anyting
<|aaron> ahhh i see
<|aaron> yeah attribute ios a helper method provided by this particular Chef object apparently
bak1an has quit [Ping timeout: 240 seconds]
leitz has quit [Quit: Leaving]
jaddison has quit [Quit: jaddison]
queip has quit [Read error: Connection reset by peer]
bak1an has joined #ruby
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cajone has joined #ruby
bak1an has quit [Quit: Textual IRC Client: www.textualapp.com]
cajone has left #ruby [#ruby]
sgen has quit [Ping timeout: 252 seconds]
smutnysy1 has quit [Ping timeout: 268 seconds]
lxsameer has quit [Ping timeout: 272 seconds]
queip has joined #ruby
ss_much has joined #ruby