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

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

    +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
    import java.util.Scanner;
    
    public class ComputeTax {
    
    public static void main(String[] args) {
    // Create a Scanner
    Scanner input = new Scanner(System.in);
    
    // Prompt the user to enter filing status
    System.out.print(
        "(0-single filer, 1-married jointly or qualifying widow(er)",
        + "\n2-married separately, 3-head of household)\n" +
        "Enter the filing status: ");
    int status = input.nextInt();
    
    // Prompt the user to enter taxable income
    System.out.print("Enter the taxable income: ");
    double income = input.nextDouble();
    
    // Compute tax
    double tax = 0;
    
    if (status == 0) {// Compute tax for single filers
        if (income <= 8350)
              tax = income * 0.10;
        else if (income <= 33950)
              tax = 8350 * 0.10 + (income - 8350) * 0.15;
        else if (income <= 82250)
              tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
             (income - 33950) * 0.25;
        else if (income <= 171550)
              tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
             (82250 - 33950) * 0.25 + (income - 82250) * 0.28;
        else if (income <= 372950)
              tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
              (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
              (income - 171550) * 0.33;
        else
              tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
             (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
             (372950 - 171550) * 0.33 + (income - 372950) * 0.35;
    }
    else if (status == 1) {
    // Left as exercise
    // Compute tax for married file jointly or qualifying widow(er)
    }
    else if (status == 2) {
    // Compute tax for married separately
    // Left as exercise
    }
    else if (status == 3) {
    // Compute tax for head of household
    // Left as exercise
    }
    else {
        System.out.println("Error: invalid status");
        System.exit(1);
    }
    // Display the result
    System.out.println("Tax is " + (int)(tax * 100) / 100.0);
    
    }

    Ksyrx, 26 Октября 2019

    Комментарии (52)
  3. JavaScript / Говнокод #25993

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    const getSizeString = (size: number) => {
        const mesuarments = ["Б", "кБ", "МБ", "ГБ"];
        let i = 0;
        for (; size/1024 > 1; size /= 1024, i++)
            ;
    
        return ${Math.floor(size) === size ? size : (size).toFixed(1)} ${mesuarments[i]};
    }

    m_sandman, 25 Октября 2019

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

    +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
    class Container:
        def __init__(self, liquid):
            self.liquid = liquid
    
        def look_inside(self):
            return f"{self.liquid} in container"
    
        @classmethod
        def create_with(cls, liquid):
            return cls(liquid)
    
    
    class Bottle(Container):
        def look_inside(self):
            return f"bottle full of {self.liquid}"
    
    
    class Glass(Container):
        def look_inside(self):
            return f"A glass of {self.liquid}"
    
    
    for c in (c.create_with("beer") for c in [Glass, Bottle]):
        print(c.look_inside())

    ми маємо class polymorphism

    DypHuu_niBEHb, 23 Октября 2019

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>

    Защита контента для самых маленьких

    bootcamp_dropout, 22 Октября 2019

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

    +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
    #include <cstdio>
    
    class tag;
    
    template<class>
    struct type { friend constexpr auto get(type); };
    
    template<class TKey, class TValue>
    struct set { friend constexpr auto get(TKey) { return TValue{}; } };
    
    void foo() {            // never called
      if constexpr(false) { // never true
        if (false) {        // never true
            constexpr auto call = [](auto value) { std::printf("called %d", value); };
            void(set<type<tag>, decltype(call)>{});
        }
      }
    }
    
    int main() {
      get(type<tag>{})(42); // prints called 42
    }

    https://twitter.com/krisjusiak/status/1186363017329594368
    Какой C++20 )))

    j123123, 21 Октября 2019

    Комментарии (71)
  7. Куча / Говнокод #25979

    +1

    1. 1
    "Performance is easy. All you need to know is everything" (c) S. Kuksenko (@kuksenk0)

    Умеете профилировать программы?
    Знаете, что такое flame diagram? Умеете посмотреть стектрейс от входа в тред до какого-нить спинлока в ядре? Смотрите асм своего компилятора или джита? Знаете, какая инструкция сколько занимает?
    Умеете по vmstat/iostat или xperf/perf counters увидать проблему и соотнести ее с программой? Используете dtrace голый или с instruments? yourkit? vTune? valgrind? bpf?
    Или такие же дебилы, как я?

    MAKAKA, 20 Октября 2019

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

    +1

    1. 1
    public int HowManyHoursWillGoBackForConvertingUkToUtc(DateTime ukTime) => IsAlreadyGoForward(ukTime) ? 1 : 0;

    когда название говорит само за себя

    govnoBet, 17 Октября 2019

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

    +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
    <?php
    
    require_once '../vendor/autoload.php';
    require_once 'functions.php';
    require_once 'KPFile.php';
    require_once 'KPLogger.php';
    
    use Intervention\Image\ImageManagerStatic as Шакализатор;
    
    Шакализатор::configure(array('driver' => 'imagick'));
    
    $logger = new KPLogger();
    
    function сжать(KPFile $шакал, $степеньСжатия, Array $ебучесть, $output) {
        $индексЕбучести = 0;
        if (!is_null($ебучесть[0])) {
            $индексЕбучести = $ебучесть[0];
        }
        if (!is_null($ебучесть[1]) && ($ебучесть[1] > $ебучесть[0])) {
            $индексЕбучести = $ебучесть[1];
        }
    
        $img = Шакализатор::make($шакал->path);
        $img->resize($ебучесть[0], $ебучесть[1], function ($constraint) {
            $constraint->aspectRatio();
            $constraint->upsize();
        });
        if ($img->mime() !== 'image/jpeg') {
            $img->encode('jpg', 100);
        }
        $img->save($output."$шакал->name-$индексЕбучести.jpg", $степеньСжатия);
    }
    
    function сжатьВсехШакалов($path, $степеньСжатия, $ебучестьШакалов, $output) {
        global $logger;
        $files = scandir($path);
        foreach($files as $key => $file) {
            $logger->colorLogWithFiles('blue', $file, $key);
            try {
                $шакал = new KPFile($path.$file);
                if ($шакал->type !== KPFile::FILE_TYPE_IMAGE) {
                    continue;
                }
                if (trim($шакал->name) == '') {
                    throw new Exception("file=$file, kpFileName=$шакал->name");
                }
                foreach ($ебучестьШакалов as $ебучесть) {
                    сжать($шакал, $степеньСжатия, $ебучесть, $output);
                }
            } catch (Exception $e) {
                $logger->exception($e, $key);
            }
        }
    }
    
    $степеньСжатия = 22;
    $ебучестьШакалов = [
        [60, 60],
        [38, 38]
    ];
    сжатьВсехШакалов('dataHeavy/carsOrig/', $степеньСжатия, $ебучестьШакалов, "../public/img/cars/");
    
    
    $logger->colorLogWithFiles('blue', '10/10 *** еб/шакалов', null, "\n");

    shakal of jpeg-street

    raduloh, 17 Октября 2019

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

    +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
    #include "pch.h"
    #include <iostream>
    #include <conio.h>
    #include <stdlib.h>
    #include <ctime>
    
    using namespace std;
    
    int main()
    {
    	setlocale(0, "rus");
    	int n, a[1000], max, c;
    	cout << "число элементов: "; cin >> n;
    	srand(time(0));
    	
    	cout << "\nчисла массива:\n";
    	for (int i = 0; i < n; i++) {
    		a[i] = rand() % 2000 -1000;
    		cout << a[i] << " ";
    		if (i == 0) max = abs(a[i]); else if (abs(a[i]) > max) max = abs(a[i]);
    	}
    	cout << "\n\nабс. максимум = " << max << endl;
    
    	for (int i = 0; i < n; i++) {
    		for (int j = n-1; j > 0; j--) {
    			if (a[j - 1] < a[j]) {
    				c = a[j - 1];
    				a[j - 1] = a[j];
    				a[j] = c;
    			}
    		}
    	}
    
    	cout << "\nотсортированный массив:\n";
    	for (int i = 0; i < n; i++) {
    		cout << a[i]<<" ";
    	}
    
    	_getch();
    	return 0;
    }

    maxrbs, 15 Октября 2019

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

    +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
    // File icontact.h
    // Describes a contact in the address book
    class IContact
    {
    public:
        virtual ~IContact();
        virtual void ... 
        ... 
        void setContact(const QString& contact);
        ...
    private:
        QString m_contact;
        // ... other fields ...
    };
    
    // File icontact.cpp
    void IContact::setContact(const QString &contact)
    {
        m_contact = contact;
    }

    "Ну и че тут непонятного?" (Senior software developer, 8+ years of experience)

    salamon_style, 11 Октября 2019

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