MarekKnapek

joined 1 year ago
[–] [email protected] 2 points 1 month ago

You can always take a look how for example Windows 3.11 and earlier did it for their *.rtf file format and their "write.exe" editor / viewer / renderer (if you want to call it that way).

[–] [email protected] 3 points 2 months ago

You have stack buffer out of bounds write. On line 52 you declare h an array of 70 unsigned ints. On line 57 you store reference to such array. Later, on line 35 you write out of bounds, one element past end of the array. The _SPR_history[i] writes to _SPR_history[70]. Created an issue: https://github.com/X64X2/sh/issues/1

[–] [email protected] 4 points 8 months ago (2 children)

Doesn't depend on programming language but something with visual debugger. You know that stuff when you can see current line of your source code highlighted, press a key to step into, step over and so on. You can see values inside your variables. You can also change your variables mid-run right form the debugger.

Because you spend 20% of your time writing bugs and the other 80% debugging them. At least make it pleasant experience (no printf-style debugging).

Back in the day I was using Turbo Pascal, Delphi, Visual Basic, C#, Java, PHP with Zend, Java Script, today I'm using Visual C++.

[–] [email protected] 1 points 11 months ago (2 children)

Yes, I know this. It took me long time to figure this out. My entire life I focused on technical skills / programming / math / logic. As I deemed them most important for the job. I was like: "Hey, if you cannot program, why do you work as programmer (you stupido)?" Only few years ago I realized that even as programmer (as opposed to sales man) you really need those "meh" soft skills. And that they are really important and I should not call them "meh". I'm very good at solving problems, improving product's performance, memory consumption, discovering and fixings bugs, security vulnerabilities. But I'm very very bad at communicating my skills and communicating with people in general. I'm not able to politely tell people that theirs idea is bad, I just say "that's stupid". And I'm mostly/sometimes right (if I'm not 100% sure, I don't say anything), but the damage caused by the way I say it is often inreversible. That post of mine about the job interview and CV was half joke and half reality. I just freeze/stutter when I'm asked something that is obvious because it is written I my CV. I'm immediately thinking "Did he not received the CV?" or "Did he not read it?" "Why the fuck is he not prepared for the call? Why are we wasting time asking me what should be obvious because I sent it in advance?" I'm more robot than human. Put me in front of problem and forget to tell me that it is impossible to solve ... and I will solve it. But easy small talk ... disaster. Communicating what the problem really was ... disaster. Communicating how I solved it ... disaster. "It was not working before and now it works fine, what the hell do you want from me now?" Yes, I'm very bad in team, in collective. I didn't know the reason why, but since few years ago I know the root of the problem. It's not that everybody around me is stupid and don't know basic stuff (what I consider basic), but me unable to communicate with other humans.

[–] [email protected] 5 points 11 months ago (6 children)

The interview starts ... the interviewer asks me "Tell me about yourself." ... I respond "Did you receive my CV? I put all important details about me ... right there. What questions do you have about my past jobs?" The interviewer encourages me again to tell him about myself, my past projects, etc. ... Me: Awkward silence. ... Me to myself: Dafuq? Should I read the CV from top to bottom OR WHAT?

[–] [email protected] 2 points 11 months ago

Yes, but (there is always a but) it does not apply if you implement off-line encryption. Meaning no on-line service encrypting / decrypting attacker provided data (such as SSL / TLS / HTTPS). Meaning if you are running the cipher on your own computer with your own keys / plaintexts / ciphertexts. There is nobody to snoop time differences or power usage differences when using different key / different ciphertext. Then I would suggest this is fine. The only one who can attack you is yourself. In fact, I implemented AES from scratch in C89 language, this source code is at the same time compatible with C++14 constexpr evaluation mode. I also implemented the Serpent cipher, Serpent was an AES candidate back then when there were no AES and Rijndael was not AES yet. The code is on my GitHub page.

[–] [email protected] 12 points 1 year ago

std::vector::reserve + std::vector::push_back in loop is sub-optimal, because push_back needs to check for re-allocation, but that never comes.

std::vector::resize + std::vector::operator[] in loop is also sub-optimal, because resize default-initializes all elements only to be overwritten soon anyway.

