RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.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
ylluminate has joined #crystal-lang
<FromGitter> <whitenoiseoss> hey guys I've just started looking at Crystal and I had a question around the C bindings.
<FromGitter> <whitenoiseoss> how would you accomplish something like this in Crystal? https://www.opsdash.com/blog/postgresql-triggers-golang.html
<FromGitter> <whitenoiseoss> specifically how do you do the #include and such that you can put in /* CGO */ in Go?
<FromGitter> <whitenoiseoss> is there a @[Link(include: "") or something?
<FromGitter> <whitenoiseoss> or @[Link(define: "")
<FromGitter> <Blacksmoke16> can prob start off with reading the docs? https://crystal-lang.org/reference/syntax_and_semantics/c_bindings/lib.html
<FromGitter> <Blacksmoke16> i dont know too much about c bindings tho :/
<FromGitter> <whitenoiseoss> I have read through those
<FromGitter> <Blacksmoke16> ah, fair enough
<FromGitter> <whitenoiseoss> the docs in this area seem a bit sparse, but it could also be it's a new area for me. I have only done FFI a few tiems
<FromGitter> <whitenoiseoss> I may have found some insight
<FromGitter> <whitenoiseoss> seems that @[Link("SDL")] is the same as #include <SDL.h> and setting the constants seems consistent with doing a #define
<FromGitter> <Blacksmoke16> nice oen!
<FromGitter> <Blacksmoke16> one*
_whitelogger has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> is there any way to define a macro-scoped variable besides defining a constant? I tried `{% varname = value %}` and that didn't work...
<FromGitter> <Blacksmoke16> yes but use `{% begin %} xxx {% end %}`
<FromGitter> <dscottboggs_gitlab> hm, ok
<FromGitter> <Blacksmoke16> i mean like wrap all your macro stuff in that
<FromGitter> <Blacksmoke16> and should allow for that
<FromGitter> <dscottboggs_gitlab> doesn't appear to work like that https://carc.in/#/r/6d16
<FromGitter> <Blacksmoke16> is for macro vars
<FromGitter> <Blacksmoke16> https://carc.in/#/r/6d19
<FromGitter> <dscottboggs_gitlab> OH I see thank you
<FromGitter> <Blacksmoke16> np
<FromGitter> <whitenoiseoss> ah
<FromGitter> <whitenoiseoss> the {% %} is for doing "outside" stuff in a macro
RX14 has quit [Quit: Fuck this shit, I'm out!]
Vexatos has quit [Quit: ZNC Quit]
<FromGitter> <whitenoiseoss> i was curious about that. i am keeping your validation code
<FromGitter> <whitenoiseoss> i'm sure that will come in useful
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/CrSerializer is also that, might be helpful :)
<FromGitter> <whitenoiseoss> Make working with JSON APIs in Crystal much easier <- yis
<FromGitter> <Blacksmoke16> also built a web framework around it, works pretty good, although is a bit young
RX14 has joined #crystal-lang
Vexatos has joined #crystal-lang
<FromGitter> <whitenoiseoss> athena?
<FromGitter> <Blacksmoke16> yea
<FromGitter> <whitenoiseoss> everything Crystal-related is "a bit young" :P
<FromGitter> <Blacksmoke16> compared to kemal or amber i mean :p
<FromGitter> <whitenoiseoss> I just got a new job at a Ruby shop as an engineer, and they are running Crystal in production for some analytics (because it's quick enough to do their analytics but is also very similar to Ruby)
<FromGitter> <whitenoiseoss> and so uh
<FromGitter> <whitenoiseoss> I'm a bit concerned about the maturity level of Crystal in that regard, I think there's going to be a lot of pioneering I have to do to build out all of the stuff they need.
<FromGitter> <whitenoiseoss> but it's an interesting language
<FromGitter> <Blacksmoke16> indeed
<FromGitter> <Blacksmoke16> have a bog post on athena nearly ready, just waiting on some PRs to get merged to provide issue-less experience
<FromGitter> <Blacksmoke16> is pretty slick i must say :P
<FromGitter> <whitenoiseoss> i am sure you are an unbiased reviewer
<FromGitter> <whitenoiseoss> but, it's worth a shot. i like having a rest api handy in any language i deal with
<FromGitter> <Blacksmoke16> sec
f1refly has quit [Ping timeout: 264 seconds]
f1refly has joined #crystal-lang
<FromGitter> <weirdbricks> hello folks, I'm having trouble with getting the inode of a file on Linux. I'm using Crystal 0.27.2 - I'm trying something like: `puts File.info(filename)` and I see this in the results: `@st_ino=3157687_u64`, however there seems to be no way to actually get that value. What's the easiest way to get the inode of a file in Crystal ?
_whitelogger has joined #crystal-lang
laaron has joined #crystal-lang
mps has quit [Ping timeout: 250 seconds]
<FromGitter> <mavu> @weirdbricks You could use LibC.stat, and use the systemcall directly, that should be possible. ⏎ or you maybe you can monkeypatch File and add a getter for the @st_ino
<FromGitter> <mavu> No idea if there is a better way, i'm new here :)
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<livcd> In regards to Ruby and Crystal RM is going to get open sourced and ported to all platforms
<livcd> wonder what happens then
<FromGitter> <iambudi> Since crystal has the same concurrency in go, so the statement in Honourable Mentions also apply to crystal?
<FromGitter> <mavu> @livcd "In regards to Ruby and Crystal RM is going to get open sourced" ⏎ I don't understand what you mean, could you elaborate?
<livcd> RubyMotion
<livcd> It's a dialec of Ruby that uses LLVM and compiles to machine code with a custom ARC GGC. Was used till now only for mobile apps on iOS/Android
<livcd> also was proprietary with a steep license costs
<FromGitter> <mavu> ohhh that. nice.
ashirase has quit [Ping timeout: 245 seconds]
ashirase has joined #crystal-lang
<FromGitter> <j8r> is there a `String` method to take a part of a string until a character/string is fund?
<FromGitter> <j8r> a bit like `String#split(string_or_char, limit: 2)[0]` without creating an intermediary Array
<FromGitter> <Prutheus> How to pass nil as pointer to a function like in C the null pointer?
<FromGitter> <asterite> just pass nil
<FromGitter> <asterite> or a null pointer
marmotini_ has joined #crystal-lang
<FromGitter> <vladfaust> RFC https://github.com/onyxframework/sql/issues/71, really interesting issue
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 244 seconds]
<FromGitter> <yxhuvud> @j8r Don't #split have a block version that does what you want?
<FromGitter> <j8r> @yxhuvud right. I can then return on the first block invocation, thx
mps has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <drum445> I'm connecting to MySQL via: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ If MySQL is restarted on the server Crystal will return 500s like it can't reconnect. Does anyone know how to make crystal reconnect to mysql if the connection drops for a short while? [https://gitter.im/crystal-lang/crystal?at=5c73f0941f146304211a6ea2]
<FromGitter> <drum445> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c73f15eab952d30858b7a3c]
<FromGitter> <vladfaust> Should use some kind of wrapper
<FromGitter> <drum445> In Ruby's MySQL2 lib, you could pass reconnect: true into the connection
<FromGitter> <drum445> Which would mean it would just reconnect if it went down
<FromGitter> <drum445> How have you implemented a wrapper @vladfaust ?
<FromGitter> <vladfaust> Nope
<FromGitter> <vladfaust> AFAIK crystal-db has a pool
<FromGitter> <vladfaust> It's poorly documented, though
<FromGitter> <vladfaust> `postgres://benchmarkdbuser:benchmarkdbpass@tfb-database:5432/hello_world?initial_pool_size=56&max_pool_size=56&max_idle_pool_size=56`
<FromGitter> <drum445> I think it might be checkout_timeout
<FromGitter> <vladfaust> It's greatly documented then
<FromGitter> <drum445> Do you reckon it's safe to put retry attempts very high ?
<FromGitter> <vladfaust> Um. It depends on the average time your DB restarts in
<FromGitter> <Sija> @livcd IIRC RubyMotion for the time being is still proprietary, where did you get the news about opensourcing it?
<FromGitter> <Sija> Hmm, I guess you refer to https://twitter.com/amirrajan/status/1079422890012000256
lucasb has joined #crystal-lang
<FromGitter> <Sija> there's nuffin' stated verbatim about opensourcing it though, let's w8 and see...
<FromGitter> <j8r> how muffin are related to this @Sija ?
<FromGitter> <Sija> :D
<FromGitter> <Sija> Muffins are as good as opensource, that's for sure
<FromGitter> <Sija> nuffin = non-standard spelling of nothing, representing speech.
<FromGitter> <j8r> isn't nothin, `s/ff/th/` ?
<FromGitter> <j8r> there is no really point of using all of this in text, because `nuffin'` == 7chars and `nothing` == 7chars
<FromGitter> <Sija> :D
<FromGitter> <Sija> it ain't coding my dear ;)
<FromGitter> <j8r> I didn't know `w8`, it saves chars
<FromGitter> <Sija> that's just alternative, non-standard way of sayin' that
<FromGitter> <j8r> writing, you w
<FromGitter> <j8r> mean
<FromGitter> <j8r> but this words are mostly spoken, not real written AFAIK
marmotini_ has quit [Ping timeout: 245 seconds]
<FromGitter> <kinxer> It's a transcription of a way of saying the word we write as "nothing".
<FromGitter> <Sija> @j8r for me "nuffin" sounds funnier than "nothing". and it rhymes with "muffin", yay! ;)
<FromGitter> <kinxer> Since it's primarily a way of communicating the way the word sounds (a job which writing systems grow worse at as time goes on and language changes), it doesn't really need to conform to any writing rules.
<FromGitter> <kinxer> But Sija's most recent description is a more reasonable way of looking at that. :P
<FromGitter> <j8r> don't know... "If u spik lik zis", some can take what you said less seriously
<FromGitter> <j8r> or simply don't understand :)
<FromGitter> <Sija> yeah, well, I'll take my chances, I see nuffin' wrong with a pinch of salt in a good muffin ;)
<FromGitter> <vladfaust> > https://crystal-lang.org/reference/database/connection_pool.html ⏎ ⏎ It's bad design IMO. DATABASE_URL is often set externally (e.g. in Heroku or Dokku), and there is no standard for these pool-related variables in the URL
<FromGitter> <j8r> someone knows what the pros of `db.exec "insert into contacts values (?, ?)", name, num` vs ` db.exec "insert into contacts values (#{name},#{num}?)"`?
<rkeene> Is the second one vulnerable to SQL injection, or does it know to quote it somehow ?
<z64> yes, the former will prevent SQL injection, and DBs can optimize calls to prepared statements
<FromGitter> <j8r> so vs `db.exec "... '#{name}'"`?
<rkeene> What if name === "' -- DELETE FROM foo;" ?
<rkeene> oops
<mps> rkeene: yes, from my experience in other languages second version is risky because of possible SQL injections
<rkeene> What if name === "'; DELETE FROM foo; -- '" ?
rohitpaulk has joined #crystal-lang
<mps> first version should be safe, but I don't know for how it is implemented in crystal
<z64> it isn't implemented in crystal; the database handles it
rohitpaulk has quit [Remote host closed the connection]
<mps> and I will be unpleasantly surprised if it is not safe
<FromGitter> <j8r> snap `wrong number of arguments for 'DB::Database#unprepared' (given 2, expected 0..1)`
<mps> z64: right, I should write 'crystal DB drivers/shards'
<z64> not crystal drivers/shards either.. its part of DB protocol. you send the template query, then the values, and the DB takes care of inserting them safely
<mps> eh, right, but didn't wanted to go so deep. ;)
<mps> j8r: asterite, straight-shoota, we updated Alpine stable and edge libxml2 with patch which fixes derefence bug
<mps> now, crystal build and test passes, right now I'm testing on aarch64 complete rebuild of the 0.27.2
<FromGitter> <j8r> mps you're awesome, thanks :)
sagax has quit [Ping timeout: 245 seconds]
<mps> you are welcome. I don't think I'm it's my credit, we all (mentioned above) worked on it and solved it so credit and thanks belong to anyone who helped with it
<FromGitter> <straight-shoota> 👍
<FromGitter> <j8r> I'm a noob in SQL: is this correct `db.exec "ALTER USER 'root'@'%' IDENTIFIED BY ?", password`?
<FromGitter> <j8r> or `db.exec "GRANT USAGE ON *.* TO ?@? IDENTIFIED BY ?", user, hostname, password`
<FromGitter> <j8r> I don't think I nees this interpolation, i'll just use `#{}`. I already check if there is no space, only ascii letters and numbers before
return0e has quit [Ping timeout: 245 seconds]
return0e has joined #crystal-lang
sagax has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
lucasb has quit [Quit: Connection closed for inactivity]
blassin has quit [Ping timeout: 244 seconds]
blassin has joined #crystal-lang
lucasb has joined #crystal-lang
jemc has joined #crystal-lang
<FromGitter> <bew> Hi RX14 I remember (from one of your live stream) that you have a special workflow around git, using worktrees to have multiple branch checked out at the same time, and wrote some tools around that.. I also use worktrees from times to time but only when needed and was thinking about doing something like you. I was wondering, did you ever do a post on your config? or did you base it on some other example setup I can
<FromGitter> ... read about?
<RX14> not really
<FromGitter> <bew> thx!
<FromGitter> <GaryMiller> Has anyone benchmarked Crystal against Truffle Ruby. I didn't find any comparative benchmarks with Crystal but it looked a lot faster than JRuby and MRI on the ones I found. I was just looking at alternatives until the native Windows version of Crystal becomes available. I know new products tend to leapfrog each other over time in both performance and features but I was just trying to get a feel for the
<FromGitter> ... landscape of competing Rubys out there.
<FromGitter> <j8r> I'll bet it's considerably faster, and use a lot less memory
<FromGitter> <j8r> *not Truffle, Crystal
<FromGitter> <j8r> Interested too for a benchmark
<FromGitter> <j8r> @GaryMiller there is https://github.com/kostya/benchmarks/blob/master/README.md
fullforce has joined #crystal-lang
<fullforce> hi
<fullforce> is thre a way to disable hostname checks for openssl?
<fullforce> s/hostname/certifciate
moei has quit [Quit: Leaving...]
lucasb has quit [Quit: Connection closed for inactivity]
<fullforce> nvm, set the verify_mode for my context to be VerifyMode::NONE
<fullforce> the server doesnt seem to be receiving anything I send using Client.puts though
<fullforce> any idea why?
<rkeene> Maybe you need to flush ?