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

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function test() {
        const ws = new WebSocket('ws://127.0.0.1:445');
        ws.addEventListener('close', event =>
            console.log('event.code = ', event.code, '; event.reason = ', event.reason)
        );
        ws.close(3500, 'some reason');
    }
    test();

    Кто угадает значения полей event.code и event.reason — тому два нихуя.
    Кто угадает значение одного из полей — тому одно нихуя.

    ISO, 10 Февраля 2022

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

    +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
    <?php include_once("routing" .DIRECTORY_SEPARATOR  . "Router.php");?>
    <?php include_once("task" . DIRECTORY_SEPARATOR . "Task.php");?>
    <?php include_once("db" . DIRECTORY_SEPARATOR . "DB.php");?>
    <?php include_once("model" . DIRECTORY_SEPARATOR . "Model.php");?>
    <?php 
    class App{
    	public static $webuser = null;
    	public static $config;
    	public static $routing;
    	public static $DB;
    	public static $document_root;
    	
    	public static function run($config){
    		//config
                    self::$config = $config;
                    
                    /**
                     * init database
                     */
                    
                    
                    $db = new DB();
                    $db->connect(self::$config['db']);
                    self::$DB = $db;
                    
                    
                    
                    /**
                     * Run task
                     */
    		$request      = Router::getRequest(self::$config['default_task']);
    		
    		$task_path    = self::$document_root . DIRECTORY_SEPARATOR . "tasks" . DIRECTORY_SEPARATOR . $request . ".php";
                    
                    
                    
    		if(file_exists($task_path )){
    			include_once($task_path);
    			
    			$task = new $request();
    			
    			$task->init();
    		
    		}else {
    			throw new Exception("File don't exists");
    		}
                    
    			
    	}
            
            public static function isGuest(){
                if(is_null(self::$webuser)){
                    return true;
                }
                return false;
            }
    }
    ?>

    http://govnokod.ru/27036#comment585451

    https://habr.com/ru/post/523828/https://habr.com/ru/post/523828/

    я так ахуел, что скачал и посмотрел... говорят теперь я должен сжечь комп

    pahhan, 04 Декабря 2020

    Комментарии (85)
  4. Java / Говнокод #27044

    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
    var io = java.io
    var BufferedReader = io.BufferedReader
    var BufferedWriter = io.BufferedWriter
    var InputStreamReader = io.InputStreamReader
    var OutputStreamWriter = io.OutputStreamWriter
    
    var Socket = java.net.Socket
    var socket = new Socket("localhost", 5050)
    var input = new BufferedReader(new InputStreamReader(socket.getInputStream()))
    var output = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
    
    while(true){
      var data = input.readLine()
      console.log(data)
    }

    Один петух написал мне в три часа ночи с прозьбой помочь с кодом

    digitalEugene, 21 Октября 2020

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

    +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
    catch (Exception &exception)
    	{
    		Application->ShowException(&exception);
    	}
    	catch (...)
    	{
    		try
    		{
    			throw Exception("");
    		}
    		catch (Exception &exception)
    		{
    			Application->ShowException(&exception);
    		}
    	}

    https://github.com/greatis/Anti-WebMiner/blob/master/AntiWebMiner.cpp#L23

    MAKAKA, 13 Сентября 2020

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

    +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
    #include "gc.h"
    
    static bool PointerNotOwnedByParentStackFrame(struct StackFrame *frame,
                                                  struct StackFrame *parent,
                                                  void *ptr) {
      return !(((intptr_t)ptr > (intptr_t)frame) &&
               ((intptr_t)ptr < (intptr_t)parent));
    }
    
    /**
     * Adds destructor to garbage shadow stack.
     *
     * @param frame is passed automatically by wrapper macro
     * @param fn takes one argument
     * @param arg is passed to fn(arg)
     * @return arg
     */
    void __defer(struct StackFrame *frame, void *fn, void *arg) {
      struct StackFrame *frame2;
      if (!arg) return;
      frame2 = __builtin_frame_address(0);
      assert(frame2->next == frame);
      assert(PointerNotOwnedByParentStackFrame(frame2, frame, arg));
      if (append(&__garbage, /* note: append() not included */
                 (&(const struct Garbage){frame->next, (intptr_t)fn, (intptr_t)arg,
                                          frame->addr})) != -1) {
        frame->addr = (intptr_t)&__gc;
      } else {
        abort();
      }
    }

    deferы в Сищечке

    https://gist.github.com/jart/aed0fd7a7fa68385d19e76a63db687ff

    3.14159265, 04 Июня 2020

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

    +5

    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
    #include <stdio.h>
    #define UPP 300
    float conversion(float fahr);
    
    main(){
    	float far;
    	int a;
    	a = UPP;
    	for(far = 0; far <= a; ++++++++++++++++++++++++++++++++++++++++far)
    		printf("%.f\t%.1f\n", far, conversion(far));
    }
    
    float conversion(float cels){
    	float c;
    	c = ((5*(cels-32))/(9));
    	return c;
    }

    how do I make it 20 by 20 in a shorter way, without having to put 20 times "++" please

    https://www.reddit.com/r/C_Programming/comments/ff5zph/how_do_i_make_it_20_by_20_in_a_shorter_w ay/

    eukaryote, 08 Марта 2020

    Комментарии (85)
  8. Python / Говнокод #26001

    +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
    import re, copy, json
    
    config = {}
    
    
    def domain_mapper(domain):
    	def injector(f):
    		if domain not in config:
    			config[domain] = []
    		config[domain].append(f)
    	return injector
    
    def default(f):
    	config['default'] = [f]
    	return f
    
    @domain_mapper("gmail.com")
    @default
    def google_filter(content):
    	regex = r"([^\!\?\.]*?offer.*?[\!\?\.])"
    	repl = r""
    	return re.sub(regex, repl, content, re.M)
    
    @domain_mapper("gmail.com")
    def another_google_filter(content):
    	return content
    
    @domain_mapper("yandex.ru")
    def yandex_filter(content):
    	regex = r"<img src=[\"'](.+?)[\"'].*/>"
    	repl = r"\1"
    	return re.sub(regex, repl, content, re.M)
    
    @domain_mapper("mail.ru")
    def mail_filter(content):
    	regex = r"<img src=[\"'](.+?)\.gif[\"'].*/>"
    	repl = r"<img src='\1.png'/>"
    	return re.sub(regex, repl, content, re.M)

    Говно или нет?

    miwomare, 28 Октября 2019

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

    −1

    1. 1
    Чем "Go" влажнее "PHP"?

    Увидел, что "Авито" переводит свои вспомогательные сервисы на "Go", и запаниковал.

    inseminator, 15 Июля 2019

    Комментарии (85)
  10. Python / Говнокод #25451

    +2

    1. 1
    int(data[:4][::-1].encode('hex'),16)

    Кто-то не знал про struct

    syoma, 16 Марта 2019

    Комментарии (85)
  11. Си / Говнокод #25296

    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
    void decode_chunk(const char* s, uint8_t* out)
    {
        __m128i a = _mm_loadu_si128((const __m128i*)s);
    
        __m128i u = _mm_and_si128(a, _mm_set1_epi8(0x74));
        u = _mm_add_epi8(u, _mm_set1_epi8(0x04));
        u = _mm_srli_epi32(u, 0x03);
        u = _mm_and_si128(u, _mm_set1_epi8(0x0F));
        u = _mm_shuffle_epi8(_mm_set_epi32(0xB9B9B9B9, 0xBFBFBFBF, 0x04041013, 0x00000000), u);
        a = _mm_add_epi8(a, u);
    
        __m128i m1 = _mm_set1_epi32(0xFF00FF00);
        __m128i m2 = _mm_set1_epi32(0xFFFF0000);
        a = _mm_shuffle_epi8(a, _mm_set_epi32(0x00010203, 0x04050607, 0x08090A0B, 0x0C0D0E0F));
        a = _mm_or_si128(_mm_srli_epi32(_mm_and_si128(m1, a), 2), _mm_andnot_si128(m1, a));
        a = _mm_or_si128(_mm_srli_epi32(_mm_and_si128(m2, a), 4), _mm_andnot_si128(m2, a));
        a = _mm_shuffle_epi8(a, _mm_set_epi32(0x80808080, 0x00010204, 0x05060809, 0x0A0C0D0E));
    
        _mm_storeu_si128((__m128i*)out, a);
    }

    Байтоёбский парсинг base64 (16 символов → 12 байт).

    По мотивам http://govnokod.ru/12822#comment173404

    bormand, 09 Января 2019

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