1. Лучший говнокод

    В номинации:
    За время:
  2. JavaScript / Говнокод #29175

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    /* "[...] To fix this I added a delay at the end of the function and the events
    now fire properly. Thank you for all of your help. Fixed Code:"
    */
    
    data.indexedDB.addSource = function(sourceBlob) {
    //adds source to data base
      var version = 1;
      var request = indexedDB.open("content", version);
      request.onerror = errorHandler;
      request.onsuccess = function(e) {
        db = e.target.result;
        var trans = db.transaction(["nContent"], "readwrite");
        var store = trans.objectStore("nContent");
        var request = store.put(sourceBlob);
        trans.oncomplete = function(e) {
          extron.indexedDB.getIndexedSource();
        };
    
      };
        var token = 100000;
        while(token != 0)
        {
          token = token-1;
    
        }
    };

    https://stackoverflow.com/questions/27494247/why-is-my-indexeddb-open-onsuccess-event-not-called

    ISO, 02 Сентября 2025

    Комментарии (27)
  3. C++ / Говнокод #29176

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    SparseMatrix<double> mat(rows,cols);
    for (int k=0; k<mat.outerSize(); ++k)
      for (SparseMatrix<double>::InnerIterator it(mat,k); it; ++it)
      {
        it.value();
        it.row();   // row index
        it.col();   // col index (here it is equal to k)
        it.index(); // inner index, here it is equal to it.row()
      }

    Random access to the elements of a sparse object can be done through the coeffRef(i,j) function. However, this function involves a quite expensive binary search. In most cases, one only wants to iterate over the non-zeros elements. This is achieved by a standard loop over the outer dimension, and then by iterating over the non-zeros of the current inner vector via an InnerIterator. Thus, the non-zero entries have to be visited in the same order than the storage order.

    CHayT, 03 Сентября 2025

    Комментарии (1)