shawn42 has quit [Quit: Connection closed for inactivity]
Fichtenstein has quit [Quit: Fichtenstein]
matp has quit [Remote host closed the connection]
matp has joined #crystal-lang
<FromGitter>
<samueleaton> @johnjansen I'm in pacific time (Seattle)
onec has joined #crystal-lang
<FromGitter>
<johnjansen> cool @samueleaton
soveran has joined #crystal-lang
pduncan has joined #crystal-lang
soveran has quit [Ping timeout: 250 seconds]
pduncan has quit [Ping timeout: 240 seconds]
onec has quit []
hako has quit [Remote host closed the connection]
onec has joined #crystal-lang
noblehelm has joined #crystal-lang
_whitelogger has joined #crystal-lang
noblehelm has quit [Quit: noblehelm]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 256 seconds]
ponga has quit []
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 268 seconds]
pawnbox has joined #crystal-lang
_whitelogger has joined #crystal-lang
pawnbox has quit [Ping timeout: 245 seconds]
pawnbox has joined #crystal-lang
<FromGitter>
<jots_twitter> one of my often used rubyisms missing: `File.open(fn).each_with_index do |line,x| ` I see #each_line but no index.
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<FromGitter>
<sdogruyol> How about using each line with a self assigned index
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Fichtenstein has joined #crystal-lang
<FromGitter>
<jots_twitter> you mean declaring x above and incrementing it? that's what i'm doing for now. i usually use it to skip header lines of files.
soveran has quit [Remote host closed the connection]
akwiatkowski has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 256 seconds]
pawnbox has quit [Remote host closed the connection]
zaiste has joined #crystal-lang
Kilo`byte has quit [Quit: ZNC - 1.6.0 - http://znc.in]
mgarciaisaia has joined #crystal-lang
hako has joined #crystal-lang
sane_k_ has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 244 seconds]
sane_k_ has quit [Ping timeout: 244 seconds]
<Papierkorb>
jots_twitter, you shouldn't use that line (even in ruby), it leaks the file handle. A non-leaking version in crystal is: `File.open("foo"){|h| h.each_line.with_index{|line, idx| pp line, idx} }'`
<Papierkorb>
Oh, remove the trailing ' from the snippet, left-over from my crystal eval invocation
Kilo`byte has joined #crystal-lang
<FromGitter>
<sdogruyol> @asterite does LLVM optimize this into String Constants context.response.headers["Content-Encoding"] = "gzip"
<FromGitter>
<sdogruyol> or shall i use constants explicity ⏎ context.response.headers[CONTENT_ENCODING] = GZIP
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Remote host closed the connection]
mgarciaisaia has quit [Quit: Leaving.]
poikon has quit [Ping timeout: 258 seconds]
poikon has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 256 seconds]
pawnbox has joined #crystal-lang
matp has quit [Remote host closed the connection]
matp has joined #crystal-lang
bjz has joined #crystal-lang
bjz_ has quit [Ping timeout: 244 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 250 seconds]
<crystal-gh>
[crystal] asterite opened pull request #3560: Make String and Char methods like downcase and upcase unicode aware (master...feature/unicode) https://git.io/vXFwQ
dhk has joined #crystal-lang
<FromGitter>
<asterite> @sdogruyol string literals are constants, yes, they are placed in the data section of the executable :-)
<FromGitter>
<sdogruyol> That's great then
<FromGitter>
<asterite> (so no need to put them behind a constant)
<FromGitter>
<sdogruyol> I love Crystal :heart:
<FromGitter>
<asterite> Yeah... this is one reason why strings are immutable, because then you can place literals in the data section. That's why many other languages do this (java, c#)
<FromGitter>
<asterite> I delayed the release a bit because I was curious about how hard it would be to correctly implement upcase/downcase with unicode awareness... I think we'll have that in 0.20.0 too :-)
<BlaXpirit>
asterite, will we have a Unicode database? :o
matp has quit [Remote host closed the connection]
<FromGitter>
<sdogruyol> Wow awesome
akwiatkowski has quit [Ping timeout: 264 seconds]
<BlaXpirit>
i like having the names of Unicode characters, the groups that they're in
matp has joined #crystal-lang
Fichtenstein has quit [Read error: Connection reset by peer]
Fichtenstein has joined #crystal-lang
kulelu88 has joined #crystal-lang
<FromGitter>
<asterite> @BlaXpirit Kind of: https://github.com/crystal-lang/crystal/pull/3560 . Not all data is exposed because it's way too much, I'm only using what's needed so far. But you can ask the groups, for example if a character is a space, letter, number, mark, etc. (but not the subgroups, though that data is there, it just needs to be exposed in a nice way)
dhk has quit [Quit: Leaving]
zaiste has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<BlaXpirit>
amazing anyway
Philpax has quit [Ping timeout: 260 seconds]
<FromGitter>
<sdogruyol> @asterite are you planning to release this week?
mgarciaisaia has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 265 seconds]
woodruffw has quit [Ping timeout: 260 seconds]
<Yxhuvud>
asterite: Is the compiler knowledgable enough to treat compiled regexpes like constants as well?
vikaton has joined #crystal-lang
woodruffw has joined #crystal-lang
<FromGitter>
<johnjansen> @asterite did you get the unicode casing working????
<FromGitter>
<johnjansen> please say yes
<FromGitter>
<johnjansen> @asterite did you see the Ruby `Unicode` gem
<FromGitter>
<sdogruyol> @johnjansen you seem to be too excited :D
<FromGitter>
<johnjansen> well id rather he do it than me ...
<FromGitter>
<johnjansen> and i need it soon
<FromGitter>
<johnjansen> i had to park my tokenizer until unicode is all go
<FromGitter>
<sdogruyol> @johnjansen i like that
<FromGitter>
<sdogruyol> i mean the tokenizer
<FromGitter>
<sdogruyol> :P
<FromGitter>
<johnjansen> i’ll like it more one all the tests pass ...
<FromGitter>
<sdogruyol> that's for sure :) How's the performance btw?
<FromGitter>
<sdogruyol> Have you compared it with Ruby e.g?
<FromGitter>
<johnjansen> its very fast, but until its done i cant compare really
<FromGitter>
<sdogruyol> how much complete is it?
mgarciaisaia has quit [Quit: Leaving.]
mgarciaisaia has joined #crystal-lang
<FromGitter>
<johnjansen> logical is complete, but the code i was porting was spaghetti, so i want the original tests to pass in order to verify its accuracy. Unicode casing is causing a 50% failure
<Yxhuvud>
Papierkorb: It has been showed in other languages that injecting raises is not very safe.
<Papierkorb>
Yxhuvud: What else then? A "running" bool check doesn't always cut it.
<RX14>
injecting raises is kind of pointless too.
<RX14>
if you can inject a raise, then you can inject a jump
<RX14>
and then jump to code which rescedules the fiber
<Papierkorb>
RX14: Of course, but you could also do a substraction in #+
<Papierkorb>
If you do that, you did it on purpose
<RX14>
what?
<Papierkorb>
That's not an issue at all. If the Fiber reschedules itself, you wrote the code for it, and thus you did it on purpose.
<Papierkorb>
It doesn't happen by accident
<RX14>
of course
Ven has quit [Read error: Connection reset by peer]
<RX14>
what are you trying to do
Ven has joined #crystal-lang
<RX14>
stop a fiber from the outside?
<RX14>
asap?
<Papierkorb>
Yes, possibly interrupting network requests, Channel#send waits, etc.
<RX14>
well channel#send waits are in the libevent event loop
<RX14>
i don't know if you can do it to be honest
<RX14>
i would think that the best way would be to cause some sort of CPU interrupt
<RX14>
maybe linux has a way to do it
<RX14>
oh, signals sound like the way to go
<Papierkorb>
Signals are ran in their own Fiber
<RX14>
well
<Papierkorb>
and then I'd have to inject a signal into each fiber, which would effectively resemble injecting a #raise
<RX14>
if you're running in the signal handler fiber
<RX14>
and you have a handle to the fiber you want to stop
<RX14>
you can just remove it from the scheduler
<RX14>
how would you "inject a raise" anyway
<RX14>
what do you mean by that
<RX14>
injecting assembly?
<RX14>
if you can inject assembly then you have control of the fiber and don't need any sort of raise mechanism
<Papierkorb>
You could push the call to #raise with whatever parameters on the stack and jump into the fiber. Not thread-safe though.
<RX14>
but then
<RX14>
you're outside the fiber already if you're modifying it's stack or code
<RX14>
and so it's stopped
<RX14>
and so you've already achived your goal
<RX14>
plus calls don't go on the stack
<Papierkorb>
I want to halt it while letting it release handles if it needs to
<RX14>
ah
<RX14>
yes in that case a raise would be what you want
<RX14>
or actually
<RX14>
some sort of unwind, just calling finally handlers
<Papierkorb>
Sure exceptions are crude, but that's what'd be the easiest to use, as they either do error handling correctly, or don't care - both are fine in their own ways
akwiatkowski has quit [Quit: Konversation terminated!]
<Papierkorb>
Yxhuvud: What'd be a different generic solution then?
pawnbox has quit [Ping timeout: 240 seconds]
<RX14>
what do you want this for anyway?
hako has quit [Remote host closed the connection]
hako has joined #crystal-lang
<Yxhuvud>
Papierkorb: dunno. You may want to look into what java did when they choose to not use exceptions for that anymore.
pawnbox has joined #crystal-lang
<Papierkorb>
Working on BitTorrent DHT, I want to find data in the DHT. So, I have a list of nodes to ask. Then I have a set amount of fibers doing concurrent requests (the list of nodes is sorted by possibility of them having the data). One break condition is, I want to break if all fibers did not find a better node (which indicates the data can not be found). I wanted to do this through a channel where each fiber sends its best candidate to, and a
<Papierkorb>
control fiber which receives all of them (fiber_count.times), and then checks if the last generation did (or did not) find a better candidate. Now here's the thing. Another break condition is when the data is found. However, now I'd need to send the remaining amount of times into the control fiber, which is still waiting for better candidates.
<Papierkorb>
Maybe I need yet another channel to break the control fiber, and then have it select on the candidates channel and on the break channel
<FromGitter>
<sdogruyol> @papierkorb respect for that
<Papierkorb>
Yxhuvud: Are you sure? Java went away from outright killing threads and went to throwing exceptions instead (to release resources properly, etc.). Or did they now move on from that too?
<Papierkorb>
sdogruyol, Cheers. I'm like a week or two (?) away from updating the torrent shard with that stuff :)
<FromGitter>
<sdogruyol> i think your project might be a great study for using Crystal in a different way (other than web)
<RX14>
hmm it's a hard problem
<RX14>
you should make an issue on the github issue tracker for a way to do this.
<RX14>
my first impression would be to assume that the fiber in question is not currently running when we issue the stop request
<RX14>
and simply attempt to stop it from resuming
<RX14>
and instead attempt to release resources in the fiber
<RX14>
so then it comes down to 2 things:
<RX14>
have a boolean on a fiber for "closed"
<RX14>
which fiber#resume checks
<RX14>
and second, to provide a way of releasing resources in a fiber
<RX14>
which would just be running finaly blocks
<RX14>
which the fiber#resume will do if it's closing the fiber.
<Papierkorb>
and releasing event notifiers (or however libevent calls them) held by it
<RX14>
hmm
<RX14>
i don't think that happens currently
<Papierkorb>
Would have to though, as it most likely will have at least one if it's not running
<RX14>
well io/file_descriptor doesn't seem to do it currently
<RX14>
oh
<RX14>
never mind
<RX14>
it's unbuffered_close
<RX14>
it's done by finally
<RX14>
so technically you don't have to worry about it
<RX14>
but really thats not something you have to worry about if you run the finally blocks
<RX14>
because it will (should, if the fiber is programmed correctly) run the #close on all resources it has
<RX14>
which then should release their event handles
pawnbox has quit [Remote host closed the connection]
<crystal-gh>
[crystal] asterite closed pull request #3560: Make String and Char methods like downcase and upcase unicode aware (master...feature/unicode) https://git.io/vXFwQ
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: https://git.io/vXFFx
<crystal-gh>
crystal/master d3bc110 Max Gurela: Support to_yaml in YAML.mapping generated classes (#3559)...
<FromGitter>
<sdogruyol> @asterite Kemal built with --release takes 136 KB on Crystal master versus 245 KB on 0.19.4, what might be the reason for that?
<Papierkorb>
32 GiB, and apparently too many. It's some sort of bug in my code though which I'll look at tomorrow. And the output looked like maybe a hundred
<RX14>
yeah thats weird because stack size is MiB
<RX14>
8*
vikaton has quit [Quit: Connection closed for inactivity]
<RX14>
so thats only 800MiB if the whole stack was used
<FromGitter>
<sdogruyol> hundred won't be enough to to dhat
<Papierkorb>
8MiB, with each fiber usually only using the last 4KiB page, so..
<Papierkorb>
nope. Will investigate tomorrow
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
<FromGitter>
<jots_twitter> is there a way to run a kemal app as my own uid, but listen on port 80 and 443? and a way to force everything through 443 (ssl)?
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<BlaXpirit>
jots_twitter, probably no but if you have a router you can forward ports
<BlaXpirit>
to force https you just redirect any http request to https
<FromGitter>
<fridgerator> can be done with iptables
<BlaXpirit>
ok
<FromGitter>
<jots_twitter> thank you
<FromGitter>
<fridgerator> well maybe not force through ssl
<BlaXpirit>
dont know how to do redirects in kemal
<Papierkorb>
jots_twitter, you can also use a reverse proxy, e.g. with NGINX
<BlaXpirit>
the only missing part is whether we are currently on http
<BlaXpirit>
yeah, it's best done with nginx
<BlaXpirit>
and you can run nginx on port 80 and tell it to communicate with your app on whatever port
<Papierkorb>
jots_twitter, then the app runs as whichever user you want it to, and the heavy lifting (listening on 80/443, doing TLS, security stuff, redirect http -> https, ...) is done by NGINX
<BlaXpirit>
so... is there any sane and not html-specific runtime templating language?
<BlaXpirit>
forget it.. any runtime templating language?
<FromGitter>
<jots_twitter> yeah maybe i'll go the nginx route.
<BlaXpirit>
yeah these template libraries are all either a crazier/html-specific version of ecr, or crazy DSLs
<BlaXpirit>
aaand it's back to ignoring the Web-related stuff in Crystal for me
<RX14>
BlaXpirit, why do you need to generate templates at runtime?
<BlaXpirit>
RX14, to not restart the web app
<RX14>
lol
<RX14>
oh
<RX14>
bit aren't SPA's hip now :)
<BlaXpirit>
not on my watch
<RX14>
yeah i pretty much feel the same
<Papierkorb>
I puke everytime I see a blog written with AngularJS
<FromGitter>
<fridgerator> why?
<RX14>
BlaXpirit, isn't crustache basically what you want
<RX14>
parse a string into a template
<RX14>
then render template, model
<Papierkorb>
fridgerator, they're having all the issues of angular (and similar), while their benefits are to no value to the user.
<FromGitter>
<jots_twitter> friends don't let friends use angular
<Papierkorb>
Breaking 404, being sometimes slow for no reason, they're especially bad for mobile users, loading crucial stuff after I loaded the page. They're rebuilding a web browser in the web browser. "Loading page content". For real? That's what my browser does all the time, it's really good at it too, these people should try that once in a while.
<RX14>
blogs are really stupid for angular honestly
<RX14>
but i don't think SPAs are in general stupid
<Papierkorb>
They have their place, but people built SPAs where more often than not a usual page, sometimes even static pages, would've sufficed, without sacrificing any "user experience"
soveran has quit [Remote host closed the connection]
<BlaXpirit>
RX14, it says crustache is logicless
<BlaXpirit>
so like no loops, i possums
<BlaXpirit>
presume* lol
<RX14>
no it has loops
<BlaXpirit>
weird. let's see
<RX14>
it's just
<RX14>
a for each loop
<RX14>
not a conditional loop
<RX14>
it's logic less because you loop over collections instead of looping on conditions
<BlaXpirit>
hm that's interesting, thanks. but I'll most likely need more complex logic
<RX14>
the idea is that you do that in the view controller
<RX14>
then serialize that into a map
<RX14>
and then send that to the model
<RX14>
s/model/template
<BlaXpirit>
yeah that's what i do with templates
<RX14>
if you have more complex logic you're creating a programming language inside crystal
<RX14>
which is a bit redundant if you ask me
<RX14>
and that's why there's no projects other than the simple crustache
<RX14>
because, like the rules of rocketry, if any project includes a new programming language, it's a programming language project more than anything else
<BlaXpirit>
more complex logic is not redundant
<RX14>
it is when you can do it in crystal instead of making your own language
<RX14>
and current languages do it in one of two ways:
<BlaXpirit>
what's redundant is passing pre rendered data to templates
<RX14>
compiling to crystal
<RX14>
or moving that logic to the view controller
<BlaXpirit>
hmm yeah i just realized that arbitrary code is not possible in runtime templates
<BlaXpirit>
i was thinking like... passing a Time object to a template
<BlaXpirit>
and putting time.to_s("%h") or whatever the way to do it is
<BlaXpirit>
but it's just not possible
<BlaXpirit>
but i hope you understand what i mean: it's more redundant to pass the time string preformatted in different ways than just letting the template decide
<RX14>
yep
<RX14>
but such is compiled languages
Fichtenstein has quit [Quit: Fichtenstein]
<FromGitter>
<jots_twitter> what is the crystal way: function that takes and array as arg and returns array of all elements except last element (leaving orginal array untouched) This works, but it is tied to a particular type and seems clunky: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5830e1eee712c9a1188aafad]
<Papierkorb>
guessing here, but try def front(ary : Enumerable(T)) forall T; r = Array(T).new ...
<RX14>
well first of all array[0..-2] works
<RX14>
but to make THAT method work, you need to make it generic
<Papierkorb>
Assuming you did that to learn something, else what RX14 wrote