ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.19.4 | Fund Crystals 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
Philpax has joined #crystal-lang
pawnbox has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Client Quit]
snsei has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
Philpax has joined #crystal-lang
pawnbox has quit [Read error: Connection reset by peer]
<FromGitter> <jwoertink> Has anyone here done much with https://github.com/will/crystal-pg and kemal?
<FromGitter> <jwoertink> I have this weird error that technically blows up in crystal, but I think it might be more of the pg shard issue
<FromGitter> <johnjansen> i havent used it, but whats the problem
<FromGitter> <raydf> I have used crystal-pg with toro
<FromGitter> <raydf> what are you trying to do?
<FromGitter> <raydf> For me is very stable.
<FromGitter> <johnjansen> id like to know what the “weird error” is
<FromGitter> <jwoertink> Ok, so what makes it "weird" is that with the `DB.exec`, if I add the tuple to specify the types, the error goes away. Alternatively, if I remove the `to_json` with this setup, it will work
<FromGitter> <johnjansen> what does the hash look like (does that work) without the to_json
<FromGitter> <jwoertink> yes, without the `to_json` it works. It's just a normal hash
<FromGitter> <raydf> the problem i believe is that some types, like Array(PG::Geo::Point) are not very json serialization friendly
<FromGitter> <jwoertink> ^ that's what I figured
<FromGitter> <jwoertink> which is why I'm thinking it's a pg error
<FromGitter> <johnjansen> agreed,
<FromGitter> <johnjansen> its not PG IMO
<FromGitter> <johnjansen> can you drop the hash into that gist
<FromGitter> <jwoertink> `[{"id" => "277632170022f4b540", "username" => "andrewz17"}]`
<FromGitter> <jwoertink> it looks like that
<FromGitter> <raydf> you should do this: DB.exec({Int32, String} ,"SELECT id, username FROM members LIMIT 1000")
<FromGitter> <raydf> try to restrict the returning data types for better experience with the lib
pawnbox has joined #crystal-lang
<FromGitter> <johnjansen> @raydf you hit the mark ;-)
pawnbox has quit [Remote host closed the connection]
<FromGitter> <jwoertink> yeah, that works, but for my queries, I can't specify the types
<FromGitter> <raydf> then use case when Int32, String, etc...
<FromGitter> <johnjansen> why not, the data in the DB is a fixed type
<FromGitter> <raydf> he's using dynamic sql
<FromGitter> <johnjansen> not to be argumentative
<FromGitter> <johnjansen> ok ;-)
<FromGitter> <raydf> i suppose
<FromGitter> <jwoertink> yup
<FromGitter> <raydf> I'm almost sure you're only returning some limited types like, String, Int64, Float64, etc. etc. if you use case of types you'll have a clean structure to serialize
<FromGitter> <raydf> Generics could help you in this case
<FromGitter> <jwoertink> my database has some tables without IDs, some had IDs as ints, some have IDs as strings
<FromGitter> <jwoertink> so, the types have to be specified per "model"
<FromGitter> <raydf> use generics
<FromGitter> <jwoertink> ?
<FromGitter> <raydf> in each model try to specify with free variables the type of data for the id
<FromGitter> <jwoertink> Have an example?
<FromGitter> <jwoertink> Like, what would that look like in a simple example?
<FromGitter> <raydf> in this view engine i used generics for the props
<FromGitter> <jwoertink> ah, ok. I've seen this syntax of `View(T)`, but never really understood it
<FromGitter> <johnjansen> have you read this https://crystal-lang.org/docs/syntax_and_semantics/generics.html
<FromGitter> <jwoertink> I've read the entire docs, but only understood about half of it
<FromGitter> <raydf> that happens to me also :)
<FromGitter> <raydf> but each day i use more and more the features of the language
<FromGitter> <johnjansen> haha, i understand more after a red bull
<FromGitter> <jwoertink> In this example, since View is abstract, how do you instantiate one of the sub classes?
<FromGitter> <raydf> sorry for all the garbage
<FromGitter> <raydf> is a WIP
<FromGitter> <raydf> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5812d62a83a2008d22df89de]
<FromGitter> <jwoertink> no worries.
<FromGitter> <jwoertink> Just trying to wrap my head around this
<FromGitter> <jwoertink> So you have something like `class Whatever < Warp::View` and then you can just do `Whatever.new`? Where does that `T` come in to play?
<FromGitter> <raydf> class inherited ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5812d6805a1cfa016e552245]
<FromGitter> <raydf> as you may see props[:title]? is a String | Nil
<FromGitter> <raydf> there's the generics in action
<FromGitter> <raydf> if i use a Int32 in title then the types would be String | Int32
<FromGitter> <raydf> For your models you can create some kind of usage like that for each column
<FromGitter> <jwoertink> The concept makes sense. I'm still unclear how you would instantiate the `Entities`. Would it just be `Web::View::Entities::Entities(String).new` ?
<FromGitter> <johnjansen> @jwoertink here is another way generics can be used ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5812d771806316005dcab516]
<FromGitter> <raydf> in the @johnjansen case: ⏎ ``````
<FromGitter> <raydf> Thanks @johnjansen, much simpler example
<FromGitter> <jwoertink> Oh, ok. That's cool
<FromGitter> <raydf> :)
<FromGitter> <johnjansen> right, and i often use it for Enumerables of unknown types, where the collection has behaviours, but i dont know what the collection will have in it
<FromGitter> <johnjansen> oh and @jwoertink if its not obvious `T` is not the only name you can use, its just the standard one, call it anything that makes sense
<FromGitter> <johnjansen> just make it a constant
<FromGitter> <jwoertink> right. Thanks!
<FromGitter> <raydf> And maybe you'll like to try this: ⏎ https://github.com/sdogruyol/tren
<FromGitter> <jwoertink> Good call! I've been watching this.
<FromGitter> <raydf> I believe the JSON mapping structure is too specific right now
<FromGitter> <raydf> later we'll see something like golang attributes
<FromGitter> <jwoertink> Should I report this issue to somewhere?
<FromGitter> <jwoertink> or shrug it off as implementation issue?
<FromGitter> <raydf> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5812d9a8806316005dcabc79]
<FromGitter> <jwoertink> is that go?
<FromGitter> <raydf> yeah
<FromGitter> <raydf> the problem right know is that some classes in crystal you are repeating yourself when you need to have multiple mappings
<FromGitter> <raydf> and that's your case, you need multiple mappings to sqldb and to json, and who knows maybe later you'll need yaml or msgpack
<FromGitter> <jwoertink> exactly
<FromGitter> <johnjansen> just a question, did you try result_set.to_json directly?
<FromGitter> <jwoertink> yeah
<FromGitter> <jwoertink> same error
<FromGitter> <raydf> why not convert your record to json from postgres and then parse it with crystal?
<FromGitter> <jwoertink> I didn't know that was a thing lol
<FromGitter> <raydf> i haven't used it much, but there's a function row_to_json
<FromGitter> <jwoertink> checking it out now
<FromGitter> <raydf> the you can restrict in crystal-pg {JSON::Any}.
<FromGitter> <raydf> *then
<FromGitter> <iDev0urer> @raydf I was thinking the same thing for marshaling and unmarshaling data
<FromGitter> <raydf> remember that one should take a lot of things in consideration, with row_to_json you're taxing the DB even more :).
pawnbox has joined #crystal-lang
<FromGitter> <raydf> ```select row_to_json(table_name) from table_name;``` ⏎ It works :) [https://gitter.im/crystal-lang/crystal?at=5812dd3b8ed1c0ff5c384381]
<FromGitter> <raydf> bye everyone , it's getting very late here.
<FromGitter> <jwoertink> same here! Thanks for the help
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<FromGitter> <sdogruyol> @jwoertink just map the types instead of directly calling to_json on Hash
<FromGitter> <sdogruyol> results.to_hash.map { |h| h["something"].as(Float64) } for example
<FromGitter> <sdogruyol> it's more core to write but really explicity
bazaar_ has joined #crystal-lang
bazaar_ is now known as bazaar
snsei has quit [Remote host closed the connection]
Philpax has quit [Ping timeout: 260 seconds]
Philpax has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
Philpax has quit [Quit: Leaving]
pawnbox has joined #crystal-lang
soveran has quit [Read error: Connection reset by peer]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
bjz has joined #crystal-lang
Philpax has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
matp_ has joined #crystal-lang
matp has quit [Ping timeout: 260 seconds]
pawnbox has quit [Remote host closed the connection]
soveran has quit [Remote host closed the connection]
gloscombe has joined #crystal-lang
gloscombe has quit [Client Quit]
gloscombe has joined #crystal-lang
gloscombe has quit [Client Quit]
gloscombe has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
matp_ is now known as matp
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
ponga has quit [Quit: Connection closed for inactivity]
bjz has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
bjz has quit [Client Quit]
bjz has joined #crystal-lang
bjz has quit [Client Quit]
gloscombe has quit [*.net *.split]
wmoxam has quit [*.net *.split]
am_ has joined #crystal-lang
am__ has joined #crystal-lang
am__ has quit [Client Quit]
am_ has quit [Read error: Connection reset by peer]
wmoxam has joined #crystal-lang
gloscombe has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 250 seconds]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vXklv
<crystal-gh> crystal/master 6f6ddc0 Ary Borenszweig: Compiler: don't use byval in codegen
<FromGitter> <sdogruyol> @asterite the ARM support is coming good :)
<travis-ci> crystal-lang/crystal#6f6ddc0 (master - Compiler: don't use byval in codegen): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/171386834
soveran has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
bjz has joined #crystal-lang
<FromGitter> <zatherz> does Crystal have anything like Marshal in Ruby?
<FromGitter> <johnjansen> not exactly, closest is to_json or to_yaml, those modules document mappings for objects
mhib has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
pawnbox has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Philpax has quit [Ping timeout: 260 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 265 seconds]
mhib has quit [Quit: Leaving]
fedruantine has quit [Ping timeout: 252 seconds]
jwaldrip has quit [Read error: Connection reset by peer]
jwaldrip has joined #crystal-lang
daekano has quit [Ping timeout: 256 seconds]
daekano has joined #crystal-lang
<FromGitter> <jwoertink> Anyone that's used the pg shard know how to just get the raw response from a query? I'm digging through the source but not seeing any methods
<FromGitter> <fkchang> @sdogruyol u might like my slides for a quick talk I did at OCRuby last night, the title is Crystal, but it';s basically kemal to the rescue http://www.slideshare.net/fkchang/crystal-is-a-rubyists-friend-quick-anecdote
<FromGitter> <sdogruyol> @fkchang awesome!
<FromGitter> <sdogruyol> How was the reaction of people
<FromGitter> <sdogruyol> @jwoertink results.rows?
<FromGitter> <jwoertink> I'm using the postgres json, so my raw result is json, but `rows` returns hashes
<FromGitter> <jwoertink> I was hoping to just do something like `JSON.parse(DB.exec(...).raw)`, and be done with it instead of iterating over the results and having to map each one
<FromGitter> <johnjansen> @jwoertink can you put the json somewhere for a quick look
<FromGitter> <jwoertink> `{"id" : "2776339000b56f68e8", "username" : "jmic4231"}`
<FromGitter> <jwoertink> nothing fancy. Just normal JSON
<FromGitter> <johnjansen> whats that wrapped in, i mean to make it “rows"
<FromGitter> <jwoertink> I can run `SELECT json_build_object('id', id, 'username', username) FROM members LIMIT 1000;` in `psql` to get that result, but once I run it through `DB.exec` I get back `[[{"id" => "2776339000b56f68e8", "username" => "jmic4231"}]]`
<FromGitter> <jwoertink> but calling `to_json` on that hash throws that wonky error
<FromGitter> <johnjansen> whats the error
<FromGitter> <jwoertink> the one that I posted last night
<FromGitter> <johnjansen> oh that one again ;-)
<FromGitter> <jwoertink> I know why I get that error. I'm just trying to come up with a solution around it
<FromGitter> <johnjansen> i have to run, but ill have alook at it later on
gloscombe has quit [Quit: Lost terminal]
<FromGitter> <sdogruyol> @jwoertink to_hash.to_json
<FromGitter> <jwoertink> that fails :(
<FromGitter> <jwoertink> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=581392f6c3569a036e2c25a6]
<FromGitter> <sdogruyol> Like I said
<FromGitter> <sdogruyol> You need to cast types
<FromGitter> <sdogruyol> to_hash.map {|row| {"name" => row["name"].as(String)....}}
<FromGitter> <jwoertink> Yeah, I was trying to avoid that
<FromGitter> <jwoertink> My issue there is that there's going to be some hashes with 100 keys in them, so these mappings will become really massive
<FromGitter> <paulcsmith> I'm having trouble understanding why this macro doesn't "see" the FIELDS constant in this example https://gist.github.com/paulcsmith/2b42d51fbba74b18c2fe72261da0f9c8
<FromGitter> <paulcsmith> If I move the FIELDS constant outside the inherited macro it works, but then that same constant is shared across all subclasses that inherit from `App::Record`, which I don't want
<FromGitter> <sdogruyol> @jwoertink ugh now that's tough
<FromGitter> <jwoertink> Looks like @paulcsmith is headed down the same road I am lol
<FromGitter> <jwoertink> my issue would probably be solved by the active_record.cr shard, but it looks like that's not really being updated
<FromGitter> <sdogruyol> A shard for that kind of conversion would be great
bjz has joined #crystal-lang
<FromGitter> <paulcsmith> Haha. Yeah I had `FIELDS` outside of the `macro inherited`, but then when I went to add another model I realized the `FIELDS` constant was shared :S
<FromGitter> <paulcsmith> @jwoertink Looks like we definitely are. I'm trying to learn Crystal by building an app and the web framework at the same time
<FromGitter> <jwoertink> scary!
<FromGitter> <sdogruyol> @paulcsmith use kemal
<FromGitter> <paulcsmith> Yeah, but fun
<FromGitter> <sdogruyol> And build some product so that we can showcase
<FromGitter> <paulcsmith> I'd rather build my own thing right now. It's fun :)
<FromGitter> <paulcsmith> I've been looking at Kemal though, and I've used some of the concepts in my app :D
<FromGitter> <sdogruyol> :smile:
<FromGitter> <sdogruyol> Cool
<FromGitter> <jwoertink> unfortunately, you won't be able to showcase my apps :(
<FromGitter> <paulcsmith> The ORM is the hard part. I know you don't like ORMs, but I do haha. It's proving difficult though. Trying to figure out how to do things without `send` is tricky
<FromGitter> <sdogruyol> I am building a big platform gateway with Kemal
<FromGitter> <paulcsmith> I'd love to share the app I'm working on, but probably won't be done for at least a few months
<FromGitter> <sdogruyol> @paulcsmith use tren I know it's more code but it's just sql
<FromGitter> <paulcsmith> I saw that. It was interesting, but I like the comparability of query builders
<FromGitter> <sdogruyol> @jwoertink we can If the company wants to
<FromGitter> <paulcsmith> Plus I want to make the queries type safe. By declaring fields and their types in the model I can ensure that the fields actually exist and that types are correct. I think that would be really cool
<FromGitter> <sdogruyol> You can do that with tren
<FromGitter> <sdogruyol> Even overload queries
<FromGitter> <sdogruyol> For nilable or optional params
<FromGitter> <paulcsmith> Oh I see that now. Very cool.
<FromGitter> <paulcsmith> But how can you compose queries? I want to be able to do something like `Post.published.popular`
<FromGitter> <sdogruyol> I do that in sql
<FromGitter> <paulcsmith> That's pretty important IMO
<FromGitter> <paulcsmith> Can you give an example of what you mean?
<FromGitter> <sdogruyol> Tren has composable queries
<FromGitter> <jwoertink> @sdogruyol I think the company would be ok with it, but I work in the Adult video industry ;) lol
<FromGitter> <sdogruyol> Hold on
<FromGitter> <sdogruyol> @jwoertink rofl
<FromGitter> <jwoertink> and most of our logos alone are pretty gnarly.... So even just showing a logo would be pretty bad haha
<FromGitter> <paulcsmith> @sdogruyol Ah I see the example in the readme now. That's an interesting way to handle it
<FromGitter> <jwoertink> but once I have Namechk fully moved over, that will be a good one to showcase :D
<FromGitter> <sdogruyol> @jwoertink yeah that'd be great
<FromGitter> <sdogruyol> @paulcsmith Tren is what ECR is to SQL
<FromGitter> <sdogruyol> Sql templating :smile:
snsei has joined #crystal-lang
<FromGitter> <sdogruyol> And we are already using it in production for some badass reporting stuff
<FromGitter> <sdogruyol> Which are SQL heavy
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <sdogruyol> And the good part is that I can talk with a DB admin with the same file
<FromGitter> <sdogruyol> @jwoertink combining Kemal logo with that logos may produce some interesting stuff :smile:
<FromGitter> <jwoertink> LOL
<FromGitter> <sdogruyol> Especially the mustache
<FromGitter> <sdogruyol> Lol
snsei has quit [Ping timeout: 265 seconds]
<FromGitter> <paulcsmith> So say I still wanted to do an ORM, why is it not possible to access the FIELDS constant in that gist? https://gist.github.com/paulcsmith/2b42d51fbba74b18c2fe72261da0f9c8
<FromGitter> <jwoertink> @paulcsmith I have no clue, but going to take a guess here. The outter macro generates the inner macro. The inner macro has the {% %} tags to generate crystal, but at the time that's ran, the outter macro hasn't generated the FIELDS constant yet
<FromGitter> <paulcsmith> Oh yeah that makes sense
<FromGitter> <paulcsmith> Thanks Jeremy :)
<FromGitter> <jwoertink> I could be totally wrong, but that would be my best guess
<FromGitter> <sdogruyol> @paulcsmith I'd advise you to take a look at Tren code
<FromGitter> <sdogruyol> The run macro may be what you are looking for
<Papierkorb> A port of the (albeit huge) `sequel` gem would be amazing
<FromGitter> <sdogruyol> It's kinda hard to get at first but pretty useful
<FromGitter> <paulcsmith> @sdogruyol Will do. Thanks for the tip!
<FromGitter> <sdogruyol> Just a wild guess
<FromGitter> <sdogruyol> Wish I could be more help
<FromGitter> <paulcsmith> And what does the `\` do before macro interpolation? I checked the macro docs, but haven't ever found anything about that :S
<FromGitter> <sdogruyol> It's actually for escaping
<FromGitter> <sdogruyol> Takes a bit trial and error to actually understand macros
<FromGitter> <paulcsmith> Ohhh, gotcha
<FromGitter> <paulcsmith> Yeah it's tricky :P
<FromGitter> <sdogruyol> But it's super powerful
<FromGitter> <sdogruyol> You should really talk to @f when it comes to macros
<FromGitter> <sdogruyol> He built some crazy stuff with macros
<FromGitter> <fkchang> @sdogruyol they liked it, I generally frame crystal as the go to for Rubyists who need the speed/perf/low resources, I think they were surprised at both results and how close to Ruby it is
<FromGitter> <sdogruyol> That's really nice to hear
<FromGitter> <iDev0urer> In other news my [article](https://hackernoon.com/crystal-ruby-syntax-with-almost-c-efficiency-ce1fb9c977b8#.3yfjkdi41) has reached 63 shares. Surprisingly well received for my first publication :)
<FromGitter> <sdogruyol> Wow congratulations
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
no0p has joined #crystal-lang
soveran has quit [Remote host closed the connection]
bjz has joined #crystal-lang
<crystal-gh> [crystal] hugoabonizio opened pull request #3480: Fix wrong result in YAML docs (master...patch-4) https://git.io/vXIqX
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
soveran has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
no0p has quit [Quit: Leaving]
snsei has joined #crystal-lang
<FromGitter> <zatherz> why do UInt64s serialize to strings in JSON
<FromGitter> <zatherz> which breaks from_json on things like hashes using UInt64s as keys
snsei has quit [Ping timeout: 260 seconds]
<FromGitter> <zatherz> ```icr(0.19.4) > 1_u64.to_json ⏎ => "1"``` [https://gitter.im/crystal-lang/crystal?at=5813b57b7b15d16e55bc827c]
<BlaXpirit> >> {1.to_json; 1u64.to_json}
<DeBot> BlaXpirit: Syntax error in eval:21: expecting token '=>', not ';' - https://carc.in/#/r/1cxo
<BlaXpirit> >> {1.to_json, 1u64.to_json}
<DeBot> BlaXpirit: undefined method 'to_json' for Int32 - https://carc.in/#/r/1cxp
<FromGitter> <zatherz> so it's numbers in general
<BlaXpirit> sigh, regardles...
<FromGitter> <zatherz> it still breaks hashes
<BlaXpirit> everything in general lol
<BlaXpirit> zatherz, JSON is a string, what else is it supposed to be?
<FromGitter> <zatherz> wait, I confused myself there
<FromGitter> <zatherz> let me make an example of what I mean
<FromGitter> <zatherz> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5813b62f5a1cfa016e5986b6]
<BlaXpirit> sigh
<FromGitter> <zatherz> if that looks terrible in irc then https://gitter.im/crystal-lang/crystal
<BlaXpirit> zatherz, JSON can have only strings as a key
<FromGitter> <zatherz> BlaXpirit: yes, that doesn't change the fact that it could somehow verify the type of the hash key and properly convert it
<FromGitter> <zatherz> also, is there any better format available for serialization?
<BlaXpirit> this makes no sense
<FromGitter> <zatherz> using JSON feels like a hack
<FromGitter> <zatherz> BlaXpirit: at the very least it should raise when you try to do from_json on a Hash with non-string keys
<BlaXpirit> maybe you mean `to_json`
<BlaXpirit> then sure, perhaps
<FromGitter> <zatherz> yeah, that'd make more sense probably, but a raise in from_json as well wouldn't hurt
<FromGitter> <johnjansen> @zatherz you could look at http://msgpack.org/index.html
<FromGitter> <zatherz> also
<FromGitter> <zatherz> couldn't it serialize hashes as a list of 2-element lists where the 1st element is the key and the 2nd element is the value
<BlaXpirit> zatherz, ok, then what?
<FromGitter> <zatherz> then keys wouldn't be limited to strings
<FromGitter> <zatherz> @johnjansen found this https://github.com/benoist/msgpack-crystal
<FromGitter> <johnjansen> yeah, try it out
<FromGitter> <johnjansen> i havent had a chance to get it going, although i played about for a short while
<FromGitter> <johnjansen> or @zatherz even yaml may work
pawnbox has quit [Remote host closed the connection]
<FromGitter> <zatherz> @johnjansen crap, it doesn't work :/
<FromGitter> <zatherz> breaks with hashes too
<FromGitter> <zatherz> `unexpected token 'UINT' expected HASH at 1 (MessagePack::UnpackException)`
<FromGitter> <johnjansen> YAML ?
<FromGitter> <zatherz> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5813baff482c168b22c7d394]
<FromGitter> <zatherz> what
<FromGitter> <zatherz> I used YAML.mapping
<FromGitter> <zatherz> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5813bb6b8ed1c0ff5c3c767b]
<FromGitter> <johnjansen> @zatherz this worked for me ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5813bb947b15d16e55bc9c5a]
<FromGitter> <johnjansen> @zatherz so does this ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5813bd0e806316005dcef0b8]
<FromGitter> <zatherz> @johnjansen inspected the file in a hex editor... http://i.imgur.com/tOsfoNy.png
<FromGitter> <zatherz> yes, it saved the literal string
<FromGitter> <zatherz> I used `File.write`
<FromGitter> <zatherz> and looking at the crystal source, ⏎ ```
<FromGitter> <zatherz> `print(content)`
<FromGitter> <johnjansen> try write_bytes
<FromGitter> <johnjansen> ?
<FromGitter> <zatherz> yup
Raimondi has quit [Write error: Broken pipe]
Raimondi has joined #crystal-lang
<FromGitter> <johnjansen> did you to_slice the packer?
matp has quit [Excess Flood]
<FromGitter> <zatherz> what packer, it's using MessagePacker.mapping
<FromGitter> <zatherz> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5813bf7bc3569a036e2d0776]
<FromGitter> <johnjansen> oh yeah sorry, looking at my code not yours
<FromGitter> <zatherz> also
<FromGitter> <zatherz> fantastic, it's working now
<FromGitter> <johnjansen> ok what did you do
bjz has joined #crystal-lang
<FromGitter> <zatherz> I just used file.write
<FromGitter> <zatherz> note: `file`, not `File`
<FromGitter> <zatherz> ```File.open(@save_path.not_nil!, "w") do |file| ⏎ file.write to_msgpack ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5813bfd80e25dbfa11714cda]
<FromGitter> <johnjansen> great
woodruffw has quit [Ping timeout: 256 seconds]
<FromGitter> <johnjansen> BTW @zatherz you can also send that msgpack data around the place, as you can unpack it to something usable without the class ⏎ ```unpacker = MessagePack::Unpacker.new(File.read("msgpack_test")) ⏎ unpacker.read``` [https://gitter.im/crystal-lang/crystal?at=5813c1fa0e25dbfa11715844]
woodruffw has joined #crystal-lang
<FromGitter> <zatherz> oh, nice! what does .read return? the class that was packed?
<FromGitter> <johnjansen> from the House example `{"address" => "Something", "location" => {"lat" => 12.3, "lng" => 34.5}}`
<FromGitter> <johnjansen> its meant to be used for API’s etc
<FromGitter> <johnjansen> im tempted to use it for all my internal stuff, but then id be forgetting that it can be unpacked in the browser too http://msgpack.org/#msgpack-lite--
<FromGitter> <zatherz> wow, nice
soveran has quit [Remote host closed the connection]
<crystal-gh> [crystal] ysbaddaden pushed 11 new commits to master: https://git.io/vXIVe
<crystal-gh> crystal/master a2a204a Julien Portalier: Add arm-linux-gnueabihf target (eg: RaspberryPi)
<crystal-gh> crystal/master 925c6f6 Julien Portalier: Support for ARM ABI...
<crystal-gh> crystal/master 61cb32b Julien Portalier: ARM: exit instead of raising (until unwind support is fixed)
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 256 seconds]
soveran has quit [Remote host closed the connection]
<travis-ci> crystal-lang/crystal#82ddcb5 (master - Merge pull request #3424 from ysbaddaden/arm-support): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/171524025
<DeBot> https://github.com/crystal-lang/crystal/pull/3424 (Add ARMv6 / ARMv7 support)
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14> Char#to_i returns Int8
<FromGitter> <johnjansen> @RX14 to_i32
<RX14> yes
<RX14> well not on char
<RX14> #to_i is define to already return an Int32
<RX14> always*
<RX14> so #to_int32 is an alias for #to_i
<RX14> #to_i32*
<RX14> check the code
<RX14> it's broken
<RX14> and it's 1am
<FromGitter> <johnjansen> yeah, i see that now
<FromGitter> <johnjansen> ;-)
bjz has joined #crystal-lang