1. Java / Говнокод #4595

    +68

    1. 1
    2. 2
    3. 3
    if (url == null) {
     throw new RuntimeException("Error reading resource " + url.getFile());
    }

    ха.
    туториалы jogl

    Lure Of Chaos, 11 Ноября 2010

    Комментарии (13)
  2. Perl / Говнокод #4594

    −121

    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
    sub captcha {
    	my $msg = $_[0];
    	## make colors for validation image into hex again ##
    	$rgb_foreground =~ s/\#//g;
    	$rgb_shade =~ s/\#//g;
    	$rgb_background =~ s/\#//g;
    	$r_f = substr($rgb_foreground,0,2);
    	$g_f = substr($rgb_foreground,2,2);
    	$b_f = substr($rgb_foreground,4,2);
    	$r_s = substr($rgb_shade,0,2);
    	$g_s = substr($rgb_shade,2,2);
    	$b_s = substr($rgb_shade,4,2);
    	$r_b = substr($rgb_background,0,2);
    	$g_b = substr($rgb_background,2,2);
    	$b_b = substr($rgb_background,4,2);
    // Тут я вырезал кусок никчемного кода
    $ci{' '} = qq~
    .......
    .......
    .......
    .......
    .......
    .......
    .......
    .......
    .......
    .......
    ~;
    $ci{'!'} = qq~
    .......
    ...X...
    ...X...
    ...X...
    ...X...
    ...X...
    .......
    ...X...
    .......
    .......
    ~;
    $ci{'"'} = qq~
    .......
    ..X.X..
    ..X.X..
    ..X.X..
    .......
    .......
    .......
    .......
    .......
    .......
    ~;
    $ci{'#'} = qq~
    .......
    ..X.X..
    ..X.X..
    .XXXXX.
    ..X.X..
    .XXXXX.
    ..X.X..
    ..X.X..
    .......
    .......
    ~;
    $ci{'$'} = qq~
    .......
    ...X...
    ..XXXX.
    .X.X...
    ..XXX..
    ...X.X.
    .XXXX..
    ...X...
    .......
    .......
    ~;
    // Дальше идет вся таблица ASCII

    Вот таким вот образом выводили каптчу в далеком 2009 году. Очень надежный метод :)

    Arigato, 11 Ноября 2010

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    double *ptr = new (nothrow) double[n];
    if (ptr) {
    //....
    } else throw bad_alloc();

    Sanya_M, 11 Ноября 2010

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

    −122

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    sub generate_code {
    	my ($arrey_pos,$code);
    	my @arrey = ('a'..'q', 'C'..'O', '1'..'9', 'g'..'u', 'l'..'z', '9'..'1', 'H'..'W');
    
    	for (my $i = 0; $i < $_[0]; $i++) {
    		$arrey_pos = int(rand($#arrey));
    		$code .= $arrey[$arrey_pos];
    	}
    	$code;
    }

    Генерация кода.

    Arigato, 11 Ноября 2010

    Комментарии (17)
  5. Perl / Говнокод #4591

    −155

    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
    sub write_cookie {
    	my %params = @_;
    
    	if ($params{'-expires'} =~ /\+(\d+)m/) {
    		my ($sec, $min, $hour, $mday, $mon, $year, $wday) = gmtime($date + $1 * 60);
    
    		$year += 1900;
    		my @mos = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    		my @dys = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
    		$mon  = $mos[$mon];
    		$wday = $dys[$wday];
    
    		$params{'-expires'} = sprintf("%s, %02i-%s-%04i %02i:%02i:%02i GMT", $wday, $mday, $mon, $year, $hour, $min, $sec);
    	}
    
    	$params{'-path'}    = " path=$params{'-path'};"       if $params{'-path'};
    	$params{'-expires'} = " expires=$params{'-expires'};" if $params{'-expires'};
    
    	"$params{'-name'}=$params{'-value'};$params{'-path'}$params{'-expires'}";
    }

    setcookie() Perl-вариант.

    Arigato, 11 Ноября 2010

    Комментарии (15)
  6. C# / Говнокод #4590

    +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
    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
    if ((!(((constmonth == 1) && (Finalday > 31))
    || ((constmonth == 2) && (Finalyear % 4 == 0) && (Finalday > 29))
    || ((constmonth == 2) && (Finalyear % 4 != 0) && (Finalday> 28))
    || ((constmonth == 3) && (Finalday > 31))
    || ((constmonth == 4) && (Finalday > 30))
    || ((constmonth == 5) && (Finalday > 31))
    || ((constmonth == 6) && (Finalday > 30))
    || ((constmonth == 7) && (Finalday > 31))
    || ((constmonth == 8) && (Finalday > 31))
    || ((constmonth == 9) && (Finalday > 30))
    || ((constmonth == 10) && (Finalday > 31))
    || ((constmonth == 11) && (Finalday > 30))
    || ((constmonth == 12) && (Finalday > 31))))
    && ((((constmonth + 1 == 1) && (Finalday > 31))
    || ((constmonth + 1 == 2) && (Finalyear % 4 == 0) && (Finalday > 29))
    || ((constmonth + 1 == 2) && (Finalyear % 4 != 0) && (Finalday > 28))
    || ((constmonth + 1 == 3) && (Finalday > 31))
    || ((constmonth + 1 == 4) && (Finalday > 30))
    || ((constmonth + 1 == 5) && (Finalday > 31))
    || ((constmonth + 1 == 6) && (Finalday > 30))
    || ((constmonth + 1 == 7) && (Finalday > 31))
    || ((constmonth + 1 == 8) && (Finalday > 31))
    || ((constmonth + 1 == 9) && (Finalday > 30))
    || ((constmonth + 1 == 10) && (Finalday > 31))
    || ((constmonth + 1 == 11) && (Finalday > 30))
    || ((constmonth + 1 == 12) && (Finalday > 31)))))
    {
    if ((constmonth + 1 == 2) && (Finalyear % 4 == 0)) { Finalday = 29; }
    if ((constmonth + 1 == 2) && (Finalyear % 4 != 0)) { Finalday = 28; }
    
    switch (constmonth + 1)
    {
    case 1: Finalday = 31; break;
    case 3: Finalday = 31; break;
    case 4: Finalday = 30; break;
    case 5: Finalday = 31; break;
    case 6: Finalday = 30; break;
    case 7: Finalday = 31; break;
    case 8: Finalday = 31; break;
    case 9: Finalday = 30; break;
    case 10: Finalday = 31; break;
    case 11: Finalday = 30; break;
    case 12: Finalday = 31; break;
    }
    //constmonth++;

    GreBer, 11 Ноября 2010

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

    −119

    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
    sub mainMenu {
    	if ($action eq "addtab" && $iamadmin) { require "$sourcedir/AdvancedTabs.pl"; &AddNewTab; }
    	elsif ($action eq "edittab" && $iamadmin) { require "$sourcedir/AdvancedTabs.pl"; &EditTab; }
    	elsif ($action ne "") {
    		if ($action eq "search2") {
    			$tmpaction = "search";
    		} elsif ($action eq "favorites" || $action eq "shownotify" || $action eq "im" || $action eq "imdraft" || $action eq "imoutbox" || $action eq "imstorage" || $action eq "imsend" || $action eq "imsend2" || $action eq "imshow" || $action eq "profileCheck" || $action eq "myviewprofile" || $action eq "myprofile" || $action eq "myprofileContacts" || $action eq "myprofileOptions" || $action eq "myprofileBuddy" || $action eq "myprofileIM" || $action eq "myprofileAdmin" || $action eq "myusersrecentposts") {
    			$tmpaction = "mycenter";
    		} elsif ($action eq "messagepagetext" || $action eq "messagepagedrop" || $action eq "threadpagetext" || $action eq "threadpagedrop" || $action eq "post" || $action eq "notify" || $action eq "boardnotify" || $action eq "sendtopic" || $action eq "modify") {
    			$tmpaction = "home";
    		} elsif ($action eq "guestpm2") {
    			$tmpaction = "guestpm";
    		} else { $tmpaction = $action; }
    
    	} else {
    		$tmpaction = "home";
    	}
    
    	$tab{'home'} = qq~<span |><a href="$scripturl" title = "$img_txt{'103'}" style="padding: 3px 0 4px 0;">$tabfill$img_txt{'103'}$tabfill</a></span>~;
    	$tab{'help'} = qq~<span |><a href="$scripturl?action=help" title = "$img_txt{'119'}" style="padding: 3px 0 4px 0; cursor:help;">$tabfill$img_txt{'119'}$tabfill</a></span>~;
    	if ($maxsearchdisplay > -1) {
    		$tab{'search'} = qq~<span |><a href="$scripturl?action=search" title = "$img_txt{'182'}" style="padding: 3px 0 4px 0;">$tabfill$img_txt{'182'}$tabfill</a></span>~;
    	}
    	if (!$ML_Allowed || ($ML_Allowed == 1 && !$iamguest) || ($ML_Allowed == 2 && $staff) || ($ML_Allowed == 3 && ($iamadmin || $iamgmod))) {
    		$tab{'ml'} = qq~<span |><a href="$scripturl?action=ml" title = "$img_txt{'331'}" style="padding: 3px 0 4px 0;">$tabfill$img_txt{'331'}$tabfill</a></span>~;
    	}
    	if ($iamadmin) {
    		$tab{'admin'} = qq~<span |><a href="$boardurl/AdminIndex.$yyaext" title = "$img_txt{'2'}" style="padding: 3px 0 4px 0;">$tabfill$img_txt{'2'}$tabfill</a></span>~;
    	}
    	if ($iamgmod) {
    		if (-e "$vardir/gmodsettings.txt") { require "$vardir/gmodsettings.txt"; }
    		if ($allow_gmod_admin) {
    			$tab{'admin'} = qq~<span |><a href="$boardurl/AdminIndex.$yyaext" title = "$img_txt{'2'}" style="padding: 3px 0 4px 0;">$tabfill$img_txt{'2'}$tabfill</a></span>~;
    		}
    	}
    	if ($sessionvalid == 0 && !$iamguest) {
    		my $sesredir;
    		unless (!$testenv || $action eq "revalidatesession" || $action eq "revalidatesession2") {
    			$sesredir = $testenv;
    			$sesredir =~ s/\=/\~/g;
    			$sesredir =~ s/;/x3B/g;
    			$sesredir = qq~;sesredir=$sesredir~;
    		}
    		$tab{'revalidatesession'} = qq~<span |><a href="$scripturl?action=revalidatesession$sesredir" title = "$img_txt{'34a'}" style="padding: 3px 0 4px 0;">$tabfill$img_txt{'34a'}$tabfill</a></span>~;
    	}
    
    // далее мало что меняется в стиле...

    Формируем меню...

    Arigato, 11 Ноября 2010

    Комментарии (42)
  8. Java / Говнокод #4588

    +79

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    public class Daemon {
       //...
    
       /**
       * Constant defines url pattern for register
       */
       private static final String S_ID_D_URL_S_STRATEGY_CLASS_S_STATE_S = "%s?id=%d&url=%s&strategyClass=%s&state=%s";
     
       //...
    }

    ....

    nikelin, 11 Ноября 2010

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

    +145

    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
    /**
         * Returns an array of all the objects currently registered
         * as <code><em>Foo</em>Listener</code>s
         * upon this <code>Component</code>.
         * <code><em>Foo</em>Listener</code>s are registered using the
         * <code>add<em>Foo</em>Listener</code> method.
         *
         * <p>
         * You can specify the <code>listenerType</code> argument
         * with a class literal, such as
         * <code><em>Foo</em>Listener.class</code>.
         * For example, you can query a
         * <code>Component</code> <code>c</code>
         * for its mouse listeners with the following code:
         *
         * <pre>MouseListener[] mls = (MouseListener[])(c.getListeners(MouseListener.class));</pre>
         *
         * If no such listeners exist, this method returns an empty array.
         *
         * @param listenerType the type of listeners requested; this parameter
         *          should specify an interface that descends from
         *          <code>java.util.EventListener</code>
         * @return an array of all objects registered as
         *          <code><em>Foo</em>Listener</code>s on this component,
         *          or an empty array if no such listeners have been added
         * @exception ClassCastException if <code>listenerType</code>
         *          doesn't specify a class or interface that implements
         *          <code>java.util.EventListener</code>
         *
         * @see #getComponentListeners
         * @see #getFocusListeners
         * @see #getHierarchyListeners
         * @see #getHierarchyBoundsListeners
         * @see #getKeyListeners
         * @see #getMouseListeners
         * @see #getMouseMotionListeners
         * @see #getMouseWheelListeners
         * @see #getInputMethodListeners
         * @see #getPropertyChangeListeners
         *
         * @since 1.3
         */
        public <T extends EventListener> T[] getListeners(Class<T> listenerType) { 
            EventListener l = null; 
            if  (listenerType == ComponentListener.class) { 
                l = componentListener;
            } else if (listenerType == FocusListener.class) {
                l = focusListener;
            } else if (listenerType == HierarchyListener.class) {
                l = hierarchyListener;
            } else if (listenerType == HierarchyBoundsListener.class) {
                l = hierarchyBoundsListener;
            } else if (listenerType == KeyListener.class) {
                l = keyListener;
            } else if (listenerType == MouseListener.class) {
                l = mouseListener;
            } else if (listenerType == MouseMotionListener.class) {
                l = mouseMotionListener; 
            } else if (listenerType == MouseWheelListener.class) {
                l = mouseWheelListener; 
            } else if (listenerType == InputMethodListener.class) {
                l = inputMethodListener; 
            } else if (listenerType == PropertyChangeListener.class) {
                return (T[])getPropertyChangeListeners();
            }
            return AWTEventMulticaster.getListeners(l, listenerType);
        }

    как вы думаете, что это? внутренности Java
    java.awt.Component

    Lure Of Chaos, 11 Ноября 2010

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

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    function goToURL() { //v3.0
      var i, args=goToURL.arguments; document.returnValue = false;
      for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    }

    ну вы понели

    GoodTalkBot, 11 Ноября 2010

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