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

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    Руби говно на всей Земле
    Руби говно другим во благо
    Не за красивое "спасибо"
    А за хорошее бабло

    inho, 05 Октября 2017

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

    +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
    N = int(input())
    S = []
    for i in range(N):
        S.append(list(map(float, input().split())))
    for i in range(len(S)):
        S[i][0], S[i][1] = S[i][1], S[i][0]
    S.sort()
    for x in range(N):
        for i in range(N-1):
            if S[i][0] == S[i+1][0]:
                if S[i][1] < S[i+1][1]:
                    S[i][1], S[i+1][1] = S[i+1][1], S[i][1]
    for i in range(N):
    print((str(round(S[i][1], 2))[:str(round(S[i][1], 2)).index('.')]+(str(round(S[i][1], 2))+'00000000')[str(round(S[i][1], 2)).index('.'):str(round(S[i][1], 2)).index('.')+3]),(str(round(S[i][0], 3))[:str(round(S[i][0], 3)).index('.')]+(str(round(S[i][0], 3))+'00000000')[str(round(S[i][0], 3)).index('.'):str(round(S[i][0], 3)).index('.')+4]))

    Нужно было дописать эту прогу во что бы то ни стало...

    Caladrius, 03 Сентября 2017

    Комментарии (5)
  4. PHP / Говнокод #23317

    +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
    $parent = (new \yii\db\Query())
    ->select(['parent','parent_1','parent_2'])
    ->from('user')
    ->where(['id' => "$user_id",])
    ->all();
    
    $sum_for_parent = (new \yii\db\Query())
    ->select(['first_parent'])
    ->from('referal_control')
    ->all();
    
    $sum_for_parent = $sum_for_parent[0]['first_parent'];    
    
    $sum_for_parent_1 = (new \yii\db\Query())
    ->select(['second_parent'])
    ->from('referal_control')
    ->all();
    $sum_for_parent_1 = $sum_for_parent_1[0]['second_parent'];     
    
    $sum_for_parent_2 = (new \yii\db\Query())
    ->select(['third_parent'])
    ->from('referal_control')
    ->all();    
    $sum_for_parent_2 = $sum_for_parent_2[0]['third_parent'];

    Обращение к одной записи к 3-м полям через три запроса

    reddevil, 31 Августа 2017

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public function get_link(){
            if (function(){
                return stripos(strtolower($_SERVER['HTTP_USER_AGENT']), 'android');}){
                return $this->get_android_link();
            }
            else{
                return $this->get_ios_link();
            }
        }

    mk354, 30 Августа 2017

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

    +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
    // https://github.com/julycoding/The-Art-Of-Programming-By-July/blob/master/ebook/code/c/1.1%EF%BC%9A%E5%B7%A6%E6%97%8B%E8%BD%AC%E5%AD%97%E7%AC%A6%E4%B8%B2.c
    
    #include <stdio.h>
    #include <string.h>
    //字符串旋转问题,例如abcdef 左旋2位 变成 cdefab
    
    //暴力移位法
    void leftShift1(char * arr, int n)
    {
        size_t tmpLen = strlen(arr);
        char tmpChar;
        int i, j;
        if (n >= 0)
        {
            for (i = 0; i < n; i++)
            {
                tmpChar = *arr;
                for (j = 0; j < tmpLen - 1; j++)
                {
                    *(arr + j) = *(arr + j + 1);
                }
                *(arr + tmpLen - 1) = tmpChar;
            }
        }
        else
        {
            for (i = 0; i < -n; i++)
            {
                tmpChar = *(arr + tmpLen - 1);
                for (j = tmpLen - 1; j > 0; j--)
                {
                    *(arr + j) = *(arr + j - 1);
                }
                *arr = tmpChar;
            }
        }
    }

    Копаясь в гитхабе, нашел я тут The Art Of Programming By July, написанный каким-то китайцем.
    https://github.com/julycoding/The-Art-Of-Programming-By-July

    j123123, 18 Августа 2017

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    if($category_id!='')
            $this->db->where('group_category =', $category_id);
            if($group_by == TRUE)
            $this->db->group_by('blog_cat_name');

    У меня создалось впечатление, что здесь специально замаскировали все ифы. Чтобы читающий думал, что это линейный код. На скобках - экономят, на пробелах - экономят.

    gorsash, 17 Августа 2017

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    internal static object CopyImmutableSortedDictionary<K, V>(object original, ICopyContext context)
    {
                return original;
    }

    Microsoft Orleans https://github.com/dotnet/orleans

    Копирование объекта в 2к17

    ClockworkAlex, 04 Августа 2017

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

    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
    primary_list = tuple([line.strip() for line in open('file1.txt', 'r')])
    secondary_list = tuple([line.strip() for line in open('file2.txt', 'r')])
    f = open('test.txt', 'w')
    
    users_unique = []
    
    def isUnique(value):
      if value not in users_unique:
        users_unique.append(value)
        return True
      else:
        return False
    
    def common():
      for item in primary_list:
        if item is None:
          continue
        elif item in secondary_list and isUnique(item):
          f.write(str(item)+'\r\n')
      print 'Complete'

    Masha-Rostova, 07 Июня 2017

    Комментарии (5)
  10. PHP / Говнокод #23102

    +4

    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
    function check_for_injection($_arr_check) {
        $inj = 0;
        foreach ($_arr_check as $n=>$v) {
            $_text = "SELECT ";
            if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
            $_text = " SELECT";
            if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
            $_text = "DELETE ";
            if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
            $_text = "UPDATE ";
            if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
            $_text = "INSERT ";
            if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
            $_text = "LOAD ";
            if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
            $_text = "DROP ";
            if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
            $_text = "INTO ";
            if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
            $_text = "OUTFILE ";
            if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
            $_text = "CALL ";
            if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
        }
        return $inj;
    }
    $dd = check_for_injection($_REQUEST);
    if ($dd==1) die();

    Надежный способ проверки на взлом

    ostin, 05 Июня 2017

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

    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
    #!/usr/bin/python
    #encoding: utf-8
    
    import sys
    import time
    import socket
    import asyncore
    import exceptions
    
    from socket import AF_INET, SOCK_STREAM
    from asyncore import dispatcher
    from threading import Thread, RLock
    
    class PiCalcThread(Thread):
        def __init__(self, buffer, lock):
            Thread.__init__(self)
            self.buffer = buffer
            self.lock = lock
            
        def run(self):
            """ See http://web.comlab.ox.ac.uk/oucl/work/jeremy.gibbons/publications/spigot.pdf """
            q,r,t,k,n,l = 1,0,1,1,3,3
            
            while True:
                if 4*q+r-t < n*t:
                    self.lock.acquire()
                    self.buffer.newDigits(str(n))
                    self.lock.release()
                    
                    q,r,t,k,n,l = (10*q,10*(r-n*t),t,k,(10*(3*q+r))/t-10*n,l)
                else:
                    q,r,t,k,n,l = (q*k,(2*q+r)*l,t*l,k+1,(q*(7*k+2)+r*l)/(t*l),l+2)
                
                time.sleep(0.001)
    
    class PiGenerator(list):
        def __init__(self):
            list.__init__(self)
            self.calculator = None
            self.lock = RLock()
            self.digits = ''
        
        def subscribe(self, obj):  
            self.lock.acquire()
            try:     
                self.append(obj)
                self._notify(obj=obj)
            finally:
                self.lock.release()            
                
            if not self.calculator:
                self.calculator = PiCalcThread(self, self.lock)
                self.calculator.start()
            else:
                if len(self) > 0:
                    self._resumeCalculator()
                    
        def unsubscribe(self, obj):
            self.lock.acquire()
            self.remove(obj)   
            self.lock.release()
                 
            if len(self) <= 0:
                self._pauseCalulator()
                
        def _pauseCalulator(self):
            self.lock.acquire()
        
        def _resumeCalculator(self):
            try: self.lock.release()
            except exceptions.AssertionError: pass
                
        def _notify(self, digits = None, obj = None):
            objs = [obj] if obj else self
            digits = digits or self.digits
            
            for obj in objs:
                obj.update(digits)
            
        def newDigits(self, digits):
            self.digits += digits
            self._notify(digits)

    Lis, 23 Мая 2017

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