- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
/*
Func get_top($msg_number,$lines)
Access: Public
*/
function get_top( $msg_number , $lines = "0" )
{
// ....
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+144.9
/*
Func get_top($msg_number,$lines)
Access: Public
*/
function get_top( $msg_number , $lines = "0" )
{
// ....
}
Очень ценный комментарий к функции, о одном классе.. Более того, там все каменты в этом стиле. Кэп снова с нами!
+65
for(;;)
{
try
{
game();
}
catch(game_end e)
{
if(e.reason == GAME_WIN)
{
printf("** Would you like to play again? (y-n) ");
if(get_y_n()) continue;
break;
}
else if(e.reason == GAME_LOSE)
{
printf("** Try again? (y-n) ");
if(get_y_n()) continue;
printf("** Are you coward? (y-n) ");
if(get_y_n()) break;
printf("** Try again? (y-n) ");
if(get_y_n()) continue;
break;
}
else if(e.reason == GAME_RESTART)
{
continue;
}
else
{
break;
}
}
}
Писал игру в школе
+102.5
procedure TFrmCashBook.ButtonGroupDeleteClick(Sender: TObject);
var
CmpField : String;
CmpOperator : String;
StringToCmp : String;
DeletedCount : Integer;
begin
if MessageDLG('Âû óâåðåíû?', mtConfirmation,
[mbYes,mbNo],0) <> mrYes then Exit;
CmpField := GroupDeleteSelectFieldComboBox.Text;
CmpOperator := GroupDeleteSelectComparisonOperatorComboBox.Text;
// âîçìîæíûå îïåðàòîðû '=', '>', '>=', '<', '<='
StringToCmp := GroupDeleteEdit.Text;
DeletedCount := 0;
with DM.TblCashBook do begin
First();
while not EOF do begin
if ( (CmpOperator = '=' ) and
(FieldByName(CmpField).AsString = StringToCmp ) ) or
( (CmpOperator = '>' ) and
(FieldByName(CmpField).AsString > StringToCmp) ) or
( (CmpOperator = '>=') and
(FieldByName(CmpField).AsString >= StringToCmp) ) or
( (CmpOperator = '<' ) and
(FieldByName(CmpField).AsString < StringToCmp) ) or
( (CmpOperator = '<=') and
(FieldByName(CmpField).AsString <= StringToCmp) ) then
begin
Delete();
DeletedCount := DeletedCount + 1;
end
else //åñëè çàïèñü óäàëåíà, next() íå íóæåí
Next();
end;
end; //with
ShowMessage('Óäàëåíî çàïèñåé: ' + inttostr(DeletedCount));
end;
−130.2
class FinancialEventObserver < ActiveRecord::Observer
observe Payment, Invoice
def before_save(model)
event = nil
if model.class == Payment
if model.new_record?
event = FinancialEvent.new(:event => FinancialEvent::Event::PAYMENT_INVOICE,
:arguments => {:client_name => model.invoice.client.short_name, :invoice_number => model.invoice.invoice_number},
:company_id=>model.invoice.client.company.id)
end
elsif model.class == Invoice
i = Invoice.find_by_id model.id
if model.new_record? or i.status != model.status
if model.status == Invoice::Status::ESTIMATE
event = FinancialEvent.new(:event => FinancialEvent::Event::ESTIMATE_SEND,
:arguments => {:client_name => model.client.short_name, :invoice_number => model.invoice_number},
:company_id=>model.client.company.id)
elsif model.status == Invoice::Status::APPROVED
event = FinancialEvent.new(:event => FinancialEvent::Event::ESTIMATE_APPROVED,
:arguments => {:client_name => model.client.short_name, :invoice_number => model.invoice_number},
:company_id=>model.client.company.id)
elsif model.status == Invoice::Status::REJECTED
event = FinancialEvent.new(:event => FinancialEvent::Event::ESTIMATE_REJECTED,
:arguments => {:client_name => model.client.short_name, :invoice_number => model.invoice_number},
:company_id=>model.client.company.id)
elsif model.status == Invoice::Status::SEND
event = FinancialEvent.new(:event => FinancialEvent::Event::INVOICE_SEND,
:arguments => {:client_name => model.client.short_name, :invoice_number => model.invoice_number},
:company_id=>model.client.company.id)
end
elsif !model.new_record? and i.state != model.state
if model.state == Invoice::State::DELETED
event = FinancialEvent.new(:event => FinancialEvent::Event::INVOICE_DELETED,
:arguments => {:invoice_number => model.invoice_number},
:company_id=>model.client.company.id)
end
end
end
event.eventable = model.requester unless event.blank?
event.save unless event.blank?
end
def before_destroy(model)
if model.class == Payment
event = FinancialEvent.new(:event => FinancialEvent::Event::PAYMENT_DELETED,
:arguments => {:invoice_number => model.invoice.invoice_number},
:company_id=>model.invoice.client.company.id)
event.eventable = model.requester
event.save
end
end
end
о боже, зачем я открыл этот файл?
+144.9
char str[n]="Programmirivanie eto horoshiy predmet";
for(i=0; i<n; i++)
{
printf("%c", str[i]);
}
printf("\n");
Без комментариев ))
+162
<?
$str = "";
$amp="";
foreach ($p as $i=>$v)
{
$str .= $amp."$i=$v";
$amp = "&";
}
?>
+66.6
//Дефайн в некотором хэдере
#define _TAPI(b) do {BOOL _b = (BOOL)(b); if (!b) throw(system_exception(GetLastError())); } while (false);
//...
// И далее такое:
//...
_TAPI (::CreateProcess(0, (LPWSTR)m_process.c_str(), 0,
0, FALSE, CREATE_SUSPENDED, 0, 0, &si, &pi));
Мой говнокод, хотя скорее опечатка =), я с такими явлениями уже не раз сталкивался, но все равно в течение получаса не мог понять, почему у меня по два процесса запускается =)))
−109.5
sub title {
my ($str, $len) = @_;
while (1) {
last if substr($str, $len, 1) eq ' ';
++$len;
}
return substr($str, 0, $len) . "...";
}
аналог Index.
+159.6
document.getElementById('myID').disabled = document.getElementById('myCheckbox').checked == false ? true : false;
Это замечательно, тащем-та! =) Досталось в наследство от команды аутсорсеров. =)
−131.4
some_variable = (some_condition && some_other_condition) ? true : false
Иногда встречаю ГК подобный этому но реализованный в виде case..when. Еще более впечатляет :)