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

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

    +77

    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
    public CommandResult update() {
                CommandResult res = null;
                try {
                    long start = System.nanoTime();
                    res = _port.runCommand(_mongo.getDB("admin"), isMasterCmd);
                    long end = System.nanoTime();
                    float newPingMS = (end - start) / 1000000F;
                    if (!successfullyContacted)
                        _pingTimeMS = newPingMS;
                    else
                        _pingTimeMS = _pingTimeMS + ((newPingMS - _pingTimeMS) / latencySmoothFactor);
    
                    getLogger().log(Level.FINE, "Latency to " + _addr + " actual=" + newPingMS + " smoothed=" + _pingTimeMS);
    
                    successfullyContacted = true;
    
                    if (res == null) {
                        throw new MongoInternalException("Invalid null value returned from isMaster");
                    }
    
                    if (!_ok) {
                        getLogger().log(Level.INFO, "Server seen up: " + _addr);
                    }
                    _ok = true;
    
                    // max size was added in 1.8
                    if (res.containsField("maxBsonObjectSize")) {
                        _maxBsonObjectSize = (Integer) res.get("maxBsonObjectSize");
                    } else {
                        _maxBsonObjectSize = Bytes.MAX_OBJECT_SIZE;
                    }
                } catch (Exception e) {
                    if (!((_ok) ? true : (Math.random() > 0.1))) {
                        return res;
                    }
    
                    final StringBuilder logError = (new StringBuilder("Server seen down: ")).append(_addr);
    
                    if (e instanceof IOException) {
    
                        logError.append(" - ").append(IOException.class.getName());
    
                        if (e.getMessage() != null) {
                            logError.append(" - message: ").append(e.getMessage());
                        }
    
                        getLogger().log(Level.WARNING, logError.toString());
    
                    } else {
                        getLogger().log(Level.WARNING, logError.toString(), e);
                    }
                    _ok = false;
                }
    
                return res;
            }

    https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/ConnectionStatus.java

    Незаметен.

    serpinski, 31 Мая 2013

    Комментарии (7)
  3. Java / Говнокод #13064

    +65

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    // вот такой вот паттерн инициализации статических переменных во всех классах проекта... 
    private static Properties globalProps = null;
    
    static {
            globalProps = new Properties();
    }

    вот такой вот паттерн инициализации статических переменных во всех классах проекта...ин-лайн инициализацию автору делать почему то не хотелось...и ведь вроде не индус писал, а белый человек...

    aa_kovalev, 29 Мая 2013

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

    +130

    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
    Class barcode
    	...
    	Dim CharData
    
    	Dim CharNumber
    
    	Public Function GetHTMLBar(BarData  ,  BarHeight  )
    		...
    		For lop = 1 To Len(x)
    			For s = 0 To UBound(CharData)
    					...
    					tsum = tsum + (CLng(CharNumber(s)) * lop)
    					...
    				End If
    			Next 
    		Next 
    	End Function
    
    	Private Sub Class_Initialize()
    		CharNumber = Split("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106", ",")
    		...
    	End Sub
    End class

    VBScript.
    Массив, содержащий собственные индексы?

    slbsomeone, 24 Мая 2013

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

    +150

    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 deleteDublicateItems(){
        $q = '
        select COUNT(*), id, vk_id
        from `items`
        group by `vk_id`
        having COUNT(*) > 1';
        $sql = mysql_query($q);
        
        if (mysql_num_rows($sql)){	
    	while($row = mysql_fetch_assoc($sql)){
    	    $sql2 = mysql_query('select * from `items` where `vk_id` = "'.$row['vk_id'].'" and `id` != "'.$row['id'].'"');
    	    
    	    if (mysql_num_rows($sql2)) {
    		while($row2 = mysql_fetch_assoc($sql2)) {
    		    $sql3 = mysql_query('select * from `images` where `item_id` = "'.$row2['id'].'"');
    		    
    		    if (mysql_num_rows($sql3)) {
    			while ($row3 = mysql_fetch_assoc($sql3)) {
    			    @unlink( ROOT . DS . 'uploads' . DS . 'images' . DS . $row3['name'] . '.' . $row3['ext']);
    			    mysql_query('delete from `images` where `id` = "'.$row3['id'].'"');
    			}
    		    }		    
    		    mysql_query('delete from `items` where `id` = "'.$row2['id'].'"');
    		}
    	    }
    	}
        }
    }

    удаление дубликатов

    Serious_Andy, 22 Мая 2013

    Комментарии (7)
  6. JavaScript / Говнокод #12986

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    (function() {
        (function init() {
            document.addEventListener("DOMContentLoaded", DOMContentLoaded, false);
        })();
    })();
    
    function DOMContentLoaded() {
        //...
    }

    И да, jQuery подключена на странице.

    madhead, 13 Мая 2013

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

    +17

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    #include<iostream>
    using namespace std;
    int main(){
    	int n,a[100100],d[100100],ans=d[0]=1,i,j;
    	cin>>n>>a[0];
    	for(i = 1;i<n;++i)
    		for(j =i-1,cin>>a[i],d[i]=1;j>=0;--j) 
    			if(a[i]>a[j]) ans = max(ans, d[i]=max(d[i],d[j]+1));
    	cout<<ans;
    }

    Решение задачи нахождения НВП (наибольшей возр. подпосл-ти)

    AvadaKedavra, 26 Апреля 2013

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

    +137

    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
    if (curMenu != null)
    {
      depth = curMenu.Depth;
      Menu menuG = null;
      if (depth == 1)
      {
        menuG = curMenu;
      }
      if (depth == 2)
      {
        menuG = curMenu.Menu2;
      }
      if (depth == 3)
      {
        menuG = curMenu.Menu2.Menu2;
      }
      if (depth == 4)
      {
        menuG = curMenu.Menu2.Menu2.Menu2;
      }
      if (depth == 5)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2;
      }
      if (depth == 6)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2.Menu2;
      }
      if (depth == 7)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2;
      }
      if (depth == 8)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2;
      }
    }

    Nested set для петухов!

    validol, 19 Апреля 2013

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

    +150

    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
    <?php
    class autoLoad
    {
    	const dir = 'class';
    	const ext = '.php';
    	
    	private static $class;
    	
    	public static function load($class)
    	{
    		self::$class = $class;
    		include self::dir . DIRECTORY_SEPARATOR . self::$class . self::ext;
    	}
    }
    
    spl_autoload_register(array('autoload', 'load'));

    нашел лаадер

    juice, 15 Апреля 2013

    Комментарии (7)
  10. ActionScript / Говнокод #12893

    −116

    1. 1
    2. 2
    3. 3
    _itemList.splice(0, uint.MAX_VALUE);
    _amuletList.splice(0, uint.MAX_VALUE);
    _timeArtefactList.splice(0, uint.MAX_VALUE);

    crazy_horse, 15 Апреля 2013

    Комментарии (7)
  11. Assembler / Говнокод #12876

    +123

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    xorl %eax, %eax                           # cx - source, ebx - result
        movw %cx, %ax
        andw $0x8000, %ax
        shrw $15, %ax
        movl $0xFFFFFFFF, %ebx
        addl %eax, %ebx
        notl %ebx
        andl $0xffff0000, %ebx
        addw %cx, %bx

    LispGovno, 10 Апреля 2013

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