ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Crystal 0.22.0 | Fund Crystal's development: | Paste > 3 lines of text to | GH: | Docs: | API: | Logs:
<Disrecollection> If a method expects to be invoked with a block does that mean I need to do the "do method_name /n somecode /n end" ?
Kug3lis is now known as Kug3lis_off
<FromGitter> <johnjansen> or `{ code }`
Kug3lis_off is now known as Kug3lis
<Disrecollection> got it. Thanks.
<FromGitter> <faultyserver> also, the `do` syntax is more like `method_name do ... end`
<FromGitter> <johnjansen> nice spotting @faultyserver …
<Disrecollection> Oh, alright On another note, I just tried to run a really simple thing on the command line and it's giving back this huge error about missing -lxml2 ?
Kug3lis is now known as Kug3lis_off
<FromGitter> <faultyserver> probably crystagiri depends on a specific version
<FromGitter> <faultyserver> should be able to just `brew install libxml2` or `sudo apt-get install libxml2`
<Disrecollection> I'll try that. This error has been driving me insane.
<Disrecollection> Yeah it appears to be something with Crystagiri, seeing as some other simple scripts are compiling just fine.
<FromGitter> <faultyserver> I've never been a fan of the *giri family of libraries for exactly that reason
<Disrecollection> Well darn. This was supposed to be sort of my "getting into crystal" project, and I learned a bit, but I'm not sure where to go from here.
<Disrecollection> I guess I'm gonna go run through excercism? Apparently it has some code challenges.
<FromGitter> <faultyserver> is where I like to go when starting with a new language
<FromGitter> <faultyserver> it's more logic focused than anything else, so after you've done it once, it's less of "how do I solve this problem" kind of thing, and more of a "how can this language best express the solution"
Disrecollection has quit [Quit: Leaving.]
<FromGitter> <fridgerator> if anyone is interested, @elorest will be presenting Amber at a ruby meetup, live here in a few minutes:
Disrecollection has joined #crystal-lang
<FromGitter> <bigtunacan> @Disrecollection have you looked at meta scraper as an alternative?
<FromGitter> <bigtunacan>
<Disrecollection> I'll take a look.
<Disrecollection> Yeah, that could definitly work. I'll note it as a possibility, and once I hit up that project again in a bit we'll see if it goes.
Disrecollection has quit [Quit: Leaving.]
Disrecollection has joined #crystal-lang
<Disrecollection> I want to compare 2 strings with each other and count the differences. In C, I know how to do it because strings are just an array of characters which I can iterate through as normal. I wonder what the Crystal solution might be. Is there a standard method to convert a string to an array of characters(and one to determine the length of an array?)
<FromGitter> <johnjansen> you need levenstein i assume
<FromGitter> <johnjansen> look at the `String` class
<FromGitter> <johnjansen> it has its own class
<Disrecollection> Oh yes this looks like it will fit perfectly. Thank you.
<FromGitter> <johnjansen> no problem … FYI its available in most languages … you can also take a look at (not for Levenshtein - although its there) but there are other `text` features you might want
<FromGitter> <johnjansen> like WhiteSimilarity
<Disrecollection> So I'm looking at the string class, and it says some methods are instance, but it has those as using a # when I thought # was for comments? do I still use those methods by appending . to the end of an obj, or am I confused/missed something?
<FromGitter> <johnjansen> any of those can be called as `”mystring”.blank?` or `”mystring”.at(1)` etc
<Disrecollection> Alright. And is 0 not falesy in crystal?
<FromGitter> <johnjansen> that does a better job of explaining it than i would have ;-)
<Disrecollection> Thanks again for all the help.
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
livcd has quit [Ping timeout: 245 seconds]
livcd has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Philpax_ has joined #crystal-lang
<Disrecollection> Yeah so I got back on the project with metascraper(Ikeep thinking metasploit) and gave it a whirl. Installed the deps, etc. But when I try to run crystal it still has the "can't find -lxml2" even though that appears to be installed all good.
<Disrecollection> Running xubuntu 16.04
<Disrecollection> Uninstalled Crystal w/ autoremove, ran sudo apt-get install libxml2-dev and things seem to be working now.
greengriminal has joined #crystal-lang
rohitpaulk has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
<Disrecollection> What does it mean when something in Crystal is in ||? |example|
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
yogg-saron has joined #crystal-lang
<Disrecollection> In a block, at the start, is it some sort of local var or something?
<Disrecollection> When you use {|example| puts example}?
<Disrecollection> So it's some form of local variable that gets assigned a value based on the argument from the yield...?
Disrecollection has quit [Quit: Leaving.]
<FromGitter> <bararchy> local var created in block scope
<FromGitter> <bararchy> [1,2,3].each do |num| ; puts num; end ⏎ Will produce "1" "2" "3"
<FromGitter> <overnet> Hi all. What is the regex engine that crystal lang uses? and is possible add to the Crystal the same regex engine as Ruby uses or Golang? As a current crystals regex engine has limitations in the max regex length. Golang and Ruby do not have this limitation and this is one of the reasons that stopped us from using crystal and we had to choose Golang. ⏎ Thanks!
<FromGitter> <bararchy> @overnet It seems that Crystal uses PCRE underneth
<FromGitter> <bararchy> ```code paste, see link``` []
Kug3lis_off is now known as Kug3lis
<FromGitter> <overnet> Is it possible to change this regex engine?
<FromGitter> <bararchy> Not that I'm aware of, but PCRE is one of the most known engines, if you can find the issue of "limited string" or W\E you're seeing, we can maybe trace that back to a solution :) ⏎ ⏎ Like, if we find that PCRE can have some argument like `limit PCRE::UNLIMITED_STRING` etc ... in the C code
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
<FromGitter> <overnet> For example in Golang you can easily use regex with 1 00 000 characters long and over, In Crystal regex with even 20 000 characters long fails to work, can you extend this limit please?
Kug3lis is now known as Kug3lis_off
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter> <bararchy> When you say "fail" what does it do ?
<FromGitter> <bararchy> @overnet Seems like it's working for me ⏎
<FromGitter> <bararchy> it's 60000 chars long
<FromGitter> <bararchy> Oh, ok
<FromGitter> <bararchy> I saw what you mean
<FromGitter> <bararchy> @overnet Found an answer here -->
<FromGitter> <bararchy> if you re-compile PCRE in your ENV to use more bytes for offset, you wont see this issue
<FromGitter> <Val> Why do *crystal* *release* container is still based on Ubuntu 14.04 LTS (see: ), is there a plan to upgrade to Ubuntu 16.04 LTS (Xenial) or better a smaller base like Debian stable ?
<FromGitter> <bararchy> @Val Does it really matters ? as in , if it's in a container , why do we care what OS it is ?
<FromGitter> <Val> The size matter you know
<FromGitter> <Val> The freshness too
<FromGitter> <Val> I don't care about the distrib (Ubuntu/Debian/CentOS/etc.) but a recent one is better for available libraries
rohitpaulk has quit [Ping timeout: 255 seconds]
<FromGitter> <overnet> @bararchy thank you for the link but is it posible to fix it on the language level as a permanent fix? I did not get what exactly I have to do. Can I open it as a new issue on the crystal github repo, as this work out of the box on Golang?
<FromGitter> <Val> @bararchy what do you think about a simple upgrade to 16.04, not a distribution change ?
<FromGitter> <akzhan> What do you think about replacing of PCRE with RE2 engine?
<FromGitter> <bararchy> @overnet ⏎ ⏎ 1) You can open an issue requesting that Crystal will change it's Regex engine to X , where X should be made in Crystal or use a different C engine in binding. ⏎ 2) You can re-compile libpcre with the flag in the link which will make it work as you want with Crystal. ⏎ ... []
<FromGitter> <bararchy> @Val I'm not against, was just asking :) ⏎ moving to a new set of libs will make things work better I guess, as long as it's inside a docker it's really not that big of a deal , you can open an issue regarding that
<FromGitter> <bararchy> @akzhan RE2 is in C++, does that matters binding wise ?
<FromGitter> <bararchy> I see that even Ruby has a gem for it
<FromGitter> <bararchy> looks interesting
<FromGitter> <Val> @bararchy Ok =)
<FromGitter> <bararchy> @overnet Found something --> Try this:
<FromGitter> <akzhan> @bararchy pcre and re2 api’s very similar, but re2 doesn’t support back references (affair). it’s faster that’s very appropriated for routers for example.
<FromGitter> <bararchy> I guess adding it as a shard makes sense then
<FromGitter> <bararchy> :)
<FromGitter> <akzhan> Some doc -
<FromGitter> <bararchy> cool
yogg-saron has quit [Read error: Connection reset by peer]
mark_66 has joined #crystal-lang
<FromGitter> <overnet> @bararchy how can I do this =>"You can re-compile libpcre with the flag in the link which will make it work as you want with Crystal" across multiple servers multiple ENV and OSs? I do not think that this is correct solution, I do not need to do all this with Golang
<FromGitter> <akzhan> @bararchy thanks foe the link. just found @ziprandom article - it’s useful for me (JIT etc.).
<FromGitter> <bararchy> @overnet I linked you above a new Regex engine I found in shards, maybe try it instead ?
<FromGitter> <akzhan> As I seen crystal-dfa need more development.
rohitpaulk has joined #crystal-lang
<FromGitter> <akzhan> It supports basics only
<FromGitter> <bararchy> Maybe it's enoguh for @overnet usecase ? we can only Hope :) ⏎ and strt binding the R2 lib
<FromGitter> <overnet> @bararchy thank you for the link, does not work for me, it is very limited.
<FromGitter> <overnet> I need full regex support
<FromGitter> <bararchy> Then I guess using R2 is the best solution , @akzhan is that something you are doing ? Or just suggested ?
<FromGitter> <overnet> @bararchy Sorry but I did not get this, how can I use R2 in Crystal ?
<FromGitter> <overnet> @bararchy Sorry but I did not get this, how can I use R2 in Crystal?
<FromGitter> <akzhan> just suggested for now. have no time yet.
<FromGitter> <akzhan> Weekend will commit, later try to look at RE2. Thanks for the point to crystal-dfa, it’s great point to setup adapter.
<FromGitter> <akzhan> it allows to use /regexp/ syntax with simple move.
hightower2 has joined #crystal-lang
<hightower2> Hey folks!
<FromGitter> <sdogruyol> hey
<FromGitter> <bararchy> @overnet You can't right now, we need to implament that by Shard or addpter via STD( less likely) , right now it seems @akzhan is interested in adding R2 as a Shard, so ... for now just wait , or create it your self I guess
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <overnet> @bararchy Ok, thank you.
<FromGitter> <straight-shoota> I don't suppose RE2 would get into stlib. While being faster than PCRE it does not support backreferences, lookahead/-behind and recursion. PCRE is a general purpose engine and RE2 is only suitable for tasks where you don't need these specific features and it would probably only be worth if regular expressions are heavily used.
<FromGitter> <bew> is it wanted behaviour that a module must be declared before inclusion? I thought it could be defined anywhere:
<FromGitter> <straight-shoota> It's the same with parent classes:
<crystal-gh> [crystal] asterite closed pull request #4474: Add TypeNode#has_method? (master...fix-4472)
<FromGitter> <bew> hum, will put it above then
rohitpaulk has joined #crystal-lang
<travis-ci> crystal-lang/crystal#c84af5d (master - Add specs for TypeNode#has_method?): The build passed.
sz0 has joined #crystal-lang
Kug3lis has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
greengriminal has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
p0p0pr37 has quit [Ping timeout: 246 seconds]
p0p0pr37_ is now known as p0p0pr37
splitty_ has joined #crystal-lang
snsei has joined #crystal-lang
<crystal-gh> [crystal] denysvitali closed pull request #3967: Add support for SHA512 (master...master)
rohitpaulk has quit [Ping timeout: 255 seconds]
rohitpaulk has joined #crystal-lang
Kug3lis has quit [Ping timeout: 246 seconds]
LastWhisper____ has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
Kug3lis_off is now known as Kug3lis
Kug3lis has quit [Quit: Textual IRC Client:]
rohitpaulk has joined #crystal-lang
<crystal-gh> [crystal] Val opened pull request #4531: [release container] update ubuntu LTS to latest (master...update_release_container_to_latest_ubuntu_lts)
lacour has joined #crystal-lang
mark_66 has quit [Quit: Leaving.]
mark_66 has joined #crystal-lang
wuehlmaus has quit [Quit: Lost terminal]
<FromGitter> <codenoid> heyoo sir, what function for doing BCRYPT hash and, BCRYPT verify ? , thanks
<FromGitter> <codenoid> i'll try sir,
mark_66 has quit [Remote host closed the connection]
<FromGitter> <codenoid> can u give me example implementation sir ? i'm confused about bcrypt function name
<FromGitter> <fridgerator> `encrypted_password = Crypto::Bcrypt::Password.create(some_password).to_s` and ` == some_password`
<FromGitter> <codenoid> ` Error in src/ undefined constant Crypto::Bcrypt::Password ` ⏎ require something ?
<FromGitter> <fridgerator> `require "crypto/bcrypt/password"`
<FromGitter> <codenoid> ah wrong, i just write require "crypto", thanks sir @fridgerator
<FromGitter> <fridgerator> :thumbsup:
snsei has quit [Remote host closed the connection]
rohitpaulk has quit [Ping timeout: 268 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <codenoid> ` db.exec "insert into contacts values (?, ?)", "John", 30 ` ⏎ `Error in src/ instantiating 'DB::Database#exec(String, String, String, String, String, String)' ⏎ ⏎ ```code paste, see link``` ⏎ ... []
rohitpaulk has joined #crystal-lang
<FromGitter> <codenoid> stuck for 1 hours, :/ ⏎ ` Error in src/ instantiating 'DB::Database#exec(String, String, String, String, String, String)' `
<FromGitter> <codenoid> ===22 :(===
<FromGitter> <codenoid> ===74 :|===
<FromGitter> <codenoid> ` The following packages will be upgraded: ⏎ crystal ⏎ 1 upgraded, 0 newly installed, 0 to remove and 117 not upgraded. ⏎ Need to get 18,9 MB of archives. ` []
<FromGitter> <codenoid> really ?, and its work :/
<FromGitter> <bew> what's the full error?
<FromGitter> <codenoid> nope, my crystal just need update (from 2.1 to 2.2)
<FromGitter> <codenoid> and then ` 2017-06-09 00:18:11 +0700 200 POST /register 2450.59ms ` ⏎ ** 2450.59ms ** :worried:
<FromGitter> <bew> from 0.21 to 0.22 you mean
<FromGitter> <codenoid> yup
<FromGitter> <codenoid> i'll try with --release
<FromGitter> <codenoid> ` 2017-06-09 00:27:15 +0700 200 POST /register 347.22ms `
<FromGitter> <bew> nice perf gain
Kug3lis has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
<FromGitter> <codenoid> oh my gosh, why ? ⏎ ` 2017-06-09 02:09:44 +0700 200 POST /login 5993.49ms ` ⏎ env param body process, db process, bcrypt verify process
<FromGitter> <eliasjpr> @codenoid reduce the cost variable `password = Crypto::Bcrypt::Password.create("super secret", cost: 10)`
<FromGitter> <straight-shoota> Are you doing database queries or other external connections?
<FromGitter> <codenoid> ok, i'll try it, just query_one
<FromGitter> <straight-shoota> You can use `Benchmark` to investigate what takes so long.
Kug3lis_ has joined #crystal-lang
<FromGitter> <codenoid> ok,, ⏎ --release ` 2017-06-09 02:14:20 +0700 200 POST /login 768.09ms `
Kug3lis_ has quit [Read error: Connection reset by peer]
<FromGitter> <eliasjpr> You can also reduce the cost of bcrypt I believe 5 passes is more than enough for passwords
Kug3lis_ has joined #crystal-lang
<FromGitter> <eliasjpr> unless you are happy with 768.09ms
<FromGitter> <codenoid> god bless me, cos : 6, without --release ⏎ ` 2017-06-09 02:19:25 +0700 200 POST /login 125.22ms `
<FromGitter> <eliasjpr> :+1:
Kug3lis is now known as Kug3lis_off
sauer2 has joined #crystal-lang
<FromGitter> <codenoid> :thumbsup:
<FromGitter> <straight-shoota> For production, I would strongly recommend using a higher cost. Cost 6 takes just a few milliseconds on a halfway decent CPU.
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <eliasjpr> also consider the cost to be higher if is a public facing vs private, # of users
<FromGitter> <straight-shoota> Current default is 10 which should be suitable for most cases. Better make it bigger if performance is available. The complexity and time consumption make these hashes secure.
<FromGitter> <straight-shoota> You just need to calculate it once in a while to login your user.
<FromGitter> <codenoid> "performance is available" how we know is performance is avaible ?
<FromGitter> <codenoid> ok, then i need some sleep, thanks ^_^
<sauer2> Hi, a question regarding nil? : How comes I still sometimes have to cast a Mytype | Nil manually to Mytype, despite checking for myvar.nil? ?
<FromGitter> <eliasjpr> that means the var can be nil at a give point in time
<FromGitter> <eliasjpr> if you guarantee the var is never nil then no need to cast
<sauer2> Well, I guarantee that with unless myvar.nil?, don't I?
<jhass> myvar is likely a method call, instance variable, class variable or closured variable
<FromGitter> <bew> you should use `if myvar` instead imo
<sauer2> why doesn't it work for class variables?
<jhass> because another thread might change it between your check and next read
<FromGitter> <eliasjpr> Do you always initialize the class variable?
<sauer2> yes
Kug3lis_ has quit [Read error: Connection reset by peer]
<FromGitter> <eliasjpr> you should post an example it will help to understand what you are doing
Kug3lis has joined #crystal-lang
<sauer2> ok
<sauer2> module Lox class Environment def initialize(enclosing : Environment | Nil) @enclosing = enclosing @values = {} of String => Type end def initialize() initialize(nil) end def get(name : Token) value = @values.fetch(name.lexeme, nil) unless value.nil? return value end unless @enclosing.nil? return end raise, "Undefined vari
<jhass> ?gist
<FromGitter> <bew> ?
<jhass> duh
<sauer2> in line 20
<FromGitter> <eliasjpr> ```def initialize() ⏎ initialize(nil) ⏎ end``` ⏎ ⏎ why?? []
<FromGitter> <eliasjpr> @bew crack your fingers :smile:
<FromGitter> <bew> ?
<FromGitter> <eliasjpr> nvm, Im going for coffee falling asleep here
<sauer2> I'm not sure what the default argument syntax is. @eliasjpr
<FromGitter> <eliasjpr> ```code paste, see link``` []
<sauer2> perfect, thank you. anyway, if I can just type if myvar, why would there be myvar.nil?
<FromGitter> <bew> sauer2 you can write it like this:
<sauer2> Yeah, but technically, why .nil?
<jhass> in some compound expressions its nicer to read, say if var.nil? || var.empty?
<FromGitter> <eliasjpr> becuase it seems that the arg is optional
<FromGitter> <eliasjpr> in some cases
<FromGitter> <eliasjpr> and the way you are defining the variable
DeBot has joined #crystal-lang
<FromGitter> <bew> Also, `unless` doesn't restrict the types :/
<FromGitter> <bew> Idk why
<jhass> it does
<sauer2> So, now the important part: According to what jhass said, objects can be accessed from any thread?
<jhass> iirc in crystal it's even just a ast level rewrite to if !
<sauer2> As in, the compiler never knows that they don't?
<FromGitter> <bew> not in my tests:
<jhass> crystal doesn't attempt any data flow analysis (yet), yeah
<sauer2> ok, that solves the mystery, thanks.
<sauer2> bb
<jhass> bew: seems like a bug
sauer2 has quit [Quit: Page closed]
<FromGitter> <bew> I think the type notation is broken somewhere...
<jhass> ah maybe it's just ignored :P
riddley has joined #crystal-lang
<FromGitter> <bew> Oo why
<riddley> Hi, does Crystal have a shard (or whatever) that is roughly equivalent to Ruby's Gem::Package::TarReader ?
<FromGitter> <bew> it seems not:
<riddley> I did some searching and saw someone asterite mentioning a lib that supports tar/ustar/etc
<riddley> but I couldn't figure out what they were talking about
Philpax__ has joined #crystal-lang
<jhass> can't find anything either, but a libarchive binding shouldn't be too hard to make :)
* riddley goes off to look up libarchive
<riddley> thanks for the pointer
greengriminal has joined #crystal-lang
Philpax_ has quit [Ping timeout: 240 seconds]
<riddley> how are shards distributed?
<FromGitter> <luislavena> @riddley, @jhass:
<FromGitter> <luislavena> It was a branch on crystal repo.
<jhass> riddley: you just create a git repo somewhere, preferably github
<FromGitter> <luislavena> shards are decentralized, use git (github, gitlab, bitbucket) as distribution mechanism
<riddley> any idea if that branch will ever see daylight?
<riddley> thanks very much to that pointer
<FromGitter> <luislavena> Not sure, but perhaps is worth taking that code, creating a real life shard with it, get more eyes into it and perhaps can be moved into stdlib.
<FromGitter> <luislavena> I think there is some minor touches to IO in there to make it work, but can't remember the details.
<FromGitter> <asterite> We can probably merge it. It's missing support for some tar formats (there are *many* formats). We could maybe mark it as "incomplete" or "unstable" until we finish working on it, but at least tars created by crystal will be able to be read by crystal
<FromGitter> <bew> jhass: indeed, the type in `a : Int32|Nil = 1` is simply ignored
<FromGitter> <luislavena> @asterite what about making that a separate shard instead? that will allow more free exploration and faster contribution/release cycles
<FromGitter> <straight-shoota> @bew ` | Nil)` works:
<FromGitter> <asterite> @luislavena It's probably a good idea. If anyone wants to create a shard from that branch and continue working on it, please go ahead :-). Eventually we can merge that shard into the std if we find it convenient
<FromGitter> <bew> yes, in fact, everything is working well :D
<FromGitter> <luislavena> @asterite there was some IO additions in it, let me pull the change, not sure about that.
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
<hightower2> Why can't I call Crystal::Macros.compare_versions()? It tells me undefined constant Crystal::Macros
<hightower2> I see {{ ... }} are required. What do they mean?
Kug3lis_off has quit [Read error: Connection reset by peer]
<FromGitter> <luislavena> @hightower2: `compare_versions` is a macro that needs to be called in the macro context. Is used during compilation time.
<hightower2> Oh {{ }} is the stuff to be evaluated at compile-time?
<FromGitter> <luislavena> You can learn more about macros in the documentation:
<FromGitter> <luislavena> Correct, code within `{{ }}` is evaluated at compile time, if you need to compare versions at runtime, you can use SemanticVersion from the stdlib
Disrecollection has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 4 new commits to master:
<crystal-gh> crystal/master faf2a54 Ary Borenszweig: Compiler: error if passing void lib fun call to call, or to assignment. Related to #4414
<crystal-gh> crystal/master 47a4289 Ary Borenszweig: Fixed #4414: ICE when passing nil through a varargs C call
<crystal-gh> crystal/master 32d3d8e Ary Borenszweig: Fixed #4353: responds_to? doesn't work for generic type metaclass
greengriminal has quit [Quit: This computer has gone to sleep]
<hightower2> I see I can't create symbols in runtime. Does this essentially mean that I can't turn strings received via the network to Symbol objects? Or?
greengriminal has joined #crystal-lang
greengriminal has quit [Client Quit]
greengriminal has joined #crystal-lang
pduncan has quit [Ping timeout: 260 seconds]
<FromGitter> <bew> yes
<crystal-gh> [crystal] asterite closed pull request #4216: Separation of constructor methods in docs (
greengriminal has quit [Quit: This computer has gone to sleep]
vikaton has joined #crystal-lang
<FromGitter> <danielwestendorf> Is there a HTTP recording/replaying shard for Crystal? Similar to If not, what are people using to stub out HTTP requests?
<hightower2> What's the recommended way to slurp a file? E.g. if I want to pass file contents to INI.parse()?
<FromGitter> <bew> I think it's `content ="some/path")`
<hightower2> Oh, missed it in the API listing, thanks
<Disrecollection> I'm trying to create a file and then write either text or a jpg to it, File.write takes a slice, which is of type Bytes? Which is an alias for something? How do I convert .jpg and strings to Bytes?
<Disrecollection> Slice is some form of safe pointer..?
<FromGitter> <bew> yes, it's a pointer with a size
<Disrecollection> Okay, so I need to go read up on how Crystal handles pointers. i feel like there is a better way to create and write to files...
greengriminal has joined #crystal-lang
<FromGitter> <bew> to get a `Bytes` from a string, there is `String#to_slice`
greengriminal has quit [Remote host closed the connection]
<FromGitter> <bew> and yes, `Bytes` is an alias to `Slice(UInt8)`
<Disrecollection> I totally missed the String method. Thanks! But I'm probably going to have to implement my own method for the .jpg images anyway.
<FromGitter> <danielwestendorf> I found, I'll just use that since it has a stubbing middleware
lhz has quit [Ping timeout: 260 seconds]
lhz has joined #crystal-lang
<hightower2> How do I create a Hash of Symbol keys and arbitrary values?
<hightower2> I tried x = {} of Symbol=> Value , but get: can't use Value as generic type argument yet, use a more specific type
<travis-ci> crystal-lang/crystal#321419b (master - Fixed #4379: segfault in Array#sort with incorrect block value): The build was broken.
<DeBot> (Segfault when trying to sort by unicode characters)
<FromGitter> <straight-shoota> You have to create a union of all possible types
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<hightower2> straight-shoota: Some example? I have trouble coming up with the syntax
<Disrecollection> I think an example of a union would be String | Nil ??Don't quote me on that though?
<FromGitter> <bew> you might want to look at how JSON does: then you just need to create a `{} of Symbol => Type` or something like that
<hightower2> Indeed, thanks. I used ret= {} of Symbol=> Bool | Int64 | String
<hightower2> My next problem is that I want to provide a basic, interactive REPL as part of my app. (Like, the app runs, and opens an interactive shell which is aware of the modules/classes/etc in the current process)
<hightower2> I tried installing Icr and calling
<hightower2> This gives me the REPL, but it is unaware of the program's state - I don't see modules/classes in it which do exist in the process
<hightower2> Any hints about that? (I'm not using Icr for any particular reason - just thought it'd work, which may not be true)
<FromGitter> <bew> the running process is compiled, you have no access to crystal's modules/classes/etc..
<FromGitter> <bew> tl;dr you can't do what you want here
<FromGitter> <bew> why do you want/need this?
<hightower2> I do this often in Ruby - instead of putting the main thread to sleep, I run interactive IRB session in it, and the user can use it to access the live, running process' state
<hightower2> for whatever - introspection, stats, changing the values etc.
<Papierkorb> Not possible in Crystal in the same sense as Ruby allows to
<FromGitter> <bew> yeah, but ruby is interpreted, crystal is compiled, this is not the same flexibility at run time (and crystal waaay much faster than ruby because of that)
<hightower2> Right, sure
<hightower2> Ok, thanks
<Disrecollection> Is there a quick way to join multiple strings together?
<FromGitter> <bew> there is `{"a", "b", "c"}.join`
<hightower2> Disrecollection, in addition to "a" + "b" ?
<Disrecollection> Awesome, thanks.
<travis-ci> crystal-lang/crystal#293d06f (master - Provide return type annotations for more factory methods): The build was broken.
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Disrecollection> So I'm writing text to files pretty perfectly now, but I'm unsure how to write .jpg to files. I'm able to grab the Bytes, and place them in a new file, but it's not encoded correctly. I notice there is an encoding parameter for File.write, and I'm wondering if that's the key.
<Disrecollection> I tried taking a look at Encoding in the API, but it didn't seem helpful
<Papierkorb> Disrecollection: How are you writing the Bytes?
<Disrecollection> .to_slice ?
<Papierkorb> ...?
<Disrecollection> One sec.
<Disrecollection> I open an instance of the File class with .open("name","w") then I use the .write method(thinkIwant.to_slice)
<Papierkorb> That's correct. The #to_slice call is a noop though.
<FromGitter> <bew> what is the type of `thingIwant` ?
<Disrecollection> noop?
<Papierkorb> no-op
<Disrecollection> ?
<Papierkorb> no-operation. Doesn't do anything.
<Papierkorb> (in this case)
<Disrecollection> Think I found an error. I believe I'm writing the URL loc of the image instead of the image itself. Duh. I'm gonna go fix that, see if it was the problem.
<FromGitter> <bew> how do you get the jpg content to write?
<Disrecollection> It uh, seem I don't know. I can access an XML node which is just the <img src = "url"></> but I don't know how to access that url or get the bytes of the .jpg to copy over via File.write.
<crystal-gh> [crystal] asterite pushed 1 new commit to master:
<crystal-gh> crystal/master 54415ff Ary Borenszweig: Fixed codegen for x86