<FromGitter>
<proyb6> @Blacksmoke16 Yup, your code work but I think I could use.includes? to first check if the string is exist before adding a gsub to the variable so that I can reduce unneeded gsub
<FromGitter>
<Blacksmoke16> what are you trying to do?
<FromGitter>
<proyb6> If it's possible to add chaining dynamically?
<FromGitter>
<Blacksmoke16> maybe a macro?
<FromGitter>
<Blacksmoke16> but not matter the solution it sounds like it wont be the most optimal thing
<FromGitter>
<proyb6> To replace user input text and sanitize macilious code
<FromGitter>
<proyb6> I see, maybe a string.build is optimize
<FromGitter>
<Blacksmoke16> but how would you know what to build?
<FromGitter>
<proyb6> Haven't try, have advice?
<FromGitter>
<jeffmikels> Does anyone have experience using audio devices from crystal? I want to be able to send audio data directly to the audio device of a system.
<FromGitter>
<Blacksmoke16> i do not sorry
<FromGitter>
<Blacksmoke16> to both questions :p
<FromGitter>
<Blacksmoke16> @proyb6 if you put together an example maybe?
Dreamer3_ has joined #crystal-lang
<FromGitter>
<proyb6> Will try tonight, 20 hours time ;)
<FromGitter>
<kinxer> I'm doing some (intentionally) wonky stuff with `from_json` in the superclass (`A`, in this case), so I didn't include `JSON::Serializable`.
<FromGitter>
<redcodefinal> Oh duh I forgot that I had the change the method entirely after the fact. My original macro wasn't working because of the invalid escape sequence problem. I wanted to out a single char, not a string, but it wouldn't let me use `'\x99'`. Do you know why `"\x99"` is ok but `'\x99'` throws an error?
<FromGitter>
<Blacksmoke16> `'` denotes a char type
<FromGitter>
<redcodefinal> looked through all the `Crystal::Macro::ASTNode`docs and I didn't see a method I could use for converting a `NumberLiteral `to hex
<FromGitter>
<Blacksmoke16> hmm
<FromGitter>
<Blacksmoke16> yea i dunno mate
<FromGitter>
<redcodefinal> Yeah yours actually looks like it should work
<FromGitter>
<redcodefinal> When I space out the lines in crystal play it specifically complains about the first {{
<FromGitter>
<j8r> but since now I prefix all vars with `__`, they are considered as reserved - not needed anymore
<FromGitter>
<bew> Ah indeed, forgot about that behavior, sorry
DeBot has joined #crystal-lang
<FromGitter>
<rabingaire> Hello I want to contribute to Crystal project, The only experience I have on compiler design is that I have taken Compiler Design Course when I was on College, I have worked on ruby well enough to understand the crystal code but I am confused how to build the project for the development purpose can any of you guys help me get started.
<RX14>
but the assertion failure i couldn't understand
<FromGitter>
<asterite> RX14: it's just `brew install crystal` :-)
<RX14>
@asterite yeah but then you need to do a bunch of fiddling to work on crystal itself
<RX14>
a bunch of arcane xcode and brew commands which make little sense
<jhass>
the problem is that homebrew is not apples child so it has to fight against apples way of doing things
<RX14>
linux you just run `make`
<RX14>
and it's already working
<RX14>
jhass, exactly
<RX14>
ok, on archlinux you just run `make`
<RX14>
debian is a little different
<jhass>
and apple not providing anything remotely being a replacement of course
<RX14>
apple is a great developer OS*
<RX14>
*for interpreted languages
<jhass>
idk, I always forget to homebrew upgrade for weeks and then all the little tools updating and nagging on their own but some... it's a mess
<RX14>
btw i use arch :)
<jhass>
some stuff even is in the old windows days of oh btw there's a new version click here to go to the website and do all the same stuff you did to get me in the first place
<FromGitter>
<rabingaire> Don't know about language design but for general programming osx is great but still it's only my opinion
<RX14>
yeah, on balance it's probably better than linux for most devs
<RX14>
but it'd annoy me too much
<FromGitter>
<f1refly_gitlab> In my experience apple os is for devs who don't really care about computers
<FromGitter>
<rabingaire> I got this after I ran make
<FromGitter>
<drum445> Fair, XFCE for me
<FromGitter>
<rabingaire> what's happening here ??
<FromGitter>
<j8r> Me not too, this is why I want to have the more minimal, easy to use, distro possible. BSDs and Alpine fits this, but for now quite limited for Desktop use - packages and configurations are missing
<FromGitter>
<bew> @rabingaire well it's compiling, let it finish!
<jhass>
rabingaire: it's building
<FromGitter>
<rabingaire> it stoped after spitting those logs
<RX14>
yeah it takes a minute or two
<FromGitter>
<f1refly_gitlab> How can one even do anything with a tiling wm? i tried it for a week and almost went insane
<FromGitter>
<bew> I've written some ideas about what I'd like the lemonade framework to be, if you agree or have comments/other idea, feel free to open issues
<FromGitter>
<f1refly_gitlab> I'll check it out when i have some time :)
<FromGitter>
<bew> np :)
<FromGitter>
<rabingaire> I got two files `crystal` and `crystal.dwarf`
<FromGitter>
<rabingaire> is this what I was supposed to get ??
<RX14>
I'm probably going to end up making my own bar because its too small and too fun of a task not to nih
<FromGitter>
<bew> Totally true, please tell me when you have something somewhat usable :)
<RX14>
i'll make sure to tell you in 2020
<FromGitter>
<f1refly_gitlab> @rabingaire `crystal` is probably the compiler, run it to make sure
<FromGitter>
<bew> @rabingaire yes it's normal
<FromGitter>
<bew> crystal is the compiler, the other is debug info
<FromGitter>
<bew> (for when the compiler crashes iirc)
<FromGitter>
<bew> Whenever you're ready rx14 👍
<livcd>
RX14: interesting I was also looking into making a bar / simple bspwm thing recently
<FromGitter>
<rabingaire> Yep I am getting -dev version
<RX14>
@rabingaire once you compile the compiler with `make crystal` it's in .build/crystal
<RX14>
and then you can use bin/crystal
<RX14>
which uses the compiled compiler with the stdlib in the git repo
<FromGitter>
<f1refly_gitlab> or better copy `crystal` to somewhere in your PATH
<RX14>
no, that's worse
<RX14>
far worse
<RX14>
if you do that it probably wont be able to find the stdlib
<RX14>
and other stuff
<RX14>
thats why we have the bin/crystal wrapper script
<RX14>
plus you dont want development crystal to be your main crystal
<FromGitter>
<f1refly_gitlab> Unless you want exactly that :D
<RX14>
then add /path/to/repo/bin to PATH
<FromGitter>
<giuseongit> Hi folks, I'd like to run crystal on my raspberry pi, apt tells me it cannot find `crystal` package for `armhf` arch. I did a quick search and the last thread talking about it dates back to at least one year ago. Is it possibile to install crystal on the rbpi without having to cross-compile the compiler from x86 to arm?
<RX14>
copying .build/crystal or bin/crystal to somewhere else will break the install @f1refly_gitlab
<RX14>
@giuseongit you have to cross-compile or use something someone else has cross-compiled
<RX14>
if I had time i'd get crystal's CI and stuff sorted but...
<FromGitter>
<rabingaire> I just wanted to see what's being passed at this method as a params
<FromGitter>
<giuseongit> I'll try in the next week if I can find something, otherwise I'll have to compile the compiler. I just wanted to write a low-level interface for the GPIO, it could open an entire new market for crystal itself
<RX14>
@giuseongit I wrote a tutorial on cross-compiling on stackoverflow
<FromGitter>
<bew> @giuseongit true! I'd be interested if you manage to get sth working wrt gpio :)
<RX14>
i'm sure you've seen it
<FromGitter>
<giuseongit> @bew I'd like to have a working crystal compiler on arm to avoid any issues a kickstart the interface development
<FromGitter>
<giuseongit> it isn't difficult, after all, you only have so handle a bunch of file descriptors
<FromGitter>
<giuseongit> but considering that the largest market share for iot development goes to python (which can be slow/resource-consuming on arm) I felt that crystal would be a nice, light-weight, high level programming language to use
Renich has joined #crystal-lang
<FromGitter>
<giuseongit> still, I don't have much time as I'm working on it in my spare time
<FromGitter>
<Aaron-Fleisher> Really been enjoying Crystal lately. Works very well for the game server. The doc pages are very nice as well, love the inline examples they show!
<FromGitter>
<bew> @giuseongit I second that ;)
<FromGitter>
<kinxer> Is this expected behavior: https://play.crystal-lang.org/#/r/5n8z ? I'm trying to `include JSON::Serializable` in an intermediary superclass but then serialize a collection of the highest-level superclass. I can fix it by moving the `include JSON::Serializable` to `Specific` (https://play.crystal-lang.org/#/r/5n90), but I'm wondering if this difference is intentional.
<FromGitter>
<drujensen> there might be a better way of doing that. I personally think the macro is a little hacky
non-aristotelian has joined #crystal-lang
<FromGitter>
<rabingaire> Hey Guys Do I have to recompile when I change code on the source file of the compiler
<jokke>
yes
<FromGitter>
<rabingaire> for example if I have kept puts on some method and want to check what value is passed
<jokke>
what?
<FromGitter>
<rabingaire> I need to recompile it and throw a simple program and see logs
<jokke>
i have no idea what you mean, sorry :/
<FromGitter>
<rabingaire> Haha My bad
<jokke>
if you change anything in crystal/compiler you will obviously have to rebuild crystal and only after that your changes will be visible the next time you compile something
<FromGitter>
<rabingaire> exactly i was asking if there is some sort od automation
<FromGitter>
<Blacksmoke16> be sure to reference the compiled crystal binary not the one installed on sys
<FromGitter>
<rabingaire> *of
<FromGitter>
<Blacksmoke16> `./bin/crystal`
<FromGitter>
<rabingaire> Ok got it guys I was looking if there is automation or something
<FromGitter>
<rabingaire> It kind of hard to recompile time and again on simple changes on the code
<FromGitter>
<rabingaire> but it's a compiler not some sort of javascript framework haha
<RX14>
@rabingaire you can use something like http://entrproject.org/ to run make crystal for you
blassin has quit [Ping timeout: 264 seconds]
<FromGitter>
<kinxer> Is it recommended to avoid using `JSON::Any`?
blassin has joined #crystal-lang
<FromGitter>
<rabingaire> Thanks @RX14
<FromGitter>
<rabingaire> I will try it
<FromGitter>
<j8r> @kinxer if you want perf and nice Object abstractions, yes
<FromGitter>
<j8r> Any will parse the whole document
DTZUZO has joined #crystal-lang
<FromGitter>
<kinxer> @j8r Gotcha. I'm working on a library for working with geoJSON in an OO manner, and I'm currently trying to figure out how to de-serialize a JSON array of geometry objects (which is an abstract class/category) into their specific types of geometries.
<FromGitter>
<sdogruyol> @j8r have you ever got any stacktrace on alpine?
<FromGitter>
<j8r> @sdogruyol when compiling statically? nope
<FromGitter>
<sdogruyol> yeah, I just used your dockerfile for static compilation
<FromGitter>
<sdogruyol> it works until it's broken :P
<FromGitter>
<sdogruyol> thanks a lot for the doc
<FromGitter>
<j8r> yes I wouldn't be surprised that's its broken now
<FromGitter>
<j8r> because of openssl-libressl change
<FromGitter>
<kinxer> Given that you're using exceptions as part of your logic, I think you're going to have to go with `begin...rescue`. However, you can replace `rpc.nil?` with `!rpc`.
sz0 has joined #crystal-lang
<FromGitter>
<kinxer> Also, your `method_missing` macro usage that turns the method call into an HTTP POST is interesting but makes it a little difficult to read at first.
<FromGitter>
<greenbigfrog> TBH I had no idea how that shard actually worked in detail the first time I used to it :)
<FromGitter>
<dscottboggs_gitlab> but each example should still output four times?
<oprypin>
no. you're starting from the last item and going forward from there
<FromGitter>
<dscottboggs_gitlab> https://crystal-lang.org/api/0.27.0/Indexable.html#each_index%28%2A%2Cstart%3AInt%2Ccount%3AInt%2C%26block%29-instance-method ⏎ ⏎ > Negative indices count backward from the end of the array. (-1 is the last element).
<oprypin>
waaait a second , yeah I just reached that point
<FromGitter>
<dscottboggs_gitlab> I got a working version https://carc.in/#/r/5ndp but I think I should file a bug for that other sample
<oprypin>
dscottboggs_gitlab, well it's just confusingly worded. nothing actually counts backward, it just sets the starting point differently
<FromGitter>
<dscottboggs_gitlab> OHHH
<oprypin>
if there was some mistake there, the example would have been wrong, but it's correct
<FromGitter>
<dscottboggs_gitlab> I see
<FromGitter>
<greenbigfrog> How would I go about getting the output of `Process.run` in a string?
<FromGitter>
<dscottboggs_gitlab> in your case can you use the backtick-method?
<FromGitter>
<kinxer> @greenbigfrog It's not really much of an improvement, but it arguably looks a little cleaner and is one line shorter. You're welcome, though.
<FromGitter>
<greenbigfrog> Yep 😄
<FromGitter>
<j8r> what's the diff between `Process::Redirect::Pipe` and `IO::Memory`
<FromGitter>
<greenbigfrog> What are you trying to say @oprypin
<oprypin>
greenbigfrog, i linked you to a code example how to get output :D
<FromGitter>
<j8r> lol
<oprypin>
BUT don't use `shell: true`
<FromGitter>
<greenbigfrog> ah. now I see :)
<FromGitter>
<j8r> @oprypin do you know any advantage of `Process::Redirect::Pipe` vs `IO::Memory`?
<oprypin>
no
<oprypin>
i'm actually thinking really hard about this - why even provide an IO overload if getting the output is this easy
<FromGitter>
<greenbigfrog> If I remove `shell: true`, I get `Unhandled exception: execvp: No such file or directory: No such file or directory (Errno)`
<FromGitter>
<j8r> for example redirect to a socket? But yeah for IO::Memory it's useless
<FromGitter>
<dscottboggs_gitlab> without shell=true you need the acutal file you're executing
<FromGitter>
<dscottboggs_gitlab> then the arguments need to be in a list form
<FromGitter>
<j8r> @greenbigfrog you are using file globing?
<FromGitter>
<j8r> I think I''ll refactor the shard to replace IO::Memory
<oprypin>
j8r, i don't think that would be an overall improvement
<FromGitter>
<dscottboggs_gitlab> does that pay mind to quoted strings when it uses the shell-like syntax?
<oprypin>
no
<FromGitter>
<j8r> Maybe I'll only keep the parsing thing, and return a `Process`
<oprypin>
returning a wrapper with both output and status is a good thing
<oprypin>
j8r, actually yeah that would be an improvement
<oprypin>
j8r, but the biggest gap in your lib is that there is no way to *not* consume output. what if I want to just print it out some of the time? well, actually, now that I think about it, that would be Process.run :D
<FromGitter>
<dscottboggs_gitlab> oprypin I don't see that much of a difference between `Process.run` and `subprocess.run` or between `Process.exec` and `subprocess.Popen`
<FromGitter>
<dscottboggs_gitlab> when I'm writing python I usually use Popen these days because why not have concurrency
<oprypin>
crystal also really needs https://docs.python.org/library/shlex.html but i don't think there is any shard for that. this would fix all those `split(" ")` dangers
<FromGitter>
<dscottboggs_gitlab> ooh that's cool
<FromGitter>
<j8r> a minimal cut-off shell parser
<FromGitter>
<j8r> my shard is an even more basic lexical analyser
<oprypin>
technically true
akaiiro has quit [Ping timeout: 268 seconds]
<FromGitter>
<kinxer> I've seen discussion of the Crystal standard library avoiding methods with multiple aliases (e.g. `String#size` AND `String#length`); is this recommended style for community shards as well or just a goal for the standard library?
<FromGitter>
<dscottboggs_gitlab> I believe one of the goals of crystal is to avoid unnecessary aliases in general, yes
<oprypin>
kinxer, i have not seen any deviations between crystal's own style and the generally recommended style