« first day (4049 days earlier)      last day (894 days later) » 
01:00 - 14:0014:00 - 19:00

mr5
2:00 PM
hmmmmmmmmmmm
hmm, yeah. It seems that strcat_s appends null character at the end of each string concatenation.
 
how to concatenate strings in Kotlin: strA + strB
> How to concatenate strings in C: a five minute guide
 
mr5
if I did this on other high level language, I would have done already an hour ago.
 
on the other hand, it doesnt look that bad
 
mr5
I think it took me an hour to implement this JSONL
 
char destination[] = "Hello ";
char source[] = "World!";
strcat(destination,source);
printf("Concatenated String: %s\n", destination);
 
mr5
2:05 PM
that would not work
you have to have extra buffer for the source
wait wut
 
I just copy pasta
 
mr5
it maybe writing from the extra stack
but I think that should crash
yeah, that blog is wrong.
it's writing on the extra stack space provided by main
 
> How to concatenate strings in C: a five minute guide that will teach you how to börk
 
[Captain Obvious] Why are you comparing c and jotlin
[Captain Obvious] *kotlin
[Captain Obvious] They're not even slightly comparabnle
 
they both can do a string concatenation
I just find it interesting that for C, you need a 5 minute guide to tell you how to not do it, while in other languages, like Kotlin, you just do it without thinking
 
2:16 PM
[Captain Obvious] I mean sure, but you're comparing apples and snails
 
i can concatanate strings with a pair of scissors and cellotape but i dont compare myself to kotlin
5
 
mr5
fuck this shit I'm out
 
@Harry I just came all in the way in here to star that message
 
@CaptainObvious i respect that
 
I just woke all the way up
Good morning
 
2:18 PM
"morning"
 
What happened while I was gone?
 
Well the day ends in a y
 
Well yeah I went to bed like 4:30
In a year? What kinda strange time measurements is the UK using now?
 
so obviously wiet is complaining that <language> is inferior to kotlin because of unqualified reason x
 
Ah so just the usual
Hector looking for a new job yet?
 
2:19 PM
@CaptainObvious sure, if that is your interpretation
 
Exactly, hence the day ends in a y
 
Ah shit he outta autocomplete
 
mr5
@Squirrelkiller you just woke up all the way just to star Harry's message? impressive!
 
I was just stating that a simple operation, that pretty much all languages agreed on the same behavior and ease of use, is so difficult in C that you need a guide to do it
 
@Wietlol I think when it's how the majority of people interpret something it's called common sense
 
2:21 PM
that is not what common sense means
 
@Wietlol Since C is basically just syntactic sugar on top of assembler, all other languages can fuck right off
 
even though that is the literal translation of the words
 
mr5
we all just take the built-in string manipulation provided by these high level languages for granted.
 
Kotlin is also just syntactic sugar on top of assembly
just as C# is
and Java
 
Definitely not lol
 
mr5
2:22 PM
C doesn't have string pool
 
Neither of those literally directly translate to assembler
 
it doesnt need a pool though
 
C doesn't have fancy memory management
 
@Squirrelkiller how come?
 
c doesn't have fucking objects for fuck sake
@Squirrelkiller In fairness neither does C, but the mapping is rather simple
 
2:23 PM
@Wietlol Kotlin/C#/Java are all translated to something inbetween, be it IL or bytecode or WASM if you really want.
 
and that something inbetween is translated to something lower level inbetween... such as x86 or x64
 
...during execution
 
not necessarily
 
But the C code is not compiled to an intermediate language
 
2:25 PM
directly
I placed that word for a reason
 
It compiles straight to native code
 
It does? Wow, thought it'd be turned into assembler first actually^^
 
mr5
I think it depends on the argument you provide to the compiler or if the VM even supports JIT and AOT
 
JIT is basically during execution
 
or if you even use a vm
 
2:26 PM
Which if you're using any of the above languages, you are
 
uhm... no
 
uhm yes
 
I mean, a browser really is a VM by now
The CLR is basically a VM
 
jesus we've had this discussion before
 
So many times^^
 
mr5
2:27 PM
this JVM and MS-JVM based languages needs a VM to run on, no?
 
not really
 
VM is loose enough that the js runtime and .net runtime qualify as VMs
 
you can compile Java to native images
with Kotlin, it is even designed for it
 
