ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.23.1 | 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
astronavt has joined #crystal-lang
astronavt has quit [Ping timeout: 258 seconds]
<oprypin> RX14, clashes are the rarest in crystal compared to other languages
<RX14> yeah but sometimes i just dont want to mess with names
<RX14> i just want to prime
<oprypin> that's an underscore
<RX14> yeah but prime makes it feel fancy and not hacky :P
<RX14> i've been doing haskell
csk157 has joined #crystal-lang
csk157 has quit [Ping timeout: 268 seconds]
illyohs has joined #crystal-lang
astronavt has joined #crystal-lang
astronavt has quit [Ping timeout: 240 seconds]
hightower2 has joined #crystal-lang
hightower3 has quit [Ping timeout: 250 seconds]
csk157 has joined #crystal-lang
csk157 has quit [Ping timeout: 248 seconds]
astronavt has joined #crystal-lang
<FromGitter> <codenoid> yay, i'll manage PetaBytes data with crystal
<FromGitter> <codenoid> of data
csk157 has joined #crystal-lang
csk157 has quit [Ping timeout: 248 seconds]
astronavt has quit [Remote host closed the connection]
mbarbar has joined #crystal-lang
<FromGitter> <bararchy> @codenoid in what sense ?
illyohs has quit [Ping timeout: 268 seconds]
csk157 has joined #crystal-lang
csk157 has quit [Ping timeout: 260 seconds]
csk157 has joined #crystal-lang
csk157 has quit [Ping timeout: 240 seconds]
aroaminggeek has quit [Quit: Textual IRC Client: www.textualapp.com]
rohitpaulk has joined #crystal-lang
csk157 has joined #crystal-lang
csk157 has quit [Ping timeout: 260 seconds]
<faustinoaq> Hi community, I have an issue with shards installing dependencies 👉 https://github.com/crystal-lang/shards/issues/183
csk157 has joined #crystal-lang
csk157 has quit [Ping timeout: 260 seconds]
csk157 has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
p0p0pr37 has quit [Ping timeout: 240 seconds]
p0p0pr37_ is now known as p0p0pr37
csk157 has quit [Ping timeout: 260 seconds]
claudiuinberlin has joined #crystal-lang
p0p0pr37 has quit [Remote host closed the connection]
p0p0pr37 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
alex`` has joined #crystal-lang
stnly has quit [Ping timeout: 240 seconds]
<travis-ci> crystal-lang/crystal#e482297 (master - Merge pull request #5282 from wmoxam/fix-openbsd-linking-issue): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/310460450
<DeBot_> https://github.com/crystal-lang/crystal/pull/5282 (Fixes issue with linking lib_unwind on OpenBSD)
p0p0pr37 has quit [Read error: Connection reset by peer]
p0p0pr37 has joined #crystal-lang
p0p0pr37 has joined #crystal-lang
faustinoaq has quit [Ping timeout: 240 seconds]
Vexatos has joined #crystal-lang
<FromGitter> <codenoid> poc cr managing big data
<FromGitter> <unreadable> hacking into SFML makes such a fun :)
<FromGitter> <unreadable> one of the best written c++ lib
mbarbar has quit [Ping timeout: 255 seconds]
alex`` has quit [Quit: WeeChat 1.9.1]
snsei has joined #crystal-lang
csk157 has joined #crystal-lang
<FromGitter> <jwaldrip> can you define a default proc to &block on a method?
<FromGitter> <bew> seems not, but you can have a method with and a method without block, and the method without block can call the other with the default block/proc
<FromGitter> <bew> very small example: https://carc.in/#/r/36kr
Creatornator has joined #crystal-lang
snsei has quit [Remote host closed the connection]
dragonkh has joined #crystal-lang
<dragonkh> hi - I'm new to Crystal - is there a way to specify a local shard dependency?
<dragonkh> I think I can use path to the local dependency
csk157 has quit [Ping timeout: 260 seconds]
<dragonkh> great thanks - I got it working
<oprypin> dragonkh, but i recommend not using this at all. because you can just create a 'lib' folder and put a symlink to your other repo there
<oprypin> and the shard file will contain only what you want to publish
<oprypin> so you dont accidentally publish something containing a path on your computer
<dragonkh> I'm trying to create a Kemal application and use kemal-session-redis - but the main repo was missing an update - which was supplied as a pull request - but not applied yet - so I cloned the forked repo locally
<dragonkh> I can't seem to use either the official repo or the fork with shards though
<dragonkh> I get an error message about git
<dragonkh> no idea what this is about
<dragonkh> git command failed: git ls-tree -r --full-tree --name-only v0.5.0 -- shard.yml (). Maybe a commit, branch or file doesn't exist?
<dragonkh> so this is why I'm using a local shard dependency
<dragonkh> however it would be nice if I could just put the forked repo as a dependency - I thought that would work - but it has the same git issue
<dragonkh> maybe the github project is using an out of date shard config : https://github.com/neovintage/kemal-session-redis
<oprypin> dude i have no idea
<oprypin> just nuke it all, restore your original shard.yml
<oprypin> put the repo you cloned into 'lib' and you're done
<dragonkh> yeah I will put it in lib as you suggest
<dragonkh> I tried nuking - but whenever I add the remote repo into my shard.yml I get that same git error
<dragonkh> if I remove it again - its all good - so must be a problem with the that lib
<oprypin> dragonkh, could also be leftover repo in a hidden directory (i think it's called .shards)
faustinoaq has joined #crystal-lang
<dragonkh> hmm I get the same issue if I put the cloned repo in the lib dir
<dragonkh> if I use the shards path approach it works though
<dragonkh> very strange
csk157 has joined #crystal-lang
<dragonkh> hmm
csk157 has quit [Ping timeout: 240 seconds]
csk157 has joined #crystal-lang
<dragonkh> ah got kemal-session working now - seems many of the places I was looking were using an old version and now Session lives inside Kemal
lianchu has joined #crystal-lang
csk157 has quit [Ping timeout: 240 seconds]
csk157 has joined #crystal-lang
csk157_1 has joined #crystal-lang
<FromGitter> <Rinkana> Is there some sort of micro sleep?
<FromGitter> <bew> like `sleep` ?
<FromGitter> <bew> you can give it a duration
<FromGitter> <Rinkana> Yeah but i can only give it seconds
<FromGitter> <Rinkana> I need less then a secon
<FromGitter> <Rinkana> second*
csk157 has quit [Ping timeout: 255 seconds]
<FromGitter> <bew> you can `sleep 200.milliseconds`
<FromGitter> <bew> (because `sleep` accepts a `Time::Span`)
<FromGitter> <Rinkana> Ah yeah great
<FromGitter> <Rinkana> That does indeed work :D
<FromGitter> <Rinkana> Because what i have is a few fibers with infinite loops in them. And to make them act like they are threads i needed to sleep them a very short time (`1.milliseconds`)
<FromGitter> <bew> oh no, you should use `Fiber.yield` if you want to give the control to another fiber iirc (not sure though)
<FromGitter> <bew> yes, that's it
<FromGitter> <Rinkana> Ah yeah, that works too, and is probably better
<FromGitter> <Rinkana> Thanks!
<FromGitter> <bew> ;)
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter> <bew> lol, looking at the actual code, all it does is `sleep 0` but that's enough to reschedule the fiber
<FromGitter> <Rinkana> Haha
<FromGitter> <bew> but it's better to use `Fiber.yield` as it shows your intention ;)
<FromGitter> <Rinkana> Hmm, looking at the docs wont `loop do` overflow eventually?
<FromGitter> <bew> the `i` you mean?
<FromGitter> <Rinkana> Yeah
<FromGitter> <bew> it will probably yes (in non-release at least), but it's harmless
<FromGitter> <bew> in release mode it'll be optimized if you don't use `i`
<FromGitter> <HCLarsen> Hey guys, got a question about Crystal coding convention. Would it be bad form to start a class name with a number? Or should I just spell the number out?
<FromGitter> <Rinkana> I dont think you can even
<FromGitter> <Rinkana> Nope
<FromGitter> <HCLarsen> That was easy, thanks.
csk157_2 has joined #crystal-lang
<FromGitter> <joeyrobert> Does Crystal checkout submodules of dependencies?
csk157_1 has quit [Ping timeout: 255 seconds]
<FromGitter> <bew> the dependency manager of Crystal is called `shards`, and it doesn't seems to do that (https://github.com/crystal-lang/shards/blob/master/src/resolvers/git.cr#L180)
<FromGitter> <joeyrobert> thanks!
Creatornator has quit [Ping timeout: 258 seconds]
lianchu has quit [Quit: WeeChat 1.4]
sz0 has quit [Quit: Connection closed for inactivity]
aroaminggeek has joined #crystal-lang
<FromGitter> <bew> is there a way to determine the endianness of the computer I'm running on? can't find any method, and the only thing related to that is `alias SystemEndian = LittleEndian` in `src/io/byte_format.cr`.
<FromGitter> <bew> Does that mean that the endianness of modern computer is always LittleEndian?
<oprypin> bew, yes
<oprypin> to future-proof (or past-proof?) your code you can add a check like https://github.com/crystal-lang/crystal/blob/1b669c1c9bbc8f8264662633c4943b3f69889190/src/random.cr#L311
<oprypin> but of course you should prefer the standard operations defined in byte_format
<FromGitter> <bew> thanks @oprypin I was gonna use the `SystemEndian`ness anyway for my conversions, but I needed to know which one it was!
<oprypin> bew, exactly what this means is that for all platforms currently supported by crystal this is the endianness
<FromGitter> <bew> yeah I see, thank you for the precision. If I understand correctly this means that if one day Crystal is supported on a BigEndian machine, there will be a `if flag?(:something)` around that alias
<oprypin> ye
<FromGitter> <bew> perfect ty!
<FromGitter> <bew> @oprypin I don't get it, why as I am on a littleendian machine (I checked), when I do `1 & 0xff` I get 1 instead of 0 ?
<FromGitter> <bew> oh no ok nvm
<oprypin> 0b00000001 & 0b11111111 ??
<FromGitter> <bew> 0xff is also in little endian
<oprypin> i dont understand what you're getting at
<Papierkorb> endianess is how integers are stored, not how you calculate with them
<oprypin> the operation would have the same result
<FromGitter> <bew> yeah I figured that
<dragonkh> anyone know in Kemal how to return a bad request?
<FromGitter> <bew> I wanted to check the least significant byte, but as `0xff` is also in little endian, this is not the way to go ^^
<FromGitter> <bew> I ended up with `1.unsafe_as(StaticArray(UInt8, 4))`
<FromGitter> <bew> which happily gave me `StaticArray[1_u8, 0_u8, 0_u8, 0_u8]`
<oprypin> wtf
<oprypin> & 0xff does give you the least significant bytw
<oprypin> the results of that operation that you just showed, however, differ per platform
<dragonkh> ok got it thanks: context.response.status_code = 404
<Papierkorb> dragonkh: that's not bad request, that's not found
<dragonkh> yeah I wanted the mechanism of how to do it - more than the specific error
<FromGitter> <bew> yes, I badly expressed myself, what I wanted to check for myself was which was the last byte transmitted in a network operation when I send `1`, was it `0u8` or `1u8` (I already knew the answer, but wanted to see it)
<FromGitter> <Rinkana> Hmm, i currently need `BigDecimal` but it has just recently been merged into master. So it will probably be a while untill that release
<dragonkh> is there a way to use the Json mapping macro in Kemal from the request ? e.g. context.params.json gives me some json and I want to convert it to an object e.g. Credentials - so I tried creating a class Credentials with JSON.mapping(name: String) - and then Credentials.from_json(context.params.json) but it blows up
<oprypin> dragonkh, that seems like the correct approach, so make it not blow up
<dragonkh> I think from_json is expecting json as a string
<dragonkh> and context.params.json is of type Json
<dragonkh> but converting it to a string makes it a hashmap which is no good
<dragonkh> in fact I think it's a hashmap coming from context.params.json
<dragonkh> so I need to convert it to json format
<dragonkh> yup it works like this: context.params.json.to_json
<oprypin> dragonkh, no no no
<dragonkh> I guess I expected context.params.json to return json not a hashmap
<oprypin> plese use params.body not params.json
rohitpaulk has joined #crystal-lang
<dragonkh> but it's posting json to the endpoint?
<oprypin> and you want to get what it's posting, which is body
<oprypin> json means assume what's posted is json and convert it to a data structure but you don't want that because then .from_json doesnt work
<dragonkh> ah I see - got it now thanks
<oprypin> so if you dont want a terrible back-and-forth conversion, you dont do json.to_json
<dragonkh> passing context.params.body doesn't work though
<dragonkh> ah context.body
<oprypin> uh oops
<dragonkh> er nope
<dragonkh> it doesn't work
<oprypin> ok makes sense, so it's not posting json then
<oprypin> where do you see json involved in your request?
rohitpaulk has quit [Ping timeout: 268 seconds]
<dragonkh> in the payload
<dragonkh> and the request header says content type: application/json
<dragonkh> context.params.body is empty
<oprypin> so how do these things above not work
<dragonkh> context.param.json has the json in it converted to a hash
<dragonkh> but context.params.body - is empty string
<oprypin> dragonkh, have you tried using context.params.body without doing context.params.json first?
<dragonkh> yeah
<dragonkh> if I do p context.params.body I get: HTTP::Params(@raw_params={})
<oprypin> what the hell
<oprypin> i dont believe you. please show full code
<oprypin> you want just request.body for sure but hm
<dragonkh> oooh
<oprypin> do you seriously have to write context.request.body.not_nil!.gets_to_end
<oprypin> also don't forget that you could directly use the result of .json without dealing with json.mapping at all
<dragonkh> ok so what you pasted worked
<dragonkh> context.request.body.not_nil!.gets_to_end
<dragonkh> if I map it into an object - it will give me an object with a Type I want to work with - plus if the json is incorrect it will fail to map - so I can handle it easily - rather than checking the json structure
<oprypin> sure, that's nice
<dragonkh> so is there a downside to - context.params.json.to_json - as that is much easier to read and understand for me than the longer context.request.body.not_nil!.gets_to_end ?
<Papierkorb> You're there parsing JSON, then serializing it back to JSON, and then parsing it again.
<Papierkorb> That's a Bad Idea™, and thus simply Bad Code™.
<Papierkorb> You can try filing a feature request for kemal for a better solution
<dragonkh> I make a helper method then to hide it away
<dragonkh> and see if Kemal might consider a pull request
<oprypin> sdogruyol, please check out this use case (using json.mapping). why does kemal params provide a method for "assume the request body is json and read it and parse it and return raw" (when the body is not even related to params) but doesnt have a method for getting the body?
ShalokShalom has joined #crystal-lang
hightower2 has quit [Remote host closed the connection]
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]