Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 13:16
    hugopl closed #12062
  • May 17 20:20
    Blacksmoke16 synchronize #12044
  • May 17 18:19
    straight-shoota edited #11947
  • May 17 18:19
    straight-shoota milestoned #11947
  • May 17 18:18
    straight-shoota closed #11971
  • May 17 18:18
    straight-shoota closed #11970
  • May 17 17:21
    HertzDevil labeled #12063
  • May 17 17:21
    HertzDevil labeled #12063
  • May 17 17:21
    HertzDevil labeled #12063
  • May 17 17:21
    HertzDevil opened #12063
  • May 17 16:29
    HertzDevil labeled #12062
  • May 17 13:50
    hugopl opened #12062
  • May 17 13:50
    hugopl labeled #12062
  • May 16 19:05
    lbguilherme synchronize #11947
  • May 16 17:29
    straight-shoota milestoned #11971
  • May 16 17:15
    straight-shoota closed #12038
  • May 16 17:15
    straight-shoota closed #12036
  • May 16 17:14
    straight-shoota edited #12038
  • May 16 13:47
    straight-shoota closed #12051
  • May 16 13:47
    straight-shoota closed #12050
mfiano
@mjfiano:matrix.org
[m]
Yes, I think I just want self.foo here
Rishav Sharan
@rishavs

How should I go about converting this weird string into a normal one?

pub_key_cert = pub_key_certs[jwt_header["kid"]] # => "-----BEGIN CERTIFICATE-----\n" +
"MIIDJjCCAg6gAwIBAgIIPLhThxCpHiEwDQYJKoZIhvcNAQEFBQAwNjE0MDIGA1UE\n" +
"AxMrZmVkZXJhdGVkLXNpZ25vbi5zeXN0ZW0uZ3NlcnZpY2VhY2NvdW50LmNvbTAe\n" +
"Fw0yMTA3MTQwNDMwMDBaFw0yMTA3MzAxNjQ1MDBaMDYxNDAyBgNVBAMTK2ZlZGVy\n" +
"YXRlZC1zaWdub24uc3lzdGVtLmdzZXJ2aWNlYWNjb3VudC5jb20wggEiMA0GCSqG\n" +
"SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCdA8H9aoYbXymMZIUZDBEtxmRxGiMcfB43\n" +
"buZXWhM154faq6rk29aJssSF6K6RU/rSddwY2mQ/89rJxhqER+8CckYtf8ixwYA4\n" +
"nrtZYWzgzzBccfqDaZOdqVwBiCak3VAMxWDPg1xYhJc1NH7wVl9aAU3gsNmArh/T\n" +
"Bc5omWH8HOH6mU8slBRfJjuZlMRWwfxffCDZ+9XQfGP8e52OAWVg90OuLU6Li8jT\n" +
"CIpXickJFn4g0fc4i8+X7TlZWNn5dNJd02Ms3Hfk0zY2lyuv1Wlnxd6DumvTCNqa\n" +
"p3/TvF8QB20XGw3oDLoRzPeTSidA/7pItEIYuswDGJ/OKK+aZp8JAgMBAAGjODA2\n" +
"MAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB/wQMMAoGCCsG\n" +
"AQUFBwMCMA0GCSqGSIb3DQEBBQUAA4IBAQCaCB/WTMa79FgyczlwRtWYCH2GWJC7\n" +
"vIunI2dh3yZbzT1NBiDHx2Epp+nyz0sx1cN5s1HEsXFFTVtLa6vFl1p+O6SR/Hck\n" +
"Uj2waSiEmSXEJupzqKYXzyqgU+SE0TaaNAU9VvrSLI0HlMcSY2OReLcBgpvs8C7j\n" +
"zXyBmmlrMlUokvYE5h4Rui6JH9MahtcWARXkIPH5JwXVeXKPPie30NlqmifFPFTQ\n" +
"D3CCTbzYfk8kS4jgM5+DkYCJse3iDh4Wtfm4RuZKZ6IzgqgQr+JFkCatJcSlpgwC\n" +
"iPWtLgKNsmGDiU9Pj7KXRV5rXVygX3/Eb5m5Rug+UhXd1c3QlIlW1EF6\n" +
"-----END CERTIFICATE-----\n"

Do i need to reencode it somehow?

