1. C# / Говнокод #17509

    +94

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    combinations.AddRange(combinations4);
                combinations.AddRange(from combination5 in combinations5
                                      where
                                          (from combination4 in combinations4
                                           where
                                               (from c4class in combination4.Classes
                                                where !combination5.Classes.Contains(c4class)
                                                select c4class).Count() == 0
                                           select combination4).Count() == 0
                                      select combination5);

    Теперь у меня есть ачивка "сделать через LINQ не смотря ни на что".
    Тому, кто поймёт, что же здесь происходит - достанется воображаемый пряник.

    krypt, 24 Января 2015

    Комментарии (9)
  2. JavaScript / Говнокод #17508

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function(dateToAdjust) {
        dateToAdjust = new Date(dateToAdjust);
        var offsetMs = dateToAdjust.getTimezoneOffset() * 60000;
        return new Date(dateToAdjust.getTime() - offsetMs);
    }

    даты в js, люблю их даже больше чем в php

    movaxbx, 24 Января 2015

    Комментарии (0)
  3. Си / Говнокод #17507

    +137

    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
    // For a portable version of timegm(), set the TZ environment variable  to
    // UTC, call mktime(3) and restore the value of TZ.  Something like
    
    #include <time.h>
    #include <stdlib.h>
    
    time_t
    my_timegm(struct tm *tm)
    {
        time_t ret;
        char *tz;
    
        tz = getenv("TZ");
        if (tz)
            tz = strdup(tz);
        setenv("TZ", "", 1);
        tzset();
        ret = mktime(tm);
        if (tz) {
            setenv("TZ", tz, 1);
            free(tz);
        } else
            unsetenv("TZ");
        tzset();
        return ret;
    }

    Цитата из man timegm. Сборка unix timestamp из компонент (год, месяц и т.п.).

    Удобно, наглядно, потокобезопасно.

    bormand, 23 Января 2015

    Комментарии (1)
  4. C++ / Говнокод #17506

    +50

    1. 1
    2. 2
    3. 3
    if ( !log.append(log_line) )
    
    log.append("Can't append to log");

    laMer007, 23 Января 2015

    Комментарии (13)
  5. C++ / Говнокод #17505

    +54

    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
    // We now have a locale string, but the global locale can be changed by
    // another thread. If we allow this thread's locale to be updated before we're done
    // with this string, it might be freed from under us.
    // Call versions of the wide-to-MB-char conversions that do not update the current thread's
    // locale.
    
    //...
    
    /*
                 * Note that we are using a risky trick here.  We are adding this
                 * locale to an existing threadlocinfo struct, and thus starting
                 * the locale's refcount with the same value as the whole struct.
                 * That means all code which modifies both threadlocinfo::refcount
                 * and threadlocinfo::lc_category[]::refcount in structs that are
                 * potentially shared across threads must make those modifications
                 * under _SETLOCALE_LOCK.  Otherwise, there's a race condition
                 * for some other thread modifying threadlocinfo::refcount after
                 * we load it but before we store it to refcount.
                 */

    MS VS 2013 CRT

    LispGovno, 23 Января 2015

    Комментарии (50)
  6. PHP / Говнокод #17504

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function calcHTime($stt) {
            $secs   = time() - $stt;
            $h      = (int) ($secs / 3600);
            $m      = (int) (($secs - ($h * 3600)) / 60);
            $s      = (int) ($secs - ($h * 3600) - ($m * 60));
            return sprintf("%02d:%02d:%02d", $h, $m, $s);
    }

    dannikonov, 23 Января 2015

    Комментарии (1)
  7. JavaScript / Говнокод #17503

    +159

    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
    function time(){
    var vr=new Date();
    var hour=vr.getHours();
    var min=vr.getMinutes();
    var sec=vr.getSeconds();
    if (sec<=9) {
     if (min<=9) {
      if (hour<=9) {
          document.forms[0].elements[0].value = "0" + hour +":"+ "0" + min +":"+ "0" + sec;
      }
      else {
          document.forms[0].elements[0].value = hour +":"+ "0" + min +":"+ "0" + sec;
      }
     }
     else {
       if (hour<=9) {
          document.forms[0].elements[0].value = "0" + hour +":"+ min +":"+ "0" + sec;
       }
       else {
          document.forms[0].elements[0].value = hour +":"+ min +":"+ "0" + sec;
       }
     }
    }
    else {
     if (min<=9) {
      if (hour<=9) {
         document.forms[0].elements[0].value = "0" + hour +":"+ "0" + min +":"+ sec;
      }
      else {
         document.forms[0].elements[0].value = hour +":"+ "0" + min +":"+ sec;
      }
     }
     else {
      if (hour<=9) {
         document.forms[0].elements[0].value =  "0" + hour +":"+ min +":"+ sec;
      }
      else {
         document.forms[0].elements[0].value = hour +":"+ min +":"+ sec;
      }
     }
    }
    setTimeout("time()",1000);
    }

    Вот такой вот toString().

    yamamoto, 23 Января 2015

    Комментарии (4)
  8. Си / Говнокод #17502

    +133

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    void	Nay_Prer_Timer2(void)
    {
      Obr_Func_Prer.Sh_Time2 = Obr_Func_Prer.Sh_Time2_Init;
      Spec_Vkl_Indic.Sh_Time2 = Spec_Vkl_Indic.Sh_Time2_Init;
      Spec_Vykl_Indic.Sh_Time2 = Spec_Vykl_Indic.Sh_Time2_Init;
      Flag_Morg=0;	// Флаг моргания для Config_Bibl_Max6954
      Flag_Vykl_Diod=0;
      if(Config_Bibl_Max6954&0x4)	// 2-й бит =1 - Прерывания разрешены
        Vkl_Prer_Timer2();
      return;
    }

    Чел писал тестовое задание для микроконтроллера (поморгать светодиодами).
    На вопрос что означает слово Nay в названии функции был дан ответ - это сокращение от нач. (начало).

    synya, 23 Января 2015

    Комментарии (45)
  9. Objective C / Говнокод #17501

    −396

    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
    BOOL = omg;
        
        if (omg == YES)
        {
            [self go];
        }
        else
        {
            if (omg == YES)
            {
                omg = YES;
                [self go];
            }
        }

    МОИ ГЛАЗАААА

    ShuZik, 23 Января 2015

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

    +56

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    bool XIsEmptyString( LPCTSTR str )
    {
    	CString s(str);
    	s.TrimLeft();
    	s.TrimRight();
    
    	return ( s.IsEmpty() || s == _T("") );
    }

    Кажется разработчика настиг приступ паранойи.

    Взято из библиотека XMLite

    German_1984, 23 Января 2015

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