This article's author suggests push_back_unchecked.

I suggest std::vector::insert with pair of random access iterators with custom dereference operator that does the "transform element" or "generate element" functionality. The standard will have resize_and_overwrite hopefully soon.

Moar discussion:

https://codingnest.com/the-little-things-the-missing-performance-in-std-vector/

https://twitter.com/horenmar_ctu/status/1695823724673466532

https://twitter.com/horenmar_ctu/status/1695331079165489161

https://www.reddit.com/r/cpp/comments/162tohr/the_little_things_the_missing_performance_in/

https://www.reddit.com/r/cpp/comments/162tohr/the_little_things_the_missing_performance_in/jy21hgd/

https://twitter.com/basit_ayantunde/status/1644895468399337473

https://twitter.com/MarekKnapek/status/1645272474517422081

https://www.reddit.com/r/cpp/comments/cno9ep/improving_stdvector/

[–] [email protected] 5 points 1 year ago

Another alternative to C++ exceptions (instead of return code) is to use global (or thread local) variable. This is exactly what errno that C and POSIX are using or GetLastError what Windows is using. Of course, this has its own pros and cons.

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (1 children)

For this purpose I would search for Linux specific thing - a RAM based storage that receives data writes and even flushes/fsycs and then lazily writes them to HDD/SSD. There would be problem in case of power loss, but the gained performance... Unfortunately, I don't know any such tool.

[–] [email protected] 2 points 1 year ago

ABI break when?

I know some unnamed big customers want ABI stability. But common ... VS2015, VS2017, VS2019 and VS2022 all compatible with each other if used with new enough linker? They all are sharing pre-defined macro _MSC_VER 19xx and VC++ toolset version number 14.xx. That is too much of holding back progress on performance and correctness fronts. Eight years is enough.

Customers need to learn that they cannot rely on ABI stability of STL provided classes, cos guess what: The Holy Standard doesn't specify any. Toolchain vendors do. This also applies to MFC/ATL/whatnot distributed as part of Visual Studio. Remember the GCC copy-on-write string ABI problem? We already have technology to help migrate between ABI versions: one is called COM, other is pimpl, other is version number as first member of struct or first function parameter. I bet there are many more out there.

[–] [email protected] 37 points 1 year ago (2 children)

Makes sense, how would you represent floor(1e42) or ceil(1e120) as integer? It would not fit into 32bit (unsigned) or 31bit (signed) integer. Not even into 64bit integer.

 

Do you want to encrypt something and include it into your application? Don't want to use pre-build step? Encrypt it at compile-time! Decrypt it at run-time, assuming end-user knows the key or password. Plain-text is not stored inside your binary file. https://github.com/MarekKnapek/mk_clib#constexpr-aes-256-encryption-and-run-time-decryption

 

Wanna encrypt something? I implemented AES-256 (aka military grade encryption) from scratch in C89, compiled it into WebAssembly and published it on web at https://marekknapek.github.io/crypt/ You need web browser that supports writing files to your disk from JavaScript.

 

Hi all, I implemented yet another on-line cryptographic hash functions calculator. It is written in C, compiled into WebAssembly and is running inside your web browser (nothing is sent to the server). The calculator: https://marekknapek.github.io/hash, web page source code: https://github.com/MarekKnapek/MarekKnapek.github.io, C source code: https://github.com/MarekKnapek/mk_clib.

 

Hi all, I implemented yet another on-line cryptographic hash functions calculator. It is written in C, compiled into WebAssembly and is running inside your web browser (nothing is sent to the server). The calculator: https://marekknapek.github.io/hash, web page source code: https://github.com/MarekKnapek/MarekKnapek.github.io, C source code: https://github.com/MarekKnapek/mk_clib.

 

Hi all, I implemented yet another on-line cryptographic hash functions calculator. It is written in C, compiled into WebAssembly and is running inside your web browser (nothing is sent to the server). The calculator: https://marekknapek.github.io/hash, web page source code: https://github.com/MarekKnapek/MarekKnapek.github.io, C source code: https://github.com/MarekKnapek/mk_clib.

view more: next ›