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
<FromGitter> <jjjaaayyy> hipocrates said, application, supervise thyself
<oprypin> i'm probably missing some of the difficulties of managing multiple processes
<oprypin> i'm in a "what could go wrong" mode
<Papierkorb> oprypin: well a manager process has to watch them and restart it if one dies
<oprypin> no, that's easy
<Papierkorb> Or something along those lines
<RX14> oprypin, yes it's easy but it's still more new code in more processes
<RX14> and new code is bad
<Papierkorb> Well sure it's easy by itself, and it's probably how I'd do it too. But honestly, whichever doesn't really matter as the current state will hopefully be made obsolete with real multi-threading.
<Papierkorb> So, as long the solution used isn't stupid in itself..
vikaton has joined #crystal-lang
daemonwrangler_ has joined #crystal-lang
alex`` has quit [Ping timeout: 246 seconds]
alex`` has joined #crystal-lang
mbarbar has joined #crystal-lang
hightower2 has joined #crystal-lang
hightower3 has quit [Ping timeout: 260 seconds]
<FromGitter> <jjjaaayyy> i've come to the conclusion that with a little tweaking, crystal + grub can run on bare metal
<FromGitter> <jjjaaayyy> well, + a bunch of C libraries, if you want things like file system access
<illyohs> boop
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
mbarbar has quit [Ping timeout: 268 seconds]
faustinoaq has quit [Ping timeout: 240 seconds]
alex`` has quit [Ping timeout: 246 seconds]
faustinoaq has joined #crystal-lang
astronavt has quit [Quit: Leaving...]
astronavt has joined #crystal-lang
vivus has quit [Quit: Leaving]
vikaton has quit [Quit: Connection closed for inactivity]
faustinoaq has quit [Ping timeout: 260 seconds]
faustinoaq has joined #crystal-lang
vikaton has joined #crystal-lang
<FromGitter> <codenoid> helo
snsei has joined #crystal-lang
Groogy_ has quit [Ping timeout: 240 seconds]
Groogy_ has joined #crystal-lang
<FromGitter> <codenoid> how to check / debug more on nil backtrace error
<FromGitter> <codenoid> can compiled crystal app use adb ?
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]
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]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
aroaminggeek[awa is now known as aroaminggeek
vikaton has quit [Quit: Connection closed for inactivity]
aroaminggeek is now known as aroaminggeek[awa
rohitpaulk has joined #crystal-lang
illyohs has quit [Ping timeout: 240 seconds]
rohitpaulk has quit [Ping timeout: 255 seconds]
aroaminggeek[awa is now known as aroaminggeek
rohitpaulk has joined #crystal-lang
aroaminggeek has quit [Quit: Textual IRC Client: www.textualapp.com]
DTZUZO has quit [Ping timeout: 255 seconds]
alex`` has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
cyberarm has quit [Ping timeout: 255 seconds]
rohitpaulk has quit [Ping timeout: 260 seconds]
astronavt has quit [Ping timeout: 255 seconds]
cyberarm has joined #crystal-lang
<Papierkorb> jjjaaayyy, there are already kernels written in Crystal.
<Papierkorb> "A bunch of C libs" lul
faustinoaq has quit [Ping timeout: 260 seconds]
Groogy has joined #crystal-lang
cyberarm has quit [Ping timeout: 250 seconds]
<FromGitter> <extremety1989> @jjjaaayyy do you have any tutorial with crysta+grub ?
<Groogy> Morning!
<FromGitter> <Rinkana> morning
snsei has joined #crystal-lang
<FromGitter> <unreadable> morning all, did you guys know about this?
<FromGitter> <unreadable> https://github.com/kripken/emscripten
<FromGitter> <unreadable> `An LLVM-to-JavaScript Compiler`
<Papierkorb> ...yes?
<FromGitter> <unreadable> It might sound big, but it actually does stuffs right
<Groogy> What is the purpose though
<Groogy> write C++ code that can then run on a browser?
<Papierkorb> what it says on the tin
<Papierkorb> yes
<Papierkorb> That's how Unreal Engine runs in firefox
<Groogy> but, but why?
<FromGitter> <unreadable> converting c++ to javascript, more specific for example opengl to webgl
snsei has quit [Ping timeout: 240 seconds]
<FromGitter> <unreadable> it even works with filesystem and other i/o stuffs
<Groogy> actually is there a tool to count lines of code discarding empty lines etc?
<Groogy> wanna check how much my project has grown
<Papierkorb> Groogy: `sloccount` sadly doesn't yet support Crystal. I use that line instead: `cat {spec,src}/**/*.cr | sed 's/#.*//;/^ *$/d' | wc -l`
<Papierkorb> discards empty lines and comment-only lines
<RX14> wouldn't sloccount support ruby?
<Papierkorb> It does
<RX14> just use ruby mode?
<Papierkorb> So the change would be kinda simple. But .. sloccount is perl, ain't going to touch that
<Groogy> yeah what I want is pretty much discard comments and empty lines
<Groogy> and then measure size and hopefully see that it doesn't grow too much
<Groogy> already have parts again I want to refactor so it becomes smaller
<Groogy> (Blobds are the scariest thing I know and I have a manic desire to prevent it at all costs because of work...)
<Papierkorb> blobds?
<Groogy> Blobs*
<Groogy> We have classes that are +30k lines of code only in the header....
<Papierkorb> [x] Oh Shit
<Groogy> *shiver*
<Groogy> The newer projects don't, we learn from our mistake
<Groogy> but like when project been building on old projects and then been kept patched on for +5 years it... grows fast
cyberarm has joined #crystal-lang
<Groogy> But this can't be right, only 358 lines of code?
<Papierkorb> Groogy: if something like that happens, print it out, shredder it and give it the authors to eat their own spaghetti code
<Groogy> Well we are all collectively at fault :P
<Groogy> but good teambuilding exercise to eat our own code together xD
<Groogy> But yeah it is saying Boleite is only 358 lines of code, that seems quite off
DTZUZO has joined #crystal-lang
<yxhuvud> grep -r -v -e '^$' | wc -l
mbarbar has joined #crystal-lang
<Groogy> yeah but that would count every single file and its content right yxhuvud?
<Papierkorb> that's not semantically equivalent.
<Groogy> cat -> stream editor -> remove comments and empty lines -> wordcount lines right?
<Groogy> is what you do Papierkorb
<Groogy> so just wondering what's going wrong if it is telling me that I only have 358 lines of code
<Papierkorb> Groogy: Are you sure it's broken? I'd otherwise write a quick script in ruby doing the same. it should get to the same count.
<Groogy> also counting every single line gives me 64318
<Groogy> Eh 358 just seems insanely low
<Papierkorb> `Dir["{spec,src}/**/*.cr"].map{|x| File.readlines(x).map{|l| l.sub(/#.*/, "")}.count{|l| l !~ /^ *$/}}.sum`
<Groogy> crystal compiler supports like running something inline from commandline?
<Papierkorb> not tried, should do the same
<Papierkorb> Groogy: crystal eval 'CMD'
<Groogy> yeah could just have the build environment run that
<Groogy> yeah crystal is giving me 5059
<Groogy> sounds a lot more correct
<Papierkorb> For a test file it gives me the correct expected output, it should work
<Groogy> not sure where it's breaking, maybe it isn't going through every file? Might not work recursively?
<Groogy> or it doesn't count lines that start with too much whitespace?
<Papierkorb> ** is recursive, though that syntax there is for zsh
<Papierkorb> may not work in bash
<Papierkorb> No problem with leading whitespace
Ven`` has joined #crystal-lang
<Groogy> might be me running in bash then ¯\(°_o)/¯
<Papierkorb> Bash doesn't support **
<Papierkorb> That alone is a reason to use zsh lul
<Groogy> you sure? Pretty sure I've used it several times
<Papierkorb> Just run that glob pattern there to `ls`
<Groogy> might not work recursively though but I've used it several times as a "every subfolder of this folder"
<Papierkorb> (For naysayers, putting that through echo would suffice, but its formatting sucks)
<Papierkorb> Yes, in bash I only get files on the first level under src,spec
<Groogy> ah yeah it only goes one level deep
<Papierkorb> Use da z-shell
<Papierkorb> You know you want it
<Groogy> there we go
<oprypin> Papierkorb, bash supports ** but it's not enabled by default
<Papierkorb> zsh globbing goes far beyond that
<oprypin> k
<Papierkorb> Not to mention that I can actually tell it to be case (in)sensitive while doing so
<travis-ci> crystal-lang/crystal#490f491 (master - Allow less than expected digits when parsing time with decimals (#5317)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/314297780
<DeBot_> https://github.com/crystal-lang/crystal/pull/5317 (Allow less than expected digits when parsing time with decimals)
<Groogy> now back to solve why my ui is not clearing 1 pixel correctly D:
csk157 has joined #crystal-lang
<FromGitter> <jjjaaayyy> one time windex was the answer
faustinoaq has joined #crystal-lang
<Groogy> hey faustinoaq since you are the pro on VS code, is there a shortcut for like symbol lookup? ( ≖‿≖)
<Groogy> can't find anything through ctrl+p
<faustinoaq> Groogy, ctrl+shift+o (list symbols for current file)
<Groogy> aaaaw nice! (っ' ▽' )ノ
csk157 has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
<faustinoaq> BTW, we are trying to improve symbol lookup, currently I'm using regex to achieve this feature, but We hope to use parsing tree for that https://github.com/crystal-lang-tools/scry/blob/master/src/scry/symbol.cr#L4
<Groogy> oh nice, somehow I can help out as a user?
<Groogy> ow yeah do you have a problem matcher for vs code?
<Groogy> Also got most of the performance back now that I made the UI a bit smarter https://i.imgur.com/kf7VmYn.png
<Groogy> still not as good though, should be able to make it even faster
<FromGitter> <extremety1989> @Groogy which c lib u use ?
Groogy has quit [Quit: WeeChat 1.9.1]
Groogy has joined #crystal-lang
<Groogy> @extremety1989 to what part?
<Groogy> most of it is written in Crystal but for instance I use GLFW3 to open up a window and opengl context, freeimage to parse image data, freetype to load font data
<FromGitter> <extremety1989> @Groogy oh okey, i never worked with ui
<Groogy> ah the ui is my own making
<FromGitter> <extremety1989> cool
<Papierkorb> is "boleite" a real thing, or is it a made up word?
<FromGitter> <extremety1989> @Groogy 8k fps omg that is crazy performance))
<Groogy> Boleite is a crystal :P
<Groogy> I was trying to come up with a nice name so I just went through wikipedia and picked something that looked pretty
<Groogy> extremety1989 I had 11k before
<faustinoaq> Groogry, No, I don't, but you can try something like `"crystal-lang.problems": "build"` https://github.com/crystal-lang-tools/vscode-crystal-lang/wiki/Settings#problems
<Groogy> working right now to get back to that
<Papierkorb> So .. akin to what I do Groogy lol
<Groogy> with Trashman and Crystal Clear it was kind of self obvious
<Groogy> but Boleite being a game framework it was a bit harder
<Groogy> ah no I meant something that can scan the build output faust
<Groogy> this is for inline in the editor right?=
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
<FromGitter> <codenoid> helo
<Groogy> o/
rohitpaulk has quit [Ping timeout: 246 seconds]
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mbarbar has quit [Ping timeout: 260 seconds]
DTZUZO has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
<Groogy> hmm is there no API documentation for 0.24?
<Groogy> Arch updated crystal for me and I am curious why it can't find Time::Span anymore
<RX14> Time::Span exists
<RX14> and no 0.24.0 isn't a release
<RX14> everything is broken
<Groogy> then why did someone upload it to the AUR D:
<oprypin> that doesnt make it not a release..
<oprypin> Groogy, it's official arch package, not aur
<Papierkorb> Groogy: Answer is "Yes"
<Groogy> ah right yeah but still
<Papierkorb> The maintainer probably didn't know it
<oprypin> Groogy, you publish a tag on github, package maintainer gets notified and updates it
<oprypin> nobody knows it still
<Groogy> ugh always find downgrading in pacman a pain
<oprypin> it's still the latest tag
<oprypin> and still no warning against using it
<Papierkorb> Groogy: pacman -U /var/cache/pacman/pkg/crystal-0.23.1-2-x86_64.pkg.tar.xz
<Papierkorb> Needed that too
<RX14> oprypin, there is
<RX14> it says it's a prerelease
<oprypin> well no shit, 0.x is always a prerelease
<RX14> no it's not
<RX14> it's a release
<RX14> just not a production quality release
<oprypin> i dont care what you think, i'm telling you what normal people think
<RX14> ...no?
<oprypin> "oh they started adding a warning that it's a prerelease? cool. let's update"
<Groogy> to be honest, if it isn't AUR the maintainers of arch just probably saw "new tag, push it"
<Groogy> I've had that several times with liri and other stuff
<oprypin> Groogy, yes, they did, and as I was saying, they had no reason not to push it
<RX14> oprypin, and most of the people I know wouldn't say that
<RX14> a prerelease is usually a version suffixed with -pre
<Groogy> AUR usually have maintaners who does it because they like that project, AUR's biggest problem is usually dependencies going out of sync
<RX14> just because it's 0.x.x means it's a beta quality release
<RX14> but it's not a prerelease
<Groogy> need to restart DE, updated drivers brb
Groogy has quit [Quit: WeeChat 1.9.1]
<RX14> oprypin, 0.23.1 isn't a prerelease, it's a release, it's just a beta release
<RX14> prerelease is something different
<oprypin> i dont care, i'm not the one that you need to convince
<RX14> sure
<RX14> but most people I talk to don't think of it your way
<RX14> which is what you claimed to be true
<oprypin> i get the point, but i also get the point that after looking at this thing in github for a minute i concluded that it's just a normal release
<RX14> yes, it doesn't really matter
<RX14> the effect is the same
<oprypin> but disregarding that, 0.24.0 looks exactly like 0.23.1
<oprypin> which is really what people look at
<RX14> yes the tag should never have been pushed
<RX14> but then I didn't push it either we just need to release 0.24.1
<RX14> and then forget 0.24.0 ever happened
Groogy has joined #crystal-lang
<oprypin> the least you can do now is add <h1>THIS IS A BROKEN RELEASE. DO NOT USE IT
<oprypin> and delete binaries lol
<FromGitter> <bew> Groogy cloc handles crystal correctly (Count Line Of Code) of you're still looking for that
<RX14> oprypin, yeah I should
<RX14> but it's too late now
<oprypin> better late than never
<RX14> probably not true now
<Groogy> @bew thanks but now I have a crystal script instead :P
<FromGitter> <bew> if*
<FromGitter> <bew> You should still try it, it does a lot of cool things :p
<FromGitter> <unreadable> does anyone know an gl community or gamedev gitter or some chat to talk about graphics stuffs related
<Groogy> freenode irc has a few
<Groogy> otherwise I am always here can always tag me
rohitpaulk has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
sz0 has joined #crystal-lang
<FromGitter> <unreadable> yeah, but that's a crystal room
<FromGitter> <unreadable> I got this hexchat client preinstalled on my machine, gonna mine for some channels
<Groogy> ##progamming, #reddit-gamedev, #gamedev, ##opengl are my recommendations
<Groogy> though just saying the programming and gamedev channels seems to have a lot of students? Eh at least people with opinions about everything at least
<Groogy> and not always helpful
DTZUZO has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <unreadable> already on them, but found a good youtube channel with a game engine building
<FromGitter> <unreadable> I find it to be golden content
rohitpaulk has quit [Ping timeout: 255 seconds]
<FromGitter> <Rinkana> Do you happen to have a link to the playlist?
<FromGitter> <Rinkana> I'm interested aswell
alex`` has quit [Quit: WeeChat 1.9.1]
aroaminggeek has joined #crystal-lang
<FromGitter> <unreadable> u're wellcome
<FromGitter> <unreadable> Once I master the batch tehnique, I'll drop SFML and start creating my gui lib from scratch
<Groogy> you mean batching sprites?
<Groogy> You can also do instancing where you do one single drawcall for everything
<FromGitter> <unreadable> yeah, my main goal is to draw as many squares as possible and one I can control each square in part, to assign than custom shaders and functionallity to make them ui widgets
<FromGitter> <unreadable> but I'll need to document more on that before
<Groogy> feel free to look at my code and steal
<Groogy> or well not straight copy paste but if you get stuck you can look at boleite and steal ideas
<FromGitter> <unreadable> not a fan of copy pasting, that's not really from scratch
<FromGitter> <unreadable> there's also in the playlist a whole 2 hours video on batching 😄
<Groogy> well yeah I meant more you don't learn if you copy paste
aroaminggeek is now known as aroaminggeek[awa
<FromGitter> <jjjaaayyy> where is boleite
<FromGitter> <jjjaaayyy> oh the shard
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <watzon> Crystal doesn't have an equivalent to Ruby's `Dir.home` does it?
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
jdnoodle has joined #crystal-lang
<jdnoodle> hi all, i have some questions about slices and how to properly use them as i am a bit confused with the docs
<jdnoodle> i am wanting to use uint8 slices with sockets to manipulate data and i am confused about when to use Bytes.new, slice(UInt8), UInt8.slice, Slice.new, etc they all seem the same to me and i was wondering if someone could name some of the differences.
<jdnoodle> Also I am having troubles setting and changing data within slices. say for instance I have a= UIny8.slice(0x05, 0x02) and I want to add or remove another byte, how is that possible?Likewise if I am receving from a socket .read requires a slice, but do slices auto expand or would I need to create a slice of approriate size before hand?
alex`` has joined #crystal-lang
alex`` is now known as alexherbo2
<Papierkorb> jdnoodle: Slices are static in size and variable in data
alexherbo2 is now known as alex``
<Papierkorb> jdnoodle: If you want a dynamically sized "Slice" use Array(UInt8) instead. doing `ary.to_unsafe.to_slice(ary.size)` will turn it into a slice.
<jdnoodle> that actually seems like an easier solution. ill have to check the docs to see if TCPSocket << and .read methods support Array(UInt8)
<Papierkorb> jdnoodle: UInt8.slice is the same as UInt8[...] is the same as Bytes[...] (Note that `Bytes` is an alias for `Slice(UInt8)`). Personally, I use the Bytes[..] notation
<RX14> jdnoodle, what are you attempting to do on a higher level
<RX14> because you don't seem to be thinking about this in the right way
<jdnoodle> Socks4 client implentation
<jdnoodle> i need to send raw bytes to intialize the socsk4 connection
<RX14> you don't want to think about "resizing" or even really modifying a slice
<RX14> jdnoodle, so you create a slice of those raw bytes and use io.write
aroaminggeek[awa has quit [Ping timeout: 260 seconds]
<RX14> you don't want to really modify that slice again
<RX14> you want to use io.write again witha nother slice
<RX14> assuming youw ant to send dynamic data
<RX14> I don't know the socks4 protocol
<RX14> but I wouldn't think it even requires explicitly modifying a slice ever
<RX14> let alone using realloc
<jdnoodle> i see, so i would create a new slice for each writing operation discarding the previous slice
<RX14> yes
<RX14> but really you wouldn't want to use slices for data that's always the same
<RX14> for example if you always send the same 2 bytes
<RX14> in the future we'll probably have binary constants
<RX14> so that you don't need to use UInt8.slice(0xab, 0xcd)
<RX14> and there will be no overhead
<RX14> but for now worry about getting it working then about performance
<jdnoodle> that would be neat
<RX14> jdnoodle, if you send me some code i'll be happy to show you how I would do it
<jdnoodle> sure let me clean up some of it. it is currently in a non functioning state so ill be a minute
<jdnoodle> cant seem to get that Bytes[] slice to compile think it has something to do with the LibC call
<RX14> yeah thats probably not the best approach
<RX14> especially the htons calls
<jdnoodle> how about should i go correcting it
<RX14> typically if you're reaching for LibC you should be asking here if there's a better way first
<RX14> LibC ideally should be used by the stdlib only
<jdnoodle> ah
<RX14> you want to use
<RX14> @sock.write_byte 0x04
<RX14> @sock.write_byte 0x01
<RX14> @sock.write_bytes(remote_port, IO::ByteFormat::NetworkEndian)
<RX14> @sock.write_bytes(remote_host, IO::ByteFormat::NetworkEndian)
<RX14> @sock.write_byte 0x00
<Papierkorb> gist
<RX14> come on it was 5 lines Papierkorb
<jdnoodle> heh
<RX14> jdnoodle, also uninitualized is unsafe and you should never ever use it
<RX14> you want to use getter! sock : TCPSocket
<jdnoodle> yea i was going to change that eventually
<RX14> and that defines a `sock` method which raises if sock is nil
<RX14> and use that
<RX14> you'll just get a nill error at runtime if connect isn't called at the right time
snsei has joined #crystal-lang
<RX14> but in such cases, it's a really good idea to think about doing the connection inside the constructor
<RX14> or at least *a* constructor
<jdnoodle> if I define getter remote_host : String, is there a way to not be forced to give it an assignment in te initialize method?
<RX14> you might want a def initialize which only takes an alreaady-open socks connection
<Papierkorb> Just pass the socket into the #initialize, let that class do one thing only.
<RX14> and then perform the connection negotiation in a def self.connect method
<jdnoodle> good idea
<RX14> and then you get more flexibility
<RX14> and more safety
<Papierkorb> Also make sure @sock needs to be a TCPSocket, or if e.g. IO suffices
<RX14> yep
<RX14> using just IO makes it a lot easier to test
<jdnoodle> taking notes on all these suggestions lol
<RX14> also connect really shouldn't be doing to connection negotiation right?
<RX14> can you multiplex multiple TCP conenctions into 1 socks conenction?
<Papierkorb> jdnoodle, old but still applicable: the SOLID paradigm. Doesn't work for everything in existance, but it's a decent foundation to go from
<jdnoodle> RX14: im not sure
<RX14> lol
snsei has quit [Ping timeout: 258 seconds]
<Papierkorb> jdnoodle: That's something you want to know before writing code. It drastically changes your architecture.
<RX14> you should probably do some research on the protocol before starting
<RX14> exactly
<RX14> it changes between SocksConnection.new(proxy_host, proxy_port, remote_host, remote_port) to
<RX14> SocksCOnnection.new(proxy_host, proxy_port)
<RX14> and a connection.connect(remote_hostm, remote_port)
<RX14> which would return a SocksRemoteConnection
<RX14> thats bad naming
<RX14> but you get the idea
<jdnoodle> yea
<jhass> well, some scripting to learn a protocol is fine IMO, just don't even bother with creating classes or anything then
<jhass> and be prepared to throw all of it away for the real implementation
<jdnoodle> ill have to think about the structure a bit more i guess
<jdnoodle> this was initially just something i could throw into side projects to add socks capabilities but if im going through the effort i might as well do it right
<RX14> jhass, i like to at least skim the RFC
<RX14> like
<RX14> you shouldn't know the protocol off by heart
<RX14> you should however at least be able to know the arechitecture
<jdnoodle> RFC hah!
<jdnoodle> ive been basing this off wikipedia
<RX14> does socks not have an rfc?
<jdnoodle> go me
<RX14> oh dear
<RX14> also socks5
<RX14> honestly
<jdnoodle> yea i was just about to pull it up
<RX14> RFCs are absolutely fantastic
<RX14> wow check out that short RFC
<RX14> you've hit a jackpot
<RX14> the IRC rfc is about
<RX14> 30 pages
<jdnoodle> yep been through that one
<jdnoodle> multiple times
<jhass> the IRC RFC is everything but fantastic though :P
<RX14> YES
<RX14> i remember the irc rfc number off the top of my head
<RX14> hahaha i'm a nerd
<Papierkorb> wauw s0 n3rdy
<RX14> i was wrong
<RX14> 63 pages
<RX14> Papierkorb, pls
<jdnoodle> wow fake nerd
<jdnoodle> anyways thanks for the help guys ill do a redesign and probably poke my head around later for critque
<RX14> cool
<RX14> the main thing is you know how we do binary data over IO now jdnoodle
<RX14> (the IO doc does say it in the header btw)
<RX14> you'll probably use slices when you're actually sending client data over that socket
<jdnoodle> im not sure why i started using slices at all think a quick google query led me astray on that one
<RX14> i.e. you'll eventually have to implement an instance of IO
<RX14> representing the proxied TCP connection
<RX14> which means you have to implement read(Slice) and write(Slice)
<RX14> which means you are dealing with slices
<RX14> but not yet
<RX14> read/write_bytes(s) is the 4 methods you want now
<RX14> also jdnoodle it's easy to get caught out with << because it always calls to_s
<RX14> and calling to_s on bytes will just get you a human readable output
<RX14> which is not at all what you want to send on the network
<jdnoodle> yea i noticed that
<jdnoodle> p also seems to do that
<jdnoodle> i noticed there was a hexdump method for uint8 slices though
<jdnoodle> which would be helpful
<jdnoodle> RX14: was there a shortcut for defining initialize method arguments as class instance variables?
<jdnoodle> could of swore there was
<jdnoodle> or maybe that was ruby
<RX14> no
<RX14> im confused
<jdnoodle> if you have def initialize(my_var : String), is there a way you wouldnt have to write @my_var = my_var within the method
<RX14> yes
<RX14> just use @var
<RX14> in the args
<jdnoodle> ah okay
csk157 has joined #crystal-lang
<jdnoodle> RX14: is there a reason why crystal is infering 0x04 as Int32 rather than UInt8 in the call @socket.write_byte 0x04
<Groogy> it always default to Int32, though you should be able to write 0x04u32 I think?
<Groogy> u8 I mean
<Groogy> 0x04u8
<jdnoodle> hmm a bit quirky but it works, thanks
<Groogy> that's just the language. when you write literal integers without a postfix like that it will always assume Int32
<Groogy> when you write 0.01 it will assouble Float64
<Groogy> assume*
<jdnoodle> yea i noticed that sometimes in other projects
<Groogy> need to use it a lot with anything that has to go through opengl
<Groogy> drivers support 64bit floating point but eh... I don't trust it and pretty sure its super slow
<Groogy> especially if you want to support as big range as possible
<RX14> jdnoodle, it's just how the type system works
<RX14> the type system "grows types" out of literals
<jdnoodle> yea
<RX14> so step 1) type literals
<RX14> step 2) infer types of things you can infer types of based on those literals
<RX14> repeat 2 until you have everything typed
<RX14> not really like that but you get the gist
<RX14> it should theoretically be possible to do backwards type inference in basic situations
<RX14> but its not done yet
<jdnoodle> so i was using the wrong function initially in my previous code
<jdnoodle> is there a way to turn the network address string into the 4 bytes in network byte order in crystal?
<jdnoodle> i want to see inet_addr is the function in C but i cant recall
<jdnoodle> say*
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
balduin has joined #crystal-lang
<Groogy> oh god crystal makes everything so simple and the code so pretty compared to my c++ code
<Groogy> also Papierkorb Cute is really making it easy to make sure things are run properly
<Papierkorb> Groogy: to put the logic on the same line as the 'when' use `then`
<Papierkorb> `when X then Y`
<Groogy> ah cool
<Groogy> but yeah because of cute, whenever a child changes the layout is notified and when layout changes it will notify the window that it has to resize to fit
<Groogy> etc.
<Groogy> it "just works"
<Papierkorb> Declarative patterns simply rule
astronavt has joined #crystal-lang
yxhuvud has quit [Read error: Connection reset by peer]
yxhuvud has joined #crystal-lang
aroaminggeek has joined #crystal-lang
<jdnoodle> does anyone know of a crystal method that converts quad dot ip addresses to their hex byte representitives? ex: 127.0.0.1 becomes 7f000001 to be used with IO::write_bytes
snsei has joined #crystal-lang
<jdnoodle> i wrote a one liner for it but was wondering if there was a proper method for use in socket applications
<Groogy> sounds like something there should be already
<Groogy> don't work in that area so no idea though
<yxhuvud> jdnoodle: you are probably looking for ByteFormat.
<jdnoodle> thats the thing, I am using byteformat but i get a compile error for undefined method to_io for string
<jdnoodle> unless im using it wrong
<jdnoodle> @socket.write_bytes(@remote_host, IO::ByteFormat::NetworkEndian)
<jdnoodle> where @remote_host equals "127.0.0.1"
balduin has quit [Remote host closed the connection]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
csk157 has quit [Ping timeout: 260 seconds]
astronavt has quit [Remote host closed the connection]
astronavt has joined #crystal-lang
astronav_ has joined #crystal-lang
astronavt has quit [Ping timeout: 276 seconds]
astronav_ has quit [Remote host closed the connection]
aroaminggeek is now known as aroaminggeek[awa
<FromGitter> <paulcsmith> Is there a way to get the type of a variable inside of a macro? https://play.crystal-lang.org/#/r/385n
<FromGitter> <paulcsmith> And `typeof` doesn't work: https://play.crystal-lang.org/#/r/385o
astronavt has joined #crystal-lang
aroaminggeek[awa has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
astronavt has quit [Remote host closed the connection]
<RX14> no
<oprypin> paulcsmith, it's not a variable, just a literal. that.class would be StringLiteral
<RX14> uhh what oprypin
<RX14> thats a variable to me
astronavt has joined #crystal-lang
<FromGitter> <paulcsmith> Yeah, I'm wondering if I can get the same thing that `typeof(myvar)` would return, but inside of the macro
snsei has quit [Remote host closed the connection]
<RX14> nope
<RX14> impossible
snsei has joined #crystal-lang
<FromGitter> <paulcsmith> Bummer. Thanks for letting me know
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<oprypin> paulcsmith, closest thing https://play.crystal-lang.org/#/r/385r
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<RX14> @paulcsmith macros run before type inference
<RX14> since macros can affect type inference themself
<FromGitter> <paulcsmith> Ahh, I didn't realize that
snsei has quit [Remote host closed the connection]
<RX14> so it's impossible
<FromGitter> <paulcsmith> That makes sense now
astronavt has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<RX14> because you'd get situations where either results dont make sense
<RX14> or that you just end up with something you can't compile
snsei has quit [Remote host closed the connection]
<RX14> imagine you have a macro which does raise if foo is a String
<RX14> and it was a union
<RX14> the contents of that macro affects the type of the variable
snsei has joined #crystal-lang
<FromGitter> <paulcsmith> Yeah good point
<RX14> so it's impossible to resolve
snsei has quit [Remote host closed the connection]
<FromGitter> <paulcsmith> It seems like at this point the compiler knows what the type of `_response` would be. Maybe it's possible, but not right now because Crystal doesn't support it?
<RX14> nope
<RX14> well
<RX14> sure there are some cases where it'd be OK
<RX14> but the general case is that it's not OK
<RX14> and so i'd rather say no everywhere than yes but nobody knows where
<FromGitter> <paulcsmith> Makes sense. Yeah I'd only really need/care about it for raising helpful errors
<FromGitter> <paulcsmith> Most of the time it's unnecessary
<oprypin> how about type annotations
<RX14> oh
<RX14> guess what
<RX14> @paulcsmith make the method generic on T
<RX14> do _response : T
<RX14> then you can use T
<RX14> problem solved
<FromGitter> <paulcsmith> @RX14 I'm not sure I understand. Can I use T to so I can print it in the error message?
<FromGitter> <paulcsmith> @oprypin It did have a type restriction before, but people did not understand what they needed to do to fix it.
<RX14> yeah T is a constant
<RX14> it works because macro defs are run while typing (i presume, not 100%)
<RX14> and when you make the thing generic on T
<RX14> you basically say copy this method for every possible value of T
<RX14> and then you run the same macro for each value of T
<FromGitter> <paulcsmith> I'm probably being super dense here, but how would I do this? Here's what I tried https://play.crystal-lang.org/#/r/385s
<RX14> you forgot forall T
<FromGitter> <paulcsmith> Oh I've never used/heard of that. I'll look it up
<RX14> def foo(bar : T) forall T
<RX14> it's literally for declaring the type variables which can be used in that individual dev
<RX14> just like you use Clazz(T, U) when doing generic classes
<RX14> except this time for methods
<FromGitter> <paulcsmith> Saweet! https://play.crystal-lang.org/#/r/385v
<FromGitter> <paulcsmith> Thank you so much @rx14
<FromGitter> <paulcsmith> That is super cool
<FromGitter> <paulcsmith> And I think I could use `forall` in another method I was writing
<RX14> yup thats how we do generic methods in crystal
<RX14> they're just like generic classes... but only for methods
<RX14> you can also do stuff like
<RX14> def foo(bar : T.class) forall T
<RX14> and then do foo(Bar) and T is now a constant Bar
<RX14> which you can use in macros
<RX14> or do all sorts of cool DSL stuff with
<RX14> which you couldn't before
<FromGitter> <paulcsmith> Yeah this might cleanup a lot of stuff in Lucky. Great tip 👍
claudiuinberlin has joined #crystal-lang
<FromGitter> <lhz> Hi. I am experiencing the same issue as describe in the last couple of comments here when building small docker images and trying to access external resources from inside the container: https://gist.github.com/bcardiff/85ae47e66ff0df35a78697508fcb49af Any ideas what is needed to get it working?
astronavt has joined #crystal-lang
<RX14> have you used docker before
<RX14> where are you running postgres?
<RX14> because that error message says localhost
<RX14> and postgres almost certainly is not running on localhost in docker
<yxhuvud> paulcsmith: sometimes it is possible to get around the macro limitations by extacting a regular method for just the typeof call (or whatever limitation you are working around - I've used it to let me use generic variables - sure you don't see it while the macro is evaluating, but it usually doesn't matter)
snsei has joined #crystal-lang
<RX14> i should build a web framework in crystal
<FromGitter> <paulcsmith> @yxhuvud Very cool. Do you have an example of that?
<FromGitter> <lhz> RX14: well those comments are not mine, I just have a similar issue (No address found) no matter what URL is used (I have my database living on a server somewhere)
<RX14> oh ok
<RX14> well it's the dreaded DNS bug
<RX14> DNS in docker suuucks
<RX14> and crystal uses evented DNS which breaks docker's DNS hacks
vivus has joined #crystal-lang
<RX14> the workaround is to literally shell out to `getent hosts <hostname>` and parse it
<yxhuvud> @paulcsmith, see also line 47, that use the same technique to hide internal types from the user
<RX14> huh
<RX14> i'm wrong?
<FromGitter> <lhz> RX14: Ouch. So I'll need to add quite a bit more to the container then, for that to work.
<RX14> thats weird
<yxhuvud> (and in other news, I need to refactor that code to not be generic all over the place)
<RX14> we should be using libc's getaddrinfo
<RX14> @lhz I think i'm wrong since https://github.com/crystal-lang/crystal/pull/2745
<RX14> which was a long time ago now
<FromGitter> <paulcsmith> @yxhuvud Nice! Thanks for sharing
<RX14> @lhz, just to humor the problem, try using `getent hosts` inside the docker image
<RX14> oh yeah i see why
<RX14> yeah just don't do that @lhz
<FromGitter> <lhz> RX14: well, the image has nothing but my executable and whatever so output by running ldd on it at the moment
<RX14> gnu libc has external dependencies which you're not copying using ldd
<RX14> as libc dynamically loads them itself using dlopen
<RX14> so
<RX14> basically
<RX14> give up and distribute a larger container
<RX14> OR
<RX14> build in alpine linux
<RX14> I recommend the latter
<RX14> alpune linux is much more sane
<FromGitter> <lhz> RX14: okay, I will try that. might as well use alpine as base for the final image too, I probably want to be able to run a shell in there at some point
<FromGitter> <lhz> RX14: thanks!
<RX14> no like
<RX14> just use alpine
<RX14> flat out
<RX14> no special ldd tricks
snsei has quit [Remote host closed the connection]
<FromGitter> <unreadable> I've just realized why manastech called their Sinatra framework clone Frank while listening to Frank Sinatra
<RX14> ...
<FromGitter> <unreadable> well never actually thought of libraries names, I might be wrong though
<FromGitter> <lhz> Getting "in lib/mysql/src/mysql/read_packet.cr:2: IO is not a module, it's a class" during `shards build` when using Dockerfile from crystal-alpine as template.
<FromGitter> <lhz> My app is doing `require "mysql"` since it needs to talk to a mysql database using crystal-db, and somewhere in there it is doing `include IO`.
<FromGitter> <lhz> Is this something that changed between 0.23.1 and 0.24.0-r1?
<RX14> @lhz IO was changed to a class in 0.24.0
<RX14> yes
<RX14> i guess crystal-alpine doesn't have version tags
<RX14> smh
<RX14> fantastic
<RX14> and edit it to say
<RX14> crystal=0.23.1-r1
<RX14> instead of crystal
<RX14> only on the apk install line
<RX14> apk add*
<RX14> and then rebuild it
<RX14> and use that as your base
aroaminggeek has joined #crystal-lang
<RX14> @ysbaddaden it would be great if you tagged https://hub.docker.com/r/ysbaddaden/crystal-alpine/ with concrete versions of crystal
<FromGitter> <lhz> RX14: thank you, that got me further, looks like I need some more packages for -lssl, -lcrypto and -lz to be available.
<RX14> you just need to RUN apk add openssl-dev libz-dev i think
<RX14> let me check those package named
<RX14> let me check those package names
<RX14> it's openssl-dev and zlib-dev @lhz
<RX14> apk add --update openssl-devzlib-dev
<RX14> apk add --update openssl-dev zlib-dev
<FromGitter> <lhz> RX14: that did the trick, thanks a bunch!
<RX14> no problem
aroaminggeek is now known as aroaminggeek[awa
aroaminggeek[awa is now known as aroaminggeek
alex`` has quit [Ping timeout: 240 seconds]
<hightower2> Yo, I have code which works fine on Crystal 0.23 and on Crystal 0.24 it produces compile time error: no overload matches 'MyClass.to_yaml' with types (Bool | Enumerable(Int32) | Int32 | Proc(Int32, Bool)), YAML::Nodes::Builder
<hightower2> Is this something known related to YAML or?
<hightower2> Hm looks like at least one incompatibility is in Time.new()
<RX14> did you uhh
<RX14> try reading the error
<RX14> by inspection you need to make the kind a named argument now
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
vivus has left #crystal-lang ["Leaving"]
<FromGitter> <sam0x17> does crystalshards.xyz just crawl github or is there manual submission somewhere?
<Papierkorb> it uses github
<FromGitter> <sam0x17> thx
sz0 has quit [Quit: Connection closed for inactivity]
aroaminggeek has quit [Read error: Connection reset by peer]
aroaming_ has joined #crystal-lang
faustinoaq has quit [Quit: IRC client terminated!]
faustinoaq has joined #crystal-lang
<hightower2> RX14, it seems I need to use named arguments for more than just kind: (I need to use them for hour, day, minute, second, and millisecond). But then I run into the issue that the place for "millisecond" in 0.24 code contains * in that place, so if I just put ms value, it tells me it expects named argument, and if I put millisecond: ms, it tells me 'no argument named millisecond'
<hightower2> RX14, so I had to work around that by specifying nanosecond: ms*1000
<RX14> uhh what
<RX14> no you do not need to use named arguments for those
<RX14> the solution is that there *is no milliseconds argument* any more
<Papierkorb> hightower2: 1000ns = 1µs
<hightower2> Papierkorb, right, thanks
<RX14> hightower2, you want Time.new( y, m, d, h, min, sec, nanoseconds: ms * 1_000_000, kind: Time::Kind::Unspecified)
<RX14> that works
<RX14> you'll get the hang of calling functions with enough practice
<RX14> Papierkorb, do you read the mailinglist?
<Papierkorb> I lurk on it, why?
<RX14> do you understand this latest eamil from Benny
<RX14> email*
aroaming_ is now known as aroaminggeek[awa
<Papierkorb> besides the rambling you mean?
<RX14> yes
<Papierkorb> Nothing to answer to, no
<RX14> he seems to imply that because I said reinventing one wheel in crystal is useless, the entirely of crystal is useless
<Papierkorb> Maybe it'd be nice to at least fix up that big snippet someone shared into something more crystal-y. besides that, thread's over I guess?
<RX14> which is like what
<Papierkorb> ¯\_(ツ)_/¯
<Papierkorb> Whatever someone would respond, the possibility of talking besides one another is super big. People made their point, and right now, there's not much that can be /actually/ improved for anyone involved in that thread. /thread
<hightower2> What can I use instead of Time#ticks that existed in 0.23?
<RX14> what are you using it for
<hightower2> RX14, I was using it as a single-number representation of Time that can then be used for math and feeding back into Time.new. It seems to me that now I could use epoch_f for comparisons, and multiplying it by some factor when I want to feed it back into Time.new( nanoseconds: ...)
<RX14> you know
<RX14> adding times doesn't make sense
<RX14> like that doesn't really answer the question
<RX14> what exactly kind of math do you want to do to TIme that it doesn't already let you hightower2?
<hightower2> The math was done on spans
<RX14> oh ok
<RX14> you want to multiply/divide timespans?
<hightower2> RX14, I have a replacement for the "Time" class which I've made to support "partial" dates, like e.g. I can define MyTime.new( month: 3, year: 2017), and this is a partial date whose all other fields are nil (I can't do this with regular Time class because in it all unspecified fields (those that can be unspecified) default to 0)
<hightower2> So it's not clear if the user really wanted to specify 0, or he wanted to leave the fields unspecified
<hightower2> Anyway, long story short, it's a system for doing various types of matching on these MyTime objects
<Papierkorb> What was wrong with #ticks? It's nice as precise timestamp
aroaminggeek[awa is now known as aroaming_
<RX14> Papierkorb, because it leaked the internal definition of Time
<RX14> and basically
<RX14> we changed the way Time is implemented (in my opinion a dumb way)
<RX14> to store seconds and nanoseconds in 64bit fields
<hightower2> Though doing x= Time.ticks; t= Time.new( x) is a bit harder now
<RX14> it's stupid because you're essentially implementing fixed point in Time
<RX14> hightower2, yes because times are described by 2 fields
<Papierkorb> wasn't there a push to support int128?
<RX14> yes Papierkorb
<RX14> you could have done the whole thing just find with 2 UInt64 fields
<RX14> but it got merged regardless
<Papierkorb> Which should represent Time until a point we're all ashes due to the heat death of the universe at which point we have bigger issues than Crystals Time type going bonkers?
<RX14> and now it's more complex for little gain
<RX14> Papierkorb, exactly
<RX14> now we have all the problems of essentially mixing base-10 and base-2
<hightower2> Now when I sum nanoseconds I'll need to check if they overflow into a second, before I can call Time.new( seconds, nanoseconds)
<Papierkorb> RX14: all your base belong to Time
<Papierkorb> lul
<RX14> ...
<RX14> hightower2, yep
<RX14> actually the time ctor does that for you
<hightower2> RX14, does it? I was looking at initialize which says: unless 0 <= @nanoseconds < NANOSECONDS_PER_SECOND raise ArgumentError.new "Invalid time: nanoseconds out of range" end
<RX14> huh
<RX14> i thought it did
<RX14> my bad
aroaming_ has quit [Ping timeout: 248 seconds]
aroaminggeek has joined #crystal-lang
<RX14> i'm off, night
<hightower2> RX14, so, my best bet is to use epoch_f?
<hightower2> Thanks
<RX14> for simplicity yes
<RX14> but you will loose precision
<RX14> :((
<hightower2> Well, simplicity is out of the door, things become more complicated with these changes
<hightower2> I also need a macro to detect pre and post 0.24 :)
<Papierkorb> {% pre_24 = Crystal::VERSION < "0.24.0" %}
<hightower2> Papierkorb, yes, (with having in mind that this pre-24 is identified as 0.23.0+313 in Crystal::VERSION, lol)
<Papierkorb> that +313 stuff is your distro, mine is flat "0.23.1"
<hightower2> I downloaded the tgz
<hightower2> from the website
<hightower2> From https://github.com/crystal-lang/crystal/releases I mean, from the 0.24.0 section
<hightower2> Really unnecessary hassle now
<RX14> Papierkorb: there might possibly be a version compare function by default as a macro method
<Papierkorb> compare_version or something
<RX14> https://crystal-lang.org/api/0.23.1/Crystal/Macros.html#compare_versions%28v1%3AStringLiteral%2Cv2%3AStringLiteral%29%3ANumberLiteral-instance-method
<RX14> Yup
<RX14> Use that hightower2
<RX14> It handles the build number stuff for you
<RX14> Also Papierkorb its not the distro
<RX14> We add it when you build the compiler from git
<Papierkorb> *distributor
<RX14> Its the number of commits since the tag version