What's a native image
 
2:28 PM
yes
 
mr5
java.toJpeg()
 
You compile your code to java bytecode then package the jvm with it
 
@CaptainObvious considering I use Kotlin for Kodian, I think I am pretty sure that it generates x64 on compilation
Kodian compiles
  to Kotlin
  to LLVM
  to x64
 
(assuming I build for a desktop)
 
2:28 PM
It's literallt in the name
LLVM
 
it is literally in the name, except it is not an actual vm :D
 
mr5
Lul Lul VM
 
Sure. But neither is dotnet or js runtime
They're also not "actual" VMs
 
> Despite its name, LLVM has little to do with traditional virtual machines. The name "LLVM" itself is not an acronym; it is the full name of the project.
 
traditional
Also I thought it comes from low level virtual machine?
 
2:30 PM
9
Q: Is LLVM a typical virtual machine?

smallBI'm wondering if LLVM is a typical Virtual Machine like Java's or .Net's or is it simply runtime environment, just like oridinary C++ runtime?

 
@Squirrelkiller It does
Because that's what it is
 
I mean
> LLVM IR is a kind of assembly language, or byte code similar to Java and .NET. That's where the 'virtual machine' came in.
 
LLVM spits out:
> a language-independent intermediate representation (IR) that serves as a portable, high-level assembly language that can be optimized with a variety of transformations over multiple passes
 
Kotlin spits out LLVM IR
LLVM IR is then compiled to x64 arm64 wasm or whatnot
 
@Wietlol Yes, at runtime
 
2:32 PM
at compile time
 
By the LLVM optimiser and shit
no
 
-_-
 
I swear if he hadn't invented Regex I'd kick Wietlol because he's just a spam bot.
 
the LLVM optimizer and shit is the compiler toolchain
you use it to poop out windows specific x64 bytecode
 
2:34 PM
or linux specific x64 bytecode
 
that's literally not what it does
 
So does it compile when you execute the program or when you publish it? Because I think, maybe, if you compile the IR just in time for execution, that's what we call a VM. Nontraditional if you want.
 
well... I do
@CaptainObvious but that is what Kodian does
 
The fuck is kodian
 
@Squirrelkiller you could choose to distribute the LLVM IR and tell your customers "download the toolchain and compile your own executables"
but that is stupid
imho
 
2:35 PM
The whole thing about LLVM is runtime optimisation right?
 
uhm... no
 
Why does it even exist then instead of just compiling shit to machine code?
 
primarily, bytecode abstraction to be compiled to pretty well optimized native code
@Squirrelkiller because machine code is very specific shit
why do you not just write machine code?
and instead use C#?
 
mr5
write once, compile all supported arch?
 
because it is easier
@mr5 pretty much
 
2:37 PM
But you don't write LLVM code, your compiler does
 
the added optimizers are to make the runtime really fast by optimizing what gets pooped out
 
So what do the LLVM backends do?
 
they generate code... in a different format
such as wasm or x64
iirc, that is what they called backends
 
How about x86
Don't discriminate against my toaster M'kay
 
Yes
And the backend is the shit that's included with your "compiled" LLVM code
 
2:38 PM
The backend of LLVM features a target-independent code generator that may create output for several types of target CPUs — including X86, PowerPC, ARM, and SPARC. The backend may also be used to generate code targeted at SPUs of the Cell processor or GPUs to support the execution of compute kernels.
 
I'll admit that we did get one detail wrong
The IR is the mid point that gets shipped
Along with the backend
wait no
 
You ship all the backends?
 
