1. Си / Говнокод #26701

    +3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    // https://youtu.be/KdZ4HF1SrFs?t=4473
    // про питоновский for
    
    for x in 1, 5, 2, 4, 3
        print(x**2)
    
    
    //> написать это в две строки у вас не получится
    
    for(struct {size_t cnt; int arr[5];} i = {0, {1,5,2,4,3}}; i.cnt < sizeof(i.arr)/sizeof(i.arr[0]); ++i.cnt )
      printf("%d ", (int)(pow(i.arr[i.cnt], 2) + 0.5) );

    В Си я могу и в 1 строку эту хуйню написать.

    j123123, 28 Мая 2020

    Комментарии (136)
  2. C++ / Говнокод #26700

    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
    27. 27
    28. 28
    29. 29
    30. 30
    int ACMEncoder::Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail)
    {
    	char *pin = (char *)in;
    	char *pout = (char *)out;
    	int retval = 0;
    
    	if (!m_did_header && do_header)
    	{
    		int s = 44;
    		s = 4 + 4 + 12 - 4;
    
    		int t;
    		if (m_convert_wfx.wfx.wFormatTag == WAVE_FORMAT_PCM) t = 0x10;
    		else t = sizeof(WAVEFORMATEX) + m_convert_wfx.wfx.cbSize;
    		s += 4 + t;
    		if (s&1) s++;
    
    		if (m_convert_wfx.wfx.wFormatTag != WAVE_FORMAT_PCM)
    			s += 12;
    
    		s += 8;
    
    		if (out_avail < s) return 0;
    		//xx bytes of randomness
    		m_hlen = s;
    		m_did_header = 1;
    		out_avail -= s;
    		pout += s;
    		retval = s;
    	}

    «Winamp» спиздили.

    gost, 27 Мая 2020

    Комментарии (48)
  3. VisualBasic / Говнокод #26699

    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
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    Код с продакшена рабочего проекта :-D 
    
    Dim got_new_batch As Boolean = False
    Dim batch_numb As Integer = 0
    Dim temp_batch As Integer = 0
    While got_new_batch = False
    temp_batch = objRandom.Next(400000000)
    If check_batch_avaliable(temp_batch) = True Then
    got_new_batch = True
    batch_numb = temp_batch
    End If
    End While
    
    Public Function check_batch_avaliable(ByVal batch_number As Integer) As Boolean
    
    'CWC-7/11/2016-Rewritten to avoid runtime error
    
    Dim RC As Integer = -1
    
    Dim DBConnection As New IfxConnection(INFXConnectionStr_RPCentral)
    
    'Try
    
    Dim SQL As String = ""
    SQL = " select first 1 batch_numb from " + System.Configuration.ConfigurationManager.AppSettings("InformixTable") + " where batch_numb = " & batch_number
    
    Dim DBCommand As New IfxCommand(SQL, DBConnection)
    DBCommand.CommandType = CommandType.Text
    
    DBCommand.CommandTimeout = 200
    
    DBConnection.Open()
    
    RC = CInt(DBCommand.ExecuteScalar())
    
    DBConnection.Close()
    
    ' Catch ex As Exception
    ' Dim ErrMsg = ex.Message
    
    
    ' Finally
    
    If Not DBConnection Is Nothing Then
    
    If DBConnection.State = ConnectionState.Open Then
    DBConnection.Close()
    End If
    
    DBConnection = Nothing
    End If
    
    
    ' End Try
    
    If RC > 0 Then
    Return False
    Else
    Return True
    End If
    
    End Function

    ageron, 27 Мая 2020

    Комментарии (48)
  4. PHP / Говнокод #26698

    +1

    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
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    <?php
        echo count($arr);
        $i = count($arr) - 1;
        for ($i; $i >= 0; $i--) {
        ?>
        <div class="post" id="p<?php echo $arr[$i]->_id; ?>">
          <div class="p_title"><?php echo $arr[$i]->title; ?></div>
          <div class="p_content"><?php echo $arr[$i]->content; ?></div>
          <div class="p_date"><?php echo $arr[$i]->date; ?></div>
          <form id="<?php echo $arr[$i]->_id; ?>" action="index.php" method="get">
            <!--<textarea rows="4" cols="50" name="removid" style="display: none;" ><?php echo $arr[$i]->_id; ?></textarea>-->
              <input type="text" name="removid"  form="<?php echo $arr[$i]->_id; ?>" value="<?php echo $arr[$i]->_id; ?>"/>
            <input type="submit" class="p_remove" onclick="dele('<?php echo $arr[$i]->_id; ?>');" form="<?php echo $arr[$i]->_id; ?>" value="Удалить"/>
          </form><!--</div>-->
          <?php echo $arr[$i]->_id; ?>
        </div>
        <?php
        }
        ?>
    
    <script>
          function dele(param){
            var jsVar = "<?php
            $removid = $_GET['removid'];
            $bulk = new MongoDB\Driver\BulkWrite;
            //$bulk->delete(['_id'=> new MongoDB\BSON\ObjectId($removid)]);
            $query = new MongoDB\Driver\Query(['_id'=> new MongoDB\BSON\ObjectId($removid)]);
            $bulk->delete(['_id'=> new MongoDB\BSON\ObjectId($removid)]);
            $writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 1000);
            try {
              $result = $manager->executeBulkWrite('forum.posts', $bulk, $writeConcern);
              //header('Location: https://benar.wtf/index.php');
    
            }
            catch (MongoDB\Driver\Exception\BulkWriteException $e) {
              $result = $e->getWriteResult();
            }
    
            ?>";
    
    
          }
    
        </script>

    Сделал вещь

    bodix, 27 Мая 2020

    Комментарии (37)
  5. Куча / Говнокод #26697

    0

    1. 1
    2. 2
    3. 3
    https://news.ycombinator.com/item?id=20426997
    
    LiveJournal data breach impacts 33M users with plaintext passwords

    Идиотия, кретинизм, олигофрения, и другие способы стать разработчиком в livejournal

    MAKAKA, 27 Мая 2020

    Комментарии (33)
  6. C++ / Говнокод #26696

    +2

    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
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    template <typename F, class = decltype(F()(E()))>
        auto map(F p) -> std::vector< decltype(p(E())) >
        {        
            std::vector< decltype(p(E())) > result;
            std::transform(get().begin(), get().end(), std::back_inserter(result), [=](auto &v) {
                return mutable_(p)(v);
            });
    
            return result;
        }
    
        template <typename F, class = decltype(F()(E(), 0))>
        auto map(F p) -> std::vector< decltype(p(E(), 0)) >
        {        
            std::vector< decltype(p(E(), 0)) > result;
            auto first = &(get())[0];
            std::transform(get().begin(), get().end(), std::back_inserter(result), [=](auto &v) {
                auto index = &v - first;
                return mutable_(p)(v, index);
            });
    
            return result;
        }
    
    // и применение (e) => f()
        auto strs = (array<int>{ 1, 2, 3 }).map([](auto x)
        {
            return "X" + x;
        });
    
    // или (e, index) => f()
    
        auto strs = (array<int>{ 1, 2, 3 }).map([](auto x)
        {
            return x + i;
        });

    как я выкрутился бля... с разными маперами... как генерики в c#

    ASD_77, 27 Мая 2020

    Комментарии (24)
  7. C++ / Говнокод #26695

    +5

    1. 1
    https://github.com/ASDAlexander77/TypeScript2Cxx/blob/master/cpplib/core.h

    Нужна помощь смелых и умных людей, надо сделать review кода и посоветовать что там по стандартам улучшить... короче любая помощь welcome

    https://github.com/ASDAlexander77/TypeScript2Cxx/blob/master/cpplib/core.h

    ASD_77, 27 Мая 2020

    Комментарии (76)
  8. JavaScript / Говнокод #26691

    +2

    1. 1
    2. 2
    3. 3
    function isNative (Ctor){
      return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
    }

    https://habr.com/ru/company/ruvds/blog/503634/
    >>> 5 интересных JavaScript-находок, сделанных в исходном коде Vue

    gost, 26 Мая 2020

    Комментарии (46)
  9. Куча / Говнокод #26689

    0

    1. 1
    Пиздец-оффтоп #4

    #1 https://govnokod.ru/26503 https://govnokod.xyz/_26503
    #2 https://govnokod.ru/26541 https://govnokod.xyz/_26541
    #3 https://govnokod.ru/26583 https://govnokod.xyz/_26583

    bagrinho, 25 Мая 2020

    Комментарии (573)
  10. Си / Говнокод #26687

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    // Там в стандарт сишки хотят добавить хуйни какой-то
    
    // https://habr.com/ru/company/badoo/blog/503140/
    // C2x: будущий стандарт C
    
    // Итак, с опозданием лет на 20 к нам приходят функции strdup и strndup!
    #include <string.h>
    
    char *strdup (const char *s);
    char *strndup (const char *s, size_t size);

    Они есть в позикс стандарте, да и вообще эти функции - говно, как и нуль-терминированные строки сами по себе.

    j123123, 23 Мая 2020

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