<hightower2>
yeah Ruby's method does it. The docs show only 3 examples of what it parses, but it parses a whole bunch of formats.
<hightower2>
(I mean the parse() functions in Date, Time, and DateTime)
<hightower2>
<hightower2>
If a C function takes 'int' argument, what type is that in LibC::* ?
<hightower2>
(such as char *index(const char *s, int c))
<FromGitter>
<Blacksmoke16> `LibC::Int`?
<FromGitter>
<Blacksmoke16> i think thats a thing
<hightower2>
Undefined constant LibC::Int
<FromGitter>
<Blacksmoke16> uh
<hightower2>
hm but it does exist as alias for Int32 in crystal/src/lib_c.cr
<FromGitter>
<Blacksmoke16> right
<hightower2>
I must be missing something
<hightower2>
specifying it as ::LibC::Int works, LibC::Int doesn't, at least in my case
<FromGitter>
<Blacksmoke16> are you doing something within `LibC` diretory?
<FromGitter>
<Blacksmoke16> er namespace
<hightower2>
ah yes.. no I do this from inside LibC, but it must be that default type has priority
<hightower2>
er Crystal type
<FromGitter>
<Blacksmoke16> yea, without the `::` its looking in your namespace for it
<hightower2>
yeah
<FromGitter>
<watzon> Well here we go, still early days, but I've got a kind of nice wrapper around LibUI that abstracts away all the C stuff https://github.com/watzon/cru
<FromGitter>
<watzon> I was thinking lubui was dead, but the project has seen some activity recently and the maintainer posted a notice on the readme
<hightower2>
mm interesting that it chose gtk instead of Qt
<FromGitter>
<watzon> Makes sense. Qt licensing is a mess.
<FromGitter>
<watzon> @oprypin good work on getting Crystal working in Windows!
darkstar_13 has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 246 seconds]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter>
<Blacksmoke16> @paulcsmith ⏎ ⏎ > But I can’t do what I would prefer witht he current implementation. I have to monkey patch all kinds of things on Log
<FromGitter>
<Blacksmoke16> why not just use the `Log` module's features as they are?
<FromGitter>
<Blacksmoke16> you still get structured data, and can now control the order of that context in relation to the message
<FromGitter>
<Blacksmoke16> you're fighting against the implementation
ur5us has joined #crystal-lang
<FromGitter>
<watzon> Ok apparently I still don't completely understand Crystal's event loop
<FromGitter>
<watzon> Line 48. Is there anyway to do something like what I'm trying to do without running the bot itself as another process?
<FromGitter>
<watzon> If I just run the bot with `@bot.poll` it locks the event loop, so the GUI freezes. I thought I could launch the bot in a fiber, but the fiber just exits unless I use a sleep, and then it exits immediately after the sleep.
<FromGitter>
<paulcsmith> @Blacksmoke16 I’ve written many examples of how it won’t work for me. Most of our logs do not have a string message.
<FromGitter>
<paulcsmith> And yes I’m fighting against the implementation, but I do not think that that means it can’t or shouldn’t be changed
<FromGitter>
<paulcsmith> For example I could say you are trying to render json and since log context doesn’t support that you are going against the implementation. But that doesn’t make sense as an argument because implementations can change
<FromGitter>
<Blacksmoke16> i dunno, it just seems like a lot more work to try and refactor the whole Log module so you dont have to give a string message, and just give a string message and call it a day?
<FromGitter>
<Blacksmoke16> rendering the context as json doesnt require a refactor of how context is handled
<FromGitter>
<paulcsmith> The new log itself is a refactor. The changes I propose are incredibly simple. This isn’t some massive change. As shown in the examples you can still use it as you can today and pass a message string. So there is no downside but it allows a lot more flexibility for other use cases
<FromGitter>
<Blacksmoke16> right, and now it has a way to handle extra data
<FromGitter>
<Blacksmoke16> before it didnt, and what you're doing made more sense then
<FromGitter>
<paulcsmith> Also I’ve shown examples where a message doesn’t make sense. Could you show how you would do it? For example if I want to log the query and the query args what would the message be on top of the query and args data?
<FromGitter>
<paulcsmith> So here’s the thing I’m getting frustrated by. I’m not telling you your way is wrong or shouldn’t be done but you seem to be telling me mine is
DTZUZU2 has joined #crystal-lang
<FromGitter>
<paulcsmith> That’s frustrating. Especially as I have given many examples of why I want to do things. It is a huge bummer and makes me not want to offer suggestions
<FromGitter>
<paulcsmith> Except we don’t know the class
<FromGitter>
<paulcsmith> That’s my point
<FromGitter>
<Blacksmoke16> in that case `Executing query`
<FromGitter>
<Blacksmoke16> and call it a day
DTZUZU has quit [Ping timeout: 256 seconds]
<FromGitter>
<Blacksmoke16> I'm only one person, maybe others have different opinions. However yes I think what you're doing isnt ideal. context is there for this reason
<FromGitter>
<paulcsmith> Imo that is superfluous. We have different opinions. But why should we not allow for more options if the api remains almost identical?
<FromGitter>
<paulcsmith> This is what I don’t get. It seems like you want to impose your way of doing things and I don’t get that. Are you so sure your way is better and what I’d like to do is not worth trying to do?
<FromGitter>
<Blacksmoke16> yes
<FromGitter>
<paulcsmith> Wow
<FromGitter>
<Blacksmoke16> because its not as simple as you think, `entry.message` i get the message, `entry.context` i get the context, i dont want to do `entry.context[:message]`
<FromGitter>
<Blacksmoke16> or have a getter that does that
<FromGitter>
<paulcsmith> I’ll just stop conversing ;) there is nothing else to do if you think my way is just dumb and shouldn’t be done 🤷♂️
<FromGitter>
<Blacksmoke16> 👍
<FromGitter>
<Blacksmoke16> again this is only my opinion, we'll see what others think
<FromGitter>
<Blacksmoke16> maybe ill be proved wrong 😉
<FromGitter>
<Blacksmoke16> @watzon makes sense, have you tried MT mode?
<FromGitter>
<Blacksmoke16> because currently if the main thread doesnt block that other fiber woudnt have a chance to execute
<FromGitter>
<watzon> I tried using the flag, but Crystal said it doesn't exist
<FromGitter>
<Blacksmoke16> `-Dpreview_mt`?
<FromGitter>
<watzon> Nvm I was a being a dumbass
<FromGitter>
<Blacksmoke16> 👍
<FromGitter>
<watzon> Haha well it works
<FromGitter>
<Blacksmoke16> nice
<FromGitter>
<watzon> > because currently if the main thread doesnt block that other fiber woudnt have a chance to execute ⏎ The funny thing is, the main thread should be blocking. But then again, it's a C library doing the blocking, so I don't think Crystal knows
<FromGitter>
<watzon> I guess I could fake a block by using sleep, maybe that would work
<FromGitter>
<Blacksmoke16> @paulcsmith and sorry if i was coming across as a dick. You're entitled to your opinion and idea, but to me your just trying to implement something that is already possible in a different way. When you could just do what you want now with the current feature set of `Log`. I.e. `Log.info(query: @query, args: logging_args) { }`
<FromGitter>
<Blacksmoke16> and tada everything works as you want
<FromGitter>
<watzon> Actually no, I'd have the same issue
<FromGitter>
<watzon> Nvm haha
Human_G33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Max SendQ exceeded]
<FromGitter>
<paulcsmith> @Blacksmoke16 except the message is empty and so it would be printed as “message: null” in js for example. I could strip that out (which is what I’m doing) but I’d prefer not to
<FromGitter>
<paulcsmith> It’s all good though. I can tell my proposal is not liked so I will let it be
<FromGitter>
<Blacksmoke16> no, its not liked by 1 person, there are many more people with opinions than just me :)
<FromGitter>
<Blacksmoke16> you're formatter could just ignore it
<FromGitter>
<Blacksmoke16> ah nvm, i missed the last part
<FromGitter>
<Blacksmoke16> small price to pay versus monkey patching everything tho :shrug:
<FromGitter>
<paulcsmith> There’s a bit more to it than that. Like wanting to put message context data first, and filtering out context data in some formatters but I get it is pretty niche! So I’m fine if it changes
<FromGitter>
<Blacksmoke16> but you can do that already? since the message is separate from the context, or iterate over key/values of the context and skip stuff
<FromGitter>
<Blacksmoke16> that should be a thing if its not already...
<FromGitter>
<Blacksmoke16> ogh, you cant
<FromGitter>
<Blacksmoke16> `entry.context.as_h.each do` there we go
<FromGitter>
<paulcsmith> Yeah and because if I leave the message blank and the log data is in the context then I can’t determine what is “context” and what is the log data
<FromGitter>
<Blacksmoke16> the log data would be the context?
<FromGitter>
<paulcsmith> But I’ve got a pretty simple backwards compatible monkey that should work great for my needs
<FromGitter>
<Blacksmoke16> if you dont use `with_context`, then its added to all entries logged after the context was set
<FromGitter>
<Blacksmoke16> otherwise is specific to the entries logged within the block
<FromGitter>
<tenebrousedge> was that supposed to be `Log.with_context do` and if so, why is the block not passed an argument?
<FromGitter>
<Blacksmoke16> sorry yea, my bad
<FromGitter>
<Blacksmoke16> he doesnt want a message and it requires a block so :shrug:
<FromGitter>
<tenebrousedge> `Log.with_context do |context|` sounds like a thing
<FromGitter>
<paulcsmith> Yeah that makes sense and is what I’m doing now with Dexter but it isn’t quite good enough because I can’t tell what was global and what was for just that one entry. So for the pretty formatter I have to print it all *and* the local context comes first. But I’d prefer the log specific context to come first as it is the most important part
<FromGitter>
<paulcsmith> And I can’t reverse it because sometime the log data wouldn’t make sense. For example I would want the query args to be printed before the query
<FromGitter>
<Blacksmoke16> logger we use at works has 2 "context" objects because of this
<FromGitter>
<Blacksmoke16> extra and context to be able to tell the two appart
<FromGitter>
<Blacksmoke16> but you could have the context be some other construct
<FromGitter>
<paulcsmith> Exactly. That’s what I’m proposing. A message data context and the the global fiber context
<FromGitter>
<paulcsmith> And then also add message to the message data but I know that’s probably not gonna happen
<FromGitter>
<Blacksmoke16> can already be done tho, `Log.context.set local: {entry: entry}`, something like that, then can check if `local` is defined and set
<FromGitter>
<Blacksmoke16> if so print those then do normal `context`
<FromGitter>
<paulcsmith> Ahhh that is an interesting idea.
<FromGitter>
<Blacksmoke16> could abstract it to like `def set_local(**args)`
<FromGitter>
<Blacksmoke16> either way you're going to end up with long lines if you have a lot of data
<FromGitter>
<paulcsmith> I still will need to monkey patch the log methods to allow returning a named tuple in the block. I want to keep the performance high because I plan to add a fair amount of logging and sometimes the calculations can add up
<FromGitter>
<Blacksmoke16> i would doubt the order would matter
<FromGitter>
<Blacksmoke16> do the proc thing
<FromGitter>
<paulcsmith> Not sure I understand. What Proc thing?
<FromGitter>
<Blacksmoke16> someone didnt read my entire reply :(
<FromGitter>
<Blacksmoke16> :p
<FromGitter>
<Blacksmoke16> > You got me there. However I don’t think its that big of a deal. Most of the time the context would be data you already have available. Plus if you really needed you (or the stdlib) could define an overload like ⏎ def self.info(ctx : Proc(Log::Context, ...) which would only be called when it is going to set the context, i.e. if the entry is going to be logged.
<FromGitter>
<Blacksmoke16> overload that accepts a proc of context
<FromGitter>
<Blacksmoke16> dunno how clean you could get it but :shrug:
<FromGitter>
<paulcsmith> Ohh I get what you mean. I thought you were talking about the formatter from above
<FromGitter>
<watzon> Those function pointers don't accept a `data` variable
rw has joined #crystal-lang
rw has quit [Remote host closed the connection]
<oprypin>
watzon, uh could you give some more context
<oprypin>
btw is this ui.h the entire api?
<oprypin>
does this have documentation or what
<oprypin>
watzon, btw it would be so weird to create an entire new uiAreaHandler with all of those function pointers (also newly created functions) and each of which would have a closure associated
<oprypin>
i think you create one uiAreaHandler globally
<oprypin>
and determine by the passed `uiArea *` which object we're looking at
<oprypin>
like this should be `class UIArea; @@handler = uiAreaHandler.new(->global_function1, ->global_function2); @uiarea : Pointer(uiArea);`
<FromGitter>
<watzon> Well a `uiAreaHandler` is the low level struct for creating a widget basically. So each custom widget is going to need to create a `uiAreaHandler` which then gets converted into a `uiControl` with `uiNewArea(handler)`
<oprypin>
and `def global_function1(unused_handler, uiarea, drawparams); (uiarea - 4).as(UIArea*).value.actual_draw_handler; end`
<FromGitter>
<watzon> The API is still fairly alpha, so good docs don't exist yet
<oprypin>
why bother with this
<FromGitter>
<watzon> Even though it's alpha, it's still a pretty decent cross platform UI framework
<FromGitter>
<watzon> And I plan on keeping up with its development
<oprypin>
watzon, i disagree with >each custom widget is going to need to create a `uiAreaHandler`
<oprypin>
uiNewArea *really* should let you pass data, thats just not good
<FromGitter>
<watzon> But I agree. Maybe I'll file an issue.
<oprypin>
watzon, to not be wasteful your goal should be to use one global uiAreaHandler
<FromGitter>
<watzon> Would that not cause issues if it's reused?
<oprypin>
watzon, lets forget about crystal for a sec
<oprypin>
u could write 1 global handler in C that goes like `if (uiarea == myuiarea1) do_this; else do_that`
<oprypin>
now imagine that C has classes. you could say `myuiarea1.myhandler = do_this; myuiarea2.handler = do_that` and your actual handler you pass to would just be `uiarea.handler()` - the exact same for every uiarea
<oprypin>
i know i'm explaining horribly but are u still with me 😂
<FromGitter>
<watzon> Not completely, but I think I mostly get what you're saying
<oprypin>
watzon, ok so now switch back to crystal. it *actually has* classes. and you can just save any closure that you like inside your object
<oprypin>
but the problem is that your object in crystal only *contains* a pointer to an uiarea, rather than *actually being equal* to it
<FromGitter>
<watzon> Right
<oprypin>
now you just need a way to go back from that pointer that it passes to you , to the actual crystal object
<oprypin>
which can be done with various hacks actually, like a hashtable of weak pointers or somethin
<FromGitter>
<watzon> Oof this sounds like a massive pain haha
<oprypin>
but if it let you pass through a pointer to your own crystal object as data*, then you'd just get that object
<oprypin>
in crsfml i used to do this shit by embedding the object one into another and doing pointer math but i abandoned that later
<FromGitter>
<watzon> I know this is terrible right now, but my original idea was to do something like this https://hasteb.in/yomasogu.rb
<FromGitter>
<watzon> But it's sounding like that's just not going to work
<oprypin>
well no that's *exactly* what you want
<oprypin>
and i'm showing you the only path to achieving that
<oprypin>
actually not exactly
<oprypin>
it would be `abstract class Area`, without the handler part
<oprypin>
and `abstract def on_draw(` would not accept an art
<oprypin>
but if you append another field to it, they won't be able to tell.
<oprypin>
in crystal `lib` `struct uiAreaHandler` you just add your own field `data : Void*`
<FromGitter>
<watzon> Oooh
<FromGitter>
<watzon> I didn't know that was possible
<oprypin>
that's the basics of how class inheritance works in C 😂
<oprypin>
i first learned it from libchipmunk, it's awesome
<oprypin>
watzon, anyway, so in your callback you get a pointer to this uiAreaHandler. so in crystal code you just go handler.data.as(Area*).value.my_abstract_def(foo)
<oprypin>
but now, although the actual functions will be global, you'll still need to make an uiAreaHandler every time yourself, pointing to the exact same 5 functions but differing by the data member
<FromGitter>
<randiaz95> Hi guys..
<FromGitter>
<randiaz95> Does any1 know how to copy and paste from main machine to virtual machine?
<FromGitter>
<randiaz95> in vbox?
<oprypin>
randiaz95, u can enable guest additions and then in top menu bar enable two way dragdrop
<oprypin>
but better add a shared folder
<FromGitter>
<stronny> don't use the console window
<FromGitter>
<stronny> use putty/kitty
<FromGitter>
<stronny> actually who's the host and who's the guest?
<oprypin>
watzon, in case you're still not tired of me, here's proper C inheritance. they actually use composition but then use pointers to the base class interchangeably with the subclass. the important part is that you allocate enough memory for the *sub*class first even if you use it as the base class.
<FromGitter>
<watzon> Turned out easier, albeit hackier, than I could've hoped haha
<FromGitter>
<randiaz95> Maybe I want to do 3 letters and maybe I want to do 10 letters ( Which would be 10 factorial )
<FromGitter>
<randiaz95> Im just going to write it in python for now and send it to a .txt and then read it in crystal with File.read("urls.txt").split("\n")
<FromGitter>
<kinxer> Iirc, that's one of @watzon's.
<FromGitter>
<randiaz95> I wonder if it uses bayesian conditional probabilities
<FromGitter>
<randiaz95> it's training data uses values above 1 and below -1 and includes emojis :D
<FromGitter>
<randiaz95> Very clean code I must say..
<FromGitter>
<watzon> That is indeed
<FromGitter>
<watzon> And thank you :)
<FromGitter>
<randiaz95> Watson do you want me to give you a data set for spanish?
<FromGitter>
<watzon> That would be cool, I'll have to modify the API to work with multiple languages
<FromGitter>
<randiaz95> I have virtually no bandwidth; and I am sure you don't have time either, but if I don't put it up in my github and send you the link I will forget.
<FromGitter>
<randiaz95> Ok @watzon https://github.com/randiaz95/spanish is the link essentially how I did it before was create a file for *negative words under the filename of badLexStem.txt and *positive words under the name goodLexStem.txt
<FromGitter>
<randiaz95> i put +1 for good and 0 for bad in my model
<FromGitter>
<randiaz95> ok, I will preprocess and make that file is 1 positive and -1 negative good under the tab delimited file structure?
<FromGitter>
<randiaz95> The really valuable file is the synonym one dictConjug.json
<FromGitter>
<watzon> Sounds good man
zorp_ has joined #crystal-lang
ur5us has joined #crystal-lang
<FromGitter>
<randiaz95> @watzon I am learning NLP stuff with my new job; so I will probably ask questions about your repo to learn more!
<wmoxam>
ha, I upgraded from an i3-6100 -> Ryzen 3600 and my Crystal project test suite run time went from 7.5 minutes to 1.2 minutes
<FromGitter>
<randiaz95> Nice~!
<FromGitter>
<watzon> No problem man, feel free to ask away
<FromGitter>
<randiaz95> I sent a pull request, LMK if u got it. ( The first question I have is to fully understand the result variable from the analyze method: comparative: tokens.size > 0 ? score / tokens.size : 0 ) ⏎ ⏎ What is this comparative variable for?
yxhuvud has quit [Read error: Connection reset by peer]
yxhuvud has joined #crystal-lang
<FromGitter>
<watzon> As far as I remember, the comparative is supposed to evaluate the sentiment of that token in comparison with the other tokens
<FromGitter>
<watzon> But it's been a while since I touched it
ur5us has quit [Quit: Leaving]
ur5us has joined #crystal-lang
<FromGitter>
<randiaz95> Right, the score divided by the number of words
ur5us has quit [Ping timeout: 252 seconds]
<FromGitter>
<randiaz95> I guess the hypothesis is; if there are alot of words each word carries less meaning
<FromGitter>
<watzon> Yeah basically
<FromGitter>
<watzon> I ported the sentiment from a node library, so I never completely understood the reason behind that
<FromGitter>
<randiaz95> Im sure we could go deep into optimizing stuff but your library has all the pragmatic stuff anyways.
<FromGitter>
<watzon> @oprypin got drawing working. trying to recreate that histogram example.
ur5us has quit [Ping timeout: 252 seconds]
chachasmooth_ has quit [Quit: Quit]
chachasmooth has joined #crystal-lang
<FromGitter>
<straight-shoota> wow, when creating a new PR GitHub notifies my that the contribution guidelines have changed since my last contribution (which was in #9103).