ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Crystal 0.23.1 | Fund Crystal's development: | GH: | Docs: | API: | Gitter:
snsei has joined #crystal-lang
<FromGitter> <MrSorcus> - Can someone look at my problems? Thanks.
Guest21319 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven is now known as Guest66362
Guest66362 has quit [Client Quit]
vivus has quit [Quit: Leaving]
<hightower2> When signature do I use if I have def func( *arg), and I need a type of that 'arg'
<hightower2> s/When/What/g
l0ra has joined #crystal-lang
<FromGitter> <MrSorcus> > **<hightower2>** When signature do I use if I have def func( *arg), and I need a type of that 'arg' ⏎ ⏎ This? ⏎ ⏎ ```def foo(*args : Int32) ⏎ puts "#{args}" ⏎ end ⏎ ⏎ foo(1, 2, 3)``` []
l0ra has quit [Ping timeout: 255 seconds]
<hightower2> mrsorcus: right, but I don't know in advance theyll be Int32
<hightower2> I need something generic/any type
<FromGitter> <johnjansen> @hightower surely you can narrow the list a little
<FromGitter> <MrSorcus> > **<hightower2>** mrsorcus: right, but I don't know in advance theyll be Int32 ⏎ ⏎ Maybe this can halp you?
<FromGitter> <MrSorcus> *help
<hightower2> That's a "can't do/doesn't help" answer to both suggestions, but thanks for the discussion. I'll leave this particular point unimplemented for no
<hightower2> now*
l0ra has joined #crystal-lang
<FromGitter> <johnjansen> @hightower2 my point is more pragmatic, if you want a method that acts on inputs, but the inputs are never the same type then you cant act on them anyway … if you know that when the method gets some types then it can do one thing, and with other types it can do something else, then the other approach is to implement the method with different / appropriate signatures … this totally works, although the
<FromGitter> ... sensibility of using it is questionable
<FromGitter> <johnjansen>
<hightower2> it's too complicated to explain what I need...
<FromGitter> <johnjansen> put it this way, you dont want the method signature to specify types
<FromGitter> <johnjansen> ``` # your code to handle whatever you get ⏎ end``` []
l0ra has quit [Ping timeout: 240 seconds]
watzon_ has quit [Read error: Connection reset by peer]
sz0 has quit [Quit: Connection closed for inactivity]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
<FromGitter> <backpackid> Is there a flag or something when building to compiler to enable openssl?
<FromGitter> <MrSorcus> > Is there a flag or something when building to compiler to enable openssl? ⏎ ⏎ `require "openssl"`?
<FromGitter> <backpackid> The issue is the package for Arch linux is built without-ssl so I can't use accept ssl clients and what not
<FromGitter> <backpackid> So I'm trying to build it from source however it seems by default it is built without ssl
<FromGitter> <MrSorcus> If i remember correctly, crystal package in Arch has openssl dependency. No?
<FromGitter> <MrSorcus> Try to install package openssl and insert `require "openssl"` to your source file. And compile it. Compiler must find it with ldd (or ld, i don't remember) automatically.
snsei has quit [Remote host closed the connection]
daemonwrangler has joined #crystal-lang
<FromGitter> <backpackid> Well I had openssl installed at the time I installed crystal. Maybe its my code but I'm getting a SSL_ACCEPT error every time I try to accept a client. Referring to the flag about openssl.
<FromGitter> <backpackid> I'm using curl with -k and --proxy-insecure
<FromGitter> <backpackid> I only get that error if I don't specify a location.
snsei has joined #crystal-lang
<FromGitter> <MrSorcus> i'm going to bed, good luck.
snsei has quit [Ping timeout: 250 seconds]
snsei has joined #crystal-lang
rohitpaulk has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 250 seconds]
<FromGitter> <r3bo0t> @crisward thanks for you PRs on ``. It really helped :)
<FromGitter> <r3bo0t> ```Add support for Date, Time and Mediumint. (see #31 and #41, thanks @crisward)```
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
flaviodesousa has joined #crystal-lang
<FromGitter> <Rinkana> Morning
claudiuinberlin has joined #crystal-lang
<FromGitter> <extremety1989> morining
sz0 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
snsei_ has joined #crystal-lang
<FromGitter> <extremety1989> guys who tried using redis channels ? what is the difference with websocket channels ?
snsei has quit [Read error: Connection reset by peer]
mark_66 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
Papierkorb_ has joined #crystal-lang
<FromGitter> <Qwerp-Derp> Argh nil assertions are so annoying in Crystal
<FromGitter> <Qwerp-Derp> I have to repeat myself over and over just so the compiler doesn't scream at me
<FromGitter> <Qwerp-Derp> When I do this: ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <Qwerp-Derp> Crystal screams at me, I thought `unless x.nil?` does proper type-checking for nil in the unless block
<Groogy> the instance variable is not guaranteed to not be nil
<Groogy> do bar = @bar in the unless
<FromGitter> <Qwerp-Derp> Wait, it's because `@bar` can be changed in the `unless` block to be a nil value, right?
<Groogy> yeah
<FromGitter> <Qwerp-Derp> Ah
<Groogy> if you call a member method on Foo, suddenly you don't know what @bar is again
<FromGitter> <Qwerp-Derp> Still, it's pretty annoying to deal with, I have to sprinkle `.not_nil!` everywhere I reference a `@bar`
<FromGitter> <Qwerp-Derp> And in most of my classes I don't put things like `@bar` in initialization methods, so I can't even change the value to non-nilable because of that
<Papierkorb_> I can only repeat: If what you do feels bad, it's because it is bad.
<Papierkorb_> If your classes have all-nilable instance variables, that's a huge sign for poor code design
<Papierkorb_> Nothing wrong with Crystal, infact, this is a good thing for it to do.
<FromGitter> <Qwerp-Derp> Hmmm, true
<FromGitter> <Qwerp-Derp> If I have a class which has some optional fields, is it better to just separate those optional fields out into mandatory fields in a new class?
<Papierkorb_> Nothing wrong with "optional fields". But how you word it sounds like your classes are too big.
snsei has joined #crystal-lang
<Papierkorb_> If you have a big amount of nilables, that's poor design. That's a sign for incorrectly modeled classes
snsei_ has quit [Read error: Connection reset by peer]
rohitpaulk has quit [Read error: Connection reset by peer]
<FromGitter> <bew> Maybe you didnt declared struct foo?
<Papierkorb_> RX14: You know why
<RX14> not really
<Papierkorb_> bew, `foo *foo` gives you an instance of `foo*`, named `foo`. Now there's a collision: `foo` as in `struct foo` in the global scope, and `foo` in the local scope.
<Papierkorb_> When resolving, local scope wins
<Papierkorb_> And `foo` of type `struct foo*` can't be instantiated
rohitpaulk has joined #crystal-lang
<Papierkorb_> It's kinda like doing `foo = String; foo =;` in Ruby
<Papierkorb_> R
<Papierkorb_> RX14:
<RX14> but we're defining a variable and using a type
<RX14> is C really that dumb
<Papierkorb_> Symbols live in a shared space
<Papierkorb_> Which is why some projects prefer to use `struct X` over `typedef X`, or use `typedef X_t`
<RX14> hmm thats annoying
<RX14> but I see now
<Papierkorb_> If that's dumb? No idea. It's more funny as now a C lexer and/or the parser has to take scope into account to correctly build the token stream or the AST lul
<Papierkorb_> Hey RX14, what's this? `foo * bar`
<Papierkorb_> Is that a statement giving you a bar of foo*, or a multiplication?
<Papierkorb_> Answer is: Who knows?!
<RX14> lol
<Papierkorb_> Why's there no JS event fired when you removeChild() a node -.-;
<RX14> I can read C but not write it...
<Papierkorb_> That's nothing compared to C++ lul
<RX14> yeah i hope I enver get a reason to write C++
<RX14> never*
<Papierkorb_> Though one of the biggest issues with C++ isn't even the language, it's that the compilers are slow af
<RX14> but isn't that a product of the language?
<Papierkorb_> of the standard? Kinda. But OTOH, with Clang integrated into an IDE, it can give you almost instant feedback, so that's a huge win nowadays
<RX14> clang wrote one from scratch you would think they'd know how to make compiling C++ fast if it was possible to make fast
<Papierkorb_> Oh parsing C++ is bad, but not that slow. It's okay.
<Papierkorb_> As far an editor is concerned, which can do some caching optimizations
<Papierkorb_> Bindgen spents a considerable amount of time on parsing the C/C++ sources though, about half of the time it takes to generate iirc
<RX14> well Qt is rather large
<RX14> crystal is worse re:ide though, you can't even compile any file independantly
<RX14> you need to specify a root file which actually compiles on it's own
<RX14> then track the require flow
<Papierkorb_> Well editors can cheat and simply require `src/*`
<Papierkorb_> that'll work for most projects
<RX14> i'd rather they have better defaults
<RX14> for example in an app use the shards build files as roots
<Papierkorb_> For the remaining dozen, the shard.yml could host that information
<Papierkorb_> Maybe it should anyway
<RX14> and for shards, emulate `require "shard_name"`
<RX14> so src/
<RX14> etc.
<RX14> or honestly just the spec suite
<Papierkorb_> But @C, that particular issue never happened to me in practice. What's really annoying is C89 only allowing var declarations at the beginning of a block. And there are plenty projects using C89.
<Papierkorb_> Another funny thing is how varargs (`...`) are basically the reason why the compiler evaluates arguments from the right to the left. And with `it++` being an expression, this is redily assumed in projects. Uargh.
<Papierkorb_> Bonus points for seeing `while(it) handle(it++, ++it);`
<RX14> i never use ++ outside for
<RX14> and only in i++
<RX14> otherwise it's always i += 1
<RX14> just like crystal
<Papierkorb_> In C++, prefix ++ has the benefit of saving a temporary copy, which post ++ needs
<Papierkorb_> In C it's the same, but as you can't override ++ anyway, it's a non-issue
<RX14> i'd never put += in arguments either lol
<RX14> that's just asking for confusion
<Papierkorb_> Yeah I always avoided it like the plague
snsei has quit [Ping timeout: 252 seconds]
<Papierkorb_> `foo[i++] = bar(i);` just screams for issues
<Papierkorb_> But it's perfectly valid! But putting a `++i` there would break it :)
astronavt has quit [Remote host closed the connection]
sz0 has quit [Quit: Connection closed for inactivity]
astronavt has joined #crystal-lang
<RX14> the problem is i++ and i += n being expressions
<RX14> but then sometimes assingment being an expression is useful...
<Papierkorb_> I don't think it's an issue in itself. That it's readily abused is
<Papierkorb_> All of the funky snippets I posted I've seen in one form or the other
astronavt has quit [Remote host closed the connection]
astronavt has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
<RX14> yeah but should it be abusable?
<RX14> is there a valid usecase?
<Papierkorb_> `if foo = bar` is super useful
<RX14> but only is bar has a truthiness
<RX14> it's only useful in if
<RX14> so maybe assignment should always return bool: the truthiness of the rhs
astronavt has quit [Client Quit]
<RX14> not that i'm really suggesting that
<RX14> but i think it would work
<Papierkorb_> I'd be more about teaching than restricting
<Papierkorb_> Crap can be written within any restriction, hence prevent that crap will be written in the first place
<Papierkorb_> So either we write no code at all, or we teach
<RX14> true
<RX14> however the counterpoint is that getting that error can cause someone to come in to IRC and ask:
<RX14> "why does assignment return bool"
snsei has joined #crystal-lang
<Papierkorb_> If people end up in IRC and ask (and/or learn how to ask) a question, everyone will learn something from that, usually far beyond what was initially asked
<Papierkorb_> How often do we in here already end up suggesting architectural changes when someone is fighting nil again
<FromGitter> <sdogruyol> hey everyone
Papierkorb_ has quit [Remote host closed the connection]
Papierkorb_ has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Ven has joined #crystal-lang
Ven is now known as Guest37997
snsei has joined #crystal-lang
<FromGitter> <bararchy> I want to start working on Crystal binding for Bluez, did anyone played with it yet ?
<FromGitter> <bararchy> (End goal is to create a program using BLE & crSFML to fly my sons drone using the PC)
snsei has quit [Ping timeout: 250 seconds]
Majost has quit [Ping timeout: 264 seconds]
Majost has joined #crystal-lang
livcd has quit [Ping timeout: 246 seconds]
livcd has joined #crystal-lang
Guest37997 has quit [Ping timeout: 240 seconds]
Ven_ has joined #crystal-lang
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 258 seconds]
<Papierkorb_> So I dared to use a CDN'd version of bootstrap, using the URL with the full version.
<Papierkorb_> FF suddenly refuses to load it as the integrity hash is wrong. Just why man.
Ven_ has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven is now known as Guest32259
hightower2 has joined #crystal-lang
Bish has quit [Quit: leaving]
<ton31337> hello masters
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
<FromGitter> <jose-rodrigues> which crystal version are you running?
<ton31337> 0.23.1
<ton31337> for instance this one works
<ton31337> ip_int |= word.rjust(4, '0').to_big_i(16) << (128 - 16 * (i + 1))
<ton31337> :/
snsei has quit [Ping timeout: 255 seconds]
<FromGitter> <bew> don't need to rjust, just to_big_i(16) is enough i think
<FromGitter> <jose-rodrigues> it work for me :(:
<FromGitter> <jose-rodrigues> ``` $ crystal eval 'require "big_int" ; puts "2a02".to_big_i(16)' ⏎ 10754``` []
<ton31337> puts "2a02".to_big_i(16) works for me as well
<ton31337> hm :)
snsei has joined #crystal-lang
<ton31337> I think rjut is really needed to understand "".to_big_i(16) :)
<ton31337> which exteend to "0000"
<ton31337> yeah "".to_big_i(16) raises that error
<FromGitter> <bew> oh right thought you would get 0 here
<ton31337> all good
snsei has quit [Ping timeout: 240 seconds]
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter> <bararchy> So, i'm a little bit stuck with "c to crystal example convert", I get what he is trying to do, but don't know how to do it in Crystal. ⏎ @bew or maybe Papierkorb_ any idea ? ⏎ ⏎ []
<FromGitter> <bew> first, the 3rd arg in `max_rsp` not `num_rsp`, the latter is returned from the `inquiry` call
<FromGitter> <bew> also, `ii` should be a buffer (`Slice`) of `inquiry_info` (no idea what this is, should be a struct in your lib binding), of size `max_rsp`
snsei has joined #crystal-lang
<FromGitter> <bew> which will get filled by the inquiry C function, and the returned `num_rsp` will hold the number of slots it used in the buffer
snsei has quit [Ping timeout: 276 seconds]
<FromGitter> <bararchy> Thanks @bew I'll try and fix it
<FromGitter> <bew> and the last for loop is basically a traversal of the `num_rsp` slots (that have been filled with useful values), and using the `bdaddr` field (in the `inquiry_info` struct) to call `hci_read_remote_name` in order to retrieve the name of the thing (into another buffer, `name` in the C code)
snsei has joined #crystal-lang
alex`` has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
<RX14> hopefully 0.24.1 will be coming soon
<RX14> and I want to make the release process tracked with a "changelog PR"
<RX14> which contains the changelog update PR but is used more generally for discussing and tracking the release as it happens
<RX14> changelog update commit*
<FromGitter> <bew> I suppose that when this PR is merged, the release tag is created on th merge commit?
<RX14> yup
<FromGitter> <bew> that's be a good idea!
<hightower2> Papierkorb, do I see it right that by using macros in Cute you create @listeners by making a union of all defined signal signatures?
<Papierkorb_> ?
<Papierkorb_> No?
hightower2 has quit [Ping timeout: 276 seconds]
Papierkorb_ has quit [Quit: Konversation terminated!]
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master:
<crystal-gh> crystal/master 6ee1bf9 TSUYUSATO Kitsune: Add `Set#===` as alias to `Set#includes?` (#5269)...
<jokke> hey!
<jokke> any ideas why i need to hit Ctrl-C twice to even get into the first trap block?
<jokke> (i commented out the nested trap but the behavior didn't change)
<oprypin> jokke, just like... dont do this.. u know
<oprypin> nested handler setters are just going against nature
<oprypin> and dont put code inside modules
<jokke> yeah
<jokke> ok
<jokke> but how can i achieve the same?
<jokke> the code inside the trap block can block
<oprypin> jokke, it must not block tho
<oprypin> i don't even know
<jokke> well it's actually kinda common that INT trap handlers do some cleaning up which can take a while
<jokke> in this case it can take quite some time
<FromGitter> <johnjansen> i dont know why the crystal init dumps out modules if its not ideal, but thats an aside ;-)
<jokke> i guess it's for more complex applications
<jokke> this basically is just a script
<jokke> oprypin: anyhow, it can't be the nested handler setter since i removed the second trap and it still behaved the same way
<FromGitter> <bararchy> @bew following your advice
<FromGitter> <bararchy> I tried to do ⏎ ⏎ ```ii = Slice(LibBlueZ::InquiryReq).new(max_rsp)``` []
<oprypin> jokke, remove stuff until it works
<FromGitter> <bararchy> but it says ⏎ ⏎ ```Can only use primitive integers and floats with, not LibBlueZ::InquiryReq``` []
<oprypin> jokke, if you remove zmq from this equation then someone can actually try this example
<jokke> mmh
<oprypin> bararchy, can use array instead of slice
<FromGitter> <bararchy> oh
<FromGitter> <bararchy> [] of , then .to_unsafe ?
<oprypin> yeah but nevermind
<oprypin> it's just this particular constructor. use any other constructor then you're good
<FromGitter> <sdzyba> @RX14 saw your message about 0.24.1
<FromGitter> <sdzyba> Do you have some info as a core maintainer?
<FromGitter> <sdzyba> Or it's just a wish? :)
<FromGitter> <bararchy> so just to make sure ⏎ this ⏎ ⏎ ```ii = Array(LibBlueZ::InquiryReq).new(max_rsp) ⏎ ii.to_unsafe ``` []
<FromGitter> <bararchy> ?
flaviodesousa has quit [Ping timeout: 240 seconds]
<jokke> interesting... if i don't set a capacity for the Channel it works
<jokke> but i'm sure the capacity is correct
claudiuinberlin has quit [Quit: Textual IRC Client:]
alex`` has quit [Quit: WeeChat 1.9.1]
mark_66 has quit [Remote host closed the connection]
<travis-ci> crystal-lang/crystal#6ee1bf9 (master - Add `Set#===` as alias to `Set#includes?` (#5269)): The build passed.
<DeBot_> (Add `Set#===` as alias to `Set#includes?`)
Guest32259 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<oprypin> jokke, this zmq stuff is probably blocking
<jokke> sure
<oprypin> if u dont set the capacity then it's not actually running
<jokke> oh
<oprypin> crystal cannot catch signals when it's blocked
<jokke> ah
<jokke> i see
<jokke> even though it's blocked only inside fibers?
<oprypin> this is all in one thread, remember?
<jokke> sooooo... only way to run multiple io blocking things in parallel is by forking? :/
<oprypin> almost
<jokke> hmm
<jokke> that stinks :P
<Papierkorb> Even with threading, this would always be a huge bottleneck
<Papierkorb> Go would be the same today
<Papierkorb> Blocking a whole thread is a no-go if your environment leverages green-threads
<oprypin> meh i bet in go u can just make another thread
<Papierkorb> isn't zmq super simple? I'd simply reimplement it natively.
<FromGitter> <sdzyba> You can block whatever you want in Erlang/Elixir afaik
<Papierkorb> You can do whatever in Crystal too. Doesn't make it a good idea
<jokke> Papierkorb: one can set the amount of io threads when setting up zmq
<Papierkorb> And if I were to block the whole system process in elixir, the VM would be dead
<Papierkorb> Aha
<Papierkorb> Well that's not necessary with Crystal
<jokke> so i set it to 0?
<Papierkorb> huh?
<jokke> ah ok you were answering someone else
<Papierkorb> I don't know how zmq works, nor do I want to read up on it. if it spins up threads by itself, that's fine
<Papierkorb> if it blocks the user-thread, that's not fine obviously. Do a proper integration
<Papierkorb> on what is the best way of doing so depends on the library in question
<Papierkorb> Still, spinning up tons of threads for I/O isn't great, and for a native Crystal solution, wouldn't be necessary.
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter> <Shalmezad> Lol.... playing with some "fun" character issues in ruby right now, came across ⏎ Decided to try it in crystal. Surprisingly crystal handles most of those cases pretty well.
<FromGitter> <bew> @bararchy You can use ` { }` to create a slice of size `some_size` with a lib struct
snsei has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest73722
snsei has quit [Ping timeout: 276 seconds]
rohitpaulk has joined #crystal-lang
<RX14> jokke, yes, the only way to really use zmq in crystal is to implement the zmq protocol in crystal
<RX14> using the C bindings will bring you pain
<RX14> there's a lot of documentation on the zmq protocol though so i'd give it s shot
<FromGitter> <bew> 👌 I had the same thought with libxcb, and I'm doing my own binding in Crystal now ;)
<Papierkorb> The X protocol isn't simple, as opposed to zmq
Guest73722 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<wmoxam> @bew you are writing a from scratch X11 lib in Crystal?
<wmoxam> that would be quite ambitious 😲
<Papierkorb> And with wayland on the horizon (or not) ..
<wmoxam> X11 will be around for a long time I think
<oprypin> I expect X11 to be in majority at least until 2021
<Papierkorb> Isn't the latest Ubuntu on Wayland?
<Papierkorb> And fedora too?
<wmoxam> I just know that my fav OS has 0 Wayland support 😅
<Papierkorb> ?
<oprypin> > Wayland Confirmed as Default for Ubuntu 17.10
<wmoxam> OpenBSD :p
<Papierkorb> So a huge marketshare already
<Papierkorb> And Fedora is on wayland too for a while now iirc
<oprypin> Papierkorb, you realize that like 5% of total ubuntu usage will be on 17.10
<wmoxam> it's really a Linux thing atm
<Papierkorb> From what I hear of Wayland I'm not much impressed
<Papierkorb> the compositor has to do way too much
<wmoxam> but OTOH if the big Linux distros adopt it that's probably enough to kill X11 for everyone else
snsei has joined #crystal-lang
<Yxhuvud> oprypin: I think quite many *of the desktop users* of ubuntu run the latest and shinyest.
<Yxhuvud> server users is a different thing, but don't really matter in a x vs wayland discussion, for obvious reasons
<Papierkorb> Corporate users prefer the LTS version though
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<Papierkorb> But KDE doesn't properly support Wayland yet, so I won't be on it whatever happens anyway for quite some time lol
<Yxhuvud> perhaps. I wonder if there is statistics somewhere
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
woodruffw has quit [Read error: Connection reset by peer]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter> <bew> Yes wmoxam! I plan to build a window manager in crystal , I looked at wayland, it's really great but there's no easy way to build a Wayland compositor, and there's not a lot of libs to build one. I'm waiting (and watching) the wlroots repository which is ctive and very promising about that, but for now I want to learn more X stuff, and building a window manager is easier once you have a good x binding ;)
<Papierkorb> Binding libxcb isn't implementing the X protocol (which would be kinda insane)
<wmoxam> oh its a libxcb binding
<wmoxam> I've been using this
<wmoxam> it's not libxcb though, it's xlib
<FromGitter> <bew> I started by binding libxcb but now I have the project to implement the x protocol myself ;)
<Papierkorb> ... why
<FromGitter> <bew> With a good Crystal api, fibers, etc ;)
<FromGitter> <bew> For fun ˆˆ
<wmoxam> 😲 😲 😲
<oprypin> @bew pls
<FromGitter> <bew> And I've found that libxcb is mostly generated , so I thought I could generate a crystal implementation too
* wmoxam falls over
<FromGitter> <bew> I'm afk for a while now ++ !
rohitpaulk has quit [Ping timeout: 248 seconds]
<RX14> I wish firefox supported wayland
<RX14> because wayland is the only way to support mixed-resolution displays
<Papierkorb> you mean mixed DPI?
<RX14> yes
<RX14> derp
<RX14> I frequestly connect my laptop to external monitors
<RX14> and it's 1 scaling factor everywhere
<oprypin> surely there are workarounds like rendering at the same resolution for both
<RX14> I made a hack to get my terminal to scale correctly, by wrapping it in a script which detected the display of the current workspace and setting the scaling env var
<RX14> but obviously for firefox which is 1 global instance for all windows its not possible
<Papierkorb> Well you could use profiles
<RX14> oprypin, yeah that's not really a good idea
<RX14> Papierkorb, i don't want to have to deal with different profiles depending on the monitor
<RX14> that sucks as a solution
<RX14> different history jusut to change DPI?
<RX14> having to sync addons and settings to both?
<oprypin> RX14, yeah just forget it
<RX14> oprypin, it messes with subpixel font rendering
<RX14> and it's a lot more heavy
<oprypin> i dont use subpixel anyway
<RX14> because you're essentially supersampling your desktop
<oprypin> that or the opposite
<RX14> how do your eyes cope oprypin
<oprypin> better than with subpixel anyway
<RX14> thing is my scaling factor is only 1.25x
<RX14> which is great because not having the scaling isn't really a big deal on one hand
<RX14> but on the other if I wanted to do the upscale/downscale to get the same DPI i'd end up with a massive resolution
<oprypin> oh, right..
<RX14> and given I have 2 external monitors
<RX14> both of which are slightly larger than 1080p
woodruffw has joined #crystal-lang
woodruffw has quit [Changing host]
woodruffw has joined #crystal-lang
<oprypin> RX14, just use GCD
<oprypin> wait that's not right
<RX14> lcm
<oprypin> actually is LCM
snsei has joined #crystal-lang
<RX14> do we not have gcd,lcm in Math?
<RX14> not on floats :(
<RX14> have to do 100,125
<RX14> lol it's 500
<oprypin> floats D:
<RX14> not sure why i couldn't do that in my head
vivus has joined #crystal-lang
<FromGitter> <bararchy> What do I pass as a bind in Crystal for this c value? ⏎ ⏎ ```const uint8_t *lap``` ⏎ ⏎ In a code example in C they passed `NULL`, is it the same as Void* ? []
<FromGitter> <bew> You can pass nil to a fun, if the argument is a pointer, it'll be passed like a NULL iirc
<crystal-gh> [crystal] straight-shoota opened pull request #5327: Improve WebSocket handshake validation (
<FromGitter> <bew> Not sure though
<jhass> yup, nil should be fine
<FromGitter> <bararchy> yeha seems to work, thanks
<FromGitter> <bararchy> as in, nothing works, but the passing of nil works XD
<jhass> it's essentially a shortcut to Pointer(X).null fwiw
<FromGitter> <bararchy> is there a way to tell crystal_lib to just "take everything, ignore prefix" ? it seems that if I don't specify a prefix it wont generate binding
<FromGitter> <bararchy> jhass, thanks, good to know
<FromGitter> <bararchy> It seems I do it "by the book", but it just wont work, keeps returning `-1` for error :\ ⏎
<FromGitter> <bararchy> If anyone can take a look and tell me WTH is going on I would really appriciate it :):)
<jhass> is there no error retrieval function that would give you more insight?
faustinoaq has quit [Ping timeout: 248 seconds]
<jhass> well one major difference seems to be you passing 0 for the flags, but I guess it already fails with the open if that doesn't concern you?
<jhass> did you try just dev_id = get_route(nil) btw?
<FromGitter> <bararchy> get_route is actually working, it returns `0` which is the relevant dev id (hci0), I can try using `nil` but it seems to be ok nontheless
<FromGitter> <bararchy> wait....wth
<FromGitter> <bararchy> used your suggestion and now it wont raise
<FromGitter> <bararchy> Oo
snsei has quit [Remote host closed the connection]
<jhass> yeah I'm not even sure the argument is an out param :P
<jhass> is there anywhere proper man pages?
claudiuinberlin has joined #crystal-lang
<jhass> yeah no I'd want a reference
<FromGitter> <bararchy> "BlueZ is a powerful Bluetooth communications stack with extensive APIs that allows a user to fully exploit all local Bluetooth resources, but it has no official documentation. Furthermore, there is very little unofficial documentation as well. Novice developers requesting documentation on the official mailing lists [1] are typically rebuffed and told to figure out the API by reading through the BlueZ source
<FromGitter> ... code. This is a time consuming process that can only reveal small pieces of information at a time, and is quite often enough of an obstacle to deter many potential developers. ⏎ ⏎ This chapter presents a short introduction to developing Bluetooth applications in C with BlueZ. The tasks covered in chapter 2 are now explaine ... []
<jhass> jeez, why paste all that
<FromGitter> <bararchy> yeha, just for "but it has no official documentation. Furthermore, there is very little unofficial documentation as well"
<FromGitter> <bararchy> sorry
<FromGitter> <bararchy> so it seems the only relevant "real" source is the ... source code
<FromGitter> <bararchy> would it help if I'll provide you the actual source for the function? or the header file
<jhass> that I can dig out myself, thanks :)
<FromGitter> <bararchy> just wanna be helpful if I can :) as you are actually helping me out
<FromGitter> <bararchy> haha
<jhass> (long) (bdaddr ? bdaddr : BDADDR_ANY)
<jhass> definitely not an out param :P
<FromGitter> <bararchy> oh
<FromGitter> <bararchy> XD
sagax has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter> <extremety1989> hey guys did anyone tried crysta-jwt ?
<FromGitter> <extremety1989> crystal-jwt ?
aroaminggeek has joined #crystal-lang
<FromGitter> <extremety1989> how can i get "HTTP::Headers::Key(@name=\"Authorization Bearer\")": [ ⏎ "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIiLCJleHAiOjE1MTE3ODY4NzYsImp0aSI6ImNkYjMwMGQ1LWM1NGUtNDk3ZS1hNzgwLTNjODkzMDBhNDQ2NjFjNmZjMzlkLWFjYjgtNDJiOS1iYTY2LTVlYjNkYjRlMDNiODBhZWJmZTE3LTdmOTYtNGE3NS1hOWU1LWRmNzY2MDg1ZDA4NmNlYmRiYmI2LWU4OGUtNDA1Mi04YmU0LWYyYjNmNjBmMDI3ODk3NDI5YzVjL
<FromGitter> ... WY2YjMtNGFiNS04NjRmLWY0Yzc1ZDNjNTYxNiJ9.q3EMUFmOOpvcuWh6pSI1ODDDNmXBHziyY_AyjqaJCLc" ⏎ ]
<FromGitter> <extremety1989> it is like ctx.request.headers then ?
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
aroaminggeek has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <johnjansen> can anyone spare a moment to consider a JSON Mapping issue i'm having
<jhass> it's because you don't consume anything in
<FromGitter> <johnjansen> thank you sir … fantastic … always the tiny details ;-)
aroaminggeek has joined #crystal-lang
<FromGitter> <extremety1989> well that was easy token = ctx.request.headers["Authorization Bearer"]
<FromGitter> <extremety1989> =)
<FromGitter> <johnjansen> @extremety1989 header keys should be case insensitive btw
<FromGitter> <johnjansen> just in case that comes up
<FromGitter> <extremety1989> @johnjansen hmm,i will try but this works
<FromGitter> <johnjansen> should do
<Papierkorb> huh why's there a space in the header name
<FromGitter> <extremety1989> @johnjansen okey it works too
<FromGitter> <extremety1989> @Papierkorb because i am sending this from my client
<FromGitter> <extremety1989> Authorization Bearer
<Papierkorb> Oh it's you
<Papierkorb> Don't use spaces.
<Papierkorb> use dashes.
<Papierkorb> And that's still not really standard compliant
<FromGitter> <extremety1989> @Papierkorb dashes like ?
<Papierkorb> Use the Authorization header and use Bearer as authorization scheme
<Papierkorb> The RFC can tell you how you do that
<FromGitter> <extremety1989> @Papierkorb json mapping schema ?
<Papierkorb> Please consult the RFCs
<FromGitter> <extremety1989> @Papierkorb im new here, i dont know whhat is RFCs
<Papierkorb> if you think "they're so large" and not worth your time (That'd only prompt a "wtf?" from my end), then it's more than high time to learn how to navigate technical documentation
<Papierkorb> RFC is short for Request For Comments, which are open technical documentation documents on the implementation of public protocols
<Papierkorb> All of the technology that drives the internet is literally documented by them
<FromGitter> <extremety1989> okey , and how to contact them ?
<Papierkorb> RFC 7230 should be the current one for HTTP/1.1: (Thanks Internet Engineering Task Force!)
<Papierkorb> And HTTP Authentication has some RFC flying around too.
<Papierkorb> Just google for `RFC` and then what you're looking for, you'll find it right away
<FromGitter> <johnjansen> haha “some” ;-)
<Papierkorb> Yah lul the HTTP ones are generally a good time to stock up on booze
aroaminggeek has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <johnjansen> you’ll need a ladder to reach the top shelf of course …
<FromGitter> <extremety1989> there is a lot to read
<FromGitter> <extremety1989> ctx.request.headers["authorization bearer"]
<FromGitter> <extremety1989> so what is the problem ?
<Papierkorb> extremety1989, the RFCs are the actualy docs, and thus contain the correct truth. If e.g. the Crystal HTTP server does something, the RFC is the place to look if it does the correct thing.
<FromGitter> <extremety1989> well
<FromGitter> <extremety1989> it is working
<FromGitter> <extremety1989> ctx.request.headers["authorization bearer"]
<Papierkorb> Well it's up to everyone of course if they want quality or some random code that "appears to work"
<FromGitter> <extremety1989> why i need to add dashes ?
<RX14> uhh
<RX14> it should be Authorization: Bearer <token>
<RX14> where Bearer should be in the value not the key...
<Papierkorb> RX14: Said so above
<RX14> oh
<RX14> skimming IRC is hard
<Papierkorb> But I appreciate the unvoluntary agreement :P
<FromGitter> <extremety1989> @RX14 Missing hash key: HTTP::Headers::Key(@name="Authorization: Bearer")
<FromGitter> <extremety1989> haha
<RX14> ...
* Papierkorb looks up at the RFC stuff
<RX14> the key is Authorization
<RX14> just that
<RX14> and the value you get back is a string
<RX14> and that string has the format "Bearer #{token}"
<RX14> are you parsing or emitting
<Papierkorb> Parsing by the looks of it
<Papierkorb> And generating on the other end
<FromGitter> <extremety1989> not working ....
<RX14> well, you just split(" ", 2) then verify [0] is "Bearer"
<RX14> and then use [1] as the token
<FromGitter> <extremety1989> @FromIRC can you please write me a code
<FromGitter> <extremety1989> @RX14 can you please write me code ,
<RX14> no
<FromGitter> <extremety1989> ?
<FromGitter> <johnjansen> haha
<Papierkorb> 9/10
<FromGitter> <johnjansen> where are the score card emoji’s when i need them
<RX14> @extremety1989 if you paste your code snippet i might be able to point where the problem is
Creatornator has joined #crystal-lang
<FromGitter> <bew> you need to understand exactly what you're doing and why, because just copy/pasting from someone on IRC or else is counter-productive and you don't learn anything by doing that
<Papierkorb> Oh and that right now is security related
<FromGitter> <crisward> @r3bo0t thanks for the thanks... 😄
<FromGitter> <extremety1989> ```code paste, see link``` []
<Papierkorb> So "totally unimportant", just the gateway from all that junk trying to attack you
<FromGitter> <johnjansen> also is a string split is cryptic, i would suggest implementing anything related to security is rather risky
<jhass> let's all just hope this is only used for rate limiting access to public data :P
<FromGitter> <johnjansen> woah … nooooo
<Papierkorb> johnjansen, in this particular case, as long String#split is properly understood and the optional second argument is used (and its behaviour understood), it's okay when the result is correctly validated imho
<FromGitter> <extremety1989> 😟
<Papierkorb> But I'm also a fan of parser-for-everything. Maybe there should be a "one line mini-lexer/parser generator" thing for stuff like this. Dunno if that's a good idea
<RX14> well that's called regex Papierkorb
<RX14> it just needs a compiler for crystal
<Papierkorb> Too easy to fuck up
<FromGitter> <johnjansen> @Papierkorb im not suggesting there is anything wrong with the split …
<Papierkorb> johnjansen, fair enough
aroaminggeek has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass> you could just do a .starts_with? "Bearer " if you want to stay allocation free in the invalid case btw
<FromGitter> <johnjansen> Chris was meaning ⏎ ⏎ `````` []
<Papierkorb> backticks?
<FromGitter> <extremety1989> ```code paste, see link``` []
<FromGitter> <extremety1989> this works
<aroaminggeek> one of the more infamous RFC, is the Hyper Text Coffee Pot Control Protocol (rfc2324)
<FromGitter> <extremety1989> 😄
<jhass> then your client adds the : at the wrong place
<FromGitter> <extremety1989> like
<FromGitter> <extremety1989> Authorization: Bearer ?
<FromGitter> <johnjansen> ```code paste, see link``` ⏎ ⏎ kinda []
<jhass> like behind Authorization Bearer: instead of behind Authorization: Bearer
<FromGitter> <extremety1989> @johnjansen well actualy if client tries to cheat
<FromGitter> <extremety1989> he will get
<FromGitter> <extremety1989> Signature verification failed
<FromGitter> <johnjansen> sorry @extremety1989 im not going to write every line for you
<jhass> should really do split(" ", 2) or else I can just send you lots of spaces
<FromGitter> <johnjansen> totally
<oprypin> :D
<Papierkorb> Quite entertaining tonight in here
<oprypin> you really gotta be security-minded to catch this
<FromGitter> <extremety1989> Error in src/ undefined local variable or method '“Authorization”' ⏎ ⏎ ``` m, t = ctx.request.headers[“Authorization”].split(“ “)``` []
<FromGitter> <extremety1989> 👎
<Papierkorb> oprypin: What, to catch that no check of the data was being done in the posted snippets?
<oprypin> Papierkorb, what jhass said
<FromGitter> <extremety1989> oh oke
<FromGitter> <extremety1989> =)
<Papierkorb> And with that you just added a potentional truncation issue when chained with other programs
DTZUZO has joined #crystal-lang
<jhass> wasn't there some rant about JWT being garbage anyway the other day?
<Papierkorb> garbage in which way?
<Papierkorb> That it's not a security system by itself?
<jhass> iirc it was mostly arguing that it's a badly specified spec
<jhass> so no good common ground and defaults between implementations
<Papierkorb> So that it's not a security framework by itself, as opposed to e.g. OAuth
faustinoaq has joined #crystal-lang
<Papierkorb> oh yeah crypto systems allowing for a noop crypto dummy, and people forgetting to turn that off. A classic :D
<FromGitter> <extremety1989> so which security should i use ?
<Papierkorb> In your case? At least? Any full fledged framework offering authentication and authorization. Haven't heard of such a thing for Crystal.
<Papierkorb> But that doesn't help you much, as that you also have to learn and, most importantly, understand
<FromGitter> <johnjansen> oh boy
<Papierkorb> Security isn't a freebie at all
<Papierkorb> Security is a hard issue
<FromGitter> <extremety1989> as i programmed in PHP, i just implemented my own security, as blockchain exemple ))
<Papierkorb> ...
<FromGitter> <extremety1989> haha
<Papierkorb> A blockchain by itself isn't "security"
<FromGitter> <johnjansen> @Papierkorb you should run for public office ;-)
<Papierkorb> Even git could be regarded as "blockchain". Just do that if you want to get funded this year.
<FromGitter> <extremety1989> @Papierkorb yes, but it is secured ))
<Papierkorb> Against what?
<Papierkorb> Git is also 'secured'
<jhass> them russians!
<FromGitter> <johnjansen> haha
<Papierkorb> huh I thought we were blaming north korea atm
<FromGitter> <johnjansen> anyone without your diplomatic skills ;-)
<FromGitter> <extremety1989> @jhass i am from russia ))
<jhass> north korea is just a proxy of the russia is just a proxy of china is just a proxy of mossad is just a proxy of iran is just a proxy of north korea is.. wait a sec
<FromGitter> <johnjansen> damn russian crystal hackers ;-)
<FromGitter> <extremety1989> ahah
<FromGitter> <bew> 😂
<FromGitter> <extremety1989> i live in France
<Papierkorb> jhass: Who proxies the proxy!?
<FromGitter> <extremety1989> that s why
<FromGitter> <extremety1989> i can not get job here
sz0 has joined #crystal-lang
<FromGitter> <extremety1989> discrimination )))
<jhass> it's a joint venture of illuminati, bilderberger and reptiloids
<FromGitter> <johnjansen> what @jhass no mention of the masons
<jhass> sshh, don't talk about'em
<FromGitter> <extremety1989> france it is country of masons))
<Papierkorb> > Because no list of questionable public-key encryption modes could be complete without shoehorning a shared-key encryption mode, the JOSE standards also allow you to use AES-GCM to possibly exchange an AES-GCM key.
<Papierkorb> lawl
<jhass> I really want that flat earth guy to go to space with his rocket btw
<jhass> ... and not come back maybe. Should actually fund him
<Papierkorb> but isn't that rocket only capable of going up 150m or so?
<FromGitter> <johnjansen> hahaha … im so with you @jhass … i wish someone would give him the damn rocket / money
<Papierkorb> jhass: No he has to come back to tell how he was wrong. the whole popcorn industry would implode in a blackhole
<jhass> we should get him in touch with elon
<FromGitter> <johnjansen> the sooner we get rid of him the better … he’s weakening the gene pool
<aroaminggeek> He should paint flames on it. because we all know flames make things go faster
<aroaminggeek> and higher
<FromGitter> <johnjansen> shame he’s so old … probably damage done already
<FromGitter> <bew> 550m for the rocket, not high enough probably
<FromGitter> <bew> he should just climb a mountain, it's easier
<FromGitter> <johnjansen> as long as he’s dead when he hits the ground
<Papierkorb> I mean that's still kinda impressive to do for some lone guy to do. on the other hand, "wat"
<aroaminggeek> one less wingnut, i say...
<FromGitter> <johnjansen> i dont care if its 10'
<oprypin> it's getting too "entertaining" here
faustinoaq has quit [Remote host closed the connection]
<FromGitter> <johnjansen> i dont know why he doesnt buy a boat and motor to the edge … if he’s right
<FromGitter> <extremety1989> i commented in javascript community channel, nobody responded ahahah
<FromGitter> <bew> the saloon is opening, who's the barman ? ^^
<Papierkorb> johnjansen, don't look for logic if there's none
<FromGitter> <crisward> @extremety1989 it's not easy being a js dev, all those hours waiting for `npm install`
<FromGitter> <johnjansen> what i want to know is; ⏎ if the earth is flat like a biscuit, whats on the other side? chocolate perhaps?
<FromGitter> <extremety1989> @crisward ahahah
<Papierkorb> the dark side of the moon obviously johnjansen
<jhass> turtles all the way down, actually
<FromGitter> <extremety1989> it's dark side
<FromGitter> <johnjansen> i thought the oceans were rising, but if he’s right, all the water should be running off the sides
<Papierkorb> Can't we convince those people that on the other side, there are human too, unaware of our existence? On how they survive: Actually, our solar system is a binary system! It's all a big scam by the american lizard administration
<jhass> srsly, most of them believe that picture ^
<FromGitter> <extremety1989> ahahha american lizard lol
<FromGitter> <extremety1989> american goverment think that they are police of earth order
<FromGitter> <johnjansen> its awesome how earth is flat (and therefore i suppose all the other planets are) unyet they are all facing us so nicely
<FromGitter> <extremety1989> if you do not agree with us, they will bomb you down )))
<FromGitter> <extremety1989> USA
<FromGitter> <johnjansen> who is “they"
<FromGitter> <johnjansen> that will be interesting … since im there
<jhass> there are no other planets, it's all holes in the sky
<FromGitter> <extremety1989> and what about aliens ?
<FromGitter> <johnjansen> ohhhhhhh how silly of me … i guess the sky must be equidistant from every point on earth too?
<jhass> there's no aliens, we're gods sole creation
<FromGitter> <extremety1989> who were kidnapped by US secret agency ?
<FromGitter> <extremety1989> i believe in aliens ))
<FromGitter> <johnjansen> yeah, thats why we need a border wall … damn illegal aliens
<FromGitter> <johnjansen> ;-)
<FromGitter> <extremety1989> @johnjansen you from us ?
<Papierkorb> and make the klingons pay for it
<FromGitter> <johnjansen> always mowing lawns and running leaf blowers in the morning
<FromGitter> <extremety1989> good night ))
<RX14> that was an... interesting read
<FromGitter> <johnjansen> haha
aroaminggeek has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
aroaminggeek has joined #crystal-lang
claudiuinberlin has quit [Quit: Textual IRC Client:]
<FromGitter> <jwaldrip> Is there a way to check the type of a macro argument?
<FromGitter> <bew> What kind of type check?
<FromGitter> <bew> You can #is_a? with macro types
<FromGitter> <jwaldrip> Gotcha. okay
<oprypin> jwaldrip, there are so many things that "type of a macro argument" can mea
snsei has joined #crystal-lang
<oprypin> maybe you're interested in .resolve
<FromGitter> <jwaldrip> I think the is_a? will work
<oprypin> you can pass a constant and resolve it and check if it's a numberliteral or whatever
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
Creatornator has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
stephenwithav has quit [Remote host closed the connection]
aroaminggeek has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]