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

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    select * from
    (
    select case when (case when datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365 = 0 then 'Y y.,' else cast((datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365) as varchar(20)) + ',' end + case when (datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/30 - (datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365) * 12) = 0 then 'M m.' else cast((datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/30 - (datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365) * 12) as varchar(20)) end) = 'Y y.,M m.' then '' else (case when datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365 = 0 then 'Y y.,' else cast((datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365) as varchar(20)) + ',' end + case when (datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/30 - (datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365) * 12) = 0 then 'M m.' else cast((datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/30 - (datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365) * 12) as varchar(20)) end) end as 'Возраст', date as date1, (select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date) as date2 from Battles as P1 where (select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date) is not null) as t
    union
    (select case when (case when datediff(day,date,CONVERT (date, GETDATE()))/365 = 0 then 'Y y.,' else cast((datediff(day,date,CONVERT (date, GETDATE()))/365) as varchar(20)) + ',' end + case when (datediff(day,date,CONVERT (date, GETDATE()))/30 - (datediff(day,date,CONVERT (date, GETDATE()))/365) * 12) = 0 then 'M m.' else cast((datediff(day,date,CONVERT (date, GETDATE()))/30 - (datediff(day,date,CONVERT (date, GETDATE()))/365) * 12) as varchar(20)) end) = 'Y y.,M m.' then '' else (case when datediff(day,date,CONVERT (date, GETDATE()))/365 = 0 then 'Y y.,' else cast((datediff(day,date,CONVERT (date, GETDATE()))/365) as varchar(20)) + ',' end + case when (datediff(day,date,CONVERT (date, GETDATE()))/30 - (datediff(day,date,CONVERT (date, GETDATE()))/365) * 12) = 0 then 'M m.' else cast((datediff(day,date,CONVERT (date, GETDATE()))/30 - (datediff(day,date,CONVERT (date, GETDATE()))/365) * 12) as varchar(20)) end) end, date, CONVERT (date, GETDATE()) from Battles as T1 where (select top (1) date from Battles as T2 where T2.date > T1.date order by T2.date) is null
    );

    BDcorabli@nomer5

    akimachan, 12 Сентября 2018

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

    +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
    /* Get LDAC handle */
    LDACBT_API HANDLE_LDAC_BT ldacBT_get_handle( void )
    
    /* Free LDAC handle */
    LDACBT_API void ldacBT_free_handle( HANDLE_LDAC_BT hLdacBT )
    
    /* Close LDAC handle */
    LDACBT_API void ldacBT_close_handle( HANDLE_LDAC_BT hLdacBT )
    
    /* Get ERROR CODE */
    LDACBT_API int ldacBT_get_error_code( HANDLE_LDAC_BT hLdacBT )
    
    /* Get Configured Sampling frequency */
    LDACBT_API int ldacBT_get_sampling_freq( HANDLE_LDAC_BT hLdacBT )

    СОНЭ умеет в комментарии.

    https://android.googlesource.com/platform/external/libldac/+/master/src/ldacBT_api.c

    Elvenfighter, 09 Сентября 2018

    Комментарии (3)
  4. Куча / Говнокод #24707

    −4

    1. 1
    2. 2
    3. 3
    Как называется физическая сеть, разбитая на подсети?
    
    (man dhcpd.conf)

    OlegUP, 01 Сентября 2018

    Комментарии (3)
  5. Python / Говнокод #24706

    −2

    1. 1
    if type(colType) == type(0): # it's a length

    Библиотека csv, встроенная в питон.

    syoma, 01 Сентября 2018

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

    −3

    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
    //+-------------------------------------------------------------------------
    //
    //  Function:   GetNumberOfType
    //              SetNumberOfType
    //
    //  Synopsis:   Helpers to get/set an integer value of given variant type
    //              by dereferencing a pointer
    //
    //              pv - pointer to dereference
    //              vt - variant type
    //
    //--------------------------------------------------------------------------
    
    // BUGBUG: The VC 5 compiler flags this as an error because VT_BOOL4 is not
    // a valid VARENUM value.  Disable the warning for now.
    #pragma warning(disable:4063)       // case '254' is not a valid value for switch of enum 'VARENUM'
    
    long
    GetNumberOfType (void * pv, VARENUM vt)
    {
        switch(vt)
        {
            case VT_I2:
            case VT_BOOL:
                return * (SHORT*) pv;
    
            case VT_I4:
            case VT_BOOL4:
                return * (LONG*) pv;
    
            default:
                Assert(FALSE);
                return 0;
        }
    }
    
    void
    SetNumberOfType (void * pv, VARENUM vt, long l)
    {
        switch(vt)
        {
            case VT_BOOL:
                l = l ? VB_TRUE : VB_FALSE;
                //  vvvvvvvvvvv  FALL THROUGH vvvvvvvvvvvvv
    
            case VT_I2:
                Assert(l >= SHRT_MIN && l <= SHRT_MAX);
                * (SHORT*) pv = SHORT(l);
                break;
    
            case VT_BOOL4:
                l = l ? VB_TRUE : VB_FALSE;
                //  vvvvvvvvvvv  FALL THROUGH vvvvvvvvvvvvv
    
            case VT_I4:
                * (LONG_UNALIGNED *) pv = l;
                break;
    
            default:
                Assert(FALSE);
        }
    }

    Опять какая-то сранина известно откуда.

    CCAHA9I_CPAHIHA, 31 Августа 2018

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

    0

    1. 1
    2. 2
    #define ONE_GB 1024
    #define FIVE_GB 5115

    Написано в очень известной Калифорнийской конторе

    Starl1ght, 30 Августа 2018

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

    +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
    class TaxStorage {
    public:
      using TaxCode = Code<3>; // Code<int N, typename Storage = uint32_t> тип для маленьких строк
      using TaxType = Code<3>;
      using TaxId = std::tuple<TaxCode, TaxType>;
      using TaxMap = std::map<TaxId, int>
    
      using CityId = int;
      using TaxPointMap = std::unordered_map<CityId, TaxMap>;
    
      TaxMap forCityOrOther(const TaxPointMap& map, const CityId cityId) const {
        const auto found = map.find(cityId);
        return found == map.cend() ? map.at(OTHER_CITY) : *found; // должно быть found->second
      }
    }

    Dev: Ok GCC, tell me what is wrong.
    GCC: /home/whatever/project/TaxStorage.h:102: error: incompatible operand types ('const std::unordered_map<int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > >, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<const int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > > > > >::mapped_type' (aka 'const std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > >') and 'const std::pair<const int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > > >')

    ДОКОЛЕ?!!

    Elvenfighter, 24 Августа 2018

    Комментарии (3)
  9. PHP / Говнокод #24648

    −1

    1. 1
    2. 2
    $query  = "SELECT * FROM archivo_mhora WHERE id_aparato=" . $aparatos_row->id;
    $query .= " && DATE_FORMAT(fecha, '%Y.%m.%d')='" . date('Y.m.d', $cur_fecha) . "' ORDER BY energy";

    Я не знаю, к какой секции следует отнести этот высер:
    1) Автор решил учить испанский. Таблицы имеют имена `aparatos`, `abonandos`, etc
    2) Само собой, SQL injection
    3) Порнография при работе с датой

    kai, 23 Августа 2018

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

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    #include <stdio.h>
    #include <inttypes.h> 
    
    int main(void) {
    	float a = 0;
    	float b = -9.8 * 0;
    	uint32_t* pa = (void*)&a;
    	uint32_t* pb = (void*)&b;
    	printf("%li %li %i %f %f\n",pa[0] , pb[0], pb[0]>>31, b+0, b);
    	return 0;
    }

    Нолик со взведенным знаковым битом. Вот зачем он нужен?

    Psionic, 16 Августа 2018

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

    −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
    try
    {
        ...
    }
    #if DEBUG
          catch
    #else
          catch
    #endif
    {
          ...
    }

    delpher, 18 Июля 2018

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