- 1
- 2
- 3
- 4
double *ptr = new (nothrow) double[n];
if (ptr) {
//....
} else throw bad_alloc();
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+164
double *ptr = new (nothrow) double[n];
if (ptr) {
//....
} else throw bad_alloc();
−122
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;
}
Генерация кода.
−155
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-вариант.
+130
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++;
−119
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>~;
}
// далее мало что меняется в стиле...
Формируем меню...
+79
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";
//...
}
....
+145
/**
* 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
+166
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]+"'");
}
ну вы понели
−159
if( !ruleWithLongName1 )
{
return;
}
if( !ruleWithLongName2 )
{
return;
}
if( !ruleWithLongName3 )
{
return;
}
if( !ruleWithLongName4 )
{
return;
}
if( !ruleWithLongName5 )
{
return;
}
клевый кусочек (повторяется в нескольких функциях) имена условий изменены, но скажу что они не Boolean типа
+77
JavaServer Faces 1.2, Facelets, страница .xhtml:
<p:nbsp/>
Что является вызовом facelet-тага, ссылающегося на другой (НEвалидный) .xhtml-файл:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:component xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets">
<h:outputText escape="false" value="&nbsp;" />
</ui:component>
Это, типа, способ вставить на страницу. Вместо того, что бы просто написать где это нужно.
А что бы это работало в xhtml-нике, нужно всего лишь поставить правильный DOCTYPE вначале
документа.