- 1
;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+145
;
Пример реализации абстрактного класса
https://lh6.googleusercontent.com/-rKfFtpL_K1A/Tuh34-faW_I/AAAAAAAAAi8/B05ygbQKIu8/w402/abstract_class.png
+76
public int RemoveEquals(AtASEData[] ar,int ln) {
if (ln==0) return 0;
int i=1;
int j=0;
while (i<ln) {
if (((Integer)ar[i].inData).intValue()==((Integer)ar[j].inData).intValue())
ar[i].SetRootData(ar[j]); else ar[++j]=ar[i];
i++;
}
return j+1;
}
+980
private string doubleToString(double v)
{
if (v < 0)
return "-" + (-(int)v).ToString() + "." + (-(v - (int)v) * 10000000).ToString("0000000.");
return ((int)v).ToString() + "." + ((v - (int)v) * 10000000).ToString("0000000.");
}
Превращаем double в строку. Разделитель - надо точку, а то "блин, он ставит запятую, SQL-сервер потом это не понимает" (с)
+1002
string Daumants::getReverse()
{
string message = this->data();
char *reverseMessage = new char[this->length()];
for (int i = this->length() - 1, j = 0; i >= 0; i--, j++)
{
reverseMessage[j] = message[i];
}
for (int i = 0; i < this->length(); i++)
{
message[i] = reverseMessage[i];
}
return message;
}
Даумант ХУЙ!
+158
<!--//
calendar = new Date();
day = calendar.getDay();
document.write("<table width=100 border=1><tr><td><center><font size=2>")
if (day == 0) {
document.write("<font color=#ff0000>Воскресенье</font>")
}
if (day == 1) {
document.write("Понедельник")
}
if (day == 2) {
document.write("Вторник")
}
if (day == 3) {
document.write("Среда")
}
if (day == 4) {
document.write("Четверг")
}
if (day == 5) {
document.write("Пятница")
}
if (day == 6) {
document.write("<font color=#ff0000>Суббота</font>")
}
document.write("</font></center></td></tr><tr><td><center><font size=2>")
month = calendar.getMonth();
if (month == 0) {
document.write("Январь")
}
if (month == 1) {
document.write("Февраль")
}
if (month == 2) {
document.write("Март")
}
if (month == 3) {
document.write("Апрель")
}
if (month == 4) {
document.write("Май")
}
if (month == 5) {
document.write("Июнь")
}
if (month == 6) {
document.write("Июль")
}
if (month == 7) {
document.write("Август")
}
if (month == 8) {
document.write("Сентябрь")
}
if (month == 9) {
document.write("Октябрь")
}
if (month == 10) {
document.write("Ноябрь")
}
if (month == 11) {
document.write("Декабрь")
}
document.write("</font></center></td></tr><tr><td><center><font size=6>")
date = calendar.getDate();
document.write(date)
document.write("</font></center></td></tr><tr><td><center><font size=2>")
year = calendar.getYear();
if (year < 100) {
document.write("19" + year + "")
}
else if (year > 1999) {
document.write(year)
}
document.write("</font></center></td></tr></table>")
//-->
Вывод даты в человеко-понятном формате. Найдено в коде одного украинского МВДшного сайта.
+120
for (; itemList.Parent != null; {
Item parent;
itemList = parent.Parent;
}
)
{
parent = itemList.Parent.Parent.Parent;
list.Add((object) parent);
}
−109
end;
create or replace package body "MUT_TABLE" is
type a_table is table of number index by pls_integer;
position a_table;
empty a_table;
procedure SET_INITIAL_STATE
as
begin
position:=empty;
end SET_INITIAL_STATE;
procedure BEF_TR( ID IN NUMBER, A IN NUMBER)
as
begin
position (ID):= A;
end BEF_TR;
procedure AFT_TR
is
v number;
begin
v:=position.FIRST;
while v is not null loop
update A set
A=1,
B='!!!!!!!!!'
where A = 1;
v:= position.next(v);
end loop;
end AFT_TR;
end "MUT_TABLE";
−111
CREATE TABLE "A"
( "ID" NUMBER,
"A" NUMBER,
"B" VARCHAR2(20),
CONSTRAINT "A_PK" PRIMARY KEY ("ID") ENABLE
)
/
CREATE OR REPLACE TRIGGER "A_2"
AFTER
insert or update on "A"
for each row
begin
mut_table.bef_tr(:NEW.ID,:NEW.A);
end;
/
ALTER TRIGGER "A_2" ENABLE
/
CREATE OR REPLACE TRIGGER "A_3"
AFTER
insert on "A"
declare
b number;
begin
mut_table.aft_tr;
end;
/
ALTER TRIGGER "A_3" ENABLE
/
CREATE OR REPLACE TRIGGER "A_AT"
BEFORE
insert or update on "A"
for each row
declare
v number;
PRAGMA AUTONOMOUS_TRANSACTION;
begin
:NEW.A:=:NEW.A+1;
:NEW.B:='!!!!!!!!!!';
commit;
end;
/
ALTER TRIGGER "A_AT" DISABLE
/
CREATE OR REPLACE TRIGGER "A_I_S"
BEFORE
insert or update on "A"
begin
mut_table.set_initial_state;
end;
/
ALTER TRIGGER "A_I_S" ENABLE
/
CREATE OR REPLACE TRIGGER "A_T1"
BEFORE
insert or update on "A"
for each row
begin
update A set
A = :NEW.A+1,
B = 'was incremented'
where A = :NEW.A;
end;
/
ALTER TRIGGER "A_T1" DISABLE
/
CREATE OR REPLACE TRIGGER "BI_A"
before insert on "A"
for each row
begin
if :NEW."ID" is null then
select "A_SEQ".nextval into :NEW."ID" from dual;
end if;
end;
/
ALTER TRIGGER "BI_A" ENABLE
/
create or replace package MUT_TABLE as
procedure set_initial_state;
procedure bef_tr(ID number,A NUMBER);
procedure aft_tr;
+161
<?
if(!file_exists($abs_path)){
$new = "Y";
// ...
}
//...
if(strlen($new) > 0 ){
// ...
?>
Угадай CMS по коду!
+993
if(pObject == NULL)
{
//code
}else if(pObject != NULL && pObject->getProperty() == Class::VALUE)
{
//code
}
Идентификаторы надуманные, но суть такова