Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 03:41
    Blacksmoke16 edited #12393
  • 01:59
    Blacksmoke16 edited #12393
  • 01:57
    Blacksmoke16 edited #12393
  • 01:57
    Blacksmoke16 edited #12393
  • 01:49
    Blacksmoke16 labeled #12393
  • 01:49
    Blacksmoke16 labeled #12393
  • 01:49
    Blacksmoke16 labeled #12393
  • 01:49
    Blacksmoke16 opened #12393
  • 01:09
    phil294 edited #12392
  • 01:08
    phil294 edited #12392
  • 01:07
    phil294 edited #12392
  • 01:00
    phil294 edited #12392
  • 00:58
    phil294 edited #12392
  • 00:58
    phil294 edited #12392
  • 00:57
    phil294 edited #12392
  • 00:56
    phil294 edited #12392
  • 00:55
    phil294 labeled #12392
  • 00:55
    phil294 opened #12392
  • Aug 15 23:55
    HertzDevil labeled #12391
  • Aug 15 23:55
    HertzDevil labeled #12391
From IRC (bridge bot)
@FromIRC
<Sankalp> Perhaps something like this: Digest::MD5.digest
<frojnd> Thank you
George Dietrich
@Blacksmoke16
frojnd: Digest::MD5.digest &.file(file_path)
From IRC (bridge bot)
@FromIRC
<frojnd> @Blacksmoke16 yes, it prints in bytes e.g.: => Bytes[60, 215, 160, 219, 118, 255, 157, 202, 72, 151, 158, 36, 195, 155, 64, 140] I need hex, so Digest::MD5.hexdigest(file) prints in hex: "3cd7a0db76ff9dca48979e24c39b408c"
<frojnd> Or just: Digest::MD5.hexdigest &.file("./bla.txt")
<frojnd> What's called &. after hexdigest?
George Dietrich
@Blacksmoke16
its the same as like Digest::MD5.hexdigest { |ctx| ctx.file "./bla.txt" }
From IRC (bridge bot)
@FromIRC
<frojnd> Ok
<frojnd> What's this called? Semanticlly?
From IRC (bridge bot)
@FromIRC
<frojnd> s/Semantically/semantically
<frojnd> Ah blocks and procs
<frojnd> While I'm here, What's the meaning of :: e.g. inside Digest::MD5
<frojnd> https://crystal-lang.org/api/1.3.2/Digest/MD5.html It says: Class Digest::MD5
George Dietrich
@Blacksmoke16
i dont think its ever explicitly called out anywhere, but its the same as ruby
From IRC (bridge bot)
@FromIRC
<frojnd> Thank you
Ramakrishnan Vasantha Gopal
@vgramkris
hi, is there any ways to check if a channel is empty w/o calling receive?
Hayden Jones
@wrq

https://carc.in/#/r/d3fx

with large enums, should crystal have a cap on trying to expand cases for exhaustive case?

It's trying to enumerate 308915776 cases here, just as an example
George Dietrich
@Blacksmoke16
@vgramkris i dont think there is. But could probably use select to handle the case where there is no value ready to be consumed. E.g. https://lbarasti.com/post/select_statement/#non-blocking-channel-operations
Ramakrishnan Vasantha Gopal
@vgramkris
thanks George, let me check that
claytoneast
@claytoneast

Hello, I have a type-narrowing question. I have the following code:

  tweets.each do |tweet|
    if tweet.referenced_tweets
      parent_tweet = tweet.referenced_tweets.first
      # do stuff
    end
  end

When I run crystal build, I get the following error:

271 | parent_tweet = tweet.referenced_tweets.first
                                              ^----
Error: undefined method 'first' for Nil (compile-time type is (Array(ReferencedTweet) | Nil))

I'm a little confused, since according to the crystal docs as I understand them here https://crystal-lang.org/reference/1.4/syntax_and_semantics/if_var.html, I've already ruled out the possibility of .referenced_tweets being nil by the check if tweets.referenced_tweets. I additionally tried with if !tweets.referenced_tweets.nil?, and I get the same problem.

What am I missing here?

tl;dr the 2nd half of that page :P
claytoneast
@claytoneast
:facepalm: wish I'd actually learned how to read. Thank you!!
Jonathan Silverman
@mixflame
How do I remove the dependency on Sqlite from the amber crystal heroku build?
George Dietrich
@Blacksmoke16
sqlite is a dep of the framework itself, (and so are the other two drivers for some reason?) so in short i dont think you can
From IRC (bridge bot)
@FromIRC
<dukester> Noob here! Just installed crystal. created hello/cr for 45bytes. ran crystal build hello.cr and got hello for 1745560bytes
<dukester> Why so huge? Can it be trimmed down?
George Dietrich
@Blacksmoke16
add --no-debug
tl;dr its the stdlib
From IRC (bridge bot)
@FromIRC
<dukester> ok will do l8r
George Dietrich
@Blacksmoke16
you can override what is required by default, but its not really designed to be piecemilled
as there are a lot of interdependencies
From IRC (bridge bot)
@FromIRC
<dukester> re-compiled! now 1441272bytes. better but not great.
George Dietrich
@Blacksmoke16
:shrug: is what it is. its not really that big either
From IRC (bridge bot)
@FromIRC
<dukester> ok thanks!
From IRC (bridge bot)
@FromIRC
<dukester> re-compiled hello.cr and used --release --no-debug. trimmed hello to 491960. Much better! I may like this lang after all. :⁠)
George Dietrich
@Blacksmoke16
could prob get a bit more via strip ./hello
but yea, as called out in that thread, its not really a big deal the majority of the time
From IRC (bridge bot)
@FromIRC
<dukester> I'll try it.
<dukester> after strip = 426264. I'm happy. Thx ...
George Dietrich
@Blacksmoke16
:thumbsup:
From IRC (bridge bot)
@FromIRC
<dukester> l8r