-
+57.4
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
volatile void* AllocatedMemory;
int AllocateMemoryThread(const int size)
{
char buffer[size];
AllocatedMemory=(void*)buffer;
AllocatingDone.Signal();
Sleep(INFINITY);
return 0;
};
...
void* MAlloc(const int size)
{
CriticalSection.Lock();
if( !CreateThread(AllocateMemoryThread,true,size,0) )
return NULL;
AllocatingDone.Wait();
const void* AllocatedBuffer=AllocatedMemory;
CriticalSection.UnLock();
return AllocatedBuffer;
};
CriticalSection - критическая секция.
AllocatingDone - какой-то семафор.
Вообще не могу понять код. Что он этим хотел сказать...
Говногость,
02 Сентября 2009
-
−128.3
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
Select Case Microsoft.VisualBasic.Right(FileLBL.Text.Trim, 3)
Case "pdf"
IconIMG.ImageUrl = "~/img/pdf.bmp"
Case "doc"
IconIMG.ImageUrl = "~/img/word.bmp"
Case "xls", "csv"
IconIMG.ImageUrl = "~/img/excel.bmp"
Case "rpt"
IconIMG.ImageUrl = "~/img/crystal.bmp"
Case "txt"
IconIMG.ImageUrl = "~/img/text.bmp"
Case Else
IconIMG.ImageUrl = "~/img/blank.bmp"
End Select
Valera,
02 Сентября 2009
-
+71.1
- 1
if (getHook() != null ? !getHook().equals(pmCounty.getHook()) : pmCounty.getHook() != null) return false;
Код западной enterprise системы для риэлторов. Написан русскими.
vladimir.loshchin,
02 Сентября 2009
-
+58.4
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
// кусок из хидера
#define b__bl {
#define e__bl }
#define b__st {
#define e__st }
#define b__un {
#define e__un }
...
#define end_if else ;
// Один коротенький метод
void Sud::vosstkdr()
b__fu int i=0, imv=0, imasOut=0, lpovt;
for(; i<isl; i++) b__fo
if(imv < lmv)
if(i==(Pmvosst=mvosst+imv)->imkdrish)
{ lpovt=Pmvosst->nvosst+1; imv++;}
else lpovt=1;
else lpovt=1;
for(int k=0; k<lpovt; k++) b__fo
masOut[imasOut] = mkdrish[i];
if(mdm) if(++imasOut == 35) return; end_if
else if(++imasOut == 32) return; end_if
e__fo
e__fo
e__fu
Вот так у нас пишет один матёрый программист (юникс). Привёл для примера коротенький метод.
Особое внимание заслуживает идентификатор mkdrish. Это какая-то комбинация слов "массив", "кадр", "short"
Dimarius,
02 Сентября 2009
-
+132.9
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
if ("Recap".Equals(Request["post_back"]))
{
<...>
if (Request["apply_coupon.x"] != null)
{
ValidateCoupon();
}
else if ("Recap".Equals(Request["post_back"]))
{ <...> }
<...>
}
Из одного очень древнего проекта, с самопальным post back'ом
Капитан Очевидность,
02 Сентября 2009
-
+152.9
- 1
- 2
- 3
if(empty($result) || false === $result) {
//
}
Написано человеком с 9ти летним опытом... Что б точно не прошло...
makadaw,
02 Сентября 2009
-
+136
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
public bool IsPositiveNumber(String strNumber)
{
Regex objNotPositivePattern = new Regex("[^0-9.]");
Regex objPositivePattern = new Regex("^[.][0-9]+$|[0-9]*[.]*[0-9]+$");
Regex objTwoDotPattern = new Regex("[0-9]*[.][0-9]*[.][0-9]*");
return !objNotPositivePattern.IsMatch(strNumber) &&
objPositivePattern.IsMatch(strNumber) &&
!objTwoDotPattern.IsMatch(strNumber);
}
Валидатор :)
Coffeeholic,
01 Сентября 2009
-
+101.9
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
function DatePlusOneDay(Date: TDate): TDate;
var
Day, Month, Year: string;
begin
Day := Copy(DateToStr(Date), 1, 2);
Month := Copy(DateToStr(Date), 4, 2);
Year := Copy(DateToStr(Date), 7, 4);
if frac(StrToFloat(Year) / 4) <> 0 then
if (Month = '01') or (Month = '03') or (Month = '05') or (Month = '07') or (Month = '08') or (Month = '10') or (Month = '12') then
if Day <> '31' then
if StrToInt(Day) < 9 then Day := '0' + IntToStr(StrToInt(Day) + 1)
else Day := IntToStr(StrToInt(Day) + 1)
else
begin
Day := '01';
if StrToInt(Month) < 9 then
Month := '0' + IntToStr(StrToInt(Month) + 1)
else
if Month = '12' then
begin
Month := '01';
Year := IntToStr(StrToInt(Year) + 1);
end
else Month := IntToStr(StrToInt(Month) + 1);
end
else
if (Month = '04') or (Month = '06') or
(Month = '09') or (Month = '11') then
if Day <> '30' then
if StrToInt(Day) < 9 then Day := '0' + IntToStr(StrToInt(Day) + 1)
else Day := IntToStr(StrToInt(Day) + 1)
else
begin
Day := '01';
if StrToInt(Month) < 9 then Month := '0' + IntToStr(StrToInt(Month) + 1)
else Month := IntToStr(StrToInt(Month) + 1);
end
else
if Day <> '28' then
if StrToInt(Day) < 9 then Day := '0' + IntToStr(StrToInt(Day) + 1)
else Day := IntToStr(StrToInt(Day) + 1)
else
begin
Day := '01';
if StrToInt(Month) < 9 then Month := '0' + IntToStr(StrToInt(Month) + 1)
else Month := IntToStr(StrToInt(Month) + 1);
end
else
if (Month = '01') or (Month = '03') or (Month = '05') or (Month = '07') or (Month = '08') or (Month = '10') or (Month = '12') then
if Day <> '31' then
if StrToInt(Day) < 9 then Day := '0' + IntToStr(StrToInt(Day) + 1)
else Day := IntToStr(StrToInt(Day) + 1)
else
begin
Day := '01';
if StrToInt(Month) < 9 then
Month := '0' + IntToStr(StrToInt(Month) + 1)
else
if Month = '12' then
begin
Month := '01';
Year := IntToStr(StrToInt(Year) + 1);
end
else
Month := IntToStr(StrToInt(Month) + 1);
end
else
if (Month = '04') or (Month = '06') or
(Month = '09') or (Month = '11') then
if Day <> '30' then
if StrToInt(Day) < 9 then
Day := '0' + IntToStr(StrToInt(Day) + 1)
else
Day := IntToStr(StrToInt(Day) + 1)
else
begin
Day := '01';
if StrToInt(Month) < 9 then
Month := '0' + IntToStr(StrToInt(Month) + 1)
else
Month := IntToStr(StrToInt(Month) + 1);
end
else
if Day <> '28' then
if StrToInt(Day) < 9 then
Day := '0' + IntToStr(StrToInt(Day) + 1)
else
Day := IntToStr(StrToInt(Day) + 1)
else
begin
Day := '01';
if StrToInt(Month) < 9 then
Month := '0' + IntToStr(StrToInt(Month) + 1)
else
Month := IntToStr(StrToInt(Month) + 1);
end;
DatePlusOneDay := StrToDate(Day + '.' + Month + '.' + Year);
end;
Писалось, когда не знали о эквиваленте (Date + 1)
SaNdMaN,
01 Сентября 2009
-
+50.1
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
...
double total, free;
GetCensoredServer()->GetCensoredMemory(total, free);
if (free<0.) // <-- чудесная проверка
{
MessageBox(AfxGetMainWnd()->m_hWnd, censored("Please check censored for enough memory!")), _T(""), MB_OK|MB_ICONWARNING);
return false;
}
...
Найдено в рабочем коде. Некоторые идентификаторы изменены.
Xentrax,
01 Сентября 2009
-
+47
- 1
- 2
- 3
- 4
- 5
- 6
- 7
#if defined(_WIN32_WCE_PSPC)
if(SHSipInfo(SPI_GETSIPINFO, 0, &si, 0))
#else if (_WIN32_WCE >= 400) // <-- "хитрое" место
if(SipGetInfo(&si))
#endif
{
// bla bla
Найдено в рабочем коде.
Удивительно, но это работает, как задумывалось.
Xentrax,
01 Сентября 2009