<FromGitter>
<Blacksmoke16> Also passing in the second arg?
<FromGitter>
<EriKWDev> Well, I didn't really know what to pass there so the errors might have come from that.. xP ⏎ How do I pass a pointer to a Void?
<FromGitter>
<EriKWDev> (Or is it just a pointer to anything?)
<FromGitter>
<Blacksmoke16> Dunno, my assumption was void values are essentially ignored
<FromGitter>
<Blacksmoke16> Like when you need to define a type but aren't using the value
<FromGitter>
<EriKWDev> I'll have to read the real C implementation/documentation of Cairo's method to understand what that "closure" Pointer is supposed to be..
<riffraff169>
apparently the function is what does the actual write, it appears...
alexherbo2 has quit [Ping timeout: 272 seconds]
<FromGitter>
<Blacksmoke16> @watzon what ever became of that CLI lib you were working on
sampope has joined #crystal-lang
sampope has quit [Client Quit]
deavmi has quit [Ping timeout: 264 seconds]
deavmi has joined #crystal-lang
<FromGitter>
<EriKWDev> > *<riffraff169>* apparently the function is what does the actual write, it appears... ⏎ ⏎ Yeah, I want to use Cairo to generate PNGs and then pipe them out to the STDOUT. I'm having trouble now translating the data: *UInt8 nad and size: UInt32 into a Bytes that can be used with STDOUT-write ....
<FromGitter>
<ilourt> @Blacksmoke16 Yes I have already seen https://github.com/amberframework/granite/issues/358. The problem is that it is still an open issue. IMHO the problem is that it is not possible to disable validations in granit. In my case I prefer to use a dedicated lib: https://github.com/Nicolab/crystal-validator. I am more in favor of the unix philosophy of each lib do only one thing
alexherbo2 has joined #crystal-lang
frojnd has joined #crystal-lang
<frojnd>
Hi there
<frojnd>
This should be like the most used parser for crystal: https://github.com/kostya/myhtml/tree/master/examples Now I have problem reading docs/or source code/ My issue is Within `content = parser.css(".bt_bb_wrapper p, .bt_bb h3").map(&.inner_text).to_a` (which nicely gives me desired content) I would like to create some sort of switch statemet to match beginning of the word.
<frojnd>
Like this: content.each {|content| if content.begins_with "Petition:" # do stuff}
<frojnd>
Hm But why shouldn't I be able to do this...
<frojnd>
I already have array with strings :) Ok Ithink this is just a matter of regex matcher
<frojnd>
It even has starts_with? nice
<alexherbo2>
how to display a character unicode point and the inverse?
<FromGitter>
<riffraff169> ah thats right...i just rarely see it not with plain words...
<FromGitter>
<riffraff169> made me think it was something else
<FromGitter>
<riffraff169> and the debot is something that automatically gets created and posted if you do code preceded by `>>` ?
<jhass>
it's an IRC bbot
<jhass>
*bot
<FromGitter>
<riffraff169> interesting, cool
<mps>
RespiteSage: re: yesterday bug, looks like it is problem in libgc (garbage collector lib) not crystal
<frojnd>
I have .ics calendar... any ideas how can I use/extract data with crystal from that file?
<FromGitter>
<Blacksmoke16> Write a parser for it
<FromGitter>
<Blacksmoke16> Or some fancy regex
<frojnd>
How would one write a parser with no prior knowladge of writing parsers
<FromGitter>
<Blacksmoke16> to google! :p
<FromGitter>
<Blacksmoke16> i assume its in some structure format?
<frojnd>
yes
<FromGitter>
<Blacksmoke16> so i imagine you'll just iterate over each line and do something based on what the key is
<frojnd>
Yeah
<FromGitter>
<Blacksmoke16> @ilourt yes thats the point. The built in validation lib is whats preventing inheritance support. So by removing it, the problem is now moot
<FromGitter>
<Blacksmoke16> granite columns support annotations, so dont need another DSL for defining them
<FromGitter>
<christopherzimmerman> Is there a way to take a passed `Proc` return the same proc just with a changed signature, taking different input types?
<oprypin>
christopherzimmerman, no you have to implement a proc that accepts the types, converts, and calls the prior proc
<FromGitter>
<christopherzimmerman> Well, it feels a bit hacky, but a macro reduces the boilerplate a bit, so now I have automatic differentiation of arbitrary functions:
<frojnd>
So I have this .ics file and using just grep I can get desired string like this: grep -B 1 "30.10.2020" file.ics | grep -Po '^(?:.*?\\n){2}\K.*?(?=\\n)' I have no idea how would I match that in crystal. First I assume I would have to read file and load it and then perform similar regex somehow?
<FromGitter>
<Blacksmoke16> @emanzx id assume the latter
<FromGitter>
<Blacksmoke16> given thats the purpose of the method
<FromGitter>
<emanzx> ok thanks @Blacksmoke16
<FromGitter>
<Blacksmoke16> could also do `File.open "test.txt", "w" &.truncate`
<FromGitter>
<emanzx> > could also do `File.open "test.txt", "w" &.truncate` ⏎ ⏎ this looks better thanks.
<frojnd>
Can i load result from bash script into crystal variable?
<frojnd>
That would be second option :P
<FromGitter>
<Blacksmoke16> frojnd, its possible to run a system command and get the result back as a string yes
<FromGitter>
<j8r> From the docs: ⏎ ⏎ > w+ | Read-write, truncates existing file to zero length or creates a new file if the file doesn't exist.
<FromGitter>
<Blacksmoke16> huh, fair enough
<FromGitter>
<j8r> There is no difference between File.new and File.open?
<FromGitter>
<j8r> by reading the code, no...
<FromGitter>
<Blacksmoke16> open closes it after the block yields
<FromGitter>
<j8r> the non yielding one
<FromGitter>
<Blacksmoke16> otherwise you have to manually close it if you use .new
ua has quit [Ping timeout: 264 seconds]
<FromGitter>
<j8r> `File.open("text.txt")` works, like `File.new("text.txt")`
<FromGitter>
<Blacksmoke16> oh
<FromGitter>
<Blacksmoke16> :shrug: *alias*
<oprypin>
there were some discussions which one should be deprecated
deavmi has quit [Ping timeout: 268 seconds]
deavmi has joined #crystal-lang
ua has joined #crystal-lang
<FromGitter>
<emanzx> guys.. if we declare a variable in a fiber and when the fiber end does the variable got cleared? or it wait for garbage collector to clear it?
<FromGitter>
<Blacksmoke16> id imagine the latter
<FromGitter>
<Blacksmoke16> at least the memory held by that var
<FromGitter>
<emanzx> lazy question, anyway to clear the var and return the memory to system
<FromGitter>
<emanzx> just var=nil?
<FromGitter>
<Blacksmoke16> you can manually do a GC cycle, but whats the use case?
<FromGitter>
<Blacksmoke16> whats the end goal here?
<FromGitter>
<emanzx> im reading a large file
<FromGitter>
<emanzx> not slurping but just take a large portion of the file and save it in variable and send to DB.. this run every minute by spawning a fiber each minutes that read the file.. the process mostly take about less than a minute.. and finish..
<FromGitter>
<emanzx> I saw the memory increase and decrease
<FromGitter>
<emanzx> but some of other worker I saw large memory use.. more than 2GB or memory use..
<FromGitter>
<Blacksmoke16> i mean if you're loading in a 2GB file into memory its going to use at least 2GB of memory
<FromGitter>
<emanzx> sadly.. its not like that..
<FromGitter>
<emanzx> im only loading a 100m or less file
<FromGitter>
<emanzx> but it seem increasing a lot..
<FromGitter>
<emanzx> im not sure if it just my code or other dependency..
<FromGitter>
<Blacksmoke16> :shrug: without seeing the code its hard to say
<FromGitter>
<HertzDevil> i'd start by replacing `JSON.parse` with `JSON::Serializable` since you're expecting the same fixed json format every time you read a file
<FromGitter>
<Blacksmoke16> then you can tap into granite's log and it just works
<FromGitter>
<Blacksmoke16> i.e. you'll be tapped into the log system and not just consuming the output
<FromGitter>
<emanzx> > i.e. you'll be tapped into the log system and not just consuming the output ⏎ ⏎ what do you mean taping on granite log?
<FromGitter>
<Blacksmoke16> idk, i just saw some Granite ORM stuff and assumed you were consuming the logs generated by its logging
<FromGitter>
<emanzx> no.. I actually consuming the BIND9 query log..
<FromGitter>
<Blacksmoke16> and whats generating those logs? non crystal code?
<FromGitter>
<emanzx> > i'd start by replacing `JSON.parse` with `JSON::Serializable` since you're expecting the same fixed json format every time you read a file ⏎ ⏎ yes.. I should have done that.. I will try to improved it soon.. thanks
<FromGitter>
<emanzx> > and whats generating those logs? non crystal code? ⏎ ⏎ its BIND9 DNS server it self..
<FromGitter>
<Blacksmoke16> ah alright
<FromGitter>
<Blacksmoke16> nvm then, `Log` isnt what you want then
<FromGitter>
<emanzx> btw while we at it I have few question.. one is this... error while i compile my code.. it seem as a warning only..
<FromGitter>
<Blacksmoke16> it means you (or one of your dependencies) are using the `Logger` type
<FromGitter>
<Blacksmoke16> like `require "logger"` when thats deprecated in favor of `Log` module instead
<FromGitter>
<emanzx> and if I use --static argument my code will not able to connect to the DB.. not sure if it has problem with granite code..
<FromGitter>
<Blacksmoke16> are you building in an alpine image?
<FromGitter>
<emanzx> > it means you (or one of your dependencies) are using the `Logger` type ⏎ ⏎ oh.. so I just need to update my dependency then cause I use none on my code :P
<FromGitter>
<Blacksmoke16> prob
<FromGitter>
<Blacksmoke16> assuming your deps are still maintained
<FromGitter>
<emanzx> > are you building in an alpine image? ⏎ ⏎ in FreeBSD 12.1
<FromGitter>
<Blacksmoke16> to build a static binary you'd have to build in alpine linux
<FromGitter>
<emanzx> @Blacksmoke16 how big batch_size for amber/granite can accept? when I set it above 1000 it just crash with Arithmetic overflow exception error
<FromGitter>
<Blacksmoke16> are you using the `.import` method?
<FromGitter>
<Blacksmoke16> nvm, obs are
<FromGitter>
<Blacksmoke16> can you share the error?
<FromGitter>
<emanzx> yes..
<FromGitter>
<emanzx> Im wraping in rescue this is the backtrace I got [Sender] Exception backtrace:["__crystal_sigfault_handler", "__crystal_sigfault_handler", "__crystal_sigfault_handler", "Fiber::swapcontext<Pointer(Fiber::Context), Pointer(Fiber::Context)>:Nil"]
<FromGitter>
<Blacksmoke16> and whats the exception message?
<FromGitter>
<Blacksmoke16> looks like you got a segfault, not an overflow?
<FromGitter>
<emanzx> maybe I just remove the rescue
<FromGitter>
<emanzx> Unhandled exception in spawn: Arithmetic overflow (DB::Error) ⏎ from __crystal_sigfault_handler ⏎ from __crystal_sigfault_handler ⏎ from __crystal_sigfault_handler ⏎ from Fiber::swapcontext<Pointer(Fiber::Context), Pointer(Fiber::Context)>:Nil [https://gitter.im/crystal-lang/crystal?at=5f9c5118b86f6407041ef0da]
<FromGitter>
<emanzx> do I need to do something to increase the batch size? in my OS..
<FromGitter>
<Blacksmoke16> :shrug:
<FromGitter>
<emanzx> nvm.. this mean its too much for me.. haha.. sticking with 1000 batch size..
<mps>
ok, crystal on alpine is fixed by rebuilding 'gc' with ./configure option '--disable-parallel-mark'
<mps>
but now with 'make compiler_spec' it sigfaults with '..Invalid memory access (signal 11) at address 0x7f72e8253378'
<mps>
jhass: sorry to annoy you but I see that the 'make spec' is 'disabled' on Arch linux. did you tried it and if does it shows these problem
<jhass>
mps: it's split on arch and CI because it consumes too much memory for the build environments. I don't think anybody reevaluated that recently
<jhass>
--disable-parallel-mark seems like a bad solution, I guess it simply disables any threading done by libgc
<mps>
jhass: that option fixes some other packages from hangs, not only crystal
<jhass>
I'm just saying it seems like a crude workaround rather than a fix
<mps>
we will see if the new musl 1.2.2 will have something better for this
<jhass>
I'm sure it makes things considerably slower
<mps>
well, looks like 'gc' have more serious issues than this, according to bug reports
<mps>
main issue 'gc' doesn't use MT-forks properly, I think
<mps>
and not only 'gc' but a lot of software around
companion_cube has joined #crystal-lang
<mps>
btw, how core crystal developers can be contacted, except github where I don't have account (and will not open it)
v2px__ has quit [Ping timeout: 240 seconds]
davic has quit [Ping timeout: 260 seconds]
davic has joined #crystal-lang
r0bby has quit [Ping timeout: 240 seconds]
r0bby has joined #crystal-lang
<FromGitter>
<Blacksmoke16> maybe the forums?
<mps>
Blacksmoke16: yes, I thought about it, I'm subscribed there