ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.22.0 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
zipR4ND has quit [Ping timeout: 260 seconds]
unshadow has quit [Ping timeout: 260 seconds]
greenbigfrog has quit [Ping timeout: 240 seconds]
<FromGitter> <eliasjpr> is there a way to lazy initialize a class?
<FromGitter> <Sija> save a class to a variable and call `.new` on it l8r?
<FromGitter> <eliasjpr> I did that and it says undefined method 'new'
<FromGitter> <Sija> ```class Foo ⏎ class_property instance : Foo { Foo.new } ⏎ end ⏎ ⏎ pp Foo.instance``` [https://gitter.im/crystal-lang/crystal?at=58fea3bf01d449152eb62647]
<FromGitter> <eliasjpr> sweet
<FromGitter> <eliasjpr> can that live in a base class to initialize a child class?
<FromGitter> <eliasjpr> I mean I can try it
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
greenbigfrog has joined #crystal-lang
bjz has joined #crystal-lang
Philpax_ has joined #crystal-lang
Philpax has quit [Ping timeout: 255 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
Philpax_ has quit [Ping timeout: 260 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
greenbigfrog has quit [Ping timeout: 240 seconds]
greenbigfrog has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
<FromGitter> <elorest> I’m running into a weird compile issue: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I’ve clearly checked that it both is what I want it to be and not nil before I try doing anything with it. How am I getting an error from this? [https://gitter.im/crystal-lang/crystal?at=58fede2d6aea30763d3c9bf0]
Kilo`byte has quit [Ping timeout: 255 seconds]
Kilo`byte has joined #crystal-lang
<FromGitter> <bew> You can remove `context &&`
<FromGitter> <sdogruyol> @elorest `context.not_nil!`
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
sz0 has joined #crystal-lang
<FromGitter> <elorest> @sdogruyol I already noticed that `not_nil!` fixes it but in most cases it’s not necessary. Usually checking if something is nil first is good enough for the compiler. For instance this case. It could be nil or string but because I check first it’s fine with it. https://play.crystal-lang.org/#/r/1xdl
mark_66 has joined #crystal-lang
<FromGitter> <sdogruyol> @elorest yeah, that's right
<FromGitter> <elorest> So if I’ve said only run this if it’s not nil why do I also have to tell it to use `.not_nil!`
<FromGitter> <sdogruyol> context has a special lifecycle
Qchmqs has joined #crystal-lang
fedruantine_ has quit [Excess Flood]
fedruantine has joined #crystal-lang
<crystal-gh> [crystal] vegai closed pull request #4219: WIP/POC: Remove exclusive range syntax (master...remove_exclusive_range_syntax) https://git.io/vSCia
<vegai> (closed it because it was just a silly WIP :))
zipR4ND has joined #crystal-lang
McSoFake has joined #crystal-lang
<wuehlmaus> that's just a very nice feature, so you don't have to write var - 1 all the time :)
unshadow has joined #crystal-lang
<wuehlmaus> for me it's the best of perl and python to have both .. and ...
<unshadow> So.. a little issue with types, why can't I do this: can't cast Hash(String, Hash(String, Array(Slice(UInt8)) | Slice(UInt8))) to Hash(String, Hash(String, Slice(UInt8))) ?
Raimondii has joined #crystal-lang
<vegai> can you normally cast an Array(Slice(Uint8)) to Hash(String,Slice(UInt8)) ?
<vegai> seems like a completely separate type
<vegai> might be useful to see the actual code, actually :P
<unshadow> vegai: Here's the thing, I want to cas (Array(Slice(UInt8))| Slice(UInt8)) to Slice(UInt8)
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<unshadow> as in, just so that the compiler knows I know exactly which of the 2 options are going to be
<unshadow> not array or slice, but only slice
<vegai> wuehlmaus: yeah, perhaps... it's also highly confusing :)
<vegai> if you use more than one language that has .. and ... -operators, there's no way to figure out what they mean
<vegai> well, you can always run the code and see what happens, of course :)
<RX14> unshadow, you can't cast inside generics
<RX14> Array(String | Int32) has an entirely different binary representation than Array(String)
<RX14> so you can't use .as because it would have no way of safely transmuting it's contents
<RX14> you have to use .map(&.as(String))
<wuehlmaus> nim has ..<, perhaps that explains better what the range does
<vegai> I was semi-seriously suggesting having all four: ..., >.., ..< and finally the best: >.<
<vegai> but why not?
<vegai> somebody commented though that the > will be fun to lex
<vegai> or parse? Don't remember
<vegai> but that it won't be fun to implement
zipR4ND has quit [Ping timeout: 260 seconds]
<unshadow> RX14: Thanks :)
<unshadow> RX14: So ... no overload matches 'Array(Hash(String, Hash(String, Slice(UInt8))))#<<' with type Array(Hash(String, Hash(String, Slice(UInt8)))) aren't they the same ? Oo
<FromGitter> <bew> basically, in a `Array(T)` you must insert (`<<`) a `T`, not an `Array(T)`
<FromGitter> <bew> so here you can insert `Hash(String, Hash(String, Slice(UInt8)))`
zipR4ND has joined #crystal-lang
j2k has joined #crystal-lang
j2k has quit [Client Quit]
<unshadow> Is there a way to merge or join two Slice(UInt8) ?
<zipR4ND> hey all, If I would go on implementing graphql for crystal ... and given that a big part of graphql is about defining a type system .. and given that that the ruby implementation, of course making heavy use of metaprogramming and runtime introspection is able to create a GraphQL Schema from a serialized (String) GraphQL Definition (although this lacks the concrete resolvers for queries). which road would you go down? defining GraphQL ty
<zipR4ND> (oh sorry for the big text...)
<FromGitter> <Sija> @zipR4ND I’d look at `JSON/YAML.mapping` from stdlib, `DB.mapping` from crystal-db and Crecto for starters
<zipR4ND> sija[m]: yeah, that would be the static way ... but you cant dynamically define a json mapping at runtinme ..
<FromGitter> <ysbaddaden> don't bother with the Ruby implementation, look at compiled/typed languages
<FromGitter> <Sija> yep, Crystal ain’t made for runtime magic
<FromGitter> <ysbaddaden> a server can have compile-time definitions (macros)
<zipR4ND> yeah i guess so ..
<FromGitter> <Sija> compile-time magic is good enough in most cases in terms of flexibility and way moar efficent than runtime
<FromGitter> <ysbaddaden> hence why you should look at `JSON.mapping` for example: the accessible data is static; you may have simple structs holding the requested data based on what is accessible, and use that struct to return (or not) data; unknown field may raise or be silently ignored.
<zipR4ND> true true
<zipR4ND> btw, can JSON.mapping handle inheritance?
<zipR4ND> like if you call it on a child class it will extend the definition of the parent class?
<FromGitter> <ysbaddaden> JSON.mapping merely relies on `Type#initialize(parser : JSON::PullParser)`
<FromGitter> <ysbaddaden> so, as long as Type either has such an initializer or defined a mapping, then it will just work (so, yeah, inheritance)
McSoFake has quit [Ping timeout: 240 seconds]
<FromGitter> <Sija> ATM there’s also a `finished` macro hook which allows for even moar magic
<FromGitter> <ysbaddaden> oh no, wrong understanding
<FromGitter> <ysbaddaden> inheritance is complicated, because `mapping` will create a single method that will parse JSON, and there is no way to check whether `super` or the current method will need/use which field.
bjz_ has joined #crystal-lang
<zipR4ND> I created something like this for cltks astnode implementation: https://github.com/ziprandom/cltk/blob/master/spec/cltk/ast_spec.cr#L6
<zipR4ND> the macro code is not very beautifull but it does what you'd expect ..
<zipR4ND> what does the finish macro hook do?
bjz has quit [Ping timeout: 260 seconds]
livcd has joined #crystal-lang
<FromGitter> <Sija> it runs after all other compiler passes (macro constructs, etc)
unshadow has quit [Quit: leaving]
yogg-saron has joined #crystal-lang
sija[m] has quit [K-Lined]
vegai has quit [K-Lined]
MatrixTraveler[m has quit [K-Lined]
krigare[m] has quit [K-Lined]
kodo[m] has quit [K-Lined]
thelonelyghost has quit [K-Lined]
braidn[m] has quit [K-Lined]
postmodern[m] has quit [K-Lined]
mark_66 has quit [Remote host closed the connection]
MatrixTraveler[m has joined #crystal-lang
<FromGitter> <ricardobeat> is it possible to create two instances of `HTTP::Server` listening on different ports?
<FromGitter> <ricardobeat> `listen_fork` is gone and `.listen` blocks
<FromGitter> <bew> you can use `spawn` to run your server in a 'kind of' coroutine (a fiber)
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <bew> there are documentations about it in https://crystal-lang.org/docs/guides/concurrency.html
kodo[m] has joined #crystal-lang
vegai has joined #crystal-lang
postmodern[m] has joined #crystal-lang
braidn[m] has joined #crystal-lang
thelonelyghost has joined #crystal-lang
krigare[m] has joined #crystal-lang
sija[m] has joined #crystal-lang
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
zipR4ND has quit [Ping timeout: 260 seconds]
<FromGitter> <ricardobeat> thanks! calling `listen` inside a fiber works, thought it wouldn't
<FromGitter> <ricardobeat> is the final `sleep` required?
<FromGitter> <ricardobeat> won't it keep going since there are running fibers?
<FromGitter> <bew> no, the main fiber must sleep so the other fibers can run
<FromGitter> <bew> you can do something else of course, sleep is just an exemple
<FromGitter> <eliasjpr> it would be nice to implement this in crystal https://nodejs.org/api/cluster.html
<FromGitter> <eliasjpr> to do what @ricardobeat wants
<FromGitter> <eliasjpr> a cluster module will allow you to easily create child processes that all share server ports.
<FromGitter> <bew> I think you can already do that
<FromGitter> <ricardobeat> ^ yes, just saw that in the docs https://crystal-lang.org/api/0.22.0/HTTP/Server.html#bind%28reuse_port%3Dfalse%29-instance-method
<FromGitter> <ricardobeat> but that's about reusing the same port, I wanted to listen to different ports like @luislavena showed
<FromGitter> <fridgerator> @eliasjpr see the section "Crystal lang multi-threaded code" here : http://blog.seraum.com/crystal-lang-vs-nodejs-vs-golang-vs-http-benchmark
<FromGitter> <eliasjpr> reading @fridgerator
<FromGitter> <eliasjpr> nice!
Qchmqs has quit [Ping timeout: 240 seconds]
<FromGitter> <fridgerator> :thumbsup:
yogg-saron has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zipR4ND has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest25397
marcosdsanchez has joined #crystal-lang
Guest25397 has quit [Client Quit]
zipR4ND1 has joined #crystal-lang
zipR4ND has quit [Ping timeout: 255 seconds]
<FromGitter> <arubinofaux_twitter> Hello everyone
<FromGitter> <bew> Hello @arubinofaux_twitter!
<FromGitter> <arubinofaux_twitter> i have some issues using websocket, is this channel ok for questions
<FromGitter> <bew> yes go ahead!
<FromGitter> <arubinofaux_twitter> im messing around with HTTP::WebSocket and i keep getting an error and cant figure it out. ⏎ ⏎ this is the error block ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58ff88d3d32c6f2f093d1d3b]
<FromGitter> <arubinofaux_twitter> code ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58ff88e2cfec91927273c637]
<FromGitter> <Sija> @arubinofaux_twitter what version of Crystal you’re using?
<FromGitter> <arubinofaux_twitter> @Sija Crystal 0.22.0 (2017-04-20) LLVM 4.0.0
<FromGitter> <arubinofaux_twitter> the latest
<FromGitter> <Sija> cool, just checkin'
<FromGitter> <fridgerator> do you get the same error if you comment out the json parse line in `on_message` block?
<FromGitter> <arubinofaux_twitter> yeap @fridgerator getting the same error
<FromGitter> <fridgerator> seems like it should be working, looks like a bug to me
unshadow has joined #crystal-lang
<FromGitter> <arubinofaux_twitter> the only new error i get is `Handshake got denied. Status code was 502 (Socket::Error)` when the url is changed to `wss://ws.bitso.com` from `ws://ws.bitso.com`
<FromGitter> <fridgerator> the server probably only accepts `wss` connections
<FromGitter> <arubinofaux_twitter> yea just tried connecting to a different socket server and im getting the same `Unexpected end of http request`
<FromGitter> <arubinofaux_twitter> :( guess i dont get to play around with sockets today
Ven has joined #crystal-lang
Ven is now known as Guest3812
<zipR4ND1> hey all, should NamedTupleLiteral.keys give me an array of Symbol / SymbolLiteral ? https://play.crystal-lang.org/#/r/1xhi
<zipR4ND1> (i mean shouldn't it ..)
unshadow_ has joined #crystal-lang
unshadow has quit [Ping timeout: 255 seconds]
Guest3812 has quit [Ping timeout: 245 seconds]
yogg-saron has joined #crystal-lang
Ven_ has joined #crystal-lang
<FromGitter> <bew> it gives you `MacroId`s https://play.crystal-lang.org/#/r/1xhn so you can do what you want with it. But I think it'd be good to have a `MacroId#symbolize` (or something similar to `ASTNode#stringify`)
<zipR4ND1> bew yes that would be cool
<Papierkorb> zipR4ND1: just put a colon in front of the {{
<FromGitter> <mjago> @arubinofaux_twitter This works for me: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58ff9aca8fcce56b20375357]
<crystal-gh> [crystal] f-mer opened pull request #4339: Docs: Add missing parenthese (master...patch-1) https://git.io/v9mnL
<FromGitter> <fridgerator> @mjago it seems its failing on tls connections using `wss`
<FromGitter> <fridgerator> I've seen other people with issues using `wss`
<FromGitter> <mjago> @fridgerator yes confirm doesn’t work with was (but works fine in chrome)
<FromGitter> <mjago> wss*
unshadow has joined #crystal-lang
unshadow_ has quit [Ping timeout: 264 seconds]
marcosdsanchez has quit [Ping timeout: 240 seconds]
<crystal-gh> [crystal] jhass closed pull request #4339: Docs: Add missing parenthese (master...patch-1) https://git.io/v9mnL
<FromGitter> <bew> Why does struct inheritance can't be done without abstract structs? https://carc.in/#/r/1xij
<Papierkorb> bew, say you have a class with a `@foo : MyStruct`
<Papierkorb> bew, structures are stack allocated, meaning if you store them, all of their memory is allocated right there. If your struct is 200 Bytes in size, the class itself becomes (at least) 200B in size
marcosdsanchez has joined #crystal-lang
<Papierkorb> bew, Meaning, the size is now 'fixed' to that known size. Now, you inherit from the non-abstract struct MyStruct, MyBetterStruct. You add a field into MyBetterStruct, so it becomes 200+x Bytes in size. You pass an instance of that better one into the class: This should work, that's what's inheritance all about after all.
<Papierkorb> bew, but now, you try to store a 200+x Byte structure into a place that has 200B in size only. So, it doesn't work
<Papierkorb> bew, the point about abstract structs is that you can't inherit it, so this case can never happen.
<Papierkorb> bew, In more general terms, if you need to inherit from a structure, reevaluate if you don't want a class instead, OR if you need to remodel your architecture
<FromGitter> <bew> Very nice explanation, thanks @Papierkorb!
<FromGitter> <bew> in fact I was just testing sth else, an said myself "why not put struct everywhere"
<Papierkorb> bew, And from my subjective POV, use structures as read-only things: They're Value types just like an integer. Everything else will result in unexpected results really really quickly, and this is hard to debug as it seems as if suddenly, the setter method is broken.
A124 has quit [Quit: '']
gewo has quit [Ping timeout: 255 seconds]
<Papierkorb> bew, structures are big. If you do `def foo(bar : MyStruct)`, and call that, the MyStruct instance is literally *copied* into the method, you get a brand new copy of it
<Papierkorb> So if your struct is large, this takes time. But don't overthink this: Small structures are fine. My Rule of thumb: Max 4 pointers in size, on x64, 4*8 = 32Byte. But I can't give you any hard data on this being a good size at all :)
<FromGitter> <bew> I agree with you on that, on the other end, sometimes it'd be necessary to pass a reference to a struct (non-dynamically allocated) to a function, especially on embedded systems where dynaically allocations is not a good practice..
gewo has joined #crystal-lang
<FromGitter> <bew> but yeah for every other usage, classes are ok
A124 has joined #crystal-lang
<Papierkorb> Yeah you have to be super careful with this in Crystal. This fell on my foot in my "Is Crystal a good language for Kernel dev?" project more than once.
<Papierkorb> (My answer to that question btw: No, it's not. Possible though.)
<FromGitter> <bew> :(
<FromGitter> <bew> I wanted to too... (but more on arduino and other µctroler stuff)
<Papierkorb> I can give you my ValueRef class though, which basically lets you pass a writable reference around of a structure, like `MyStruct &` would in C++
<FromGitter> <bew> how?
<FromGitter> <bew> did you abstract the pointerof(mystruct) or sth like this?
<FromGitter> <bew> or wrap it in a struct?
<Papierkorb> Basically pointerof with macro magic
<Papierkorb> Makes it completely transparent basically
<FromGitter> <bew> nice!
<FromGitter> <bew> but you still malloc the pointer, why? isn't it a value too?
<Papierkorb> You use the `of` macro: `ValueRef.of my_struct`
<Papierkorb> you can throw out the allocating initializer, it's only there to let you (to some extend) turn the struct into a more object-esque thing
<FromGitter> <bew> I see, very nice though!!!
<FromGitter> <bew> how is your kernel dev project? did you started a poc or sth?
<Papierkorb> It's not public, wasn't intended for it and thus doesn't fulfill some quality requirements I have for my public stuff ;)
<Papierkorb> The only part that is public is its memory allocator: https://gist.github.com/Papierkorb/dd40c8ac2722505d18600710abc04040
<Papierkorb> that source was ripped out of the kernel sources, so it won't work without some extra work
<FromGitter> <bew> nice! what algorithm do you use for it?
<Papierkorb> simple 2-level buddy allocator
<Papierkorb> It's surprisingly fast™
<FromGitter> <bew> I know the buddy system, I did one (in C....), but what's the "2-level" thing?
<Papierkorb> pages (usually one page, or more if required) are the first level, and each page(s) is then split into the second level as required.
<Papierkorb> it's basically a two-level slab allocator to some extent
<FromGitter> <bew> ok, neat!
<FromGitter> <bew> about private/public stuff, you have a paid github, or a gitlab or sth with private projects? Currently I have almost everything in public, and was thinking about this..
<Papierkorb> Nah I have my own root server anyway. I just have a git/ directory in my $HOME, and in there I mkdir a foo.git directory in which I run `git init --bare`, then just use gits SSH integration to push/pull
<Papierkorb> nothing fancy, but no configuration involved either.
<FromGitter> <bew> the issue I see with that is the case of the hard-drive crashes or ssd comes to end of life..
<Papierkorb> RAID
<FromGitter> <bew> hmmm
<FromGitter> <bew> of course
<Papierkorb> Also, git is decentral, my notebook has a copy of most projects, my home computer does, and my server
<Papierkorb> Good enough for me :)
<FromGitter> <bew> that's cool, I really need to setup sth similar to this, I've been thinking about that, but nothing yet
<FromGitter> <bew> private local server? or cloud based?
<Papierkorb> I wouldn't pay for a server just for git, if you don't have a private server and don't need one either, I see not *many* issues with paying for Github or Gitlab or something
<Papierkorb> Nah no cloud stuff, way too expensive for personal use.
<Papierkorb> For that, any reputable dedicated server hoster is cheaper, has better support AND gives more hw per euro
<Papierkorb> Comes at the price of having to maintain the whole thing, although with AWS, you still have to mess with linux maintenance, so ...
<FromGitter> <bew> interesting, thx alot!
<Papierkorb> I mean, if you have a private server, just give it a try. it's dead simple to setup git for that, as there are no additional steps involved. it just works. If you don't end up liking it, you can still install cgit or GitLab on your server, and if you don't want that either, pay for a git hoster
<FromGitter> <bew> I have a stupid question: how do you connect t your server from outside, do you have a custom dns (paid one?), or static ip (how?) ?
<Papierkorb> You can also do stuff like sshfs mounting your server, creating an ecryptfs in there, and then put git or whatever you want to be reasonably-securely but easily backuped on your server. that whole thing is just like 5 commands away
<Papierkorb> My server sits in a datacenter in Germany, it comes with static IPs ;)
<Papierkorb> You'd be surprised how cheap you can get, really. Where are you from?
<FromGitter> <bew> France right now, but next year US for several months
<FromGitter> <bew> if I get it, you have an AWS private server (ec2?) with your git and stuff on it?
<Papierkorb> Then, e.g. for a first somewhat private server, you can check if uberspace.de is available to you. It's not the fastest server available, but you get an account on a shared host for just 1€ (pay-what-you-want).
<Papierkorb> Oh god no, no AWS or anything
<Papierkorb> I'm with Hetzner
<Papierkorb> Not the cheapest, but great support. Can't complain really.
<Papierkorb> AWS is just insanely expensive. Just calculate what you'd pay for a 24/7 running server each month, what kind of HW you get, then factor in that it's in the direct grasp of every three-letter-agency on the planet... and then go to a bunch of server hosters and compare prices
<Papierkorb> Even without the NSA tax, you still pay much more. For commercial use AWS may be a good option for things, but personal? I don't think so.
<FromGitter> <Sija> yep, Hetzner is a decent option, I’m having several machines for yrs with constantly good experiences, quite fair priced too
<FromGitter> <Sija> some vps providers worth looking at are imo vultr.com and scaleway.com
<FromGitter> <bew> hmm ok, nice feedback ;) I'm still student, not easy to give 25/30€ per month atm^^ But I keep that in mind!
<travis-ci> crystal-lang/crystal#67d4b21 (master - Merge pull request #4339 from f-mer/patch-1): The build has errored. https://travis-ci.org/crystal-lang/crystal/builds/225735299
<DeBot> https://github.com/crystal-lang/crystal/pull/4339 (Docs: Add missing parenthese)
<Papierkorb> bew, then check out uberspace.de, it was built by students for students to get a cheap webspace with lots of features to get their feet wet
<FromGitter> <Sija> there r some small vps instances for 3-5 eur/$ per month
<RX14> try scaleway
<RX14> oh they were mentioned
<RX14> nvm
<Papierkorb> bew, that's literally 1€/Month no-strings-attached. Not premium, but to try some things? Why not?
<Papierkorb> You don't get a dedicated VPS though, and no dedicated IP either. You can however host web services, and as long you're flexible in terms of the used network port, (almost) anything you desire.
<FromGitter> <bew> about uberspace any way to get the website in english somewhere ? :D
<FromGitter> <Sija> google translate it ;)
<FromGitter> <bew> good idea, not perfect but better^^
<Papierkorb> huh must have dreamed that there was an EN page. it's at https://uberspace.de/register
<FromGitter> <bew> just 1 question: support is in german ?
<jhass> OVH has some great student deals if you're fine with france as a hosting country
<Papierkorb> Never tried tbh, you can just ask them I guess, they were quick to respond when I was still with them bew
<FromGitter> <bew> I think I'll try other first
<jhass> kimsufi was the brand for that iirc
<Papierkorb> jhass: Welcome back
<FromGitter> <bew> yeah I knew ovh and kimsuffi, completly forgot about them, thanks
<FromGitter> <pglombardo> Hi all. I’m attempting to port some pure Ruby code to Crystal for the first time. I have some autoload directories where I loop through the files and call require with a variable. It seems this isn’t going to work in Crystal. Any tips/tricks/shortcuts?
<Papierkorb> pglombardo, no trick, just not possible. What do you need it for?
<FromGitter> <pglombardo> Autoloading of all files in a directory. Ok though - if not possible I can rewrite.
<Papierkorb> pglombardo, try `require "./my_shard/**"`
<RX14> ** and * globs work in require
<RX14> ** is directory recursive, * is only top-level files
<Papierkorb> *work in require, as long the string ends in them, and only then
<Papierkorb> eg `foo/*/bar/*` won't work
<FromGitter> <bew> note that it'll work at compile time only, as runtime arbitrary code execution is not allowed
<FromGitter> <pglombardo> Excellent all - that was exactly what I needed. Thanks
<FromGitter> <bew> yw!
<FromGitter> <bew> and thanks all too for server infos :)
<RX14> @bew essentially scaleway have the best prices, and they're pretty good, but if it does go wrong their support sucks
<Papierkorb> bew, np, just make sure to think about securing that thing (firewalling, configuration), patching regularly, etc. - Bots *are* out there to e.g. crack your SSH account. (Hint: Disable password authentication and only use key-based authentication)
<RX14> ovh are a bit better but still support is a bit off
<RX14> and they're a bit more expensive
<FromGitter> <bew> one last question (I think) what OS do you use on thoses server? I'm an arch-only guy for desktop, but I know arch is not the best fit for servers..
<RX14> debian 8
<RX14> solid and reliable
<Papierkorb> In fact, I do use Arch on my Server. Why? Because it's what I know best
<RX14> arch is fine on the server if you can get it on the server :)
<FromGitter> <bew> ahah, I second that
<RX14> with VPSes it's way too much effort to install arch
<RX14> debian 8 will always just be an available image
<unshadow> Ubuntu Server is also great, I don't really like RedhHat\CentOS
<Papierkorb> bew, I'd go with ubuntu server otherwise. well supported and so on. you do have to put up with it being ubuntu and debian though :P
<FromGitter> <bew> hmm yeah dedicated server would be best for arch install, but there are "some" other things you need to deal with then..
<FromGitter> <bew> okay
<Papierkorb> Make sure to follow some kind of reputable IT news source who also publish important linux security news
<FromGitter> <bew> any preference?
<Papierkorb> And be prepared to patch as soon as possible when the next critical bug has been discovered in OpenSSL
<FromGitter> <bew> ahah
<jhass> btw I have arch on (almost) all my servers ;)
<Papierkorb> bew, I don't follow much english news. Slashdot, but that's neither reputable nor actually good.
<jhass> but you at least need a KVM host for that yeah
<Papierkorb> (Only follow it for the lulz)
<BlaXpirit> i have arch on my personal server - https://www.vultr.com/pricing/
<Papierkorb> Same, Arch on hetzner root server
<FromGitter> <bew> too much interesting thing in the last 30mins
<Papierkorb> bew, in general, take your time! There is *SO* much bad information on linux administration, it's a real issue when you're starting out. Many are so bad that they leave your server in vulnerable state and stuff. Not fun.
<FromGitter> <bew> vultr seems very nice, good support?
<jhass> the arch wiki is pretty good, whether you're using arch or not
<Papierkorb> Don't know french law, but at least in Germany, the server owner is responsible for the servers actions. so if your server is hacked and becomes part of a botnet and takes down the US internet (again), you may be liable. Not fun.
<BlaXpirit> bew, good in my limited experience. needed it once in over a year of service, was good
<FromGitter> <pglombardo> Sorry if you’ll allow me one more question that I can’t find the answer to in the docs or on google. How to replace `ENV.key?` or more generally how to retrieve environment variables?
<FromGitter> <eliasjpr> so help me god https://carc.in/#/r/1xj0
<BlaXpirit> the thing is, `key?` is not a thing in crystal, it's been renamed to be more descriptive
<Papierkorb> pglombardo, Crystal adds the #[]? operator, which returns `nil` if the key was not found. #[] generally raises if the key was not found.
<BlaXpirit> hence has_key?, both in this case and in case of normal Hash
<Papierkorb> pglombardo, in Crystal, you'll see/do stuff like this often: `if foo = ENV["BAR"]? \n puts foo \n end`
yogg-saron has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<BlaXpirit> eliasjpr, https://carc.in/#/r/1xj4
<BlaXpirit> i like to add unnecessary brackets to highlight such assignment. `if (foo = ENV["BAR"]?)
<BlaXpirit> eliasjpr, weird error message for sure.
<FromGitter> <eliasjpr> yeah! But thanks for shedding some light on that
<FromGitter> <eliasjpr> Docs should be updated
<FromGitter> <pglombardo> Excellent - not expecting a 1 to 1 mapping so this is fine. Just had trouble finding the equivalents. Didn’t know about that api doc page though.
<FromGitter> <eliasjpr> nope nevermind
<Papierkorb> bew, you're a student I read. If you want to do something fun with your server to learn more about administration/configuration, make it a OpenVPN server (Sidenote, also learn how to disable internet tunneling if you don't want that, or how to enable it if you do), then configure all of your linux devices to connect to it as client upon boot. That way, you have access from anywhere to all of your (powered on) devices. Quiet useful to
<Papierkorb> quickly grab files off your desktop computer.
<Papierkorb> bew, pro tip: Have a raspi or similar device lying around? Have it powered on at all times, SSH into it and then use network wakeup to power on your desktop computer while away to fetch files or make it do stuff. Great while being on vacation :P
<FromGitter> <bew> I did (too much) sysadmin at school, and a lot of config on my arch, but never on actuall servers.. yeah I have a RPi lying around :) ... but no desktop computer atm, only laptop
<FromGitter> <bew> thx all for ideas, all that is one more thing on my (giant) todo list^^ I need to prioritize a bit
<FromGitter> <eliasjpr> is it possible to pattern match an array tuple within for each block
<FromGitter> <eliasjpr> ?
<FromGitter> <bew> in the block args, yes iirc
<FromGitter> <eliasjpr> a hash of tuples like `do |key, (a, b)|` or
<FromGitter> <eliasjpr> `do |key, a, b|`
<FromGitter> <eliasjpr> ?
<Papierkorb> the former
<FromGitter> <eliasjpr> :thumbsup:
<FromGitter> <eliasjpr> Does it work for hashes?
<Papierkorb> you mean, if the value is a tuple? yep
<FromGitter> <eliasjpr> nice :)
<Papierkorb> works anywhere you have a tuple. not an array though.
Ven_ has quit [Ping timeout: 252 seconds]
<FromGitter> <eliasjpr> wait until my wife find out that I’ve felt in love with Crystal
Ven has joined #crystal-lang
<FromGitter> <bew> note: would be good to add link to documentation h1, h2, etc.. having to open the webconsole is.. boring
<FromGitter> <eliasjpr> :laughing:
Ven is now known as Guest73192
<FromGitter> <bew> ^^ *not good*
<FromGitter> <bew> (open webconsole to find the #id of the headers)
<FromGitter> <bew> is there a difference btw `delegate something, to: @a` & `forward_missing_to @a` ?
<FromGitter> <eliasjpr> I would say that delegate you have to specified the methods to be delgated
<Papierkorb> the former creates the `something` delegator right there, the forward_missing_to does through a method_missing hook
<Papierkorb> if you know which to delegate, or only want to forward some, prefer the `delegate` macro
<FromGitter> <eliasjpr> forward_missing_to all methods not found will be send to the delegator
<Papierkorb> makes it much more obvious what's going on
<FromGitter> <bew> you did the two in your ValueRef
<FromGitter> <bew> don't understand why..
<Papierkorb> yeah, that's to forward some calls that are already defined on the outer class. the method_missing wouldn't fire.
<FromGitter> <bew> oooh niice
bjz has joined #crystal-lang
<Papierkorb> I think I missed one or two though. Not sure.
<Papierkorb> For others, I chose deliberatly to exclude them, like #same?
<FromGitter> <bew> I see, it would break in weird things for some things I thnk
<FromGitter> <bew> +i
Guest73192 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter> <elorest> How would I get the name of the file that calls that macro without passing it in a param. The first option works but I would prefer to not have the param there. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58ffcd528bb56c2d11e19c6a]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
postmodern[m] has left #crystal-lang ["User left"]
marcosdsanchez has quit [Ping timeout: 240 seconds]
sz0 has joined #crystal-lang
<FromGitter> <codingphasedotcom> Rocky stack trending on github!
<FromGitter> <fridgerator> :thumbsup: