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

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

    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
    public function insert(array $data)
    {
        $hstoreData = array();
        if (isset($data['description'])) {
            $hstoreData['description'] = $data['description'];
            unset($data['description']);
        }
        if (isset($data['developer'])) {
            $hstoreData['developer'] = $data['developer'];
            unset($data['developer']);
        }
        if (isset($data['localizer'])) {
            $hstoreData['localizer'] = $data['localizer'];
            unset($data['localizer']);
        }
        if (isset($data['gameplay_video'])) {
            $hstoreData['gameplay_video'] = $data['gameplay_video'];
            unset($data['gameplay_video']);
        }
        if (isset($data['news_community_id'])) {
            $hstoreData['news_community_id'] = $data['news_community_id'];
            unset($data['news_community_id']);
        }
        if (isset($data['bg_color'])) {
            $hstoreData['bg_color'] = $data['bg_color'];
            unset($data['bg_color']);
        }
        if (isset($data['bg_image'])) {
            $hstoreData['bg_image'] = $data['bg_image'];
            unset($data['bg_image']);
        }
        if (isset($data['bg_link'])) {
            $hstoreData['bg_link'] = $data['bg_link'];
            unset($data['bg_link']);
        }
        $result = parent::insert($data);
        $this->updateByID($result, $hstoreData);
        return $result;
    }

    Это зачем, интересно?

    vistefan, 13 Марта 2018

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

    +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
    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
    63. 63
    64. 64
    #!/usr/bin/env escript
    %% -*- erlang -*-
    %%! -smp enable -debug verbose
    
    -include_lib("xmerl/include/xmerl.hrl").
    
    -export([main/1, install_mod/1]).
    
    -record(mod_info, { name  :: string()
                      , links :: [{file:filepath(), file:filepath()}]
                      }).
    
    main(Args) ->
        [ModeDir, GameDir] = Args,
        VirtualInstall = filename:absname(ModeDir ++ "/VirtualInstall/"),
        RealPath = filename:absname(GameDir),
        VirtualModCfg = VirtualInstall ++ "/VirtualModConfig.xml",
        io:format( "Mode dir: ~p~n"
                   "Install dir: ~p~n"
                   "Current dir: ~p~n"
                 , [VirtualInstall, RealPath, element(2, file:get_cwd())]),
        {Doc, []} = xmerl_scan:file(VirtualModCfg),
        Mods = get_mods(VirtualInstall, RealPath, Doc),
        [install_mod(I) || I <- Mods],
        ok.
    
    get_mods(VirtPath, RealPath, Doc) ->
        [ #mod_info
              { name  = xpath("/modInfo/@modName", Mod)
              , links = get_links(VirtPath, RealPath, Mod)
              }
          || Mod <- xmerl_xpath:string( "/virtualModActivator/modList/modInfo"
                                      , Doc)].
    
    get_links(VirtPath, RealPath, Doc) ->
        [{ filename:absname( unixify(xpath("/fileLink/@realPath", FL))
                           , VirtPath)
         , filename:absname( unixify(xpath("/fileLink/@virtualPath", FL))
                           , RealPath)
         }
         || FL <- xmerl_xpath:string( "//fileLink[isActive = 'True']"
                                    , Doc)].
    
    xpath(Query, Doc) ->
        case xmerl_xpath:string(Query, Doc) of
            [#xmlAttribute{value = Val}] ->
                Val
        end.
    
    unixify(Path) ->
        lists:map(
          fun($\\) -> $/;
             (A)   -> A
          end,
          Path).
    
    install_mod(#mod_info{name = Name, links = Links}) ->
        io:format("Installing ~s...~n", [Name]),
        lists:foreach(
          fun({From, To}) ->
                  filelib:ensure_dir(To),
                  file:make_symlink(From, To)
          end,
          Links).

    CHayT, 12 Марта 2018

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

    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
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    let src1 = r#"
            __kernel void add1(__global float* A, __global float* BBB, __global float* B, int m, int n) 
            {
                __local float Blo[64];
                int x = get_local_id(0);
                int y = get_local_id(1);
                int i = get_global_id(0);
                int j = get_global_id(1);
                int k = get_global_id(2);
                i += k / 8;
                j += k % 8;
    
                if (i >= n || j >= m) return;
    
    
                Blo[x * 8 + y] = A[i * m + j];
    
    
    
    
                barrier(CLK_LOCAL_MEM_FENCE);
    
                float BB = 0;
    
                for (int xx = 0; xx < 8; ++xx)
                    for (int yy = 0; yy < 8; ++yy)
                    {
        
                            float c = (2 * xx + 1) * x * 3.1415926535 / 16;
                            float cc = (2 * yy + 1) * y * 3.1415926535 / 16;
                            c = cos(c);
                            cc = cos(cc);
                            BB += Blo[xx * 8 + yy] * c * cc;
    
                    }
    
                float Ci, Cj;
                if (x == 0)
                    Ci = 1 / 1.4142135623;
                else
                    Ci = 1;
    
                if (y == 0)
                    Cj = 1 / 1.4142135623;
                else
                    Cj = 1;
                B[k * m * n + i * m + j] = Ci * Cj / 4 * BB;
    
                barrier(CLK_LOCAL_MEM_FENCE);
    
                i = get_global_id(0);
                j = get_global_id(1);
    
                float summ = 0;
                for (int ii = 0; ii < 64; ++ii)
                    summ += B[ii * m * n + i * m + j];
                BBB[i * m + j] = summ / 64;
                
            }
        "#;
    
    
    let pro_que = ProQue::builder().src(src1).dims((hi, wi, 64)).build().unwrap();
    
    
       let matr11 = Buffer::builder()
            .queue(pro_que.queue().clone())
            .flags(MemFlags::new().read_only().use_host_ptr())
            .dims((hi, wi))
            .host_data(&Resr)
            .build().unwrap();
    
            let matg11 = Buffer::builder()
            .queue(pro_que.queue().clone())
            .flags(MemFlags::new().read_only().use_host_ptr())
            .dims((hi, wi))
            .host_data(&Resg)
            .build().unwrap();
    
    ...
    
        let mut kernel;
        {
                let wi = wi as i32;
                let hi = hi as i32;
                kernel = pro_que.create_kernel("add1").unwrap().arg_buf(&matr11).arg_buf(&resr11).arg_buf(&bor1).arg_scl(wi).arg_scl(hi);
                kernel.lws((8, 8)).enq().unwrap();
                kernel = pro_que.create_kernel("add1").unwrap().arg_buf(&matg11).arg_buf(&resg11).arg_buf(&bog1).arg_scl(wi).arg_scl(hi);
                kernel.lws((8, 8)).enq().unwrap();
                kernel = pro_que.create_kernel("add1").unwrap().arg_buf(&matb11).arg_buf(&resb11).arg_buf(&bob1).arg_scl(wi).arg_scl(hi);
                kernel.lws((8, 8)).enq().unwrap();
        }

    Ничего особенного, лаба по opencl, написанная на Rustе

    gorthauer87, 24 Февраля 2018

    Комментарии (8)
  5. 1C / Говнокод #23713

    +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
    Запрос = Новый Запрос;
    	Запрос.Текст="ВЫБРАТЬ
    	|	ЗаказНаряд.Ссылка КАК Ссылка
    	|ИЗ
    	|	Документ.ЗаказНаряд КАК ЗаказНаряд
    	|ГДЕ
    	|	ЗаказНаряд.Проведен = ИСТИНА";	
    
    	Выборка=Запрос.Выполнить().Выбрать();
    	Выборка.Следующий();
    	Если обЗначениеНеЗаполнено(Выборка.Ссылка) Тогда
    .......

    Чуть упростил запрос для быстроты понимания...
    Как проверить запрос ПУСТОЙ() или нет... Вот один из разработчиков нашел метод.....

    timofeysin, 07 Февраля 2018

    Комментарии (8)
  6. Ruby / Говнокод #23615

    −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
    class Huyomoyo
    
      attr_reader :hui_razmer
    
      def initialize(hui_razmer = 0)
        @hui_razmer = case hui_razmer
          when 0
            'Нету'
          when 1..3
            'Пиздец маленький'
          when 4..6
            'Ну... Уже лучше'
          when 7..9
            'Норма'
          when 10..12
            'Ууажюха'
          when 13..17
            'Мдаааа'
          when 18..22
            'НИХУЯСЕБЕ'
          when 23..40
            'Да ты пиздишь'
          else
            'Че??'
        end
      end
    
      def print_hui
        puts @hui
      end
    end
    
    if __FILE__ == $0
      9.times do |i|
        kusokgovnokoda = case i
                           when 0
                             0
                           when 1
                             1
                           when 2
                             4
                           when 3
                             7
                           when 4
                             10
                           when 5
                             13
                           when 6
                             18
                           when 7
                             23
                           when 8
                             41
                         end
        Huyomoyo.new(kusokgovnokoda).print_hui
      end
    end

    Я не посню што это вообще... Вроде говнокод

    The_Nick_Dev, 23 Декабря 2017

    Комментарии (8)
  7. PHP / Говнокод #23570

    +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
    <?php
    $s       = "This";
    $is      = "an";
    $of      = "a";
    $ninja   = "coding";
    $This    = "is";
    $a       = "ninja";
    $coding  = "echo";
    $an      = "example";
    $example = "of";
    ${null}  = ' "$s';
    function z($x,$c='$'){return $x==1?$c:z($x-1,$c.'$');}
    for($i=1;$i<=7;$i++){${null}.=' ${'.z($i).'s}';}
    eval($$$$$$$$$s.${null}.'\n";');
    
    /*  Returns:
    This is an example of a ninja coding
    */

    PHP очарователен
    К посту http://govnokod.ru/23540

    ibragimych26, 08 Декабря 2017

    Комментарии (8)
  8. PHP / Говнокод #23528

    0

    1. 1
    2. 2
    3. 3
    https://github.com/VKCOM/bot-example-php/blob/master/html/bot/bot.php
    
    В великом и недосягаемом "ВКонтакте" переменные в текст по-прежнему включают с помощью фигурных скобок.

    COWuTEJIbTBOEuMAMKu, 14 Ноября 2017

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

    +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
    #define SPLICE(a,b) a##b
    #define LL(a,b) SPLICE(a,b)
    #define M(name) LL(NS,name)
    
    
    #define NS ns1_
    
    void M(somefunction)(){
    }
    
    #undef NS
    
    
    #define NS ns2_
    
    void M(somefunction)(){
    }
    
    #undef NS
    
    
    #define NS ns3_
    
    void M(somefunction)(){
    }
    
    #undef NS

    неймспейсы в Си на препроцессоре

    j123123, 30 Июля 2017

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

    +2

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    #include <iostream>
    #include <Windows.h>
    
    #define OCT_1 0
    #define OCT_2 12
    #define OCT_3 24
    #define OCT_4 36
    #define OCT_5 48
    #define OCT_6 60
    #define OCT_7 72
    #define OCT_8 84
    #define OCT_9 96
    
    #define NOTE_C 0
    #define NOTE_Ch 1
    #define NOTE_Db 1
    #define NOTE_D 2
    #define NOTE_Dh 3
    #define NOTE_Eb 3
    #define NOTE_E 4
    #define NOTE_F 5
    #define NOTE_Fh 6
    #define NOTE_Gb 6
    #define NOTE_G 7
    #define NOTE_Gh 8
    #define NOTE_Ab 8
    #define NOTE_A 9
    #define NOTE_Ah 10
    #define NOTE_Bb 10
    #define NOTE_B 11
    
    long double notes[200];
    
    #define TEMPO 100
    #define LEN1 (120000 / TEMPO)
    #define LEN2 (LEN1 / 2)
    #define LEN4 (LEN1 / 4)
    #define LEN8 (LEN1 / 8)
    #define LEN16 (LEN1 / 16)
    
    #define melody_len 28
    struct s {
    	int key, len;
    	s(int key, int len) {
    		this->key = key;
    		this->len = len;
    	}
    } melody[melody_len] = {
    	s(OCT_4 + NOTE_E, LEN8),
    	s(OCT_4 + NOTE_E, LEN8),
    	s(OCT_5 + NOTE_C, LEN4),
    	
    	s(OCT_4 + NOTE_E, LEN8),
    	s(OCT_4 + NOTE_E, LEN8),
    	s(OCT_5 + NOTE_C, LEN4),
    	
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_4 + NOTE_E, LEN4),
    	
    	s(OCT_5 + NOTE_E, LEN8),
    	s(OCT_5 + NOTE_E, LEN8),
    	s(OCT_4 + NOTE_D, LEN8),
    	s(OCT_4 + NOTE_D, LEN8),
    	
    	s(OCT_5 + NOTE_E, LEN8),
    	s(OCT_5 + NOTE_E, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_4 + NOTE_E, LEN4),
    };
    
    int main(int argc, char** argv) {
    	notes[0] = 32.7032;
    	for(int i = 1; i < 200; ++i)
    		notes[i] = notes[i - 1] * 1.05946309436;
    		
    	for(int i = 0; i < melody_len; ++i) {
    		int key = melody[i].key;
    		int len = melody[i].len;
    		
    		if(key < 0) Sleep(len);
    		else Beep(notes[key], len);
    	}
    	
    	return 0;
    }

    Дохуя мелодия... с 1 класса музыкалки...

    Losyash1337, 27 Мая 2017

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

    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
    #include "hex.h"
    #include "aes.h"
    #include <stdio.h>
    
    #define KEY (0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c)
    #define DATA (0x32, 0x43, 0xf6, 0xa8, 0x88, 0x5a, 0x30, 0x8d, 0x31, 0x31, 0x98, 0xa2, 0xe0, 0x37, 0x07, 0x34)
    
    unsigned char enc[] = { BPP_AES_ENCRYPT_ARRAY(KEY, DATA) };
    
    int main() {
        for (int i=0; i<sizeof(enc); ++i) {
            printf("%02X ", enc[i]);
        }
        printf("\n");
        return 0;

    HAPKOMAH, 14 Мая 2017

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