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

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

    +138

    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
    public void Delete(CommonType type)
            { 
                label1:
                Console.Write("Enter the title of the book: ");
                string title = Console.ReadLine();
                if (title == type.Title)
                {
                    cmainlibrary.Remove(type);
                    Console.Write("Success");
                    Console.Read();
                    goto label1;
                }
                    
                else 
                {
    
                    goto label1;
                  
                }
            
            }

    sater, 24 Сентября 2012

    Комментарии (26)
  3. Куча / Говнокод #11822

    +138

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    # it makes sense to use it only for
    # numbers up to 100
    fun StringToInteger (str) {
        int = -1;
        for (i=0; i<=100; i++) {
            if (i+"" == str) {
                int = i;
                break;
            }
        }
        return int;
    }

    Функция преобразования строк в целые числа из кода бутскрина Ubuntu на неизвестном науке кастомном скриптовом языке.
    Пруфлинк: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/precise/plymouth/precise/view/head:/themes/ubuntu-logo/ubuntu-logo.script#L149

    Shnatsel, 22 Сентября 2012

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

    +138

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    string requestUrl = Request.Path.Replace(Request.ApplicationPath, string.Empty).TrimEnd('/').ToUpperInvariant();
    string modelUrl = Model.Href.Replace(Request.ApplicationPath, string.Empty).TrimEnd('/').ToUpperInvariant();
    if (requestUrl == modelUrl) { 
    	    Model.Classes.Add("current");
    }

    Кусок кода Orchard CMS, определяет, что в меню рендерится текущая страница.
    Весело смотреть, что происходит, когда Request.ApplicationPath == "/"

    musuk, 29 Августа 2012

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

    +138

    1. 1
    2. 2
    3. 3
    4. 4
    code = _factorCodeMax[factorUnid];
    code++;
    _factorCodeMax[factorUnid] = code;
    return code;

    Maps, 10 Августа 2012

    Комментарии (47)
  6. Assembler / Говнокод #11531

    +138

    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
    .text:00018584                 EXPORT get_msg_sequence
    .text:00018584 get_msg_sequence                        ; CODE XREF: IPC_send_singleIPC+6p
    .text:00018584                                         ; __IPC_send_singleIPC+6p
    .text:00018584                 LDR             R0, =0x7800C
    .text:00018586                 PUSH            {R4,LR}
    .text:00018588                 ADD             R0, PC
    .text:0001858A                 LDR             R0, [R0]
    .text:0001858C                 LDRB            R3, [R0]
    .text:0001858E                 CBZ             R3, loc_185A2
    .text:00018590                 LDR             R1, =(aRil - 0x1859C)
    .text:00018592                 MOVS            R0, #6
    .text:00018594                 LDR             R2, =(aS_0 - 0x1859E)
    .text:00018596                 LDR             R3, =(aGet_msg_sequen - 0x185A0)
    .text:00018598                 ADD             R1, PC  ; "RIL"
    .text:0001859A                 ADD             R2, PC  ; "%s()"
    .text:0001859C                 ADD             R3, PC  ; "get_msg_sequence"
    .text:0001859E                 BLX             __android_log_print
    .text:000185A2
    .text:000185A2 loc_185A2                               ; CODE XREF: get_msg_sequence+Aj
    .text:000185A2                 LDR             R3, =(unk_98E7E - 0x185A8)
    .text:000185A4                 ADD             R3, PC
    .text:000185A6                 LDRB            R2, [R3]
    .text:000185A8                 CMP             R2, #0xFD
    .text:000185AA                 BLS             loc_185B0
    .text:000185AC                 MOVS            R2, #0
    .text:000185AE                 B               loc_185B2
    .text:000185B0 ; ---------------------------------------------------------------------------
    .text:000185B0
    .text:000185B0 loc_185B0                               ; CODE XREF: get_msg_sequence+26j
    .text:000185B0                 ADDS            R2, #1
    .text:000185B2
    .text:000185B2 loc_185B2                               ; CODE XREF: get_msg_sequence+2Aj
    .text:000185B2                 LDR             R1, =(unk_98E7E - 0x185BA)
    .text:000185B4                 STRB            R2, [R3]
    .text:000185B6                 ADD             R1, PC
    .text:000185B8                 LDRB            R0, [R1]
    .text:000185BA                 POP             {R4,PC}
    .text:000185BA ; End of function get_msg_sequence

    Потрясающе эффективный выхлоп GCC. Компилировалось, вероятно, все-таки с включенной оптимизацией.

    Например, последовательность LDR R1/ADD R1,PC/LDRB R0, [R1] в конце вообще лишняя: достаточно было использовать R0 вместо R2.

    Grindars, 04 Августа 2012

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

    +138

    1. 1
    2. 2
    3. 3
    4. 4
    int getRandomNumber(){
        return 4; //chosen by fair dice roll.
                  //guaranteed to be random.
    }

    хуита, 01 Августа 2012

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

    +138

    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
    public class ImageWorkerSingleton
    {
    	private static ImageWorkerSingleton instance;
    
    	private ImageWorkerSingleton() { }
    
    	public static ImageWorkerSingleton Instance
    	{
    		get
    		{
    			if (instance == null)
    			{
    				instance = new ImageWorkerSingleton();
    			}
    			return instance;
    		}
    	}
    
    	public void Init() {}
    
    	public string UrlToImage(Guid id, ImageTypeEnum imageType = ImageTypeEnum.PhotoUndefined)
    	{
    		...
    	}
    
    	public bool IsImageExist(Guid id, ImageTypeEnum imageType = ImageTypeEnum.PhotoUndefined)
    	{
    		...
    	}
    }

    И на кой, здесь синглтон о_О

    DarkThinker, 20 Июня 2012

    Комментарии (34)
  9. JavaScript / Говнокод #10352

    +138

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <script>window.google={kEI:"iBS9T5-8NY6CtQbXmN3PDQ",getEI:function(a){var b;while(a&&!(a.getAttribute&&(b=a.getAttribute("eid"))))a=a.parentNode;return b||google.kEI},https:function(){return window.location.protocol=="https:"},kEXPI:"24878,27400,30316,31215,35702,35703,38100,38135,38221,38285,38738,38786,38816,38941,39000",kCSI:{e:"24878,27400,30316,31215,35702,35703,38100,38135,38221,38285,38738,38786,38816,38941,39000",ei:"iBS9T5-8NY6CtQbXmN3PDQ"},authuser:0,
    ml:function(){},pageState:"#",kHL:"uk",time:function(){return(new Date).getTime()},log:function(a,b,c,e){var d=new Image,h=google,i=h.lc,f=h.li,j="";d.onerror=(d.onload=(d.onabort=function(){delete i[f]}));i[f]=d;if(!c&&b.search("&ei=")==-1)j="&ei="+google.getEI(e);var g=c||"/gen_204?atyp=i&ct="+a+"&cad="+b+j+"&zx="+google.time();
    var k=/^http:/i;if(k.test(g)&&google.https()){google.ml(new Error("GLMM"),false,{src:g});delete i[f];return}d.src=g;h.li=f+1},lc:[],li:0,j:{en:1,l:function(){google.fl=true},e:function(){google.fl=true},
    b:location.hash&&location.hash!="#",bv:21,cf:"osb",pm:"p",pl:[],mc:0,sc:0.5,u:"f05f80a8"},Toolbelt:{},y:{},x:function(a,b){google.y[a.id]=[a,b];return false}};(function(){var a=
    google.j;window.onpopstate=function(){a.psc=1};for(var b=0,c;c=["ad","bc","inpr","is","p","pa","ac","pc","pah","ph","sa","sifp","slp","spf","spn","xx","zc","zz"][b++];)(function(e){a[e]=function(){a.pl.push([e,arguments])}})(c)})();if(!window.chrome)window.chrome={};window.chrome.sv=2.00;window.chrome.userWantsQuery=function(a){google.x({id:"psyapi"},function(){google.nav.search({q:encodeURIComponent(a),
    sourceid:"chrome-psyapi1"})})};
    window.google.sn="webhp";window.google.timers={};window.google.startTick=function(a,b){window.google.timers[a]={t:{start:(new Date).getTime()},bfr:!(!b)}};window.google.tick=function(a,b,c){if(!window.google.timers[a])google.startTick(a);window.google.timers[a].t[b]=c||(new Date).getTime()};google.startTick("load",true);try{}catch(u){}
    </script>

    GggTtt, 23 Мая 2012

    Комментарии (3)
  10. Си / Говнокод #10294

    +138

    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
    typedef int32_t wl_fixed_t;
    
    //было:
    static inline double wl_fixed_to_double(wl_fixed_t f)
    {
      return (double) f / 256.0;
    }
    
    //стало:
    static inline double wl_fixed_to_double(wl_fixed_t f)
    {
      union {
        double d;
        int64_t i;
      } u;
    
      u.i = ((1023LL + 44LL) << 52) + (1LL << 51) + f;
    
      return u.d - (3LL << 43);
    }

    Заоптимизировали...

    rat4, 16 Мая 2012

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

    +138

    1. 1
    memset(cb->chars, cb->width * cb->height, ' ');

    Мой однострочный эпик фейл.

    bormand, 27 Апреля 2012

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