« first day (1441 days earlier)      last day (1814 days later) » 

 
13 hours later…
2:40 PM
Good morningv!
 
2:54 PM
good morning Quincosa...been awhile!
 
Yeah lol havent jumped on here in some time
Hows everything?
 
not dead i guess :)
 
LMFAO thats always a good thing
Have you ever used the will_paginate gem?
 
3:34 PM
Good morning, all.
 
oh yea, i use it in like 12 projects
i haven't had to do much with it besides just plopping down different parameters in each one to run multiple lists on one page
hi Wayne
 
3:51 PM
hey
was having small issue but got it
hahah
 
4:14 PM
I have to go buy a car sorry :(
 
4:30 PM
All good!
 
 
3 hours later…
7:23 PM
Oh boy. Set#to_s is sooo useful
 
8:16 PM
Haha. True!
Set#inspect works, of course, but you know that.
 
It failed for me because of what I was storing there
Now I'm solving a mystery of two Object hashes, each lower than -2**32, summing up to a positive number
 
That sounds interesting.
It sounds like underflow in a 32-bit signed integer, but I'm curious how you got Ruby to do that.
 
Observed outside of irb only (so far?)
the result is correct modulo 2**32
 
The smallest signed 32-bit integer should be -(2 ** 31). You mentioned -(2 ** 32). Is "32" instead of "31" a typo?
 
8:32 PM
ah, my mistake. I just took the value modulo 2**32 and it produced a positive value.
rechecking them shows them to be in the valid range for int32
with their sum being outside the int32 range
 
irb(main):001:0> 1000.times{a=Object.new.hash; b=Object.new.hash; raise [a, b, a+b].to_s if a<0 && b<0 && a+b>0}
RuntimeError: [-732720952, -1593851257, 1968395087]
but... they always seem to commute.
 
Does not reproduce for ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
 
irb(main):007:0> 1000000.times{a=Object.new.hash; b=Object.new.hash; raise [a, b, 0+a+b, 0+b+a].to_s if 0+a+b != 0+b+a}
RuntimeError: [-1716726456, -522735162, -2239461618, 2055505678]
irb(main):008:0> `ruby -v`
=> "ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]\n"
 
No change if you replace .to_s with .inspect, right? I don't think there will be a change, but I trust #inspect more.
 
8:39 PM
Same thing. Besides, to_s shouldn't even be invoked
 
@JohnDvorak Does not reproduce for me using ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
 
Windows-only?
 
What type is Object.new.hash for you? For me it's Integer
 
same here
Good thing to check
 
-(2**31-1) + -(2**31-1)
 => -4294967294
 
8:43 PM
This works fine for me
 
-732720952 + -1593851257
 => -2326572209
 
Taking the values that my iteration above found and copy-pasting them back into the interpreter produces the correct sums
 
Curiouser and curiouser
I'm starting to think of some code that's monkey-patched integer addition, or weirder.
@JohnDvorak Does this reproduce in a brand new irb session that does no require or load statements?
 
yes
irb(main):001:0> 1000000.times{a=Object.new.hash; b=Object.new.hash; raise [a, b, 0+a+b, 0+b+a].inspect if 0+a+b != 0+b+a}
RuntimeError: [1778366198, 486890643, 2265256841, -2029710455]
 
That's so very strange.
 
8:49 PM
irb(main):002:0> 1000000.times.count{a=Object.new.hash; b=Object.new.hash; 0+a+b != 0+b+a}
=> 84100
stable to within a percent
 
Why the zero terms?
 
statistical fluke. Further runs provide non-zero terms
 
I mean, why do the expressions include 0+?
 
a+b == b+a doesn't reproduce the issue
 
Weird.
 
8:52 PM
My code uses self.map(&:hash).reduce(0, &:+)
 
@JohnDvorak Does not reproduce in ruby 1.8.7 (2014-01-28 patchlevel 376) [x86_64-linux], nor ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
@JohnDvorak I ask this next Q not because it has anything to do with this anomaly, but as a curiosity: Why are you summing hashes?
 
I'm trying to put an unordered pair of objects into a Set, then poll the set for a fresh pair of the same two objects
 
Got it.
 
since the pair is a custom class that inherits from Array, it needs to override hash
 
It should also redefine equality.
(but if you haven't, that's not the cause of this anomaly)
 
8:58 PM
@Shane Hammock you need to create a separate view file depending on conditon
 
  def ==(other); (self[0] == other[0] && self[1] == other[1]) || (self[0] == other[1] && self[1] == other[0]); end
  alias eql? ==
 
Looks fine.
 
But Set doesn't even consider looking at equality if the hashes don't match
 
Yes.
 
even if they match modulo 2**32
should I post bug report to the Ruby tracker?
 
9:05 PM
I don't know that it's a bug you've found.
Are the elements of your hash ordered? That is, do they respond to <=> ?
 
They are ... Integers. I don't have a Hash, just Object#hash-es
 
class UnorderedKey
  def initialize(a)
    @a = a
  end

  def hash
    ordered.hash
  end

  def ==(other)
    return false unless other.is_a?(self.class)
    ordered == other.ordered
  end
  alias_method :eql?, :==

  protected

  def ordered
    @a.sort
  end
end
require "set"
s = Set.new
s << UnorderedKey.new([1, 2])
p s.include?(UnorderedKey.new([2, 1]))    # => true
p s.include?(UnorderedKey.new([2, 3]))    # => false
This doesn't solve the anomaly... just another way to look at the problem.
 
Sorting self before a hash or == would bypass the issue, yes
 
Yeah, I think I'd report it. It's very surprising behavior.
 
irb(main):004:0> 1000000.times.count{a=Object.new.hash+0; b=Object.new.hash+0; 0+a+b != 0+b+a}
=> 0
I'll see if it still reproduces in 2.4.3
 
9:19 PM
Hey guys
quick question, do you guys know a way to have a dynamic root that changes depending on a field in the database.. but the important part is that the path in the address bar remains the same like "app.localhost:3000" regardless of where they are
 
As for the pair members - they have a unique key. It isn't stable, but it is stable enough if I sort before each comparison.
If you mean the URL root for relative URLs on a page - that can be set as far as the browser is concerned, but I'm curious why. Not sure if Rails provides support for this.
 
@JohnDvorak A user can have many projects in the software and if the add one project as their favorite i want them to come into "app.example.io" and be in the project they are editing instead of "app.example.io/projects/:project_id"
thanks for the help John
 
Or rather, if Rails let you set the root from code, it probably doesn't care where it comes from
@WayneConrad Problem: I can't reproduce it in 2.4.3
Should I report anyways?
maybe it's caused by i386-mingw32 (current) vs. x64-mingw32 (2.4.1, reproduces)
Yeah, I've installed the 32-bit version by accident, and it doesn't reproduce the issue
... now it insists to run instead of the 64-bit version that I've installed just afterwards.
 
9:44 PM
@JohnDvorak I'd say not report. Work around, and put in a version check that will raise a "this workaround no longer needed" warning after Ruby is upgraded.
 
Now I have a new problem: after "manually uninstalling" the 32-bit version, powershell no longer recognizes the 64-bit version. It can still launch ruby scripts in a new console.
Fixed. No idea why the installer didn't update PATH.
 

« first day (1441 days earlier)      last day (1814 days later) »