Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 04:15
    HertzDevil synchronize #11230
  • Dec 05 22:07
    rymiel labeled #11542
  • Dec 05 22:07
    rymiel opened #11542
  • Dec 05 17:34
    Blacksmoke16 labeled #11541
  • Dec 05 15:27
    Blacksmoke16 closed #5636
  • Dec 05 14:01
    asterite labeled #11541
  • Dec 05 14:01
    asterite opened #11541
  • Dec 05 10:11
    straight-shoota milestoned #11539
  • Dec 05 04:46
    jgaskins opened #11540
  • Dec 04 22:54
    straight-shoota closed #11437
  • Dec 04 20:54
    BlobCodes synchronize #11211
  • Dec 04 20:51
    BlobCodes synchronize #11211
  • Dec 04 20:46
    BlobCodes synchronize #11211
  • Dec 04 17:55
    HertzDevil synchronize #11230
  • Dec 04 17:46
    BlobCodes synchronize #11211
  • Dec 04 17:44
    BlobCodes synchronize #11211
  • Dec 04 17:37
    BlobCodes synchronize #11211
  • Dec 04 16:10
    HertzDevil edited #11537
  • Dec 04 15:06
    HertzDevil synchronize #11230
  • Dec 04 15:03
    HertzDevil synchronize #11230
George Dietrich
@Blacksmoke16
oh, or maybe it just doesnt know how to resolve deps like that? i never used it so ill defer to someone else
From IRC (bridge bot)
@FromIRC
<mfiano> That's out of the require path, in src. without a relative path it should only be looking in the stdlib or "lib"
<mfiano> so hmm
<mfiano> Ha you're right
George Dietrich
@Blacksmoke16
:ok_hand:
From IRC (bridge bot)
@FromIRC
<mfiano> and shards install makes a lib/debug/...
<mfiano> Renaming the above gist to debug2.cr and it works
<mfiano> how odd
<mfiano> I just have to keep in mind that I shouldn't have local files with the same name as 3rd party library directories or something
George Dietrich
@Blacksmoke16
pretty much yea
From IRC (bridge bot)
@FromIRC
<mfiano> nah that actually works fine. it seems to be a bug in that the errors in nvim's LSP are cached and not properly invalidated, even across restarts...
Jason Waldrip
@jwaldrip
Why would @type.subclasses return an empty list?
require "json"
require "yaml"

module Pyrite::Kubernetes
  abstract class Spec
    include ::JSON::Serializable
    include ::YAML::Serializable

    macro def_parser
      macro finalized
        {% if @type.abstract? %}
          {% puts @type.subclasses %}
          def self.new(pull : JSON::PullParser)
            location = pull.location

            {% begin %}
              string = pull.read_raw
              {% for subtype in @type.subclasses %}
                begin
                  return {{type}}.from_json(string)
                rescue JSON::ParseException
                  # Ignore
                end
              {% end %}
              raise JSON::ParseException.new("Couldn't parse #{self} from #{string}", *location)
            {% end %}
          end
        {% end %}
      end
    end

    macro inherited
      def_parser
    end

    def_parser
  end
end
is there a point in compilation where I have access to the subclasses?
George Dietrich
@Blacksmoke16
Try adding a \
\{% puts @type.subclasses %}
Jason Waldrip
@jwaldrip
there we go
Jason Waldrip
@jwaldrip
ya, i am very familiar... just been awile
too much time in elixir lately
❯ psykube status --cluster dev
NAME                    STATUS     RESTARTS    AGE
api-665c77fbb9-2dlk9    Running    0           23h2m
api-665c77fbb9-nwmx8    Running    0           23h1m
api-665c77fbb9-rjp6k    Running    0           23h1m
there we go
Jason Waldrip
@jwaldrip
Are there good examples of how the with syntax works with blocks
the docs are pretty bare on it
George Dietrich
@Blacksmoke16
def foo(&)
  with -1 yield
end

foo do
  puts abs # => 1
end
which is similar to
def foo(&)
  yield -1
end

foo do |v|
  puts v.abs
end
Jason Waldrip
@jwaldrip
Whats the ETA on 1.1.0 docker containers?
George Dietrich
@Blacksmoke16
technically you could prob just use nightly in the meantime
if you'd be ok with it being rebuilt every night ofc
Jason Waldrip
@jwaldrip
what about the 1.1-dev?
George Dietrich
@Blacksmoke16
mm that might be the pre-release? id go with that
ryanprior
@ryanprior:matrix.org
[m]
I'd like to write data to sqlite & read it back again from query results, all without writing custom serialization code. I like how JSON::Serializable works and would like something similar. Any suggestions?
emanzx
@emanzx
hi again..

Showing last frame. Use --error-trace for full trace.

In configs_wather.cr:60:27

60 | if change.includes?(monitor_path)
^--------
Error: no overload matches 'String#includes?' with type (Hash(String, String) | String)

Overloads are:

  • String#includes?(search : Char | String)
    Couldn't find overloads for these types:
  • String#includes?(search : Hash(String, String))
I always encounter this error in crystal and most of the solutions are tries and error..
I have a hash like this.
```
configs = {"bind_conf" => {"path" => "/usr/home/system/configs/bind", "ext" => "conf", "cmd" => {"exec" => "rndc", "args" => "reconfig"}}, }
if File.file?("#{watch_log_path}")
        File.each_line("#{watch_log_path}") do |line|
        split_line = line.split(" ")
        file_path = split_line[0] + split_line[2]
        file_extension = split_line[2].split(".").last if split_line[2].split(".").size > 1
        events[file_path] = {"file_name" => split_line[2], "event" => split_line[1], "ext" => file_extension}
        end
        #cleanup the file after read
        File.open "#{watch_log_path}", "w+" { }
    end
    #dynamic event processing begin below.
    #copy the event and clean up the current.
    process_events = events.clone                                                        
    events.clear
    configs.each do |job,param|
        puts "Processing #{job}"
        process_events.each do |change, event_params|
            monitor_path = param["path"]
            if change.includes?(monitor_path)
                puts "Processing change #{change}"
            end 
        end
    end
Taupiqueur
@alexherbo2
can I use return if I yield instead of block.call?
emanzx
@emanzx
does crystal implement catch and throw like in ruby to handle nested loop?
From IRC (bridge bot)
@FromIRC
<jhass[m]> no
<jhass[m]> I never ever needed that feature in Ruby either and always found any usages of it I found strange and hard to follow
From IRC (bridge bot)
@FromIRC
<mfiano> How can I define a generic struct with all of its fields being of type T (homogeneous), where T is restricted to Float32 or Float64?
From IRC (bridge bot)
@FromIRC
<jhass[m]> We don't support restricting type variables yet. A hack is to check the type in macro land using https://carc.in/#/r/bk8d
<mfiano> :⁠( Thanks
From IRC (bridge bot)
@FromIRC
<xyhuvud> shouldn't it be possible by setting type restrictions on the constructors though?
George Dietrich
@Blacksmoke16
you could, but then you end up with a union of the two
manveru
@manveru:matrix.org
[m]
is there some trick to using @type.instance_vars in a module to get the variables of a class that it was included into?