From IRC (bridge bot)
@FromIRC
<raz> hmm, is there a way to make from_json (JSON::Serializable) invoke my setters when populating the object
Ali Naqvi
@naqvis
converter is what you are looking for
@[JSON::Field(key: "foo", converter: FooConverter)]
.......
oops, that was not your question :)
From IRC (bridge bot)
@FromIRC
<raz> hmm right, but close :⁠)
<raz> i guess what i'm really trying to ask: is there a way to add something to the constructors that JSON::Serializable generates (short of making a custom converter for every field 🙈)
<raz> i have this really nice and rather relevant logic in my settings, but serializable doesn't care to invoke them when populating the object from json :,(
<raz> s/settings/setters/
Ali Naqvi
@naqvis
macro populate the fields, it would have been better if it would have invoked setters (if any) and fall-back to current behavior
in that way, one could just define the setters for fields which require some extra processing
for the time-being what you can do is override after_initialize and invoke your setters there, this method is invoked after macro is done with populating the fields
Ali Naqvi
@naqvis
From IRC (bridge bot)
@FromIRC
<raz> ohhh, after_initialize is a thing? that might just save my bacon here
From IRC (bridge bot)
@FromIRC
<raz> it did, thx! \o/
Ali Naqvi
@naqvis
:)
From IRC (bridge bot)
@FromIRC
<raz> is that a JSON::Serializable specific thing? i can't find anything about it on google nor api docs
George Dietrich
@Blacksmoke16
it is yea
From IRC (bridge bot)
@FromIRC
<raz> gotcha
From IRC (bridge bot)
@FromIRC
<raz> well, that's amazingly useful for being so underdocumented! :⁠D
George Dietrich
@Blacksmoke16
there's also one that runs after you do to_json
From IRC (bridge bot)
@FromIRC
<raz> pffft, who needs that
Ashish Bista
@ashishbista
Is it possible to run a spec file with the interactive mode enabled?
I want to put the debugger in a spec file and then execute the spec file.
George Dietrich
@Blacksmoke16
Interactive mode?
Ashish Bista
@ashishbista
I mean crystal i, the upcoming feature that will add REPL and debugger to crystal. crystal-lang/crystal#10910
George Dietrich
@Blacksmoke16

By the way, before this PR you could also use debugger and lldb or gdb would stop at that point, if compiled with -d (otherwise it seems the program just crashes, maybe we should just ignore debugger in that case: something to improve outside of this PR)

Sounds like that wont be supported for the moment

or that is an issue not related to this PR, nvm
you can run a spec file like you would a normal file, prob best you're going to get for a while
manveru
@manveru:matrix.org
[m]
btw, is there any emacs mode out there that actually works with macro syntax?
From IRC (bridge bot)
@FromIRC
<jacotsu> Quick question, does the compiler support only these target triples "i686-unknown-linux-gnu", ""amd64-unknown-openbsd"", "amd64-unknown-openbsd"; or there's a way to compile for another arch without modifying the compiler (talking about armv7)?
mfiano
@mjfiano:matrix.org
[m]
Am I correct in thinking that the only difference between include and extend is mixing in instance or class methods?
George Dietrich
@Blacksmoke16
pretty much yea, include adds the modules instance methods as instance methods in the including type, while extend adds the module's instance methods as class methods in the extending type
iirc they're also slightly different in regards to typing
like if you include MyModule into Foo, Foo.new.is_a? MyModule # => true, but if you extend the module it affects the type of Foo.class not the actual instance type
mfiano
@mjfiano:matrix.org
[m]
and this behaves like composition over inheritance, which is what I suppose they docs mean by partial types, right?
Like mixins in some other languages/paradigms
George Dietrich
@Blacksmoke16
yes exactly
mfiano
@mjfiano:matrix.org
[m]
Great thanks
George Dietrich
@Blacksmoke16
they're also great as a means of having interfaces
as you can define abstract methods on the module that the including type would be required to implement them
Ashish Bista
@ashishbista

you can run a spec file like you would a normal file

I didn't know this. It would solve my issue. Thank you!

George Dietrich
@Blacksmoke16
crystal spec spec/path/to/file
:thumbsup:
mfiano
@mjfiano:matrix.org
[m]
I've been trying to think how to structure my module hierarchy correctly for a couple hours. I'm not used to this way of programming apparently.
George Dietrich
@Blacksmoke16
oh?
mfiano
@mjfiano:matrix.org
[m]
I have a few different structs, each in their own file under src/myproject/, and in a MyProject module. In src/myproject.cr I basically just do require "./src/myproject/*. Now I would like to add a "common.cr" file with common functionality between all the structs, implementing mostly class methods, and also available to users of the library. I can't seem to figure out how to get that to work.