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
picat has joined #crystal-lang
<oz> Hey, if I have a JSON array of objects that I'd like to map to a struct, I can't use `JSON.mapping`, right?
<Papierkorb> You can and it'll just work.
<Papierkorb> JSON.mapping generates a constructor, and structs can have c'tors, so it
<Papierkorb> 's fine
hightower2 has quit [Ping timeout: 255 seconds]
<oz> hm that's dandy. How would I go about a mapping that parses a JSON array as some Array(T)?
<Papierkorb> Exactly like that
<FromGitter> <picatz> Can someone drop some examples in that for lil 'ol me?
Dreamer3_ has joined #crystal-lang
<Papierkorb> reading and writing JSON or YAML, as long you're using the mapping macro, is almost too easy in Crystal.
<oz> Actually, I tried to hard to write a mapping when I just needed `Array(MyType).from_json` in that case. I'm talking to a weird API. :)
<FromGitter> <picatz> neat!
<oz> BTW, thanks for the help :)
<FromGitter> <codenoid> 5hours > with crystal <3 https://s3.postimg.org/faqvo9isj/Selection_028.png
sz0 has quit [Quit: Connection closed for inactivity]
Raimondi has left #crystal-lang ["WeeChat 1.8-dev"]
picat has quit [Ping timeout: 260 seconds]
snsei has joined #crystal-lang
w-p_ has quit [Ping timeout: 255 seconds]
_whitelogger has joined #crystal-lang
pwned has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter> <codenoid> please, somebody gimme tutorial about (sub) domain management with kemalcr
snsei has joined #crystal-lang
<FromGitter> <piyushranjan> Sorry to ask this but can't help it. How does Ary's movement out of Manas affect Crystal. I am rooting for Crystal and want it to succeed. Just worried
<FromGitter> <sdogruyol> Morning everyone
<FromGitter> <drujensen> Good morning
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <watzon> I'm going to be starting a You-Tube series on Crystal soon hopefully :)
<FromGitter> <watzon> Ideas and suggestions are, of course, welcome
<FromGitter> <bew> Oh awesome!
<FromGitter> <sdogruyol> @watzon I'd be happy to help
snsei has quit [Remote host closed the connection]
mark_66 has joined #crystal-lang
<FromGitter> <Qwerp-Derp> @oprypin So what's the point of using the shard?
<FromGitter> <Qwerp-Derp> @oprypin Also it still doesn't work, I followed all the instructions
<FromGitter> <Qwerp-Derp> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=597ae30b614889d475f957df]
<FromGitter> <Qwerp-Derp> Ummm... has anyone done Swift/Crystal interop?
<FromGitter> <crisward> @piyushranjan I know what you mean. It would be good if the core team could perhaps do a quick post just updating the community.
<FromGitter> <konovod> > or I'm the first one to use generics
<FromGitter> <Qwerp-Derp> NVM I got it, I don't know how crystal shards work :P
<FromGitter> <konovod> @Papierkorb not first, but they bite. especially when combined with inhertance
Groogy__ is now known as Groogy
<Groogy> Morning!
<FromGitter> <konovod> Hi!
<FromGitter> <sdogruyol> Good morning everyone
<FromGitter> <bew> morning!
<FromGitter> <code-andres> Morning!
<FromGitter> <code-andres> Anyone can help me? I'm trying to get a shell output in realtime with crystal... For example a shell script that prints a new line each second, and i need to get that line the moment when is created and use it on crystal. Is that posible?
<FromGitter> <bararchy> So, I got this erorr: ⏎ ⏎ ```No address found for 172.16.123.129http:80 over TCP (Socket::Error)``` ⏎ ⏎ Using curl or wget to this IP does seems to work, what might be the issue here ? [https://gitter.im/crystal-lang/crystal?at=597af226bc46472974315bf0]
<FromGitter> <bew> did you miss a new line between 129 & `http` ?
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=597af27c2723db8d5e53bb48]
<FromGitter> <bararchy> Nope, that's the output
hightower2 has joined #crystal-lang
<FromGitter> <bararchy> That's using Crystal http client btw, nothing fancy here :)
<FromGitter> <bew> how do you init the connection?
<FromGitter> <bew> how are you calling it?
<FromGitter> <bararchy> ```HTTP::Client.get(nurl, headers: headers, tls: nurl.includes?("https") ? ctx : nil)```
<FromGitter> <Qwerp-Derp> Ummm... how do I use `crystal play`?
<FromGitter> <Qwerp-Derp> How do I actually execute my code?
<FromGitter> <bew> @bararchy what `nurl` looks like?
<FromGitter> <bew> @Qwerp-Derp you run `crystal play` in a terminal, it'll print a URL, then you go with your browser (firefox, chrome or others) on that URL, and there you'll be able to write & execute code
hightower2 has quit [Ping timeout: 260 seconds]
<FromGitter> <code-andres> @Qwerp-Derp If your code is in an text file it must be with the extension .cr and you an execute it whit "crystal run your_file.cr"
<FromGitter> <code-andres> @Qwerp-Derp See here -> https://crystal-lang.org/docs/using_the_compiler/
<FromGitter> <bararchy> @bew Thanks for the pointer, it seems that somehow I get one of my hosts as `172.16.123.129http` ...
<FromGitter> <bew> yw
<FromGitter> <bew> ;)
<FromGitter> <bew> @code-andres see https://carc.in/#/r/2fna, try this example in your computer, to see how it prints lines in real time!
<FromGitter> <code-andres> @bew I can't load the url... broke maybe
<FromGitter> <bew> retry: https://carc.in/#/r/2fna
<FromGitter> <code-andres> Nope... i can't enter in carc.in either
<FromGitter> <Qwerp-Derp> :( Trailing `while`s aren't supported...
<FromGitter> <abidon> @Qwerp-Derp By Swift/Crystal interop you mean calling Crystal code from Swift or the opposite ?
<FromGitter> <Qwerp-Derp> @abidon Calling Crystal code from Swift
<FromGitter> <abidon> Then its doable, can take a look at it if you want
<FromGitter> <bew> @code-andres https://play.crystal-lang.org/#/r/2fnc
<FromGitter> <Qwerp-Derp> @abidon How do you do it? :P
<FromGitter> <code-andres> Someone can enter to carc.in? My browser say "Unable to connect"
<FromGitter> <bew> @code-andres or simply: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=597af7912723db8d5e53ceeb]
<FromGitter> <code-andres> @bew Nope... i will check my connection
<FromGitter> <abidon> @Qwerp-Derp You can call Crystal code from C, and you can call C code from Swift, so you can call Crystal code from Swift
<FromGitter> <code-andres> @bew Oh tanks i see... I will try it
<FromGitter> <abidon> @Qwerp-Derp If you want to figure it out by yourself, just make sure you know how to mix C/Swift, and expose Crystal functions as C functions (no mangling) using the `fun` keyword instead of `def`
<FromGitter> <bararchy> Someone really need to add Redirect follow in Crystal's HTTP client
<FromGitter> <code-andres> @bew Its working great, for mi code... Thanks 👍
<FromGitter> <bew> you're welcome :)
rohitpaulk has joined #crystal-lang
<FromGitter> <bew> @bararchy there is: #2721, but the discussion went a bit offtopic regarding the original issue..
<FromGitter> <bararchy> @bew Hm.... I commented there, I hope that maybe this can be moved on and implamented, Right now I use the cossack shard, which is great but I don't want to relay on external shard for a single basic feature like redirect follow
xiljin has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <watzon> Why is it that every time I search for a library at crystalshards.xyz, Papierkorb is the one that made the library I found? :p
<FromGitter> <abidon> @Qwerp-Derp Here you are ! Calling Crystal code from Swift: https://github.com/abidon/crystal-swift-interop
<FromGitter> <Qwerp-Derp> @abidon Thanks!
<FromGitter> <Qwerp-Derp> Is there a `sleep` function in Crystal?
<Groogy> sleep 5.seconds
<FromGitter> <Qwerp-Derp> What about clearing the screen?
<Groogy> depends on what multimedia framework you are using
<Groogy> or do you mean the terminal?
<FromGitter> <Qwerp-Derp> I mean the terminal
<Groogy> think that is system dependent, so...
<FromGitter> <bew> terminal dependent to be exact
<Groogy> yeah
<Groogy> though you could use the ANSII control characters for it
<Groogy> probably
<Groogy> though I would recommend to use a TUI framework to do it for you
<FromGitter> <code-andres> Crystal have some shard for html embed view?
<FromGitter> <bew> @Qwerp-Derp you could also use `tput clear` to clear the screen, but it'll rely on another binary (tput)
<FromGitter> <code-andres> I found this https://github.com/maxwells/layout... But is to young
rohitpaulk has joined #crystal-lang
<FromGitter> <bew> @code-andres are you looking for templating? https://github.com/veelenga/awesome-crystal#template-engine
<FromGitter> <Qwerp-Derp> @bew How do I use `Process` to run `clear`?
<FromGitter> <code-andres> @Qwerp-Derp Process.run("clear")
<FromGitter> <bew> @code-andres there is also https://github.com/crystal-lang/html_builder to have a dsl to build html string
<FromGitter> <Qwerp-Derp> @code-andres Doesn't clear the screen :(
<FromGitter> <bew> try `Process.run("tput clear")`
<FromGitter> <Qwerp-Derp> @bew Also doesn't work
<FromGitter> <bew> what terminal are you using?
<FromGitter> <Qwerp-Derp> @bew Mac OSX default terminal
<FromGitter> <code-andres> @bew Nope... I mean, open a window on crystal and draw the html view inside it...
<FromGitter> <code-andres> I can't find a shard or something like that yet on Crystal, use a webkit and draw an embed html view on a Crystal app
<Groogy> ah don't think anyone have ported a html engine to display html.
<FromGitter> <bew> then either you do that shard, either you find another way
<Groogy> you could port Gecko fairly easy I would guess
<FromGitter> <bew> @Qwerp-Derp you could try: `print "\e[2Jscreen cleared\e[0;0Hcursor moved in top left"` but it won't be a lot portable..
<FromGitter> <code-andres> @bew yeap i will do that... but i wannted to ask if exists some shard.
<FromGitter> <bew> `print "\e2J"` will clear the terminal, and `print "\e[0;0H"` will place the cursor in the top left corner
<FromGitter> <code-andres> <Groogy> yes, i'm reading that page... well, this will be a good shard
<FromGitter> <code-andres> Oh that chromiun, thanks!
<Groogy> might need to write some C wrappers as well though, since I don't seem to be able to find any C bindings to them :/
<FromGitter> <code-andres> Well... I will do a research and start working on it in my free time. Crystal need a shard like that...
<FromGitter> <code-andres> Is good to ask here, what shard is better or more recommended? (myhtml or crystagiri)
<FromGitter> <sdogruyol> i guess myhtml is actively maintained by @kostya
<FromGitter> <sdogruyol> @code-andres
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <code-andres> @sdogruyol yeah, i wil try both and see.
<FromGitter> <bew> looking at the benchmarks on myhtml readme, it looks it's the best
rohitpaulk has joined #crystal-lang
w-p has joined #crystal-lang
<FromGitter> <straight-shoota> @bew #4754
<FromGitter> <sdogruyol> How's everyone doing
<FromGitter> <bew> ok @straight-shoota I removed my comment
<FromGitter> <picatz> I've been working with Crystal recently to work with STL files.
<FromGitter> <sdogruyol> STL?
<FromGitter> <picatz> It's a type of file used a lot for things like 3D printers.
<FromGitter> <sdogruyol> Oh, thanks for the explanation :)
<FromGitter> <picatz> It's used for many other things other than just 3D printers, but I've found crystal to be a really neat language to parse STL files with.
<FromGitter> <sdogruyol> beautiful code with blazing speed = Crystal <3
<FromGitter> <bew> cool! what do you want to do with those files from crystal?
<FromGitter> <picatz> Mostly just analysis at the moment. Like, finding the greatest x,y,z coordinates from a file.
<FromGitter> <code-andres> @picatz Wow that sounds interesting... Thinking in a program for STL graphic editor? jeje
<FromGitter> <code-andres> @sdogruyol Crystal ❤️ 👍
<FromGitter> <picatz> It's more like, I don't always want to use another program's STL algorithms to the decimate the quality of the file for example.
<FromGitter> <bew> that sounds interesting!
<FromGitter> <picatz> I've been having all sorts of fun with fibers and channels.
<FromGitter> <picatz> ya' know, maybe too much so. :P
<FromGitter> <picatz> It's been interesting to benchmark where I've seen a performance gain from spawning fibers and channels and where I don't. I still have lots to learn there I'm sure.
<FromGitter> <code-andres> @picatz It start as a small script just for fun... Later is a big parser with many use on 3D software
<FromGitter> <code-andres> I created a small scrip that use ffmpeg to convert videos, now is getting form... Maybe i must upload to github
<FromGitter> <picatz> You should! :D
<FromGitter> <picatz> Before I release any sort of STL parser / analyzer in crystal I should probably make something I'd feel more confident in taking on. Like porting one of my ruby projects to Crystal.
<FromGitter> <picatz> I think Crystal could be cool for a ChartJS DSL: https://github.com/picatz/chart_js
<FromGitter> <code-andres> That remember the Amchart gem that i created with the same idea (https://github.com/code-andres/amcharts-js)... but abandoned because of time
<FromGitter> <code-andres> I will try CharJs
<FromGitter> <code-andres> I will glad to help in your port
<FromGitter> <code-andres> Well... later i will sleep (awake for 23h)... bye
<FromGitter> <picatz> No worries! I appreciate it! :D
<FromGitter> <picatz> Get some rest lol
rohitpaulk has quit [Ping timeout: 246 seconds]
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
rohitpaulk has joined #crystal-lang
dannyAAM has joined #crystal-lang
sz0 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <codenoid> hi, is Crystal HTTP support php-like CURLOPT_REFERER function
<Papierkorb> you want to set the `Referer` header in a request?
<FromGitter> <codenoid> yes
<Papierkorb> just set it as header.
saadq has quit [Ping timeout: 255 seconds]
<FromGitter> <codenoid> :shipit: : how in Crystal ?
<FromGitter> <fridgerator> `response.headers["Referer"] = "whatever"`
<FromGitter> <fridgerator> something like that?
<FromGitter> <codenoid> wait, i'll try
<FromGitter> <crisward> Anyone know of a way of converting an ip4 address to an int in crystal?
grottof has joined #crystal-lang
saadq has joined #crystal-lang
<FromGitter> <crisward> Just found an old stack overflow answer in ruby - `'10.0.2.15'.split('.').inject(0) {|total,value| (total << 8 ) + value.to_i}`
<FromGitter> <fridgerator> @crisward out of curiosity, what is that useful for?
<FromGitter> <crisward> storing ip's in database. int is much smaller / quicker than dot notation
<FromGitter> <fridgerator> ah
<FromGitter> <crisward> thanks, just roughing something out at the moment, will aim to get more robust once my proof of concept is working.
<FromGitter> <straight-shoota> it seems like `IPAdress` does not disclose the int value, you could access it through ivars `@addr6/`@addr4`
<FromGitter> <picatz> I found this: http://www.aboutmyip.com/AboutMyXApp/IP2Integer.jsp
<FromGitter> <picatz> And then wrote this: https://play.crystal-lang.org/#/r/2fp8
<FromGitter> <picatz> '\(' 0')/' I dunno
<FromGitter> <straight-shoota> Though you'd have to respect IP4 and IP6's different memory footprint
<FromGitter> <straight-shoota> IPv6 has 128 bit, so its larger than int
<FromGitter> <crisward> ipv4 = `"10.0.2.15".split(".").reduce(0) { |total, val| (total << 8 )+val.to_i }` seems to work
<FromGitter> <crisward> I'll worry about ip6 later. MySql has a built in function `INET_ATON('127.0.0.1')` which I may use later
<FromGitter> <sdogruyol> make it work then make it fast :)
Philpax_ has quit [Ping timeout: 268 seconds]
<FromGitter> <sdogruyol> Boehm GC is really conservative about deallocations
grottof has left #crystal-lang [#crystal-lang]
snsei has joined #crystal-lang
<FromGitter> <codenoid> ```code paste, see link``` ⏎ ⏎ `no overload matches 'File#write' with type String` so i must convert that to ? [https://gitter.im/crystal-lang/crystal?at=597b4d8f2723db8d5e551bac]
<FromGitter> <codenoid> oo wait
<FromGitter> <crisward> btw, int back to ip is `"#{(ipint >> 24).to_u8}.#{(ipint >> 16).to_u8}.#{(ipint >> 8).to_u8}.#{ipint.to_u8}"`
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <picatz> Cool! :D
<FromGitter> <codenoid> AAHAHHAHA YASSSS
<FromGitter> <codenoid> all of webtoons comic saved in my computer
snsei has quit [Remote host closed the connection]
<FromGitter> <codenoid> I <3 CRYSTAL
<FromGitter> <codenoid> btw, when i use ⏎ image = ⏎ anu = HTTP::Client.get("image.jpg", headers: HTTP::Headers{"User-Agent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0", "Referer" => "ref"}) # i got a response ⏎ but when use ⏎ HTTP::Client.get("image.jpg", headers: HTTP::Headers{"User-Agent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0", "Referer" =>
<FromGitter> <picatz> 👏 Crystal is awesome.
rohitpaulk has joined #crystal-lang
<FromGitter> <kazzkiq> Agreed. Just used it with Kemal to issue an authentication service with JWT. Took less than 5 minutes. Requests are orders of magnitude faster than any other equivalent simple language.
mark_66 has quit [Remote host closed the connection]
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <picatz> I just came across something interesting, figured I'd share so someone can point out if I'm being silly.
<FromGitter> <picatz> `container = Array(Hash(String, String)).new`
<FromGitter> <picatz> I can have that. `container << { "wiggle" => "waddle" }`
<FromGitter> <picatz> but
<FromGitter> <picatz> `container = Array(Hash(Symbol, String)).new`
<Papierkorb> { foo: "bar" } won't do
<FromGitter> <picatz> Right.
<FromGitter> <picatz> Learned that today 😅
<FromGitter> <picatz> `no overload matches 'Array(Hash(Symbol, String))#<<' with type NamedTuple(ok: String)` That gave me all sorts of confusion. But, figured it out.
<FromGitter> <picatz> So I have to `container << { :wiggle => "waddle" }`
snsei has joined #crystal-lang
<crystal-gh> [crystal] straight-shoota opened pull request #4755: Visual and structural improvements to docs generator HTML (master...jm-docs-improvements) https://git.io/v7C3a
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
Split has joined #crystal-lang
Split has quit [Ping timeout: 240 seconds]
tzekid has joined #crystal-lang
snsei has quit [Remote host closed the connection]
pabs has quit [Ping timeout: 240 seconds]
<Groogy2> exit
Groogy2 has quit [Quit: WeeChat 1.9]
<FromGitter> <sdogruyol> woot
kubaxvx__ has quit [Read error: Connection reset by peer]
kubaxvx__ has joined #crystal-lang
hightower2 has joined #crystal-lang
<FromGitter> <crisward> Got 4 outstanding pull requests now. 2 on crystal-mysql and 2 on crystal-db. Looking forward to them getting merged, not sure about other people but my shards files always seem full of my forks. Thinks it's my habit of - "tests pass, next! "
<FromGitter> <crisward> BTW if there is a ever a big Crystal conference, it should really be held in London at the Shard...
rohitpaulk has quit [Ping timeout: 276 seconds]
<FromGitter> <sdogruyol> the Shard
<FromGitter> <sdogruyol> that's really cool
<FromGitter> <sdogruyol> @crisward thank you, keep up the great work :)
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
<FromGitter> <faustinoaq> Excellent icon support added https://github.com/LaurentTreguier/vscode-simple-icons/pull/23
<FromGitter> <faustinoaq> The PR was funny 😄
<FromGitter> <faustinoaq> vscode-crystal-lang now supports Slang (https://github.com/faustinoaq/vscode-crystal-lang/blob/master/CHANGELOG.md#026---2017-07-28)
_tsound has joined #crystal-lang
<_tsound> Hello.
<_tsound> So i'm attempting to port over the ruby binds for gtk3 over to crystal, but ruby seems to have a lib named pathname that the compiler doesn't recognize.
<_tsound> Does crystal not have a pathname class, or am I not calling it correctly?
<FromGitter> <faustinoaq> I don't know but you can found something about GTK & Crystal here 👉 https://github.com/jhass/crystal-gobject
<FromGitter> <faustinoaq> I did a quick search and found nothing related to Pathname in Crystal
<_tsound> that lib seems excessive
<_tsound> I think i gotta use File instead
Liosha has joined #crystal-lang
Liosha has left #crystal-lang [#crystal-lang]
rohitpaulk has joined #crystal-lang
xiljin has quit [Ping timeout: 260 seconds]
xiljin has joined #crystal-lang
pabs has joined #crystal-lang
tzekid has quit [Quit: Leaving]
hightower3 has quit [Ping timeout: 260 seconds]