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

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

    +146

    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
    package gargoyle.xenox.game;
    
    import gargoyle.util.log.Log;
    
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.io.Serializable;
    
    @SuppressWarnings("rawtypes")
    public abstract class Persistent<T extends Persistent> implements Serializable {
      private static final long serialVersionUID = 1L;
    
      private File file(final Class<? extends Persistent> clazz) {
        return new File(System.getProperty("user.home"), clazz.getName() + ".dat");
      }
    
      @SuppressWarnings("unchecked")
      final protected T load(final Class<T> clazz) {
        ObjectInputStream in;
        try {
          in = new ObjectInputStream(new FileInputStream(this.file(clazz)));
          return (T) in.readObject();
        } catch (final IOException e) {
          Log.error(e);
        } catch (final ClassNotFoundException e) {
          Log.error(e);
        }
        return null;
      }
    
      final protected void save(final T o) {
        ObjectOutputStream os = null;
        try {
          os = new ObjectOutputStream(new FileOutputStream(this.file(o.getClass())));
          os.writeObject(this);
          os.flush();
        } catch (final IOException e) {
          Log.error(e);
        } finally {
          try {
            if (os != null) {
              os.close();
            }
          } catch (final IOException e) {
            Log.error(e);
          }
        }
      }
    }

    такой вот забавный сериализатор получился
    причина - запутался в генериках

    Lure Of Chaos, 21 Февраля 2011

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

    +171

    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
    if (a == 0 && b == 0 && c == 0 && d == 0) n = 0;
        if (a == 0 && b == 0 && c == 0 && d != 0) n = 0;
        if (a == 0 && b == 0 && c != 0 && d == 0) n = 0;
        if (a == 0 && b != 0 && c == 0 && d == 0) n = 0;
        if (a != 0 && b == 0 && c == 0 && d == 0) n = 0;
        if (a == 0 && b == 0 && c != 0 && d != 0 && c == d) m += 1;
        if (a == 0 && b != 0 && c != 0 && d == 0 && b == c) m += 1;
        if (a == 0 && b != 0 && c == 0 && d != 0 && b == d) m += 1;
        if (a != 0 && b == 0 && c == 0 && d != 0 && a == d) m += 1;
        if (a != 0 && b == 0 && c != 0 && d != 0 && a == c) m += 1;
        if (a != 0 && b != 0 && c == 0 && d == 0 && a == b) m += 1;////
        if (a == 0 && b != 0 && c != 0 && d != 0 && b == c) m += 1;
        if (a == 0 && b != 0 && c != 0 && d != 0 && b == d) m += 1;
        if (a == 0 && b != 0 && c != 0 && d != 0 && c == d) m += 1;//
        if (a != 0 && b == 0 && c != 0 && d != 0 && a == c) m += 1;
        if (a != 0 && b == 0 && c != 0 && d != 0 && a == d) m += 1;
        if (a != 0 && b == 0 && c != 0 && d != 0 && d == c) m += 1;//
        if (a != 0 && b != 0 && c == 0 && d != 0 && a == b) m += 1;
        if (a != 0 && b != 0 && c == 0 && d != 0 && a == d) m += 1;
        if (a != 0 && b != 0 && c == 0 && d != 0 && b == d) m += 1;//
        if (a != 0 && b != 0 && c != 0 && d == 0 && a == b) m += 1;
        if (a != 0 && b != 0 && c != 0 && d == 0 && a == c) m += 1;
        if (a != 0 && b != 0 && c != 0 && d == 0 && c == b) m += 1;////
        m--;
        if (a != 0 && b != 0 && c != 0 && d != 0 && a == b) k += 1;
        if (a != 0 && b != 0 && c != 0 && d != 0 && a == c) k += 1;
        if (a != 0 && b != 0 && c != 0 && d != 0 && a == d) k += 1;
        if (a != 0 && b != 0 && c != 0 && d != 0 && b == c) k += 1;
        if (a != 0 && b != 0 && c != 0 && d != 0 && b == d) k += 1;
        if (a != 0 && b != 0 && c != 0 && d != 0 && c == d) k += 1;
        k -= 3;
        if (m <= 0) m = 0;
        if (k <= 0) k = 0;
        n = k + m;*/

    Как на второй день после начала изучения С стал решать задачу "Сколько чисел повторяются"

    slushkov, 24 Декабря 2010

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

    +173

    1. 1
    AX=pow(A[i].r.get_x()*A[i].r.get_x(),0.5);

    Берем модуль числа.

    Taus, 17 Декабря 2010

    Комментарии (50)
  5. Java / Говнокод #3714

    +75

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    float lan = getLan();
           float lon = getLan();
           if(lan == lan || lon == lon)
           {
               throw new RuntimeException("Bad value");
           }

    Из моего реалного проекта. Этот код реально делает полезную вещь

    xaoc, 16 Июля 2010

    Комментарии (50)
  6. Java / Говнокод #3706

    +82

    1. 1
    void setEnabled(boolean disable)

    borka, 15 Июля 2010

    Комментарии (50)
  7. bash / Говнокод #3547

    −140

    1. 1
    OWNER=`ls -l $i | awk '{ print $3 }'`

    initscripts-8.45.30-2.el5, не хрен собачий...

    raorn, 23 Июня 2010

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

    +121

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    HAI
    CAN HAS STDIO?
    PLZ OPEN FILE "LOLCATS.TXT"?
    	AWSUM THX
    		VISIBLE FILE
    	O NOES
    		INVISIBLE "ERROR!"
    KTHXBYE

    Взято с http://lolcode.com/home : "Programming the LOL way. All LOLCats, LOL, ALL CAPS."

    PLZ = try
    AWSUM THX = ok branch
    O NOES = catch(...)
    VISIBLE = fprintf(stdout,...)
    INVISIBLE = fprintf(stderr,...)

    Dummy00001, 15 Июня 2010

    Комментарии (50)
  9. ActionScript / Говнокод #3051

    −180.6

    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
    package org.casalib.util {
        
        /**
            Utilities for constructing and working with Classes.
            
            @author Aaron Clinger
            @version 02/13/10
        */
        public class ClassUtil {
            
            /**
                Dynamically constructs a Class.
                
                @param type: The Class to create.
                @param arguments: Up to ten arguments to the constructor.
                @return Returns the dynamically created instance of the Class specified by <code>type</code> parameter.
                @throws Error if you pass more arguments than this method accepts (accepts ten or less).
                @example
                    <code>
                        var bData:* = ClassUtil.construct(BitmapData, 200, 200);
                        
                        trace(bData is BitmapData, bData.width);
                    </code>
            */
            public static function construct(type:Class, ...arguments):* {
                if (arguments.length > 10)
                    throw new Error('You have passed more arguments than the "construct" method accepts (accepts ten or less).');
                
                switch (arguments.length) {
                        case 0 :
                            return new type();
                        case 1 :
                            return new type(arguments[0]);
                        case 2 :
                            return new type(arguments[0], arguments[1]);
                        case 3 :
                            return new type(arguments[0], arguments[1], arguments[2]);
                        case 4 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3]);
                        case 5 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
                        case 6 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
                        case 7 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]);
                        case 8 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7]);
                        case 9 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], arguments[8]);
                        case 10 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], arguments[8], arguments[9]);
                }
            }
        }
    }

    Lavir_the_Whiolet, 19 Апреля 2010

    Комментарии (50)
  10. JavaScript / Говнокод #863

    +140.2

    1. 1
    if (port.id == {{ port.id }}) { selected = ' selected="selected"' }

    генерим аяксовым жабоскриптом option-ы в шаблоне.

    guest, 14 Апреля 2009

    Комментарии (50)
  11. PHP / Говнокод #399

    +27

    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
    <?php
    function chrs($poc)
    {
      return base64_encode($poc[1]);  
    }
    
    function callback($sel,$find, $to,$str){
    switch($sel) { 
    case 1:
    return  str_ireplace($find,$to,$str) ; 
    break;
    case 2:
    return substr($str,$find,$to) ;
    break;
    case 3:
    return preg_replace($find,$to,$str) ;
    break;
    case 4:
    return preg_replace_callback($find,$to,$str) ;
    break;
                                             
     }
    }
      echo callback(1,'you','fuck', 'You my pet').'<br/>';;
      echo callback(2,'0','5', 'You my pet').'<br/>'; 
      echo callback(4,'/(\S)/s','chrs', 'You my pet pet').'<br/>';
    ?>

    Code

    guest, 15 Января 2009

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