#ruby - 17 November 2018
« Back 1 day Forward 1 day »
[00:03:40] 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
[00:05:39] jayjo: are they defined anywhere? Is there a file or config that says db:seed -> run db/seeds.rb ?
[02:26:06] 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
[06:46:50] baweaver: Started breaking Reducing Enumerable into an illustrated novel of sorts - https://medium.com/@baweaver/reducing-enumerable-part-one-the-journey-begins-ddc1d4108490
[08:47:24] 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
[12:45:10] 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>'
[12:47:14] smutnysyn: because what you're passing is a String and there is no such method as String#read
[12:48:14] smutnysyn: I assume you're going to need to crease some sort of URI object first passing the string as param
[13:02:02] KQgt0Cl3: ./prices.rb:13:in `write': wrong number of arguments (given 1, expected 2..3) (ArgumentError) from ./prices.rb:13:in `<main>'
[13:51:29] 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.
[13:52:36] KQgt0Cl3: I want to store those hashes to a blockchain everytime there is a new file in the directory (therefore everytime a price changes).
[14:00:46] KQgt0Cl3: Got ./prices.rb:35:in `<main>': undefined method `txt' for #<File:temporary.txt (closed)> (NoMethodError)
[22:52:11] 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...
[22:53:28] phaul: why is Hash#first signifacntly slower than ~ 1.5x times than pulling the first elem by key?
[23:01:03] 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
[23:03:31] 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..
[23:05:57] 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
[23:08:12] 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.
[23:10:04] phaul: maybe it's just that Enumerable #first is cr*p that Hash is including and creates temporary objects and such
[23:30:28] |aaron: Is there any different between `if obj['my_attribute']` and `if obj.attribute?('my_attribute')`? Which should I prefer?
[23:31:39] phaul: as far as ruby goes those are completely different things. One does not mean the other would work
[23:33:25] |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)?
[23:34:40] 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
[23:35:44] |aaron: yeah attribute ios a helper method provided by this particular Chef object apparently