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

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

    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
    <div class="choose_payment">
                    	<div class="title"><span>2</span>Выберите способы оплаты (все без комиссии)</div>
                        <!-- all terminals -->
                        <div class="all_terminals">
                              <!-- fike: конечно же тут были все терминалы, а вы как думали? -->
                        </div>        
    					<!-- payments. no commisson -->
                       <div class="no_commission"><label>
                        	<div class="title_no_commission"><i>Подсказка:</i></div>
                            
                            <div class="we_recommend_2">
                            	<div class="title_we_recommend_2">
    					Оплачиваете первый раз?<br>
    					наши специалисты ответят на все вопросы <br>
    					<!--?phpphp echo preg_replace("/([0-9]{1})([0-9]{3})([0-9]{3})([0-9]{2})([0-9]{2})/", "+$1 ($2) $3-$4-$5", SUPPORT_PHONE); ?--> ежедневно с 10:00 до 19:00
    				</div>
                            </div>
    						</label>
                        </div>
                    </div>

    А впрочем нет, не ответят

    Fike, 20 Марта 2020

    Комментарии (23)
  3. Go / Говнокод #26349

    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
    // GostServer is the type that contains all of the relevant information to set
    // up the GOST HTTP Server
    type GostServer struct {
    	host       string      // Hostname for example "localhost" or "192.168.1.14"
    	port       int         // Port number where you want to run your http server on
    	api        *models.API // SensorThings api to interact with from the HttpServer
    	https      bool
    	httpsCert  string
    	httpsKey   string
    	httpServer *http.Server
    }
    
    // CreateServer initialises a new GOST HTTPServer based on the given parameters
    func CreateServer(host string, port int, api *models.API, https bool, httpsCert, httpsKey string) Server {
    	setupLogger()
    	a := *api
    	router := CreateRouter(api)
    	return &GostServer{
    		host:      host,
    		port:      port,
    		api:       api,
    		https:     https,
    		httpsCert: httpsCert,
    		httpsKey:  httpsKey,
    		httpServer: &http.Server{
    			Addr:         fmt.Sprintf("%s:%s", host, strconv.Itoa(port)),
    			Handler:      PostProcessHandler(RequestErrorHandler(LowerCaseURI(router)), a.GetConfig().Server.ExternalURI),
    			ReadTimeout:  30 * time.Second,
    			WriteTimeout: 30 * time.Second,
    		},
    	}
    }
    
    // Start command to start the GOST HTTPServer
    func (s *GostServer) Start() {
    	t := "HTTP"
    	if s.https {
    		t = "HTTPS"
    	}
    
    	logger.Infof("Started GOST %v Server on %v:%v", t, s.host, s.port)
    
    	var err error
    	if s.https {
    		err = s.httpServer.ListenAndServeTLS(s.httpsCert, s.httpsKey)
    	} else {
    		err = s.httpServer.ListenAndServe()
    	}
    
    	if err != nil {
    		logger.Panicf("GOST server not properly stopped: %v", err)
    	}
    }
    
    // Stop command to stop the GOST HTTP server
    func (s *GostServer) Stop() {
    	if s.httpServer != nil {
    		logger.Info("Stopping HTTP(S) Server")
    		s.httpServer.Shutdown(context.Background())
    	}
    }

    Нашёл ГостСервер го

    https://github.com/gost/server/blob/master/http/gostserver.go

    gostinho, 13 Января 2020

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

    +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
    /**
         * Four state boolean.
         */
        enum Bool {
            /** */
            FALSE,
    
            /** */
            TRUE,
    
            /** */
            READY,
    
            /** */
            DONE
        }

    MAKAKA, 27 Ноября 2019

    Комментарии (23)
  5. bash / Говнокод #25985

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    set -e
    
    myfunc() {
      echo "START"
      v=$(asdasdsd 1 2 3)
      echo "FINISH"
    }
    
    myfunc && echo "OK"

    Выводит:

    START
    ./b.sh: line 5: asdasdsd: command not found
    FINISH
    OK

    asdasdsd - несуществующая команда, вызывающая падение скрипта

    Помогите сделать так, чтобы ошибку можно было поймать, и чтобы до echo "FINISH" не доходило.
    Уже всё перепробовал. Нерабочие вореанты просьба не предлагать.



    Вот так работает правильно
    set -e

    myfunc() {
    echo "START"
    v=$(asdasdsd 1 2 3)
    echo "FINISH"
    }

    myfunc


    Выводит:
    START
    ./a.sh: line 5: asdasdsd: command not found

    Но мне нужно ошибку перехватить.

    guestinxo, 22 Октября 2019

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

    −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
    #include <stdio.h>
    #include <stdlib.h>
    
    
    int main(int argc, char *argv[])
    
    //типа explode в php;
    {
    int i=0;
    //char s=';';
    char s=argv[2][0];
    
    i=100;
    //char** data;
    //data=(char**)malloc(i+1);
    char data[1000][1000];
    char* str;
    str=malloc(i+1);
    str=argv[1];
    printf("%s\n",str );
    int n=0;
    int m=0;
    
    
    while (*str) {
    if (*str==s)
    {m++;n=0;str++;continue;};
      data[m][n]=*str;
      str++;n++;
    
    };
    printf("%s\n",data[0] );
    
    }

    Типа explode в php
    Кто-нить знает как это заставить работать с
    //char** data;
    //data=(char**)malloc(i+1);
    ??

    killer1804, 03 Сентября 2019

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

    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
    ВЫБРАТЬ РАЗЛИЧНЫЕ
    	ВЫРАЗИТЬ(Работы.Ссылка КАК Документ.ЗаказНаряд) КАК СсылкаЗН,
    	ДЦ.Ссылка КАК ДилерскийЦентр
    ИЗ
    	Документ.ЗаказНаряд.Работы КАК Работы
    		ЛЕВОЕ СОЕДИНЕНИЕ Справочник.CRM_ДилерскиеЦентры КАК ДЦ
    		ПО (ЛОЖЬ)
    ГДЕ
    	Работы.Ссылка.ДатаЗакрытия >= &ДатаНачала
    	И Работы.Ссылка.ДатаЗакрытия < &ДатаОкончания
    	И ДЦ.Ссылка.ПометкаУдаления = ЛОЖЬ
    ;

    Язык запросов 1С. При таком соединение запрос запрос всегда будет пустым.

    NioGoth, 29 Августа 2019

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $products = $this->cart->getProducts();
    foreach ($products as $product) {
    	$product_total = 0;
    	foreach ($products as $product_2) {
    		if ($product_2['product_id'] == $product['product_id']) {
    			$product_total += $product_2['quantity'];
    		}
    	}
    ....
    }

    Поечему опенкарт так странно вычисляет количество товаров в корзине? неужели нет способа изящней?

    pseudoJun, 14 Августа 2019

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    $id=$id-1;
    	$id++;
    	$id=(int)$id;
    	Дальше в sql запрос ее конкотенируют.

    ОМГ, я даже представить не могу для чего нужны первые 3 строки в совокупности в 3-й..

    stainer, 30 Июля 2019

    Комментарии (23)
  10. Swift / Говнокод #25705

    +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
    /* Create a JSON object from JSON data stream. The stream should be opened and configured. All other behavior of this method is the same as the JSONObjectWithData:options:error: method.
         */
    open class func jsonObject(with stream: InputStream, options opt: ReadingOptions = []) throws -> Any {
        var data = Data()
        guard stream.streamStatus == .open || stream.streamStatus == .reading else {
             fatalError("Stream is not available for reading")
         }
         repeat {
             var buffer = [UInt8](repeating: 0, count: 1024)
             var bytesRead: Int = 0
             bytesRead = stream.read(&buffer, maxLength: buffer.count)
             if bytesRead < 0 {
                 throw stream.streamError!
             } else {
                 data.append(&buffer, count: bytesRead)
             }
         } while stream.hasBytesAvailable
         return try jsonObject(with: data, options: opt)
    }

    Потоковое чтение JSON от авторов "iСделаль"

    Desktop, 07 Июля 2019

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    var type = shape switch
    {
      Rectangle((0, 0), 0, 0) => "Point at origin",
      Circle((0, 0), _) => "Circle at origin",
      Rectangle(_, var w, var h) when w == h => "Square",
      Rectangle((var x, var y), var w, var h) =>
        $"A {w}×{h} rectangle at ({x},{y})",
      _ => "something else"
    };

    https://habr.com/ru/post/454446/#comment_20232586

    Какой бароп )))

    OCETuHCKuu_nemyx, 02 Июня 2019

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