Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 15:09
    straight-shoota milestoned #11334
  • 15:09
    straight-shoota labeled #11334
  • 15:09
    straight-shoota labeled #11334
  • 15:09
    straight-shoota labeled #11334
  • 15:05
    beta-ziliani edited #11334
  • 15:04
    beta-ziliani synchronize #11334
  • 14:59
    straight-shoota labeled #11331
  • 14:59
    maxfierke closed #11329
  • 14:52
    straight-shoota synchronize #11317
  • 14:49
    straight-shoota edited #11316
  • 14:46
    straight-shoota labeled #11335
  • 14:46
    straight-shoota unlabeled #11335
  • 14:29
    mishushakov opened #11335
  • 14:29
    mishushakov labeled #11335
  • 14:21
    beta-ziliani opened #11334
  • 13:35
    straight-shoota synchronize #11317
  • 13:30
    straight-shoota assigned #11318
  • 13:25
    straight-shoota milestoned #11318
  • 13:03
    straight-shoota labeled #11328
  • 13:03
    straight-shoota labeled #11326
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?
i have this code, but both annoations and instance vars are empty:
module Test
  annotation Flag
  end

  module Configuration
    macro included
      {% puts @type %}
      {% puts @type.annotations(Flag) %}
      {% puts @type.instance_vars %}
    end
  end

  struct Config
    include Configuration

    @[Flag(name: "a", short: "a", type: String?)]
    @a : String?
  end
end
George Dietrich
@Blacksmoke16
it has to be called in the context of a method
manveru
@manveru:matrix.org
[m]
ah, i guess the problem is with the macro included...
  module Configuration
    def initialize
      {% puts @type %}
      {% puts @type.annotations(Flag) %}
      {% puts @type.instance_vars %}
    end
  end
this now gives me instance vars, but not annotations
George Dietrich
@Blacksmoke16
the problem is @type.instance_vars has to be used in the context of a method, which it is now
and annotation is empty because the macro is being expanded within the module i'd guess
manveru
@manveru:matrix.org
[m]
ah, the annotation is on the instance var
thanks :)