ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Crystal 0.23.1 | Fund Crystal's development: | GH: | Docs: | API: | Gitter:
<watzon> Anyone know of a way to use Regex in JSON.mapping? Is there a String => Regex converter?
<Papierkorb> Not OOTB
<Papierkorb> You can write a custom one of course
<Papierkorb> `mod A; def self.from_json(x); x); end; end` Prettification left as excercise
stephenwithav has quit [Ping timeout: 248 seconds]
<Papierkorb> use type: Regex, and put that modules name as converter:
<vivus> when I get to the "Seeds" part and run: "crystal db/" I get the following error:
<watzon> Papierkorb: thanks fo that
<watzon> for*
<vivus> can anyone explain what the issue is?
stephenwithav has joined #crystal-lang
stephenwithav has quit [Changing host]
stephenwithav has joined #crystal-lang
<watzon> You have to require `crystal/bcrypt/password`
<vivus> watzon: where? in ?
<watzon> In probably
<vivus> aah yes you are right watzon . I missed that
<vivus> thank you
ruby_ has joined #crystal-lang
<watzon> No problem
csk157 has joined #crystal-lang
ruby_ has joined #crystal-lang
ruby_ has quit [Client Quit]
csk157 has quit [Ping timeout: 240 seconds]
<FromGitter> <marksiemers> @vivus Can you report that as an issue?
<FromGitter> <marksiemers> Oh, nm, you are following the docs. You can also `amber g auth User` and see what it does for you.
<vivus> @marksiemers that was my fault for not including the bcrypt. However, the code doesn't compile after doing the `crystal db/` and running `amber w`
<FromGitter> <marksiemers> I don't want to pollute the group chat with debugging, but if you jump on gitter directly, we can direct message
<FromGitter> <marksiemers> Or, even better, ask here:
<vivus> I just spun up a new amber project and ran `amber g auth User` . probably something wrong I did.
<FromGitter> <marksiemers> No, the docs for that are out of date - I had the same issue last week, I just don't remember the resolution
<FromGitter> <marksiemers> In general, the generators will be more up-to-date than the docs - from my experience so far
<vivus> is this syntax familiar to Ruby users? I am looking through it and it is somewhat confusing
DTZUZO has quit [Ping timeout: 248 seconds]
<vivus> @marksiemers yeah I noticed that the docs and code in the current app are not the same. quite a few differences
<FromGitter> <marksiemers> Crystal has a lot of similarities to Ruby, Amber has some similarities to Rails, but also Phoenix and other frameworks/libs - so there will be some divergence.
<FromGitter> <marksiemers> I would say the biggest place is in the routes and the ORM
<FromGitter> <marksiemers> ecr ~= erb and slang ~= slim and the controllers should look similar
<vivus> @marksiemers do I run `amber g auth User` before or after creating the database? `amber db create`
<FromGitter> <marksiemers> If you join the amber channel, you can ask away and get probably better advice/answers from the core team.
<vivus> ill need a gitter account. or I think I have one...
<FromGitter> <faustinoaq> Wow, Manjaro Linux have dedicated hardware ✨ 👏
<FromGitter> <marksiemers> I don't know if that will matter, but you will have to run `amber db migrate` after you generate the auth
<FromGitter> <marksiemers> `amber db create && amber g auth User && amber db migrate seed` - that's probably the safest
<vivus> yeah I got some odd errors doing g auth User first
<FromGitter> <faustinoaq> @marksiemers On sqlite `amber db migrate` give an error, I have to use `amber migrate up` instead
<FromGitter> <faustinoaq> On postgres and mysql `amber db create` works as expected
<FromGitter> <faustinoaq> @marksiemers Maybe we can create an amber topic on IRC and create a binding to amber gitter room, just like crystal does here
<vivus> this room only has 111 people. Unless the gitter channel has a lot more
sz0 has joined #crystal-lang
<FromGitter> <marksiemers> @faustinoaq - That sounds like a good idea
<FromGitter> <marksiemers> @vivus - If you do want to join gitter - it just uses your GitHub credentials
<vivus> this generator is awesome. it creates a user, login and logout without writing any code
<FromGitter> <marksiemers> Yeah, it is one of the advantages (aka tradoffs) of using amber vs kemal.
alex`` has quit [Ping timeout: 258 seconds]
<vivus> @marksiemers I am working backwards and seeing if I can 'cheat' and create a reddit/twitter clone using a rails tutorial
<FromGitter> <marksiemers> That's a fun experiment - I just started contributing to Amber last week - there is a lot to address, but it looks pretty promising as a Rails replacement with Crystal speed.
<FromGitter> <marksiemers> I'm sure the core team would like to hear how it goes for you (I would too).
<vivus> @marksiemers I assume switching languages for you is a lot easier than a non-Rubyist
<FromGitter> <marksiemers> Yeah, knowing thing the "ruby way" is helpful, but if someone only has Ruby (and JS) experience then they may not immediately appreciate strong typing, compilation, and method overloading (sorely missed)
<vivus> or if they aren't used to verbose syntax either :P
<FromGitter> <marksiemers> That would be for the non-rubyist, yes, very verbose. Are you coming from go-lang?
<vivus> Python (eek)
<FromGitter> <marksiemers> Oh, yeah, there is more than one way to solve a problem here...
<vivus> and lots of `::` everywhere XD
<FromGitter> <marksiemers> And I don't think there is a benevolent dictator
<vivus> Ruby has a BDFL :P
<Papierkorb> reminds me we had people who requested crystal to use a indention-code-block thing like python. "Reject, NEXT."
<vivus> a difficult thing to implement for a compiler
<Papierkorb> and an awful thing to read as human
<vivus> indentation makes code more readable IMO
<Papierkorb> indention? Yes, sure
<Papierkorb> but not in the way python uses it
<Papierkorb> no one is saying anything against indenting code properly. just that relying on that for code blocks makes it insanely hard to read
<vivus> how do I add the following: to ../config/ ?
<FromGitter> <faustinoaq> Papierkorb, I like Python indentation, What do you think could be a good replacement for `end` keyword ? Maybe braces {} ? 😅
<FromGitter> <marksiemers> Well, you can scaffold posts, that will modify the routes for you, or...
<vivus> @marksiemers this is the tutorial: (probably something that could be replicated by the amber core-team in 3 hours)
<FromGitter> <marksiemers> `resources "/posts", PostController`
<FromGitter> <marksiemers> Hopefully someone can look into it - right now the priority is coding > tutorials. ⏎ But that and the Hartl Tutorial would be good to replicate (his is a twitter clone)
<vivus> link to Hartl tutorial?
<FromGitter> <marksiemers> `get "/", PostController, :index` - for the root route
<FromGitter> <marksiemers>
<vivus> oh that one. Yeah makes sense
<FromGitter> <faustinoaq> @marksiemers Have you been able to use `redirect_to :PostController, :index` on amber ? instead of `redirect_to "/posts"` ?
<FromGitter> <faustinoaq> I tried, but I'm getting `Nil Assertion` error
<vivus> do I need to create a PostController via amber? `amber generate controller Post ...` ?
<FromGitter> <faustinoaq> `Nil` never die 😆
<FromGitter> <marksiemers> @vivus - You don't "need" to use the amber generator for anything, but it will save you from typing a lot of code - particularly while learning
<vivus> true that
<FromGitter> <marksiemers> I would recommend you scaffold one thing, just to see all the files it creates and updates
<FromGitter> <marksiemers> `amber g scaffold Post title:string body:text` for instance
<vivus> I ran `amber generate model Post title:string url:string body:text` is this the same as `amber generate scaffold ...` ?
<vivus> I see it isn't
notdaniel has quit [Quit: Leaving]
<FromGitter> <faustinoaq> No, scaffolding is a bit more complex
<FromGitter> <faustinoaq> It generates views, spec and controllers too
<FromGitter> <marksiemers> And modifies the routes - it does quite a bit
<vivus> yep I see it now. it added the routes for me
<vivus> very powerful framework
<FromGitter> <faustinoaq> Yeah, we just need a better documentation 😅
<vivus> interesting
<vivus> this is insane. I haven't written 1 line of code and I have a reddit clone with authentication :/
<FromGitter> <faustinoaq> Wow, can you share us the commands you used ? ⏎ ⏎ I want to try too 😄
<FromGitter> <faustinoaq> Hey guys, What is your favorite programming font? I love Consolas, but isn't avaliable on Linux :( I have to copy from Windows machine, exist some good programming font on Linux, I used to use Inconsolate, but looks really bad in normal DPI screens. Also Ubuntu modo seems good but I don't like the "m" 😅
<vivus> @faustinoaq you can use the following commands:
<FromGitter> <faustinoaq> vivus, Thanks you!
<vivus> I now see why people have used Rails for prototyping. Amber is awesome!
<vivus> I shall catch up tomorrow. ciao!
<vivus> and thanks @marksiemers and others
vivus has quit [Quit: Leaving]
<FromGitter> <marksiemers> np ciao
<FromGitter> <pnloyd> @faustinoaq I tried some fonts recently and decided on roboto mono medium. Roboto scales well to small sizes, combined with the medium thickness makes it really easy to read smaller fonts. So you can fit more code on your screen 😄
<FromGitter> <faustinoaq> @pnloyd Thanks you! good recommendation, Is Roboto the same font Crystal uses in his home page code examples?
<FromGitter> <pnloyd> Looks like it ya
<FromGitter> <pnloyd> It uses roboto mono
<FromGitter> <faustinoaq> 👍
<FromGitter> <pnloyd> I think roboto is the most popular font on
<FromGitter> <pnloyd> Here is a screenshot of what it looks like.
csk157 has joined #crystal-lang
csk157 has quit [Ping timeout: 240 seconds]
lacour has joined #crystal-lang
<FromGitter> <faustinoaq> Wow, great screenshot 😍 What theme are you using? seti ?
<FromGitter> <pnloyd>
<FromGitter> <pnloyd> That's my settings file
<FromGitter> <pnloyd> What I did was make almost every background color the same with manual entries, so the theme I use just colors the syntax.
Poeticode is now known as Poeticorpse
<FromGitter> <pnloyd> Then use any settings I can to hide things that are not part of the code editors
<FromGitter> <pnloyd> The theme is "Material Theme"
jfontan has quit [Quit: Ping timeout (120 seconds)]
jfontan has joined #crystal-lang
<FromGitter> <faustinoaq> @pnloyd Oh Thanks you! <3
alex`` has joined #crystal-lang
<FromGitter> <pnloyd> @faustinoaq np!
rohitpaulk has joined #crystal-lang
<FromGitter> <codenoid> hi, how to set Content-Type in `.post_form`
rohitpaulk has quit [Ping timeout: 258 seconds]
<FromGitter> <maiha> @codenoid use `.post` ?
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
lacour has quit [Quit: Leaving]
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
csk157 has joined #crystal-lang
csk157 has quit [Ping timeout: 248 seconds]
<FromGitter> <codenoid> how ?, i use form data, *i send body data too
snsei has quit [Remote host closed the connection]
<FromGitter> <codenoid> my current script `HTTP::Client.post_form "", "to=242&messages=hhelo", headers: HTTP::Headers{"Content-Type" => "application/json"}`
<FromGitter> <codenoid> but the content type still `application/x-www-form-urlencoded`
snsei has joined #crystal-lang
<FromGitter> <maiha> Although posting data in above code doesn't seem `JSON`, you can send it like this. ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <codenoid> thank @maiha
<FromGitter> <marksiemers> For the TechEmpower benchmarks, is anyone familiar with how was able to optimize the way that it did? ⏎ In the techempower benchmarks, go-lang is quite a bit behind crystal, but that fasthttp lib is ahead: ⏎
<FromGitter> <marksiemers> based just on the description, certain routes don't use the heap at all, probably enables a lot of low level caching by the hardware.
sz0 has quit [Quit: Connection closed for inactivity]
illyohs has quit [Ping timeout: 248 seconds]
Dreamer3 has joined #crystal-lang
<FromGitter> <ansarizafar> A million requests per second with Python
alex`` has quit [Ping timeout: 258 seconds]
<vegai> I don't think it's very useful to look at the hello world benchmarks
<vegai> unless of course you're planning on productizing Hello World
<vegai> something involving IO is much more interesting, like the "multiple queries" & "data updates" benchmarks
<vegai> when something does a million requests per second while talking to postgres, *that* would be interesting :P
<vegai> kemal is doing pretty well here, in fact
alex`` has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<vegai> would be cool if techempower had a test simulating the "found from cache" scenario
Dreamer3 has left #crystal-lang ["Leaving..."]
csk157 has joined #crystal-lang
<FromGitter> <sdogruyol> morning everyone
csk157 has quit [Ping timeout: 255 seconds]
tdc has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
mark_66 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
notdaniel has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
<watzon> Ok I know this is most likely a no, but is there any way to make the second example here work?
<watzon> I'm running into one of those issues where the type system kinda gets in the way
buggs has quit [Quit: WeeChat 1.5]
<FromGitter> <yxhuvud> No, you would have to figure out what the block returns and create the new hash using that type. Does it allow you to put typeof(yield(keys.first)) into the hash definition?
<watzon> I actually figured out kind of a hacky workaround
<watzon> @yxhuvud actually yes
<watzon> Your solution also works
tdc_ has joined #crystal-lang
Ven has joined #crystal-lang
tdc has quit [Ping timeout: 248 seconds]
Ven is now known as Guest37250
tdc_ has quit [Ping timeout: 258 seconds]
<FromGitter> <yxhuvud> not certain what happens if it would be empty though.
tdc has joined #crystal-lang
<watzon> Hmm good question
<FromGitter> <bew> It will work the same
<FromGitter> <bew> typeof(method) will not actually run the method (and raise in this case), it's used to retrieve only the type that the method returns
<FromGitter> <bew> And as this one raises when it's empty, if it works ot will always return sth with the type you're looking for
<FromGitter> <unreadable> Morning all
<FromGitter> <unreadable> :)
<watzon> Hmm... any way to do a dynamic `responds_to?`
<watzon> Since it only takes a symbol as a parameter I seem to be running in to a problem
<watzon> Oh wait, nvm. I didn't realize you could do `responds_to?(:"word")`
shankar has joined #crystal-lang
shankar has quit [Quit: Leaving]
shankar has joined #crystal-lang
<FromGitter> <hugoabonizio> morning 😃
shankar has quit [Quit: Leaving]
<watzon> I know the decision was made to remove aliases, but you know where they are really useful? For making human readable DSLs
literal has quit [Read error: Connection reset by peer]
<watzon> For instance, the Duration module in ActiveSupport which allows you to do `1.month.ago` which is the same as `1.month.before`, but makes more sense in most contexts
literal has joined #crystal-lang
csk157 has joined #crystal-lang
csk157 has quit [Ping timeout: 248 seconds]
shiro` has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <sdogruyol> @watzon that's not a good example
<watzon> You're right lol, but aliases are good for DSLs
<watzon> Sometimes things just make more sense or are easier to understand with a different word
<FromGitter> <sdogruyol> IMHO that depends
alex`` has quit [Quit: WeeChat 1.9.1]
<FromGitter> <sdogruyol> if there's too much aliases that's not good
<watzon> Oh of course, but sometimes aliases are a benefit
<FromGitter> <sdogruyol> I tend to like them %30 of the time :P
<FromGitter> <exts> does crystal support static methods?
stephenwithav has quit [Ping timeout: 240 seconds]
gcds has joined #crystal-lang
notdaniel has quit [Quit: Leaving]
Guest37250 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<gcds> Hi, how hard do you think will be to make Crystal run on embedded cpus like Cortex M4 and etc? Of course without GC or small version similar to what other ported languages uses
<FromGitter> <sdogruyol> @gcds pretty hard
<Papierkorb> "Without GC" Nope.
<FromGitter> <faustinoaq> @exts yes, it does ⏎ ⏎ ```code paste, see link``` []
<gcds> but there is gc/null
<Papierkorb> GC was surprisingly never an issue for interpreted languages on micro controllers
<FromGitter> <exts> thanks @faustinoaq forgot about that
<Papierkorb> gcds: And then you run out of memory in a few seconds.
<gcds> yeah ok with gc but not bohem I think it would not run on it
<Papierkorb> why do you think that?
<FromGitter> <faustinoaq> Papierkorb, What about rewriting main, disabling GC, using prelude empty and binding LibC, just to use Crystal Syntax
<FromGitter> <asterite> Please just forget about Crystal without a GC. It will never happen. It's impossible. Just forget it.
<Papierkorb> faustinoaq, You can do it. Just because you can doesn't make it "fun"
<RX14> @asterite not in the rust sense but manual memory management C-style is possible (and horrible)
<RX14> obviously not supported by the stdlib
<RX14> someone wrote a kernel in crystal after all
<gcds> I am already trying to make llvm compile for thumb
<gcds> yeah thats was my starting point changing main and prelude
<Papierkorb> RX14: I and like 2 others did
<RX14> the core team won't expend any effort in making crystal work embedded or without an os or anything
<RX14> but I won't discourage cool experiements
<Papierkorb> And it's simply not fun, because the whole stdlib isn't meant to be used that way
<RX14> indeed
<gcds> I mean I started working with bit bigger MCU and its started to pain to work with cpp
<Papierkorb> But before everyone says "Oh boehm doesn't work for that", maybe someone should just try it.
stephenwithav has joined #crystal-lang
stephenwithav has quit [Changing host]
stephenwithav has joined #crystal-lang
<Papierkorb> I don't mean for those 4K RAM machines
<Papierkorb> For really tiny stuff, assembler, C and (now probably) Rust will always be much more useful
<gcds> I mean if ucLinux runs on it
<FromGitter> <asterite> Yes, D without a GC is possible too, and horrible
<FromGitter> <asterite> Use Rust for microcontrollers
<FromGitter> <asterite> Crystal is not for that
<Papierkorb> gcds: Use that a proper linux? How much memory?
<FromGitter> <asterite> Just... stop :-)
<shiro`> no no no
<FromGitter> <sdogruyol> lol @asterite
<shiro`> use C for microcontrollers
<gcds> 512k
<gcds> shiro` I am already using...
<shiro`> that's great!! Keep it up!
<gcds> Cortex M7 is just too masive just to work with C
<shiro`> massive?
<Papierkorb> gcds: Um that's near the realm I'd try it for the heck of it.
<RX14> @asterite sure, stop if you intend to do something useful
<shiro`> what are you doing on it that makes it so massive?
<gcds> usb, sdio, ethernet and etc
<Papierkorb> Half a meg is a ton of memory
<RX14> @asterite but I think hacking crystal to run on strange devices *just for fun* is cool
<shiro`> hm
<RX14> it's a laugh and harmless
<Papierkorb> And if new insights come out of that, why not?
<shiro`> the only time I used embedded the instructor wouldn't let us use third party libraries
<shiro`> so I don't really know what it's like to have a working application
<Papierkorb> shiro`: Normal in school environments
<shiro`> maybe C isn't good at handling that...
<Papierkorb> huh
<shiro`> I'm not sure...
<shiro`> like
<Papierkorb> The world runs on C
<shiro`> he wanted us to interface with an sd card
<gcds> I think technically I could run crystal on ucLinux for sure it has everything
<Papierkorb> C is easily capable of building a program
<shiro`> but he didn't even know how... he just said to read the datasheet and learn
<gcds> Papierkorb u can also fix engine through exhaust pipe if u want
<Papierkorb> shiro`: He probably knew, but wanted you to RTFM
<shiro`> no no no gcds thats like running a container in a container in a container or something
<FromGitter> <faustinoaq> Yeah, I mean ignoring stdlib, gc, prelude empty and using just LibC with Crystal syntax... 😅 is it possible ?
<shiro`> I tried...I'm sorry
<Papierkorb> faustinoaq, sure it is
<gcds> shiro` I know thats why I want plain Crystal
<gcds> for stdlib there is newlib
<shiro`> why not just plain C?
<shiro`> like honestly
<shiro`> what's wrong with C?
<Papierkorb> "plain Crystal" isn't crystal
<Papierkorb> shiro`: That there's Rust nowadays
<gcds> the only think I see which would not work is pcre
<gcds> pthreads already exists :D
<Papierkorb> Which you probably don't even need anyway
<gcds> yeah
<gcds> incase of rtos :D
<Papierkorb> RTOS and Crystal? Oh boy
<FromGitter> <asterite> Crystal without a GC and without a prelude is just almost C with a different syntax
<RX14> i wish llvm-cbe was actually maintained
<FromGitter> <asterite> If writing C with a different syntax is fun, go ahead :)
<FromGitter> <kazzkiq> Does Logger ( actually saves the logging to a file by default? Or it just prints them on terminal?
<RX14> @asterite i'd argue it's not
<gcds> asterite I could make GC but not original
<gcds> which still would be GC
<RX14> @asterite since you can *build* a standard library from that base
<RX14> @asterite you can build a much better uc stdlib in crystal thanh you can in C
<RX14> since crystal has better tools for abstraction
<gcds> RX14 exactly why I want crystal
<RX14> but it'll always be a pain and not "real crystal" because it won't be the "real" stdlib
<RX14> the best bet for crystal on uc is to write a stdlib from scratch
<RX14> something with an arduino-like abstraction would be cool
<gcds> RX14 but what will limit stdlib
<Papierkorb> gcds: Do you know Rust? How half of their type system revolves around memory management? With those funny suffixes like ' ? They don't do it because it's fun, but because it's needed. Language design-wise, "automatic non-GC memory management" comes at a big price. Rust wanted to pay it. We didn't.
<gcds> Papierkorb I know
<FromGitter> <sdogruyol> and Rust is hard..
<FromGitter> <sdogruyol> the learning curve is not that easy
<gcds> sdogruyol: exactly
<RX14> and writing a crystal stdlib from scratch is easier?
<Papierkorb> why rewrite it?
<RX14> we depend on virtual memory
<RX14> hard depend
<Papierkorb> mh?
<RX14> microcontrolers dont have a MMU
<RX14> spawn
<RX14> mmap
<shiro`> maybe write a virtual machine that implements crystal
<FromGitter> <sdogruyol> no please, no VM :/
<Papierkorb> Ever heard of LLVM?
<shiro`> no no no
<shiro`> that's not virtual enough
<shiro`> it has to be at least as virtual as the jvm
<Papierkorb> RX14: Why does spawn need VM though?
<RX14> you'd at least need major patches
<RX14> well we have a hardcoded stack size of 8MiB
<shiro`> basically you need to write a crystal compiler
<shiro`> wtf
<RX14> no shiro`
<shiro`> a hardcoded stack size of 8MiB?
<RX14> not at all
Ven has joined #crystal-lang
<RX14> it's possible to compile crystal code for an arm microcontroller (without the stdlib) today
Ven is now known as Guest67908
<crystal-gh> [crystal] asterite opened pull request #5226: Syntax: check Expressions#keyword in to_s (master...bug/5219-fix-parser-to_s-parens)
<RX14> i heard someone did it
<crystal-gh> [crystal] asterite closed pull request #5222: Fix ASTNode#to_s to wrap with parenthesis as needed (master...fix/crystal/ast-to-s-wrap-parenthesis-as-needed)
<RX14> Papierkorb, honestly unless it runs an OS with a FS the current stdlib is just not going to play with it
<RX14> im sure of it
<RX14> the assumptions we make
<Papierkorb> Yeah I/O is the biggest issue
<Papierkorb> But he's using ucLinux
<Papierkorb> So if that thing doesn't have a VFS, I don't know
<gcds> RX14 what if I go ucLinux way and create pseudo file system
<FromGitter> <exts> woo, coding at 7am makes me overlook spelling bugs -_- dsn != dns
<FromGitter> <sdogruyol> @exts have some coffee and you'll be good to go
<RX14> gcds, might work
<RX14> would need to absolutely not use fibers though
<RX14> oh wait
<RX14> we spawn them on init for libevent
<RX14> so now you have to rip livevent from the scheduler
<FromGitter> <exts> @sdogruyol :) *sips* someone mad a pot of some stuff I don't drink lol, need to make a new pot because this stuff isn't doing the trick
<FromGitter> <exts> made *
<RX14> it's major patches Papierkorb
<gcds> libevent is just event loop I think you can create something similar in microway
<RX14> the problem is you've now lost the benefits of a microcontroller: latency and power use
<RX14> you have an OS
<RX14> just get a raspi at this point
<crystal-gh> [crystal] asterite pushed 2 new commits to master:
<crystal-gh> crystal/master 81a4c29 Stefan Merettig: ENV#[]=: Disallow null bytes in key and value...
<crystal-gh> crystal/master 99c3d2b Ary Borenszweig: Merge pull request #5216 from Papierkorb/disallow-nul-in-setenv...
<RX14> or some cheap ARM chip
<RX14> with a mmu
<RX14> that runs linux *properly*
<gcds> it cant do much device stuff
<gcds> its more pc than a device
<RX14> you can get things with mmus which have gpio
<gcds> gpio is not an issue
<gcds> wtf "BUG: __crystal_personality is not defined"
<RX14> what did you try to do
<gcds> compile to thumbv7em
<gcds> simple a = 1 :D
<RX14> because it seems like you're trying to add a new arch
<RX14> and you're not doing it right
<RX14> whats the target gcds
<RX14> target triple
<gcds> thumbv7em-none-eabi
<gcds> by llvm its covered by "arm"
<RX14> yeah but the triple doesn't have "arm" in it
<RX14> so the "arm" flag isn't set
<RX14> and so the stdlib doesn't have a clue what you're doing
<RX14> is that really the triple?
<RX14> hmm
<gcds> there is no stdlib
<RX14> looks like you need to -Darm
<RX14> oh
<FromGitter> <exts> is there a list of std libs that are automatically loaded on compile?
<RX14> --prelude empty ?
<gcds> exts
<gcds> yeah
<RX14> gcds, you need a __crystal_personality for raise
<Papierkorb> the empty prelude isn't empty
<RX14> which you can't do anyway
<FromGitter> <exts> thanks
<RX14> i forget how the OSes did it
<RX14> you might need to def an empty __Crystal_raise
<gcds> nah empty prelude for some reasone still does something
<RX14> yeah it's empty as in empty but you get a main function with argv and argc which calls the crystal top-level init
Guest67908 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<gcds> it does not call because crystal/main is in prelude
<RX14> ???
<RX14> no but it does use LibCrystalMain
<gcds> ahh
<gcds> it compiled but I cant link :D
<gcds> oh well --specs=nosys.specs worked :D
<FromGitter> <exts> any crystal blogs out there in the wild I should bookmark?
alex`` has joined #crystal-lang
<FromGitter> <faustinoaq> Yeah,
claudiuinberlin has joined #crystal-lang
<FromGitter> <exts> :|
<crystal-gh> [crystal] asterite closed pull request #5226: Syntax: check Expressions#keyword in to_s (master...bug/5219-fix-parser-to_s-parens)
<FromGitter> <faustinoaq> The old one are the good ones, by example
<gcds> by `file` it generated same architecture as normal c code... but I do not have a board here so I cant test if it works :D
<FromGitter> <exts> I mean other people writing about crystal to get people talking about it :P
<FromGitter> <faustinoaq> 😜 @exts check medium then
<gcds> will try to run on qemu :D
<gcds> i love big repost with over 500k files....
<gcds> repos*
<crystal-gh> [crystal] asterite reopened pull request #5226: Syntax: check Expressions#keyword in to_s (master...bug/5219-fix-parser-to_s-parens)
Ven_ has joined #crystal-lang
csk157_1 has joined #crystal-lang
shankar has joined #crystal-lang
shankar has quit [Read error: Connection reset by peer]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<crystal-gh> [crystal] MakeNowJust opened pull request #5227: Can't use `self` in toplevel method (master...fix/crystal/no-self-in-toplevel-method)
<gcds> ok so problem is that libunwind is missing :D
csk157_1 has quit [Ping timeout: 260 seconds]
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<gcds> OMG IT WORKS :D
<gcds> nope false alarm :D
Poeticorpse is now known as Poeticode
claudiuinberlin has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest82369
TheGillies has quit [Ping timeout: 240 seconds]
tybee[m] has quit [Ping timeout: 240 seconds]
weston_[m] has quit [Ping timeout: 276 seconds]
weston_[m] has joined #crystal-lang
tybee[m] has joined #crystal-lang
csk157_1 has joined #crystal-lang
TheGillies has joined #crystal-lang
csk157_1 has quit [Ping timeout: 260 seconds]
mbarbar has joined #crystal-lang
mbarbar_ has joined #crystal-lang
mbarbar__ has joined #crystal-lang
<crystal-gh> [crystal] straight-shoota opened pull request #5228: Fix: Added missing name field to constant doc json (
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mbarbar has quit [Ping timeout: 240 seconds]
mbarbar__ has quit [Ping timeout: 240 seconds]
mbarbar_ has quit [Ping timeout: 260 seconds]
claudiuinberlin has joined #crystal-lang
<crystal-gh> [crystal] jhass closed pull request #3762: Implement JSON format documentation (master...json_doc)
<FromGitter> <crisward> is there a nice way to see if a `nil|string` object property has a size without first copying it to a local var. eg. user.password.size > 8, maybe using try or something??
<FromGitter> <imcrazytwkr> Hi, folks. Sorry for going straight to the point but is there any recommended way to pass the info down middleware chain in Crystal? I saw that Kemal extends `HTTP::Context` and `HTTP::Request` but I wanted to avoid monkey patching.
<FromGitter> <crisward> `user. password.try(&.size).try(&.> 5)` works, but gawd it's ugly
<FromGitter> <imcrazytwkr> @crisward not sure if it is the best solution but maybe `return false unless user.password.responds_to?(:size)`?
<FromGitter> <crisward> Think I'll wrap my ugly method in a util and call that. At least I don't have to look at it, and can fix it in the future if a nicer solution occurs. @imcrazytwkr thanks.
<Papierkorb> crisward, either `stuff.try(&.size.> 5)` or `(stuff.try(&.size) || 0) > 5`
<Papierkorb> I'd prefer the former
<Papierkorb> ... Please don't use responds_to for that.
<crystal-gh> [crystal] jhass pushed 2 new commits to master:
<crystal-gh> crystal/master b16b851 Johannes Müller: Fix: Added missing name field to constant doc json
<crystal-gh> crystal/master ef117af Jonne Haß: Merge pull request #5228 from straight-shoota/jm-json-docs--fix-constant-name...
<FromGitter> <crisward> Yeah, I prefer your former one too. didn't know you could do that. Still going to create a util with it though. Thanks.
snsei has quit [Remote host closed the connection]
mark_66 has quit [Remote host closed the connection]
<FromGitter> <faustinoaq> @crisward Why not more explicit option ? ⏎ ⏎ ```if password = user.password ⏎ password.size > 5 ⏎ end``` ⏎ ⏎ If I were a programmer without knowledge about crystal nor ruby, `.try(&` would look very strange to me ... []
lacour has joined #crystal-lang
<travis-ci> crystal-lang/crystal#ef117af (master - Merge pull request #5228 from straight-shoota/jm-json-docs--fix-constant-name): The build passed.
<DeBot_> (Fix: Added missing name field to constant doc json)
snsei has joined #crystal-lang
<gcds> I got crystal to compile, but now the problem is with linker script and whole arm init stuff...
<FromGitter> <faustinoaq> gcds, also check @ysbaddaden is THE guy that added ARM support to crystal 😄
snsei has quit [Ping timeout: 246 seconds]
<gcds> its bit different ARM stuff it runs basically on OS
Guest82369 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven is now known as Guest47329
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<gcds> Finally after merging everything with CSIS *** load of stuff now I am blinking led :D
<FromGitter> <faustinoaq> ✨ 👏
<gcds> is possible to define a Lib constant as pointer?
<gcds> because now I am using Poiner(UInt32).new(0xXXXX) to manipulate registers
<gcds> then in original headers its (uint32_t *)0xXXXX
DTZUZO has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
<FromGitter> <faustinoaq> I don't know, What do you mean? ⏎ ⏎ ```lib LibX ⏎ type CONSTANT = UInt32* ⏎ end``` ⏎ ⏎ Maybe using out to avoid writing types 👉 ... []
DTZUZO has quit [Ping timeout: 260 seconds]
<gcds> its more trash can than experiment but I can upload to gh
claudiuinberlin has joined #crystal-lang
<gcds> builds everything :D makefile doenst work D:
<gcds> I guess this is bad. But it was only thing which let me link it correctly
Creatornator has joined #crystal-lang
<Papierkorb> Simply `FOO = Pointer(UInt32).new(0x1234)`
<FromGitter> <sdogruyol> it's great to see @jhass around :D
<gcds> I will come back home and will try to port whole sysclock init stuff to Crystal
<gcds> because now it depends on c
<gcds> P.S. how I can define exported function in Crystal?
<Papierkorb> using `fun`, yes
<FromGitter> <faustinoaq> Wow, thanks you, nice to see developers experimenting with Crystal! 👏 ⏎ ⏎ even if his creator says NO 😉
<gcds> desperate situations require desperate measures :D
<Papierkorb> We don't advance by not doing insane things
<Papierkorb> Building a machine that does your math homework for you cause you're too lazy?
<Papierkorb> Yeah sure
<crystal-gh> [crystal] straight-shoota opened pull request #5229: Improved search feature for API docs (
<gcds> P.S. by doing machine which does ur homework u need to understand ur homework to write a algo... I think this way u learn way more than just doing homework :D
<FromGitter> <faustinoaq> Well, I'm wrong, He was agree ⏎ ⏎ > Crystal without a GC and without a prelude is just almost C with a different syntax ⏎ >> If writing C with a different syntax is fun, go ahead :) ⏎ ... []
csk157_1 has joined #crystal-lang
csk157_1 has quit [Ping timeout: 252 seconds]
<FromGitter> <faustinoaq> @sdogruyol How many years since you discovered Crystal? I'm here since Jun, 2016. Also I see you met almost all core team 😄
<FromGitter> <sdogruyol> hmm let me think
<FromGitter> <sdogruyol> ~2.5 years
<gcds> I think if written HAL and then nice interface on top of it with style of Crystal this would be sick for developing embedded :D
<FromGitter> <faustinoaq> > ~2.5 years ⏎ ⏎ @sdogruyol Wow, Crystal is almost 5 year old, and you are here since his middle age 😄 ⏎ ⏎ I hope to see in the future, Does railsconfbr publish their conferences? []
<FromGitter> <sdogruyol> @faustinoaq I actually discovered Crystal back in 2014 but started playing with it in 2015 :P
<FromGitter> <faustinoaq> ✨ 👍
claudiuinberlin has quit [Quit: Textual IRC Client:]
<FromGitter> <sdogruyol> time really flies
<gcds> Will be so lovely to port this file to crystal :D
<Papierkorb> use a binding generator
<Papierkorb> bindgen can do that
<gcds> will try it
<FromGitter> <sdogruyol> @Papierkorb what will be the most beneficial thing to use bindgen for?
<Papierkorb> see all those enums and #defines that act like enums? With different types and everything? Bindgen can turn that into .cr code easily.
<Papierkorb> never used that ^, I built to wrap Qt5
<Papierkorb> though it can be used for more than that
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<gcds> i saw that before but had no idea how to use it :D
<Papierkorb> Yeah samples are lacking. documentation wise, the TEMPLATE.yml is all you need
<Papierkorb> what's not in there doesn't exist
<gcds> so I need to define everything in config file?
<Papierkorb> for your stuff, see samples/ioctl.yml
<Papierkorb> not much different to what you'll need feature-wise
<Papierkorb> everything? Nah, you can use pretty broad regex's if you want to capture most/all #defines
<gcds> looks interesting
<Papierkorb> if you want them to be nicer, maybe with extended grouping features, also possible through regex's
<Papierkorb> If you want to go further than that, well then you have to tell what's an enum or not, etc
<gcds> ok
<Papierkorb> C projects are wayyyy to insane and different for such stuff to be reliably auto-detected, so I went the "configuration over magic" route
<Papierkorb> Which allows you to turn C functions into classes though, so it's not all in vain lul
csk157_1 has joined #crystal-lang
<gcds> does it follow includes?
<Papierkorb> sure
<gcds> niiice
hightower4 has joined #crystal-lang
hightower3 has quit [Ping timeout: 240 seconds]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
<crystal-gh> [crystal] j8r opened pull request #5230: FilleUtils: Add a recursive `chmod_r` and `chown_r` (master...recursive_chmod_chown)
illyohs has joined #crystal-lang
Creatornator has joined #crystal-lang
Guest47329 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest11104
<FromGitter> <exts> do you need crystal installed on a server to run the binary?
alex`` has quit [Ping timeout: 246 seconds]
<FromGitter> <sdogruyol> no, just the dependencies
gcds has quit [Ping timeout: 240 seconds]
<FromGitter> <Shalmezad> Doesn't appear so: ⏎ ⏎ ```code paste, see link``` []
alex`` has joined #crystal-lang
<FromGitter> <exts> alright thanks
<FromGitter> <Shalmezad> Since I've only known crystal for 2 days now, is there a list of ~~gems~~ shards available somewhere? Or would one just have to dig through github to find them (if there is one for whatever you're working on).
Guest11104 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
<FromGitter> <Shalmezad> Thanks!
rohitpaulk has quit [Ping timeout: 260 seconds]
Creatornator has joined #crystal-lang
<FromGitter> <salzig> Hi there. ⏎ i would like to build a crystal app and provide it as a statically linked binary. As far as i understand i can provide `--link-flags="-static"`, which will embed almost everything. Is there an easy way to also embed libc? ⏎ Background: Would love to distribute the app as statically linked docker image without the need of a "distribution" base image.
Ven has joined #crystal-lang
Ven is now known as Guest15573
illyohs has quit [Read error: Connection reset by peer]
<FromGitter> <faustinoaq> Yeah, sure you can but needs to do inside Alpine, it uses Musl instead of LibC, so is easier to link.
<FromGitter> <faustinoaq> @salzig Also if you are using ARM based architecture or RaspberryPi check
<FromGitter> <salzig> @faustinoaq Musl-libc is just another implementation of libc. I would love to embed it into the final binary without the need of a distribution like base docker image. As in -> i would like to use `FROM scratch\nCOPY my_app .\nCMD ["/my_app"]`
<FromGitter> <salzig> sadly `--link-flags="-static"` seems to still require a, so libc (being gnulibc or musllibc) is not embeded. ⏎ Or did i miss something important?
<FromGitter> <bew> @salzig did you see this post?
<FromGitter> <salzig> @bew not yet.
<FromGitter> <salzig> yeah, he is copying all necessary shared objects. Thought there would be an easier way.
<FromGitter> <watzon> I just realized that if I type `Thread.current` into icr I actually get the current thread. Is that part of the experimental thread support?
<FromGitter> <salzig> something like i know from go-lang, where you can build using cgo and have a single binary that contains everything
qard has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <mgarciaisaia> Static binaries, using muscl, is something we definitely want to achieve - but don't think we'll have that soon
Creatornator has joined #crystal-lang
<FromGitter> <salzig> oh btw, could it be that glibc is embed, but dependencies used by glibc are loaded dynamically (e.g dns resolving)?
<FromGitter> <salzig> (sry, i'm kinda new to linking and compiling. #rubyist)
<FromGitter> <salzig> @mgarciaisaia is there an problem using musl?
<FromGitter> <mgarciaisaia> I think statically linking glibc is a Bad Thing To Do™, but I'm not really sure about that - or why
<FromGitter> <mgarciaisaia> There are a couple of issues/PRs about Musl:
<FromGitter> <salzig> - ok, musl is not that easy :)
<FromGitter> <mgarciaisaia> Maybe we're just not paying enough attention to it - don't recall the convos with the rest of the team about it
<FromGitter> <salzig> at least there is
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
csk157_2 has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
csk157_1 has quit [Ping timeout: 260 seconds]
tdc has quit [Ping timeout: 260 seconds]
claudiuinberlin has joined #crystal-lang
<FromGitter> <salzig> thanks @faustinoaq @bew @mgarciaisaia for some hints. Too bad there is no easy solution right now.
<FromGitter> <mgarciaisaia> What's the issue with the blogpost's solution?
<FromGitter> <mgarciaisaia> Size?
<Papierkorb> the semantics are practically the same (the container image is consistent), but if need ever arises (It's IT, it will), you can still rip it apart in 15 years and update completely broken libraries in it without rebuilding the program you've lost the source code when that last guy left the company
<Papierkorb> Can't say the same about static linking
<FromGitter> <yxhuvud> Glibc doesnt support static linking. Xlib is the same thing, they break.
sz0 has joined #crystal-lang
csk157_2 has quit [Quit: WeeChat 1.9.1]
Creatornator has joined #crystal-lang
<FromGitter> <unreadable> I've been using musl with Rust with no problems, some may says that is not as fast as libc, but it uses less memory from what I've seen
alex`` has quit [Ping timeout: 248 seconds]
<FromGitter> <unreadable> btw, can assembly be wrapped in a crystal module? I'm trying to read a file and wrap it up
<Papierkorb> what kind of assembly?
<Papierkorb> inline assembler?
<FromGitter> <unreadable> Linux x86_64 assembly
<FromGitter> <unreadable> Maybe something like `asm(mov etc)`
<Papierkorb> The keyword is `asm(X)`, with X being compatible with LLVM/Clang and GCC-for-the-most-part:
<Papierkorb> E.g., running `asm("mov $0, %rax")` may break your program :)
<Papierkorb> Mh dunno if it's still relevant today, but sometimes you had to duplicate the $ and % in your listing
<Papierkorb> unreadable, also check out, it does stack pointer magic and hence, inline assembly
Guest15573 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has quit [Quit: Textual IRC Client:]
<FromGitter> <unreadable> Thanks
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest26819
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
Creatornator has quit [Client Quit]
Guest26819 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<robacarp> In a macro, I used TupleLiteral#map and #join to create a StringLiteral of the code being generated but I'm unclear how to get the macro to emit that StringLiteral as code instead of wrapped in "". If that's unclear, I'll extract out the pattern and make an paste
<FromGitter> <bew> Add #id
<FromGitter> <bew> {{}}
<FromGitter> <bew> Instead of {{bla}}
<robacarp> ah, why was I thinking #name? Thanks bew
<FromGitter> <watzon> So what's the best way to type a Hash who's value can either be a Hash or a String, but recursively? For instance : `{ "hello" => "world", "languages" => { "es" => "spanish" }}`
<FromGitter> <watzon> Is there any way to do that? Or would I have to just leave the type off?
<robacarp> JSON::Any does that, I think?
<FromGitter> <watzon> Yeah, it does. I guess I may have to do that
<FromGitter> <watzon> I was just wondering if there was another way to do it that didn't require importing json or yaml
<robacarp> I think you can just declare your own recursive type alias
<FromGitter> <watzon> But you can't create a recursive alias
<FromGitter> <watzon> I've tried
<robacarp> what did you try?
<FromGitter> <bew> It's how json's generic type currently works so it works ^^
<robacarp> `alias MyHash = Hash(String, MyHash | String)` I think would probably work given what you have there
<FromGitter> <watzon> Weird, I could swear I've tried that before and it didn't work
<FromGitter> <watzon> I suppose I'll try again lol