Category: Programming

PHP Class for modifying old HTML static copies / mirrors

Ok you made a static mirror(maybe with HTTrack, maybe with something else) and you still want to host it somewhere, but you also want to make a change to all the static pages without modifying each and every one of the files. In that case, you need to load that file using a script that reads the file at the time of loading then makes the changes you want and after that displays it. Sound simple enough so I made a PHP class that does just that and I even wrote 2 flavors of the script to work on an ancient PHP version( and by ancient I mean around 2010 5.3.x). View full article

C++ Windows Detect If MBR or GPT PartitionStyle Simple Example

As the title suggest this is a Windows-only example, you may notice that I used it in QT environment from qDebug() helper function, honestly, the only small project that I can think of for this function is one where you would like to change the bootloader, but as I said this is a trivial example.

A few remarks:

  • 1 CreateFile needs to be called from a process that was run as admin in order to work ( require admin in manifest )
  • 2 On MBR Fist sector/boot sector is always writeable
  • 3 L”\\\\.\\PHYSICALDRIVE0″ means the first Volume but the user might have multiple volumes and you should make additional checks

CODE:

void QtClAct::detectHddBootType(){

    HANDLE h = CreateFile ( L"\\\\.\\PHYSICALDRIVE0",
View full article

Shred Function Qt C++ on windows

So, I searched for such a function and, I did find some things on O-Stack, but I rewrote what I found because it didn’t actually work, I tested this function and it works pretty well, I think it has room for improvement as usual but I thought to share it anyway.

So here it is:

bool QtClAct::shred(const QString & fileName, uint RepeatWrite, bool DeleteFileLink) {

  if(RepeatWrite < 1) RepeatWrite = 1;
  QSaveFile file(fileName);
  QFileInfo fi(file.fileName());

  for(int i=0; i < RepeatWrite; i++){ qint64 fileSize = fi.size(); if (! file.open(QIODevice::WriteOnly )) return false; QByteArray block(65536, '\0'); while (fileSize > 0) {
    if (fileSize < block.size()) block.truncate(fileSize);
    qint64 written = file.write(block);
View full article

Java concurrent programming homework

Some days ago I published on my personal Gitlab server some project/homework. (Java concurrent programming). I did this some time ago for a master’s course at my university. I think I did spend a day or less on it so the code is just for the purpose of demonstration. In fact as usual after the presentation, I left it to rot. I will probably put some other dead corpses on a string there as I have so much code even from a decade ago.

Anyway, Where is the Link to my java concurrent programming Homework

Here it is: https://gitlab.flashsoft.eu/root/univ_PGC-project

View full article