Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 08 23:04
    HertzDevil edited #12623
  • Dec 08 22:57
    Blacksmoke16 edited #9745
  • Dec 08 22:57
    Blacksmoke16 labeled #9745
  • Dec 08 22:57
    Blacksmoke16 labeled #9745
  • Dec 08 22:54
    HertzDevil labeled #12828
  • Dec 08 22:54
    HertzDevil labeled #12828
  • Dec 08 22:54
    HertzDevil opened #12828
  • Dec 08 22:34
    straight-shoota edited #12827
  • Dec 08 22:32
    straight-shoota edited #12827
  • Dec 08 22:29
    straight-shoota labeled #12827
  • Dec 08 22:29
    straight-shoota labeled #12827
  • Dec 08 22:29
    straight-shoota opened #12827
  • Dec 08 22:15
    straight-shoota closed #12814
  • Dec 08 17:12
    straight-shoota assigned #12814
  • Dec 08 17:12
    straight-shoota assigned #12813
  • Dec 08 17:12
    straight-shoota assigned #12809
  • Dec 08 17:12
    straight-shoota assigned #12802
  • Dec 08 17:12
    straight-shoota assigned #12797
  • Dec 08 17:12
    straight-shoota assigned #12664
  • Dec 08 17:12
    straight-shoota assigned #12765
George Dietrich
@Blacksmoke16
that works too
From IRC (bridge bot)
@FromIRC
<riza> I considered doing macro inherited ... extend ClassMethods ... too
<riza> if that's what you mean
<riza> maybe I like that better
<riza> that seems to produce a compiler message at an earlier phase of compilation
<riza> before code pruning or something
George Dietrich
@Blacksmoke16
:thumbsup:
George Dietrich
@Blacksmoke16
what time are nightly images pushed?
ddd
@Dan-Do
How to temporary use another CRYSTAL_PATH when running crystal build ...?
George Dietrich
@Blacksmoke16
for what reason?
CRYSTAL_PATH=/path/you/want crystal build would do it tho
ddd
@Dan-Do
Thnx, just see the new parameter of Int.to_s(base, *, precision, and want to test it :)
George Dietrich
@Blacksmoke16
:thumbsup:
ddd
@Dan-Do
why 0 is understood as true in this example? https://carc.in/#/r/c0lb
George Dietrich
@Blacksmoke16
it's a truthy value
ddd
@Dan-Do
:thumbsup:
spTorin
@spTorin
a = 1_000_000_000
puts a.humanize_bytes(format: :IEC)
puts a.humanize_bytes(format: :JEDEC)

0.93GiB
0.93GB
why IEC not puts 1GiB?
From IRC (bridge bot)
@FromIRC
<riza> I think that a GiB is actually 1_073_741_824 B
George Dietrich
@Blacksmoke16
@jgaskins what's the status of the OTLP shard you were working on?
spTorin
@spTorin
@riza but one of them must be derivation of 10^3. In your link:
one gibibyte 1 GiB = 2^30 B = 1 073 741 824 B
one gigabyte 1 GB = 10^9 B = 1 000 000 000 B
In crystal docs:
This method by default uses the IEC standard prefixes (Ki, Mi, Gi, Ti, Pi, Ei, Zi, Yi) based on powers of 1000
spTorin
@spTorin
And if you want get result based on powers of 1000, must use:
puts 1_000_000_000.humanize(base: 1000)   #=> 1.0G
Sean Gregory
@skinnyjames

Hey all
I'm trying to dynamically raise Exceptions from a macro, but when I instantiate the subclassed exception with a message, I get this error:
Error: wrong number of arguments for 'Exception#initialize' (given 1, expected 2)

Can anyone see what i'm doing incorrectly?

 macro generate_error_handling(klass_map)
      {% for klass in klass_map.values %}
        class {{ klass }} < Exception; end
      {% end %}

      private def handle_error(body)
        if body["value"]? && body["value"].as_h? && body["value"]["error"]?
          error = body["value"]
          clazz = {{ klass_map }}[error["error"]?]
          if clazz
            raise clazz.new(error["message"].as_s) 
          end
        end
      end
    generate_error_handling(
    {
      "invalid selector" => InvalidSelectorException,
      "no such element" => ElementNotFoundException,
      "invalid argument" => InvalidArgumentException,
      #...
    })
George Dietrich
@Blacksmoke16
can you make a playground link that reproduces it?
Sean Gregory
@skinnyjames
I think so!
George Dietrich
@Blacksmoke16
i think the compiler gets the typing of the hash messed up
can re-write that part to be a case and should work fine
def handle_error(error)
  {% begin %}
    case error
      {% for k, v in klass_map %}
       when {{k}} then raise {{v}}.new(error)
      {% end %}
    end
  {% end %}
end
Sean Gregory
@skinnyjames
ah cool.
thanks!
George Dietrich
@Blacksmoke16
pp !!clazz && clazz.is_a?(Exception) # => false
Sean Gregory
@skinnyjames
this will likely be a little less performant right?
I can make the hashmap an array instead if that's easier
George Dietrich
@Blacksmoke16
probably negligible, no that would be worse i think
Sean Gregory
@skinnyjames
ah okay
George Dietrich
@Blacksmoke16
could benchmark it if you want, but i prob wouldn't worry about it too much
ofc it's all moot if you remove the need to convert arbitrary strings into exceptions. i.e. if you already know that you want to raise an unknown method exception because of the string, could just do raise UnknownMethodException.new versus going thru the case at all
but i assume there is more to it than this example?
Sean Gregory
@skinnyjames
definitely did the trick!
i was originally iterating, but I'm just being lazy
Sean Gregory
@skinnyjames

almost ready to beta my project!
https://github.com/skinnyjames/webdriver

It's a w3c compliant OO webdriver that pulls from the Watir api

George Dietrich
@Blacksmoke16
nice one!
Sean Gregory
@skinnyjames
thanks! I'm pretty excited. I've been looking at ruby's Spinach library, and I would like to implement a similar test runner in Crystal
George Dietrich
@Blacksmoke16
sounds like quite the challenge
Sean Gregory
@skinnyjames
yeah, I'll probably be bugging you all a little bit :)
Crystal is definitely my favorite language, so I hope that testing can be a bit more first class
George Dietrich
@Blacksmoke16
in regards to E2E testing you mean?