1. C# / Говнокод #11557

    +134

    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
    private void LettersOnChanged(object sender, EventArgs eventArgs)
            {
                this._lettersBinding.Clear();
                this._lettersBinding.AddRange(this._letters);
    
                this.MailAgentGridControl.ResetBindings();
                this.MailAgentGridControl.RefreshDataSource();
                _bindingSourceLetters.ResetCurrentItem();
                _bindingSourceLetters.ResetBindings(false);
    
                int pos = _bindingSourceLetters.Position;
    
                this.MailAgentGridControl.DataSource = null;
                this.MailAgentGridControl.DataSource = _bindingSourceLetters;
    
                if (_bindingSourceLetters.Current == null)
                {
                    _guiCtrl.CurrentLetter = null;
                    return;
                }
    
                if (pos > _bindingSourceLetters.Count - 1)
                    pos = _bindingSourceLetters.Count - 1;
    
                if (pos < 0)
                    return;
    
                _bindingSourceLetters.Position = pos;
    
                MailAgentGridControlTableView.UnselectRow(MailAgentGridControlTableView.GetRowHandle(0));
                MailAgentGridControlTableView.SelectRow(pos);
            }

    Все ради того,чтоб при изменении датабинда в гриде менялась строка выделения.

    partizan, 09 Августа 2012

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

    +131

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if (Cache[articlesRssData] != null)
    {
         return Cache[articlesRssData] as ArticleRssData?;
    }
    
    return null;

    uusb, 08 Августа 2012

    Комментарии (12)
  3. PHP / Говнокод #11555

    +59

    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
    //выдерает из текста все метки и вовзращает вввиде массива
    	private function returnLabels($html)
    	{
    		$labels = array();
    		$s = "" ;
    		$flag = false ;
    		for ($i=0;$i<strlen($html);$i++)
    		{
    			if (substr($html,$i,strlen("{module:")) == "{module:")
    			{
    				$flag = true ;
    			}
    
    			if (substr($html,$i,strlen("{language:")) == "{language:")
    			{
    				$flag = true ;
    			}
    
    			if (substr($html,$i,strlen("{image:")) == "{image:")
    			{
    				$flag = true ;
    			}
    
    			if (substr($html,$i,strlen("{file:")) == "{file:")
    			{
    				$flag = true ;
    			}
    
    			if (substr($html,$i,strlen("{js:")) == "{js:")
    			{
    				$flag = true ;
    			}
    
    			if (substr($html,$i,strlen("{css:")) == "{css:")
    			{
    				$flag = true ;
    			}			
    			
    			if (substr($html,$i,strlen("}")) == "}" && $flag == true)
    			{
    				$s .="}";
    				$labels [] = $s ;
    				$s = "" ;				
    				$flag = false ;
    			}
    			
    			if ($flag == true)
    			{
    				$s .= substr($html,$i,1);
    			}
    		}
    		
    		return $labels;
    	}

    О великий Никита Иванов!

    Devzirom, 08 Августа 2012

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

    +137

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private static Tag GetTopic(Guid tagId)
    {
     var tag = DataService.PerThread.TagSet.SingleOrDefault(x => x.Id == tagId);
     if (tag == null && tag.GroupId != null)
      return null;
    
     if (tag.TopicState != (byte)TopicState.GroupTopic)
      return null;
    
     return tag;
    }

    Arbium, 08 Августа 2012

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

    +139

    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
    <HEADER>
    <TITLE>The World Wide Web project</TITLE>
    <NEXTID N="55">
    </HEADER>
    <BODY>
    <H1>World Wide Web</H1>The WorldWideWeb (W3) is a wide-area<A
    NAME=0 HREF="WhatIs.html">
    hypermedia</A> information retrieval
    initiative aiming to give universal
    access to a large universe of documents.<P>
    Everything there is online about
    W3 is linked directly or indirectly
    to this document, including an <A
    NAME=24 HREF="Summary.html">executive
    summary</A> of the project, <A
    NAME=29 HREF="Administration/Mailing/Overview.html">Mailing lists</A>
    , <A
    NAME=30 HREF="Policy.html">Policy</A> , November's  <A
    NAME=34 HREF="News/9211.html">W3  news</A> ,
    <A
    NAME=41 HREF="FAQ/List.html">Frequently Asked Questions</A> .
    <DL>
    <DT><A
    NAME=44 HREF="../DataSources/Top.html">What's out there?</A>
    <DD> Pointers to the
    world's online information,<A
    NAME=45 HREF="../DataSources/bySubject/Overview.html"> subjects</A>
    , <A
    NAME=z54 HREF="../DataSources/WWW/Servers.html">W3 servers</A>, etc.
    <DT><A
    NAME=46 HREF="Help.html">Help</A>
    <DD> on the browser you are using
    <DT><A
    NAME=13 HREF="Status.html">Software Products</A>
    <DD> A list of W3 project
    components and their current state.
    (e.g. <A
    NAME=27 HREF="LineMode/Browser.html">Line Mode</A> ,X11 <A
    NAME=35 HREF="Status.html#35">Viola</A> ,  <A
    NAME=26 HREF="NeXT/WorldWideWeb.html">NeXTStep</A>
    , <A
    NAME=25 HREF="Daemon/Overview.html">Servers</A> , <A
    NAME=51 HREF="Tools/Overview.html">Tools</A> ,<A
    NAME=53 HREF="MailRobot/Overview.html"> Mail robot</A> ,<A
    NAME=52 HREF="Status.html#57">
    Library</A> )
    <DT><A
    NAME=47 HREF="Technical.html">Technical</A>
    <DD> Details of protocols, formats,
    program internals etc
    <DT><A
    NAME=40 HREF="Bibliography.html">Bibliography</A>
    <DD> Paper documentation
    on  W3 and references.
    <DT><A
    NAME=14 HREF="People.html">People</A>
    <DD> A list of some people involved
    in the project.
    <DT><A
    NAME=15 HREF="History.html">History</A>
    <DD> A summary of the history
    of the project.
    <DT><A
    NAME=37 HREF="Helping.html">How can I help</A> ?
    <DD> If you would like
    to support the web..
    <DT><A
    NAME=48 HREF="../README.html">Getting code</A>
    <DD> Getting the code by<A
    NAME=49 HREF="LineMode/Defaults/Distribution.html">
    anonymous FTP</A> , etc.</A>
    </DL>
    </BODY>

    HTML первого в мире сайта, которому на днях исполнился 21 год.

    tirinox, 08 Августа 2012

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

    +154

    1. 1
    2. 2
    3. 3
    if(Math.round(Math.random()*10)==7){
              alert('Your name/lastname alredy used! Try other.');
    }

    Валидация форм, чё

    denis90, 08 Августа 2012

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

    +75

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if ( !empty($special['catalog']) ) {
    	if (count($special['catalog'])>0) {
    		if (count($special['catalog'])>1) {
    ...
    		}
    	}
    }

    Интересная конструкция...

    domaster, 07 Августа 2012

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

    +72

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php if ($content): ?>
        <?php if($is_page): ?>  
            <?php print $content; ?>  
        <?php else: ?>  
            <?php print $content; ?>  
        <?php endif?>
    <?php endif?>

    Где-то, в глубоких кодах проекта (писанном на Drupal 7)

    Edd, 07 Августа 2012

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

    +34

    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
    #include "xsmell.hpp"
    #include <iostream>
    
    TAG(html,  NO_ATTRIBS);
    TAG(head,  NO_ATTRIBS);
    TAG(title, NO_ATTRIBS);
    TAG(body,  NO_ATTRIBS);
    TAG(p,     NO_ATTRIBS);
    TAG(a,     ATTRIB(href));
    TAG(img,   ATTRIB(src), ATTRIB(alt));
    
    int main()
    {
        using namespace xsmell;
    
        document doc = 
            _
            <html>_
                <head>_
                    <title>"XSMELL demo"<!title>_
                <!head>_
                <body>_
                    <p>"Yesssssssssssssssss!"<!p>_
                    <img .src("chucknorris.png") .alt("sneezing eyes open")>_ <!img>_
                <!body>_
            <!html>
            _;
    
        std::cout << doc << '\n';
    
        return 0;
    }

    C++ умеет HTML не хуже этих ваших похапешечек ;)

    https://bitbucket.org/edd/xsmell/src

    bormand, 07 Августа 2012

    Комментарии (259)
  10. Perl / Говнокод #11547

    −139

    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
    #!/usr/bin/perl -w
    
    use strict;
    use warnings;
    use diagnostics;
    use LWP::Simple;
    
    binmode(STDOUT, ":utf8");
    
    my $url = 'http://govnokod.ru/comments';
    my $document = get $url;  die "Couldn't get $url" unless defined $document;
    $document =~ s/\n/ /g;
    $document =~ s/\h+/ /g;
    my @arr = ( $document =~ m/(?<=\<strong class="entry-author">)(.*?)(?<=\<a class="answer")/gi );
    my $str;
    my @sink;
    
    foreach my $val (@arr) {
    	$val =~ m/(?<=\>)(.*?)(?=\<\/a\>)/i;
    	$str = "Author:    ".$1;
    	$val =~ m/(?<=published" title\=")(.*?)(?=")/i;
    	( my $dt, my $tm ) = split('T', $1);
    	$str = $str . "\nDate:      " . $dt;
    	$str = $str . "\nTime:      " . $tm;
    	$val =~ m/(?<=\<\/abbr\> \<a href\=")(.*?)(?=" name\=)/i;
    	$str = $str."\nLink:      ". $1;
    	$val =~ m/(?<=\<div class\="entry-comment">)(.*?)(?=\<\/div\>)/i;
    	$str = $str . "\nComment:   " . str_formater($1);
    	push(@sink, $str);
    }
    
    @sink = reverse (@sink);
    foreach my $v (@sink) {
    	print ("\n".("+" x 81)."\n"."$v\n");
    }
    print ("\n".("+" x 81)."\n\n");
    
    sub str_formater {
    	my $str = $_[0];
    	my $res="";
    	my $cmt_len = 69;
    	my $cmt_indent = 11;
    	while (1) {
    		if (length($str)<=$cmt_len) {
    			return $res . $str;
    		}
    		$res = $res . substr($str,0, $cmt_len) . "\n" . (" " x $cmt_indent);
    		$str = substr($str, $cmt_len);
    	}
    	return $res;
    }
    exit 0;

    Давненько перловку не заваривал...

    sayidandrtfm, 06 Августа 2012

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