RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.0 | 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
moei has quit [Quit: Leaving...]
go|dfish has joined #crystal-lang
<FromGitter> <drosehn> *aside:* Gitter will show you the full timestamp. Pick someone's comment in your timeline, and then move your mouse cursor over the `hour:minute` timestamp. It should pop up a little note which tells you the full timestamp of when that comment was made. The note disappears once you move the cursor.
<FromGitter> <anamba> it also says you can do this, which is handy:
<FromGitter> <anamba> ☝️ December 19, 2018 9:42 AM (https://gitter.im/crystal-lang/crystal?at=5c19940dc35a30024747615d)
<FromGitter> <drosehn> Huh! Is that the behavior of alt-click? I never tried that. I assumed alt-click would just copy the text down to the input area.
<FromGitter> <drosehn> ☝️ December 18, 2018 7:51 PM (https://gitter.im/crystal-lang/crystal?at=5c199610dab2222ab3b75a63)
<FromGitter> <drosehn> except that the timestamp that shows is (apparently) in the timezone of the person who did the alt-click 😄
<FromGitter> <dscottboggs_gitlab> yeah, it's still kinda a hack
<FromGitter> <anamba> oh, somehow i thought it might appear differently depending on the viewer's timezone. well then that's not great. but at least you can click it and it highlights
Raimondi has joined #crystal-lang
non-aristotelian has quit [Quit: non-aristotelian]
yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
Raimondi has quit [Ping timeout: 240 seconds]
yxhuvud has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <anamba> @yxhuvud part 2 is... interesting
DTZUZO has quit [Ping timeout: 250 seconds]
rohitpaulk has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
<FromGitter> <proyb6> @anamba Someone outsource that part 2 to Wolframalpha url to get the value, it's also interesting
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <anamba> @proyb6 @yxhuvud 😓 ``` ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5c19f8ec34a2755a1d3407b2]
<FromGitter> <proyb6> Time mean midnight?
<FromGitter> <anamba> time is duration (how long it took me to finish... 35 mins and 2 hr 47 min)
blassin has quit [Read error: Connection reset by peer]
blassin has joined #crystal-lang
ashirase has quit [Ping timeout: 250 seconds]
ashirase has joined #crystal-lang
<FromGitter> <proyb6> I would take days to complete it
rohitpaulk has joined #crystal-lang
<FromGitter> <kinxer> Anybody know why this code produces the error it does? ⏎ https://play.crystal-lang.org/#/r/5tnn
<FromGitter> <j8r> even with `as` https://play.crystal-lang.org/#/r/5tp3
<FromGitter> <j8r> The advice may be to avoid inheritance and generics, I've seen issues on them
<FromGitter> <asterite> Yes, generic inheritance doesn't work well, my advise is to avoid it
<FromGitter> <j8r> If we use abstract + generics + inheritance + macros, I wouldn't be surprised to see strange behaviors 😄
<FromGitter> <kinxer> So it's not clear *why* it produces the error, then. Besides a blanket "hey, don't use generic inheritance".
<FromGitter> <j8r> that's a compiler bug
<FromGitter> <kingsleyh> Crystal is ignoring my LD setting
<FromGitter> <kingsleyh> in my binding I have `@[Link(ldflags: "-L#{__DIR__}/../ext/openssl -lssl")]`
<FromGitter> <kingsleyh> but when I run my file - it looks like Crystal is using the default one
<FromGitter> <kingsleyh> ```Error: execution of command failed with code: 1: `cc "${@}" -o '/Users/kings/.cache/crystal/crystal-run-ecdsa-ecdh-ecies.tmp' -rdynamic -lgmp `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` -lpcre -lgc -lpthread
<FromGitter> ... /usr/local/Cellar/crystal/0.27.0/src/ext/libcrystal.a -levent -liconv -ldl -L/usr/lib -L/usr/local/lib````
<FromGitter> <kingsleyh> oh I know why! It's because I'm doing require "openssl" because I need some of the default stuff too
<FromGitter> <kingsleyh> so openssl is bringing in the default one - and mine is being ignored :(
<FromGitter> <r00ster91> but when you require openssl and then define your binding after it, shouldn't the openssl LD settings be overriden?
<FromGitter> <kingsleyh> I had the require before the require for the bindings - however still not working :(
<FromGitter> <j8r> try to pass as cli flags
<FromGitter> <kingsleyh> @j8r yay! that works by passing it
<FromGitter> <kingsleyh> but it means I can't use the default openssl at the same time
<FromGitter> <kingsleyh> hmm probably I should try to get the latest version of openssl install on my operating system
<FromGitter> <r00ster91> it should probably be made similar to `at_exit` so that you can pass multiple DL settings
<FromGitter> <r00ster91> maybe create an issue?
<FromGitter> <girng> what is a "DL setting"?
<FromGitter> <r00ster91> it's something you pass to the linker like `-llibrary` so that a c library can be found
<FromGitter> <girng> oh, c
<FromGitter> <girng> i like crystal
<FromGitter> <kingsleyh> I don't understand how this openssl brew install on OSX is working though - I just updated to `OpenSSL 1.0.2q 20 Nov 2018`
<FromGitter> <kingsleyh> if I look in `/usr/local/opt/openssl/include` there is an ecdsa.h that contains: `ECDSA_SIG_get0`
<FromGitter> <kingsleyh> but if I run `nm -gU ./libcrypto.dylib | grep ECDSA_SIG` on the dylib in the `/usr/local/Cellar/openssl/1.0.2q/lib` - It does not have it listed
<FromGitter> <kingsleyh> this is pretty confusing
<FromGitter> <girng> damn @kingsleyh you been having problems with ssl this entire week it seems like lol
<FromGitter> <girng> i feel ya though, i've been stuck on some issues for a long time, very annoying. sometimes i stop and work on something else, then come back, and think of it differently and it helps
<FromGitter> <kingsleyh> yeah - I don't understand why brew install gives me 1.0.2q
<FromGitter> <kingsleyh> the Openssl website says: All users of 1.0.2 and 1.1.0 are encouraged to upgrade to 1.1.1 as soon as possible
<FromGitter> <girng> i don't know the mac world, but isthere an alternative to brew?
<FromGitter> <girng> seems like it's the crux of all your issues
<FromGitter> <kingsleyh> woop! fixed it!
<FromGitter> <kingsleyh> I uninstalled 1.0.2 and installed 1.1.1a
<FromGitter> <kingsleyh> as the default one
<FromGitter> <girng> 👍
<FromGitter> <kingsleyh> so this means wherever I need to use this code - needs to have 1.1.1a installed
<FromGitter> <kingsleyh> oprypin thanks for your help - figured out finally!
rohitpaulk has quit [Ping timeout: 250 seconds]
return0e has quit [Ping timeout: 246 seconds]
return0e has joined #crystal-lang
akaiiro has quit [Ping timeout: 245 seconds]
<FromGitter> <greenbigfrog> ```code paste, see link``` ⏎ ⏎ Is there a more efficient way to generate a QR code png that I'm missing? [https://gitter.im/crystal-lang/crystal?at=5c1a952ab6f00a271013b52e]
<FromGitter> <greenbigfrog> (I want to modify the canvas before writing in my actual use)
<FromGitter> <l3kn> @greenbigfrog Do you want each of the squares to be 1x1 pixels in size in the final image?
akaiiro has joined #crystal-lang
<FromGitter> <greenbigfrog> Not really
<FromGitter> <l3kn> You could use the block constructor for `Canvas` and look up the bytes inside `qr.data`, ⏎ I imagine the performance will be the same but the code would be shorter
<FromGitter> <l3kn> `(QRencode::Util.black? qr.data[x + qr.width * y]) ...`
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter> <greenbigfrog> ```code paste, see link``` ⏎ ⏎ Is this what you meant? [https://gitter.im/crystal-lang/crystal?at=5c1aa294b8760c21bbf43076]
<FromGitter> <l3kn> Yes, with an `if` instead of the `next`:
<FromGitter> <greenbigfrog> true
<oprypin> i mean,.. it's still probably gonna work but who writes code like that D:
<FromGitter> <greenbigfrog> Idiots like me apparently 😏
<FromGitter> <greenbigfrog> my mind is playing tricks on me. how would I go about scaling it?
<FromGitter> <l3kn> That's what I meant with 1x1 pixels in the final image,
<FromGitter> <l3kn> just divide `x` and `y` by some factor
<FromGitter> <greenbigfrog> oh. right... thanks
<oprypin> qr.width * z, qr.height * z
<oprypin> `qr.data[x//z + qr.width * y//z]`
<FromGitter> <greenbigfrog> When I said `not really` I refered to `I do not want it to be 1x1`
<FromGitter> <greenbigfrog> *meant
<FromGitter> <greenbigfrog> ```code paste, see link``` ⏎ ⏎ Shouldn't this work? I'm getting a index out of bounds [https://gitter.im/crystal-lang/crystal?at=5c1aa3e2b6f00a27101413ed]
<FromGitter> <l3kn> try `qr.width * (y / scale)`
<FromGitter> <greenbigfrog> that works... but shouldn't `a * b / c` be the same as `a * (b / c)`?
<oprypin> too big of an integer? :o
<oprypin> ah no,this is right
<FromGitter> <l3kn> With integer divisions there should be some cases where the two are different
<oprypin> yes
<FromGitter> <greenbigfrog> oh. right. smh I blended out that we're diving ints
<oprypin> i fooled myself with just tighter spacing
<FromGitter> <greenbigfrog> thanks guys
akaiiro has quit [Ping timeout: 250 seconds]
<FromGitter> <greenbigfrog> my mind is playing tricks again... how would I add some deadspace?
<FromGitter> <l3kn> between the qr code squares or around the qr code?
<FromGitter> <greenbigfrog> around
<FromGitter> <greenbigfrog> ```code paste, see link``` ⏎ ⏎ this was my attempt [https://gitter.im/crystal-lang/crystal?at=5c1aa87cdab2222ab3be18d4]
<oprypin> `x = (x - dead) // scale; y = (y - dead) // scale; if 0 <= x < width && 0 <= y < height; previous code but without division anymore; else; empty pixel?; end`
<oprypin> `qr_size += scale * dead * 2`
<FromGitter> <greenbigfrog> thanks. but sth's wrong... ⏎ the qr code isn't centered in the deadspace. it's only 1 pixel on the left side and top ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c1aac5700ab9f271114f789]
<FromGitter> <l3kn> Can you upload the full code somewhere? Then I can try it out locally
<FromGitter> <greenbigfrog> I think I might be able to figure it out. If not I'll gist it ⏎ ⏎ ```0 <= x < qr.width``` ⏎ ⏎ How does sth like this resolve? [https://gitter.im/crystal-lang/crystal?at=5c1aafa900ab9f2711150d2d]
<woodruffw> oh hey, those are my QR bindings
<woodruffw> neat ;)
<FromGitter> <greenbigfrog> :)
<FromGitter> <greenbigfrog> Probably gonna write a whole QR code generation API on it... All currently available are horribly overpriced (unless you only want stock/basic codes, which only google offers)
<woodruffw> awesome! best of luck :D
<oprypin> greenbigfrog, is `dead = 1` by any chance??
<FromGitter> <greenbigfrog> ```0 <= x && x < qr.width``` ⏎ ⏎ Is this the same as `0 <= x < qr.width`? [https://gitter.im/crystal-lang/crystal?at=5c1ab077f404331419382323]
<FromGitter> <greenbigfrog> doesn't matter what dead
<oprypin> yeah, at least in Python it is
<oprypin> not 100% sure about Crystal
<oprypin> greenbigfrog, nice!
<FromGitter> <greenbigfrog> it's not working btw
<oprypin> yeah but perfect way to share it
<FromGitter> <greenbigfrog> oh. that's what you meant :)
<FromGitter> <l3kn> the problem is that you are scaling `dead` by `scale` when calculating the canvas size
<FromGitter> <l3kn> the top and left paddings (?) are correct and 10px wide
<oprypin> yes
<oprypin> i intentionally made `dead` not tied to scale
<FromGitter> <l3kn> *margins
<oprypin> the only mistake here then is ` + (scale * dead * 2)` should be ` + (dead * 2)`
<FromGitter> <greenbigfrog> oh. right...
<FromGitter> <greenbigfrog> thanks guys
<oprypin> OR go in the other direction and just do `x = x / scale - dead`
<FromGitter> <greenbigfrog> smh I must be sleeping or sth... but I'm failing to make the `size` constant. As in, if I have `size`, the output should always be `300x300`
<FromGitter> <l3kn> By adjusting `dead` for some fixed `scale`?
<FromGitter> <greenbigfrog> wdym?
<FromGitter> <l3kn> `dead = (size - (qr.width * scale)) / 2` + some checks to make sure this way of placement is possible
<FromGitter> <l3kn> this works with the way you are calculating `scale`, too
<oprypin> you know that `dead` is an absolute pixel value. and we're only adding that margin in addition to the original image. so just take the previous code you had and reduce the image size by `dead * 2`
<oprypin> i'd think that people want `size` and `dead` to be both constant
<oprypin> greenbigfrog, *actually* turned out to be complicated. https://bpaste.net/show/f6c4c08a834f
<oprypin> figuring out why floating point division is absolutely required is left as an exercise to the reader
akaiiro has joined #crystal-lang
<FromGitter> <greenbigfrog> yay. almost got the result I wanted without looking at what you sent :P https://gist.github.com/greenbigfrog/a642719523f451f021f20bdb3ebac3ba/revisions
<oprypin> the image size is not constant though
<FromGitter> <greenbigfrog> yeah. that's why I said `almost` 😛
<oprypin> both have advantages and disadvantages
<oprypin> in mine the sizes of "pixels" are varying but in yours it's constant
<oprypin> and there is no way to get best of both worlds
<oprypin> unless..... you kinda make the margin only approximately equal to that percentage but actually increase it until the image reaches 300
<FromGitter> <greenbigfrog> that's what I'm writing right now :)
<oprypin> in which case i'd recommend you to stop dividing `dead` by 2 and then use `x = (x - dead / 2) / scale`
JuanMiguel has joined #crystal-lang
JuanMiguel has quit [Client Quit]
<oprypin> you got it
<oprypin> probably could be reduced but w/e
<FromGitter> <greenbigfrog> I just tried to reduce, and failed..
<oprypin> qr_size always ends up equal to size so maybe u dont need to calculate
<oprypin> that's the easy thing that i noticed
<FromGitter> <talbergs> Hey, wanted to ask, how many lead developers you are for crystal? How do you get paid? ..Do you have stable income from maintaining/developing crystal? If it is only enthusiasm, when it will end (it's herring question I know, it must not end, let me give some context for these rude questions - "it's business perspective"). I am developer for company and product called Zabbix. Today tried to convince them to
<FromGitter> ... consider crystal (as php dies off slowly .. ). What arguments would You @j8r (+others) toss to convince them - that's a good decision to invest and switch to crystal?
<oprypin> one thing's for sure is that it's not for money
<oprypin> and enthusiasm is pretty low though not the all-time low
<oprypin> btw i'm nowhere near being a core developer, just long-time bystander
<FromGitter> <drosehn> There is some money coming in for compiler development, but not enough to say crystal is self-sufficient.
<FromGitter> <l3kn> > *<oprypin>* figuring out why floating point division is absolutely required is left as an exercise to the reader ⏎ ⏎ https://gist.github.com/l3kn/2c38ad3cd9cc73b72fe0bc800f9ce19f (not pixel prefect, but should be somewhat correct)
<oprypin> l3kn, isnt this the exact same result as what i wrote? https://bpaste.net/show/f6c4c08a834f
<FromGitter> <l3kn> without floating point division (sorry, I could not resist when reading the “absolutely required”)
<FromGitter> <greenbigfrog> ```code paste, see link``` ⏎ ⏎ I guess this is a tad nicer ⏎ Any suggestions what else to improve/reduce? (pointers are totally fine... I can only learn if I do stuff myself) [https://gitter.im/crystal-lang/crystal?at=5c1ac1ea1287f05a1e340270]
<oprypin> l3kn, well geez
<oprypin> wasn't supposed to be a challenge
<FromGitter> <j8r> @talbergs Zabbix?! We have it at work, I've seen your company in Paris Open Source Summit too
<FromGitter> <j8r> I dunno, Zabbix itself becomes legacy because it's doesn't scale as well as prometheus
<oprypin> greenbigfrog, it's just math equation reduction like they teach in school :p https://bpaste.net/show/a41247fab0e7
druonysus has joined #crystal-lang
<FromGitter> <j8r> A totally new Monitoting could be in Crystal, Prometheus did with Go. But rewriting Zabbix in PHP doens't look like a good idea. Maybe the Zabbix agent in Crystal (I guess it's in C today)
<FromGitter> <j8r> *I mean rewriting Zabbix which is in PHP to Crystal
<oprypin> to recap,
<oprypin> `dead += (size - qr_size)` -> `dead = dead + size - (qr.width * scale + dead)` -> `dead = size - qr.width * scale`
<oprypin> `scale = (size - dead) / qr.width` -> `scale = (size - (dead_percentage * size).to_i)) / qr.width` -> `scale = (size * (1 - dead_percentage)).to_i / qr.width`
<FromGitter> <greenbigfrog> ah. right. thanks
<FromGitter> <kevinelliott> > *<oprypin>* and enthusiasm is pretty low though not the all-time low ⏎ Why do you think this is?
Raimondi has joined #crystal-lang
<FromGitter> <talbergs> Aight, thanks for input! ;) Some php developers with 15yr of xp say that php is not for web any more. Web demands a ton of functionality - yes there are hacks - like Hack, php->llvm, php-swoole. But still we need real concurrency management and a lot more (speed too).
<FromGitter> <kevinelliott> PHP is definitely not for web apps and APIs that scale.
<FromGitter> <j8r> How do you plan to integrate Crystal in Zabbix? Micro services?
<FromGitter> <greenbigfrog> Put it on github: https://github.com/greenbigfrog/qrcr ⏎ Any suggestions on how I should/could spec this? ( CC oprypin)
<oprypin> i dunno
<oprypin> lately i've been all into golden testing
<oprypin> so, say that with these particular inputs it should produce literally this exact image, etv.
<oprypin> c
<oprypin> obviously it's kind of a stupid test because whenever you want to change something it'll just fail. but the value is in acknowledging that it changed and looking at the way it changed
<oprypin> works best if the sample can be automatically updated
<FromGitter> <greenbigfrog> hm. I guess I could generate images and compare to them
<oprypin> well that's what i mean, i dont mean that you should make it in MS paint first :>
<FromGitter> <greenbigfrog> lol