RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <j8r> @ArchaicLord I'm devops. I can recommend to have a little remote linux server like a Raspberry or in the Cloud. I'm developing in Crystal because of high level, good perf, and easy to ship (single binary)
<FromGitter> <j8r> In your linux box try t
<FromGitter> <j8r> put applications that people (you, familly, friends) will use :)
<FromGitter> <j8r> @ArchaicLord By learning Crystal I've increased my dev skills, and even had a Ruby job offer. If you have public Crystal projects to present, you can too. This also helps for devops tools that use Ruby, and even Python ones
<FromGitter> <ArchaicLord> @j8r cool. I was on a road map to learn vim and python. I was looking at zsh and terninaks. Came across alacrity. Asked a question there and was encouraged to look at rust. A week later I came across this and just keep getting side tracked.
<FromGitter> <ArchaicLord> Ruby isn't something I have been interested in but python is for sure.
<FromGitter> <Blacksmoke16> updating the error message generation on my validation lib
<FromGitter> <Blacksmoke16> old: `'name' has failed the equal_to_assertion`
<FromGitter> <Blacksmoke16> new: `'name' should be equal to John`
<FromGitter> <Blacksmoke16> 🚀
<FromGitter> <Blacksmoke16> can also override the message using placeholder values, so like `Expected {{field}} to equal {{value}} but got {{actual}}` would display as `Expected name to equal John but got foo`
<FromGitter> <Aaron-Fleisher> Hi!
<FromGitter> <Blacksmoke16> o/
<FromGitter> <Aaron-Fleisher> I am converting my old C++ tcp server, and it's been going great so far. I don't want to go back. This language is awesome, just wanted to share!
<FromGitter> <Blacksmoke16> 💯
<FromGitter> <Aaron-Fleisher> What are you all working on / doing with crystal lang? :)
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/CrSerializer this lately
<FromGitter> <DanilaFe> https://github.com/DanilaFe/pegasus
<FromGitter> <Aaron-Fleisher> Interesting... very cool
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
<FromGitter> <diegogub_gitlab> @Aaron-Fleisher I'm working on a web scraper and a Event Store for CQRS
<FromGitter> <diegogub_gitlab> @Blacksmoke16 finally I had to copy few more dependencies, but it's working now. Thanks!
<FromGitter> <Blacksmoke16> get it working with scratch?
<FromGitter> <diegogub_gitlab> @Blacksmoke16 yes, copying all libs works just fine, and I had to add also some dns / resolv libs
<FromGitter> <Blacksmoke16> how big was the final image?
<FromGitter> <hello2dj> i have made benchmark on crystal and node, crystal lose。 so sad, crystal 10k, node 18k
<FromGitter> <Blacksmoke16> benchmark of what?
<FromGitter> <hello2dj> http server
<FromGitter> <diegogub_gitlab> @Blacksmoke16 19.5MB! :)
<FromGitter> <Blacksmoke16> noice, i might have to look into doing that too ;)
<FromGitter> <Blacksmoke16> thats the same image @hello2dj
<FromGitter> <proyb6> @hello2dj nodeja use multicore, while Crystal ran one core, you can spawn process or run in cluster, Crystal could be as fast as Golang fast HTTP
<FromGitter> <hello2dj> node use multicore? i don't use node in cluster, so node also use one core
<FromGitter> <proyb6> You could examing the process using top command
<FromGitter> <hello2dj> ok
<FromGitter> <hello2dj> You can see this.
<FromGitter> <proyb6> That because they were affected by database max pool, that drag down score
<FromGitter> <hello2dj> yes i love crystal, i want use it replace node in production, but ....
<FromGitter> <proyb6> The issue was rectify by lower max connection pool to 8 from 256
<FromGitter> <proyb6> Its depend on your use case
<FromGitter> <hello2dj> thank you
<FromGitter> <Blacksmoke16> also understand node is a lot more mature of a lang, crystal isnt 1.0.0 yet so is time for improvement changes etc
<FromGitter> <Blacksmoke16> but will come down to does it matter if it can handle 8k more requests per sec based on what your prod env is like?
<FromGitter> <Blacksmoke16> i.e. in benchmark it might be lower but in real world how does it compare
<FromGitter> <hello2dj> yeah it maybe need more time for crystal
<FromGitter> <diegogub_gitlab> @hello2dj I replaced a Golang http service (redirect system) with crystal and it's working like a charm. plus , I have macros, templates , classes, generics, etc
<FromGitter> <hello2dj> go is easy to newbie but it also has many other questions, By comparison i like crystal, but it is not 1.0.0
<FromGitter> <hello2dj> so sad
<FromGitter> <Blacksmoke16> not really a big deal imo, just means you'll have to keep an eye on breaking changes
<FromGitter> <Blacksmoke16> depending on your project at least...
<FromGitter> <proyb6> At this time, you have plenty of time to learn Crystal and internal implementation
<FromGitter> <proyb6> H
<FromGitter> <proyb6> What 1.p
<FromGitter> <proyb6> Sorry, for garbage text haha
gangstacat has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <hello2dj> you are right
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
akaiiro has quit [Remote host closed the connection]
<FromGitter> <proyb6> And present us with cool shards, presentation or anything, it's your chance to create a new opportunity in what you have learn from the past and other side
OvermindDL1 has quit [Ping timeout: 250 seconds]
wmoxam has quit [Ping timeout: 276 seconds]
wmoxam has joined #crystal-lang
<FromGitter> <Blacksmoke16> looks like i broke the spec lib
<FromGitter> <Blacksmoke16> ``````
<FromGitter> <Blacksmoke16> ^.^
thews has quit [Ping timeout: 240 seconds]
thews has joined #crystal-lang
<FromGitter> <schoening> Could someone explain to this newbie what is going on here? How come a variable does not have to be passed into the function to be accessible inside the template :o ?
<FromGitter> <anamba> render is a macro, so basically the content of the template is being dumped right into that method
<FromGitter> <schoening> Ok, thanks :)
<FromGitter> <schoening> I can't decide if I find this very neat or worrying :D haha, it certainly is a very different approach to other languages. Would a experienced crystal/ruby programmer have seen at a glance that this is a macro doing its thing?
<FromGitter> <anamba> ruby doesn't have anything like that so it was new to me (i'm coming to crystal after 13 years of ruby)
<FromGitter> <schoening> Oh ok
<FromGitter> <anamba> macros are amazing but take some getting used to
<FromGitter> <schoening> I guess its all about if you like explicit or implicit kind of code :) ⏎ Macros do sound pretty great. I'm glad I am trying out different languages that broaden my view.
<FromGitter> <schoening> If i want to use mustache instead of ecr do I just install the crustache shard, or is there an option inside kemal where I toggle it :) ?
<FromGitter> <anamba> i haven't tried kemal (shocking i know) but i would assume it's just a matter of the extension on the file you pass to `render`
blassin has quit [Ping timeout: 245 seconds]
blassin has joined #crystal-lang
<FromGitter> <j8r> @ArchaicLord if you haven't progammed before,Rust isn't recommended. Crystal/Python are simpler to start with. The main problem of Python is it heavily depends on the system libs – it can run on one OS but not on another one :/
<FromGitter> <hello2dj> rust is also a awsome language
<FromGitter> <j8r> @hello2dj what's also important is memory consumption – this costs even more than CPU
<shmibs> hmmm, does anyone know if this is intended? https://shmibbles.me/tmp/2018-1542267847.png
<shmibs> specifically, the reference-style markdown link that isn't converted to html here. looked at the documentation and it says "subset of markdown" but i'd assumed that was referring only to comment docs
<shmibs> very new to this though, never written anything, so feeling uncertain where else to look...
<FromGitter> <bew> Well the whole docs generator uses the same small Markdown engine as the comments, so yeah it's a subset, not everything works..
flaviodesousa has quit [Remote host closed the connection]
<shmibs> oh ._.
<shmibs> thank you
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 276 seconds]
rohitpaulk has joined #crystal-lang
ashirase has quit [Ping timeout: 268 seconds]
ashirase has joined #crystal-lang
<FromGitter> <drum445> Who forked my repo? ;)
<FromGitter> <drum445> Thanks anyways
<FromGitter> <proyb6> I'm thinking how about changing space to 1 instead of 2 whitespaces?
<FromGitter> <proyb6> Indentation
<FromGitter> <drum445> What's your thinking behind that?
gangstacat has joined #crystal-lang
<FromGitter> <proyb6> When I looking on mobile phone, I analyse 2 whitespaces seem a bit more when Crystal is excel in concise code, some code have nested scope would use 2, 4, 6... whitespaces can be a bit wasteful. I'm thinking if Crystal wants to be a different kind of languages, why not use single Indentation since it's so expressive and we can understand as easy as Basic syntax
<FromGitter> <proyb6> It's like trying to be different
<FromGitter> <drum445> I don't think it would be clear enough where each line is
<FromGitter> <drum445> Python's 4 space is too much; I think 2 is ok
<FromGitter> <drum445> But I guess it's preference
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 246 seconds]
<FromGitter> <proyb6> Golang's space no doubt seems excessive
<FromGitter> <aboeglin> Is there any library to mock DB ?
linuksz has joined #crystal-lang
linuksz has left #crystal-lang [#crystal-lang]
<FromGitter> <drum445> Golang is ace
<FromGitter> <j8r> @proyb6 single tab indentation?
<FromGitter> <proyb6> @j8r Sorry, I mean single whitespace
<FromGitter> <j8r> for single char indentation, tab fits better
<FromGitter> <j8r> that's its purpose in fact
<FromGitter> <ArchaicLord> @j8r I have little bits. Nothing to shout home about but I probably fine more tutorial s than anything else. I want to get into it deeper though. Choosing the right one is difficult.n
<FromGitter> <ArchaicLord> .
<jokke> hey there
<jokke> i'm writing c bindings for the NATS c library and i'm currently struggling to understand how to make this play nice with libevent
<jokke> how can i access the crystal internal event loop? i'm guessing it's the one i should be passing here
<jokke> if i let the lib create threads for reading i'm running into trouble such as: Collecting from unknown thread
<FromGitter> <aboeglin> anyone has some direction about my question above ? I tried to search but couldn't find anything. Since I see you speak about Go, I look for an equivalent of sqlmock.
<jokke> aboeglin: i haven't seen one pop up yet
<FromGitter> <drum445> Not to my knowledge matey
<FromGitter> <aboeglin> So I'd need to somehow mock by hand the API my app relies on right ?
<FromGitter> <aboeglin> the API of DB in that context obviously
<FromGitter> <aboeglin> and what's the way to handle mocking in crystal ? You can just monkey patch modules so that the code test will import the mock ? ( a bit like in js ) Or do you need to inject the mock like you would say in Go ?
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <j8r> @ArchaicLord the important point, IMO, isn't to learn, and after apply in a project, more the reverse - learn because of a real need . e.g. Start with Shell for simple scripts for basic system automation, then awk/Python for advanced file manipulation and then Crystal 😏 . What
<FromGitter> <aboeglin> Well, I could also just mock my data layer somehow, might be easier to handle. So the test doesn't know about the DB at all. Something with like an in-memory array of my model as the context for the test.
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/CrSerializer/pull/4 some cool new features coming soon. Also going to make the syntax for assertions more clear, `@[Assert::Notnill]`
<RX14> I want the purple language colour for crystal back :(
<RX14> it's been purple for so long it feels weird :P
<FromGitter> <Blacksmoke16> ikr? i felt the same way
<RX14> i'll get used to it :P
<FromGitter> <vladfaust> @RX14 why can't I find `__DIR__` variable in crystal repo? Are there any other "magic" variables?
<RX14> yeah there's a few
<FromGitter> <Blacksmoke16> scroll down a bit, wish we could link to headings
<FromGitter> <vladfaust> Nice
<RX14> you can link to headings
<RX14> there's just no link to do it
<FromGitter> <Blacksmoke16> fair enough
<RX14> you have to manually add a #pseudo-constants
<RX14> gitbook is... bad
<RX14> anyway it is documented @vladfaust
<FromGitter> <vladfaust> Is that a full list?
<RX14> yes
<FromGitter> <vladfaust> Is there a built-in way to check if a shard is installed at compilation time? I.e. safe require
<RX14> no
<FromGitter> <vladfaust> Is there a way to get absolute path of an application directory -- not the current file
<FromGitter> <vladfaust> I.e. call from any file and return the same value
<RX14> what do you mean?
<RX14> do you want to find `lib`?
<FromGitter> <vladfaust> Yeah
<RX14> then say so :)
<RX14> the compiler is always executed relative to lib so just use relative paths in macros
<RX14> I don't think conditional requires should be a thing though
<RX14> better to have optional user-requires like require "mylib/foocompat"
<FromGitter> <vladfaust> It basically works, but breaks on "linked" shards
<FromGitter> <Blacksmoke16> it would kinda be cool, at least for a way to check if a given shard is installed
<RX14> it would solve some stuff...
<FromGitter> <Blacksmoke16> i could see some apps having optional dependencies that change logic based on if a specific shard is installed or not
<RX14> whats your current usecase
<FromGitter> <Blacksmoke16> main idea that comes to mind for me would be like:
<RX14> honestly if_required? as a macro would be the most powerful solution
OvermindDL1 has joined #crystal-lang
<RX14> it'd resolve the argument to a file using normal require rules
<FromGitter> <Blacksmoke16> currently i have an `Email` validation to assert that a string is a given email, currently it just uses some regex
<RX14> and then return bool if it was already required
<RX14> problem is that it doesn't solve ordering
<FromGitter> <Blacksmoke16> but say there was an RFC compliant shard to validate emails, if they have that installed then use that vs my regex
<FromGitter> <vladfaust> > problem is that it doesn't solve ordering ⏎ ⏎ What do you mean?
<RX14> @Blacksmoke16 changing behavior on required shards is a dangerous precedent to set
<FromGitter> <vladfaust> No, it's not
<RX14> @vladfaust what if you require shard b after shard a where shard a does a check for shard b
<FromGitter> <Blacksmoke16> er let me rephrase, throw an exception if they try to use the method that depends on an external shard
<FromGitter> <Blacksmoke16> that is not installed
<RX14> @vladfaust yes, it is
<FromGitter> <vladfaust> It's your opinion
<FromGitter> <vladfaust> The ordering problem could be solved if checking at the lib directory under the hood
<RX14> it makes things a lot lot harder to bug, surely you can forsee
<RX14> to debug*
<RX14> adding new behaviour is fine since it's a matter of compiling or not
<RX14> for example JSON serializers for bugnum
<RX14> where currently you need to require big/json i think
<RX14> thats a good use
<RX14> but the email validation one is very weak and I wouldn't want that behavior in a dependency i used
<FromGitter> <vladfaust> `{% if read_file("lib/myshard/shard.yml") %}` works nicely, @Blacksmoke16
<RX14> that doesn't solve the problem for the stdlib
<RX14> and it's pretty robust but sensitive to require path changes
<RX14> it's easy to lock yourself to the current `lib` layout (even if we can't see why we'd want to change it right now)
<FromGitter> <Blacksmoke16> where if they want to use the other type of validation that requires an external shard, make sure it exists before using it
<RX14> distro maintainers may well want to change CRYSTAL_PATH to suit their packaging and I don't want to make it difficult for them
<RX14> @Blacksmoke16 that's a lot more reasonable
<FromGitter> <vladfaust> How `CRYSTAL_PATH` would affect `read_file("lib/myshard/shard.yml")`, @RX14?
<RX14> by people not using shards...
<RX14> as in there's no `lib` at all
<FromGitter> <vladfaust> Ah, no problem, because I'm gonna use that code is shards only :D
<RX14> shard source could be in /usr/src/ or similar
<FromGitter> <vladfaust> Ah
<RX14> right now nobody does that
<RX14> but as i said i don't want to lock us in unneccesarily
<FromGitter> <vladfaust> Conditional require then
<jokke> any help with libevent integration? :/
<FromGitter> <vladfaust> But as it's not a thing yet, gonna stick with my approach
<RX14> yeah for now it works
<jokke> but i have now idea how
<RX14> but if such hacks (kinda) become common then it'd be nice to add required? as a macro
<jokke> at least there's no c code, only headers for those functions
<RX14> i'm not sure from those docs
<RX14> an example would be good
<RX14> ideally you'd just implement the protocol in crystal :)
<RX14> it'd probably be easier than working out how to make some C library pay well with coroutines
<jokke> yeah probably. but i don't know the protocol well enough
<RX14> seems pretty simple
<jokke> mmh
<RX14> that looks like the right function call to use if you want to use nats-c
<RX14> but unless you need nats streaming you're probably going to find it nicer to do the protocol in C
<RX14> crystal*
<RX14> actually no it's impossible to use nats-c to do this jokke
<jokke> oh no!
<jokke> why/
<jokke> ?
<RX14> nats-c wants to be notified on events
<RX14> you can't really poll on crystal, you can only read and write
<RX14> you can integrate it into the libevent loop but that doesn't really help you, it'll just segfault
<RX14> or maybe deadlock
<RX14> either way you're breaking the assumptions that crystal makes about how the scheduler works
<jokke> :/
<jokke> ic
<jokke> ok thanks for pointing that out before i waste more time on this
<RX14> if you want to use nats streaming, basically you can't use crystal
<RX14> actually it might work...
akaiiro has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<RX14> you'd need to do a lot of manual integration with the event loop though
<FromGitter> <Blacksmoke16> any idea on a workaround for https://github.com/crystal-lang/crystal/issues/6980?
<RX14> workaround for what?
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/6980?#issuecomment-432220673 this specifically
<FromGitter> <Blacksmoke16> atm im doing like `=> [:noop]` and just ignoring it when iterating
<RX14> i'm not quite sure what that code is trying to do...
<FromGitter> <Blacksmoke16> its defining a hash, where the key is the name of the annotation and the value is an array of fields that are to be read off of it
<FromGitter> <Blacksmoke16> tl;dr it seems im not able to have an empty array, in any of those 3 formats i tried
<RX14> oh i see
<FromGitter> <vladfaust> @RX14, @Blacksmoke16 is it possible to get the file + LOC which a macro is called from? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bed9a0abb88787474d34ed1]
<RX14> you just need to check if it's an expressions and take the first expression
<RX14> (foo) is an expressions containing 1 expression: foo
<RX14> so {% v = v.expressions[0] if v.is_a? Expressions %} *might* work
<FromGitter> <Blacksmoke16> sec
<FromGitter> <r00ster91> @vladfaust use `__LINE__`: https://carc.in/#/r/5j2e
<FromGitter> <vladfaust> @r00ster91 nope
<FromGitter> <vladfaust> I need it to print `Called from src/bar.cr:1:1`
<FromGitter> <vladfaust> Or at least `Called from src/bar.cr`
<RX14> thats how you do it
<RX14> works with functions too
<FromGitter> <Blacksmoke16> that seemed to do the trip, <3 hero
<RX14> the "magic" is that __FILE__ __LINE__ etc get the values of the caller when they're in default args
<RX14> well, it is magic
<FromGitter> <vladfaust> `# src/bar.cr` and `# src/foo.cr` are different files
<FromGitter> <vladfaust> `foo` is in one, `bar` in another
<RX14> yes...
<RX14> have you tried it?
<FromGitter> <vladfaust> I need filenames
<RX14> use __FILE__ then...
<FromGitter> <vladfaust> Ah, I get it
<FromGitter> <vladfaust> Seems to work, but getting a strange error: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bed9c5fbb88787474d36094]
<FromGitter> <vladfaust> `(given 0, expected 0, 1)`
<FromGitter> <vladfaust> What's that
<RX14> very weird
<RX14> source?
<FromGitter> <vladfaust> It's like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bed9c9621387234050fc0f2]
<FromGitter> <vladfaust> Why is it even working, I have different namespaces
<FromGitter> <vladfaust> Ah
<FromGitter> <vladfaust> I get it
<FromGitter> <vladfaust> different namespaces
<FromGitter> <vladfaust> Sorry, that's alright, working as expected
<FromGitter> <vladfaust> Thanks!
akaiiro has quit [Ping timeout: 252 seconds]
akaiiro has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
<FromGitter> <vladfaust> Why isn't this in the stdlib? :thinking: ⏎ ⏎ ```macro initialize(args) ⏎ def initialize({{args}}) ⏎ end ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5beda7bf6b9822140d354d8c]
<FromGitter> <vladfaust> -8 symbols to write
<FromGitter> <vladfaust> Plus highlighting
<FromGitter> <kinxer> Why wouldn't that just recurse infinitely?
<FromGitter> <kinxer> Oh, I guess it's the `def`.
<FromGitter> <vladfaust> Yep, here is an example: https://carc.in/#/r/5j2y
<FromGitter> <vladfaust> It highlights in Sublime, though
<FromGitter> <vladfaust> Or maybe `macro init`, and init being a keyword
<FromGitter> <kinxer> That seems like a really small quality of life improvement to change the language for, and it would probably be confusing for new Crystal users.
<FromGitter> <vladfaust> Yeah, confusing
<FromGitter> <Blacksmoke16> @ljuti ^ that will break your stuff, but is with it ;)
<FromGitter> <kinxer> Why does the package vendor change for every Crystal release since 0.24.1?
akaiiro has quit [Ping timeout: 244 seconds]
<FromGitter> <ArchaicLord> @j8r not heard of awk. I originally was trying to learn vim and python. But I got side tracked by zsh, then side tracked by learning and looking at different emulators where I got roped into looking at rust which lead me here lol. I am so lost down the rabbit hole.
<FromGitter> <m-o-e> wee, just released my first shard. https://github.com/busyloop/user_agent_parser
<FromGitter> <m-o-e> shoutout to everyone here who helped me out with my crystal noobie questions earlier :)
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter> <Blacksmoke16> nice one!
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter> <bararchy> btw, can I do `unique_by` ?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/0.27.0/Array.html#uniq%28%26block%3AT-%3E_%29-instance-method uniq can take a block, that what you meant?
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bedcf22513fb277beabd8e4]
<FromGitter> <bararchy> something like that @Blacksmoke16
<FromGitter> <bararchy> like you do `sort_by`
<FromGitter> <bararchy> etc..
<FromGitter> <bararchy> `max_by`
<FromGitter> <bararchy> etc..
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter> <bararchy> Thanks @Blacksmoke16 , yeha the block form does what I want :)
<FromGitter> <Blacksmoke16> 👍
DTZUZO has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 272 seconds]
<FromGitter> <codenoid> sup, why crystal color in github become black
<FromGitter> <codenoid> this is so heart breaking
<FromGitter> <codenoid> `UwU`
<FromGitter> <Blacksmoke16> i mean its not really a big deal
<FromGitter> <Blacksmoke16> black matches the logo more so either way :shrug:
<FromGitter> <Blacksmoke16> maybe they did it after me :trollface:
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
<FromGitter> <j8r> @ArchaicLord I would say, a little project to auto configure your Linux machine (in shell/make/python?) can be a good start :) On my side I've saved my dotfiles https://github.com/j8r/dotfiles , this saved me a lot of time. I use ZSH too, zim framezork, with a hand made prompt.
<FromGitter> <j8r> @Blacksmoke16 in your name I see Black's mock :)
rohitpaulk has joined #crystal-lang
<FromGitter> <ArchaicLord> yeah i need to seperate out my work stuff to things that can be used at/home work. ⏎ My work laptop is probbaly a big mess. Will need a lot of git ignore files on it
rohitpaulk has quit [Ping timeout: 245 seconds]
coderobe has joined #crystal-lang
akaiiro has joined #crystal-lang
<coderobe> can you declare arrays containing an union?
<FromGitter> <j8r> yes, `Array(Int32 | String)` for example
<FromGitter> <j8r> add a `.new` to instantiate one
rohitpaulk has joined #crystal-lang
<coderobe> hm yeah, the usual '[] of MyType' doesn't work, however
<FromGitter> <j8r> that's not the usual syntax, but a syntactic sugar. Tthis work `[] of Int32 | String`
<FromGitter> <j8r> if you do `typeof(array_var)` you'll see the real type behind. That's why i don't like the `of` syntax
rohitpaulk has quit [Ping timeout: 240 seconds]
<coderobe> hrm, i had a garbage character in the code so it couldn't resolve the union - my bad
ua_ has quit [Ping timeout: 272 seconds]
ua has joined #crystal-lang
<FromGitter> <vladfaust> @m-o-e, ⏎ ⏎ > By default this shard downloads the latest version of BrowserScope's parsing patterns at compile time and inlines it with your binary. ⏎ ⏎ That's bad! [https://gitter.im/crystal-lang/crystal?at=5bedfb803102f14521aa278e]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
devil_tux has joined #crystal-lang
<FromGitter> <m-o-e> @vladfaust well, i'm planning to make it optional soon (but haven't yet gotten around to figuring out the corresponding macro magic).
<FromGitter> <m-o-e> in normal usage it's pretty much what you want, i.e. what you'd otherwise manually implement in your build process.
<FromGitter> <vladfaust> That slows down the development
<FromGitter> <vladfaust> Should be opt-in instead
devil_tux has quit [Client Quit]
<FromGitter> <m-o-e> how so? the d/l is fast, the file is only 170kb
<FromGitter> <m-o-e> but yea, caching would another thing to add
<FromGitter> <vladfaust> With ENV variable, for example
<FromGitter> <m-o-e> i do agree about the general concern however. it's not ideal.
<FromGitter> <m-o-e> yes, i'm going to make it optional with an ENV var. i just wanted to get a first version out and haven't yet figured out how to access env vars in macros ;)
<FromGitter> <vladfaust> This https://crystal-lang.org/api/0.27.0/Crystal/Macros.html#env(name):StringLiteral|NilLiteral-instance-method
<FromGitter> <m-o-e> yup well, when it comes down to it, some more details also have to be considered. e.g. you don't want to accidentally create a production build *without* a regex file
<FromGitter> <vladfaust> It's up to you :)
<FromGitter> <m-o-e> is there a way to include a macro from a separate file? squeezing a multi line macro in the middle of a string assignment doesn't feel right
<FromGitter> <vladfaust> Yeah, you may call `\`cat`\` from a macro
<FromGitter> <vladfaust> quote - cat - quote
<FromGitter> <vladfaust> It inserts a file's content
<FromGitter> <vladfaust> Into the macro
<FromGitter> <m-o-e> hrmm ok, might try that.
DTZUZO has joined #crystal-lang
<FromGitter> <vladfaust> Or you may want to try Crystal master and its `read_file` macro (https://github.com/crystal-lang/crystal/pull/6967). Works for me
<FromGitter> <j8r> or optional with a flag?
<FromGitter> <j8r> it would be better
<FromGitter> <vladfaust> Flag for a shard, really?
<FromGitter> <j8r> when you compile your program, yes, totally
<FromGitter> <vladfaust> How to pass custom flags?
<FromGitter> <m-o-e> well another option (that's how most other libraries do it) is to simply release a new version of the shard every time the regex changes
<FromGitter> <m-o-e> but that requires people to update all the time. doesn't feel quite right either to me
<FromGitter> <m-o-e> or simply don't assist the shard-user at all, just require them to provide the file themselves...
<FromGitter> <j8r> for example ⏎ ⏎ ```{% if flag?(:test)%} ⏎ puts "test" ⏎ {% end %}``` ⏎ ⏎ `crystal run myapp -D test` [https://gitter.im/crystal-lang/crystal?at=5bee02ec7326df140e10e495]
<FromGitter> <j8r> what was the initial issue?
<FromGitter> <m-o-e> well, it's just the general question of how to deal with required 3rd party assets that change frequently
rohitpaulk has joined #crystal-lang
<FromGitter> <j8r> pin the version?
<FromGitter> <m-o-e> well, you *want* the latest version
<FromGitter> <j8r> so what's the problem? the best would be to have the choice
<FromGitter> <m-o-e> yes, well, the choice is just a bit tricky. ;)
<FromGitter> <m-o-e> in addition to the flag there should probably be caching, because a build without the regex file is useless even in development (if your tests rely on user-agents to be identified they'd break)
rohitpaulk has quit [Ping timeout: 244 seconds]
<FromGitter> <j8r> what's regex file? Sorry I haven't followed
<FromGitter> <m-o-e> perhaps just releasing a new shard version every month is indeed a better approach... i'll ponder it some more
<FromGitter> <m-o-e> @j8r no worries, not so important. it's about my shard from earlier, which needs an external regex file and currently dl's it at build time https://github.com/busyloop/user_agent_parser
<FromGitter> <j8r> I think pin the version, so no changes. I would say to follow their releases, but there are not updated since years https://github.com/ua-parser/uap-core/releases.
<FromGitter> <j8r> that's the only way to ensure that your lib won't break for users - test the dependency for version x.x.x, then if tests are OK chose it and make a new release
<FromGitter> <m-o-e> yes they do update frequently, they just don't cut releases... https://github.com/ua-parser/uap-core/commits/master/regexes.yaml
<FromGitter> <m-o-e> but i guess cutting a new version of my shard once a month would be plenty good enough
oz has quit [Ping timeout: 252 seconds]
<FromGitter> <j8r> that's bad from them. Yeah you can do patch/minor versions depending of their changes
oz has joined #crystal-lang
<FromGitter> <m-o-e> yep. i think i'll make me a travis cronjob to do that automatically and append the timestamp to the version v1.0.1-20181201
rohitpaulk has joined #crystal-lang