IR (generated by the front end) gets shoved through the LLVM optimisers and shit and converted to LLVM Machine code (which is machine code for the LLVM, which in fairness isn't far from native code, but isn't native
 
I generate what I need and distribute what I want to distribute
 
But then the LLVM machine code is packaged with the lightweight backend which executes on teh target plarform
 
mr5
2:41 PM
so if you want to create a new language for whatever reason, and you want to avoid headache for supporting different environments, you better support LLVM compatible language?
 
so, this would mean that if you build a desktop application that you download from your website, you would need a download button for windows linux and macOs
 
mr5
your_new_language > (outputs) > LLVM_lang > (outputs) > IL/image
 
@mr5 you could choose to let your compiler generate LLVM IR and then run some tool like clang to generate executables
 
2:44 PM
I chose to generate Kotlin, which in turn generates LLVM IR, etc, because the Kotlin compiler also includes memory management, with a garbage collector, and virtual method resolution
 
@Wietlol If you have different executables anyway, why even ship the backend instead of just compiling the IR to native machine code and ship that? Am I missing a link here?
 
which are 2 things I'd rather not write myself
@Squirrelkiller I dont ship the IR
I ship a .exe file (for windows)
 
A right, LLVM machine code
And the .exe file (or linux executable) include the LLVM machine code and an LLVM backend for that OS?
 
not as far as I know
 
@Squirrelkiller Correct
 
2:47 PM
So my confusion is still not cleared: Why not let the LLVM compile it down to native machine code and ship that without LLVM backend? IF the backend knows what the native machine looks like anyway?
Does it JIT to do more runtime optimization or something?
 
> The most common use case for LLVM is as an ahead-of-time (AOT) compiler for a language. For example, the Clang project ahead-of-time compiles C and C++ to native binaries. But LLVM makes other things possible as well.
Some situations require code to be generated on the fly at runtime, rather than compiled ahead of time.
 
*Other things*
*Some situations*
Why can't there at least be one concrete example damnit, I didn't sleep last night ffs
 
Oh that's cool
So when the MC is emitted it generates a bare minimum interpreter thing
Which will convert the nearly native MC to actual MC when the application runs on the target machine
 
> Some situations require code to be generated on the fly at runtime, rather than compiled ahead of time. The Julia language, for example, JIT-compiles its code, because it needs to run fast and interact with the user via a REPL (read-eval-print loop) or interactive prompt.

Numba, a math-acceleration package for Python, JIT-compiles selected Python functions to machine code. It can also compile Numba-decorated code ahead of time, but (like Julia) Python offers rapid development by being an interpreted language. Using JIT compilation to produce such code complements Python’s interactive wor
 
Depending on the constraints of the specific CPU it's running on
Like if the CPU supports using specific instruction sets which would be faster than doing the same thing but in a way supported on older CPUs, then it'll do that instead
See for example AVX-512, which runs (reasonably) well on intel hardware but things which would use it run slowly or not at all on AMD or older intel hardware
(I think recent ryzen CPUs support it but that's the most recent example I could think of)
 
3:21 PM
Hi all
In ASP.NET, is there a way in JS to check if a session has expired via AJAX without causing the session to extend again? For example, this solution pings the server and thus extends the session
Can you read the session cookie for expiration?
 
3:43 PM
Thinking it has to all be on the client
 
3:56 PM
Well a session cookie will last for a long time by default because the client might have the session open for a long time
Although technically it also "expires" as soon as the browser is closed
in that it doesn't really expire but the cookie is lost so it won't be used agaion
 
does it though?
 
does it what
Wait what kind of session
Also obviously the session will end if IIS kills the app pool unless you're using persistent session storage
 
iirc, cookies are retained even when the browser closes
 
Looking at the first answer on this post
 
at least for chrome
 
4:02 PM
Cookies set with a negative expiry won't
 
a cookie does have an expiration moment, which could be used to indicate that the session has expired, but doesn't necessarily have to mean it
 
Cookies which are expired will remain until the browser closes, at which point they should be deleted
Though yeah cookie expiry on its own is fairly meaningless
 
How do web apps manage this -- to redirect users when their session expires?
 
Usually use a seperate session management on top
 
I see apps that do a popup to warn you and then they kick you out
 
4:05 PM
So you could have it so that all requests which route through a particular contorller will refresh a session, then have a seperate controller which is used to check on the session state
There's tons of ways to do it
 
Any example articles on this?
 
To be clear, the kicking out isn't what expires the session. By the time the user gets "kicked out" their session has already expired, they just do that to stop you from clicking on something and then it breaking because your session token is no longer valid
I don't know of any, it's fairly common though
 
How do you have a controller that won't refresh the session state?
 
Like I said
You're not using the built in asp session
You're doing your own shit on top
 
Ohh
So you roll your own solution
 
4:08 PM
I don't think you can really do anything to stop that refreshing
Maybe not roll your own, but have something on top
It's somewhat common for servers to include remaining time or expiry datetime in headers for when a token will expire, especially in APIs
aaa
 
G K
Hi all,
I have following design https://gist.github.com/Ganeshcse/4a352e744629f691125d991e0c428252

I have got 1 situation here.
I tried to give a gist of my code design.
I have a MainUseCase class which contains a list of Steps.
I have a Session class which contains list of UseCase's.

Step execution -
I call only the first step from my UseCase like step.ExecuteStep().
The first step takes care of invoking the next dependent step using mediator pattern. I publish a message and then second step/dependent next step will have a handler.
 
No you should be able to manage all of that just using async properly
 
G K
But as I mentioned the step itself is not an async, it calls some other Model class and internally some other classes (might 2 layers deep) runs some code async.
Making the whole Usecase running async, I feel is it really necessary?
Because AutoResetEvent helps me to signal back the MainUseCase so that it exits from the method.
 
Well yeah, because at the moment you're starting off the new async thread and then basically letting it do it's thing and not waiting for it
Maybe try not running async code? Or await the async calls (or even just wait() them)
 
G K
2nd option I could try. I can await until that async method finishes. But then again I have to await on main use case also. Since I only call first step in my program.
Rest of the step execution handled by the step itself.
The moment first step calls, the ExecuteUseCase method exits and then starts the next UseCase.
 
4:23 PM
You need to get the contents of the step to run synchronously
Doesn't really matter how you achieve that, but if you don't do that then you're gonna have a bad time
 
G K
Yeah
Did not understand your first statement.
 
Allow me to mspaint
 
G K
Sure.
 
The top is what you're currently doing
Red symbolises your UseCase method calls and basically everything that isn't step execution. Blue is step execution
 
G K
Ok
 
4:29 PM
What you're doing is starting the steps which go off to their own thread and vanish into the ether. Meanwhile your use case method immediately continues to iterate as soon as it's called. It never waits to hear from the step method again
 
G K
Correct
But why not I should use AutoResetEvent and call the Set method from the last step.
 
The awaited one executes your async method on another thread, but waits for it to come back before continuing. The grey is essentially "idle" time where the thread could be doign something else
 
G K
and I call WaitOne before the closing braces of the ExecuteUseCase method.
 
Sync would be executing the lot on a single thread and I accidentally made the last call on that line greay
Basically, AutoResetEvent is bad unless you absolutely know what you're doing
 
> The awaited one executes your async method on another thread
 
G K
4:32 PM
Hmm
 
Async is nice because is allows normies like you and me to do things outside the main thread and not lock shit up
 
except it doesnt have to
it could be on the same thread, since the thread is released by the caller
 
@wiet now is not the time for you pedantics. Is usually will
It's not necessarily released by the caller
Especially if the task is not immediately awaited
 
and if it does use the same thread, then the line looks identical to the bottom line...
I wonder why /s
 
Also I think it does something different for control threads
But basically the average developer is almost guaranteed to fuck something up if they try to manage threads themselves
 
G K
4:35 PM
Can I think someting else.. I wait for a call back from the last step and then only exit from the ExecuteUseCase method.
Reason behind I am saying
 
I mean you could but then you can't really use the iteration that you have
 
G K
My step execution is not with me. I only execute first step.
The subsequent steps are executed by the previous step.
 
Yeah that's something which really doens't make any sense
Why are you doing that?
And more importantly, what's the limit to how many steps there are?
 
G K
Reason is - these steps can be configured in many use-cases and some times the output of 1 step have to be passed to another step and some times as I mentioned the steps are async and next step execution is dependent on the event call back inside the steps.
Considering all these factors so, I implemented the mediaotr logic that publishes a message and then the handler will be notified.
So I don't have to manage them in my use case class.
For now there are 10 steps in a use-case
 
See that doesn't make sense
 
G K
4:39 PM
Some times it grows to 20 or more than that.
@CaptainObvious Why?
 
Well you can't iterate async over steps AND use callbacks to control iteration
 
G K
1 more reason... some times Step 4 will be called from an event handler of Step 2. So it is not even sequential.
 
> Steps are async and next step execution is dependent on the event call back
That is by definition not async
 
G K
Ok, I think we mixed up two diff. thoughts.
Let me clear it once.
Step by itself is not an async. It makes a call to another class (2 or more deep levels) will have an async methods.
Some times for some of the step's there are call back's. and once I receive a call back then only I should execute the next step.
Is it clear? Reason behind making steps connected to each other using the mediator object and UseCase is not controlling the execution of their flow.
 
So you know at the point of beginning a step if you need to wait for a response from it or not?
Also that class should be able to be called synchronously without going nuts
 
G K
4:44 PM
Yes, I do know.
 
If it can't then your problem is there
 
G K
@CaptainObvious Did not get this. Can you pl. elaborare it bit more?
 
Basically, you said that somethign the step calls does something interally async
 
G K
@CaptainObvious Some times the method is sync but it subscribes to some oher event in the class and on the event fire back then I need to exeute another step. So some times the response from the method I call.
@CaptainObvious Yes, correct.
 
That doesn't matter, as you can run it all synchronously where you are
You can simply call (from your non-async code) DoSomethingAsync().Wait() which will wait for that method to finish executing before moving on to the next thing
 
G K
4:57 PM
Hmm
 
Hello, I think I have a relatively simple problem, but I'm not really getting a clear response about it from web searches.
 
I have some code that checks for a result from a database, and if that result is null, it's supposed to fill a variable
int? Cabinet = (int?)currentTerminal["CabinetID"];
bool yesnomaybe = Cabinet.HasValue;
 
I have a feeling I know where this is going
Database adapters soemtimes return DbNull instead of null, which is very unhelpful
 
This fails with "Specified cast is not valid"
 
5:07 PM
Yeah I knew it
Dbnull doesn't cast to null or to bool
 
Cabinet shows up in the debugger as null
 
You need to check if it returns dbnull
That's because Dbnull isn't technically null
 
Really? Whay doesn't it show in the debugger as DbNull? that would have been a lot more clear
 
I think the dbnull is somehow cast as a special int or something weird. It's been a while
 
So, what type should Cabinet be?
Or is the better choice to test currentTerminal["CabinetID"] directly?
 
5:13 PM
What type is currentTerminal?
Yeah I would test that
Because if CurrentTerminal is a Dictionary<string,object> as I suspect it is then you could be in for a surprise
 
It's a DataRow
 
See that bit. You're probably best off using DataTableReader.IsDbNull to check the value before you cast it
 
Okay, I guess I can do that. I really wish that the debugger had shouwn Cabinet as DbNull, it would have been a lot more clear
 
I think it's because the invalid cast is probably failing before Cabinet is set
Because it'll be throwing on the (int?)currentTerminal["CabinetID"] part when you're trying to cast it to int?
 
So, Cabinet is null because it never actually recieved a value?
 
5:18 PM
Should be
Or at least it'll be null until that exception hits
Then it doens't matter haha
 
And not because the database value was Null. Confusing, but that makes sense
 
It's only null because it hasn't been set to anything at all
If you did this for example, it would be differtent
int? Cabinet  = int.MinValue; //Initialise it as minvalue so it's not null
Cabinet = (int?)currentTerminal["CabinetId"];
Effectively that second line never completes, so cabinet never changes from int.MinValue
 
That's definately a better wtest
test, even
 
Similarly with the original, it's not that cabinet is null, rather it simply doesn't exist yet
technically it does but you should think of it as not existing until you set it to something (successfully)
 
So I think I'm going with bool yesnomaybe = DBNull.Value.Equals(currentTerminal["CabinetID"]);
And then I'll run tests from there. Thanks!
 
5:26 PM
Well all that will tell you is if it's null
 
That's all I need in this case
 
Oh cool
Glad I could help
 
Should have done that to begin with, it's simpler. Thanks for clearing that up
 
6:17 PM
Hi there I cant figure out euivalent of this cosmos query in linq

Cosmos Query:
select c_option
from c
join c_size in c.size
join c_variant in c_size.variant
join c_option in c_variant.option
where c.type = 'product'
and c_option.optionID = '869'

And my linq but it returns null all the time ehh.

return _cosmosRepository.FindFirst(query =>
query.SelectMany(product => product.Size
.SelectMany(size => size.Variant
.SelectMany(variant => variant.Option
.Where(option => option.OptionId
.Equals(optionId, StringComparison.OrdinalIgnoreCase))))));
 
01:00 - 14:0014:00 - 19:00

« first day (4049 days earlier)      last day (894 days later) »