- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
switch ($result['state'])
{
case 'Oregon':
$row->state = 'OR';
break;
case $row->state=='Washington':
$row->state = 'WA';
break;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+156.2
switch ($result['state'])
{
case 'Oregon':
$row->state = 'OR';
break;
case $row->state=='Washington':
$row->state = 'WA';
break;
}
нашел у своего потрудника, долго не мог понять что второй кейс делает и как это вообще работало
+110
Function IsBigLet(Let: String): Boolean;
var r: bool;
begin
r:=false;
if pos('Й',Let)>0 then r:=true;
if pos('Ц',Let)>0 then r:=true;
if pos('У',Let)>0 then r:=true;
if pos('К',Let)>0 then r:=true;
if pos('Е',Let)>0 then r:=true;
if pos('Н',Let)>0 then r:=true;
if pos('Г',Let)>0 then r:=true;
if pos('Ш',Let)>0 then r:=true;
if pos('Щ',Let)>0 then r:=true;
if pos('З',Let)>0 then r:=true;
if pos('Х',Let)>0 then r:=true;
if pos('Ф',Let)>0 then r:=true;
if pos('Ы',Let)>0 then r:=true;
if pos('В',Let)>0 then r:=true;
if pos('А',Let)>0 then r:=true;
if pos('П',Let)>0 then r:=true;
if pos('Р',Let)>0 then r:=true;
if pos('О',Let)>0 then r:=true;
if pos('Л',Let)>0 then r:=true;
if pos('Д',Let)>0 then r:=true;
if pos('Ж',Let)>0 then r:=true;
if pos('Э',Let)>0 then r:=true;
if pos('Я',Let)>0 then r:=true;
if pos('Ч',Let)>0 then r:=true;
if pos('С',Let)>0 then r:=true;
if pos('М',Let)>0 then r:=true;
if pos('И',Let)>0 then r:=true;
if pos('Т',Let)>0 then r:=true;
if pos('Б',Let)>0 then r:=true;
if pos('Ю',Let)>0 then r:=true;
Result:=r;
end;
Немножко индусского кода!
+60.2
bool CMLayer::operator==(CMLayer ^a, CMLayer ^b)
{
CLayer *pA;
CLayer *pB;
bool bA = false;
bool bB = false;
// Проверка в катче
try
{
pA = a->m_pelMain;
}
catch (System::NullReferenceException ^)
{
pA = NULL;
bA = true;
}
// Проверка в катче
try
{
pB = b->m_pelMain;
}
catch (System::NullReferenceException ^)
{
pB = NULL;
bB = true;
}
if ((bA == true) && (bB == true))
return true;
else if ((bA == true) || (bB == true))
return false;
return pA == pB;
}
Код на Management C++, тот кто его писал был явно в ажуре))))
Проверяются указатели на внутрении данные, а штоб System::NullReferenceException не выскакивал при сравнее на null все сделанно в катче
+144.8
bool PathProcessor::Process(PPProcess *pProcess)
{
std::vector<int> viRoute; int nRouteCount; bool bRetVal = false;
for (int i = 0; i < m_viExcludeStop.size(); i++){
if (m_viExcludeStop[i] == pProcess->nStartStopId) return false;
}
int bbb = 0;
if (pProcess->nRouteId < 0){
viRoute = GetRoutesID(pProcess->nStartStopId);
nRouteCount = viRoute.size();
if (nRouteCount <= 0) return false;
}
else{
viRoute = GetRoutesID(pProcess->nStartStopId, pProcess->nRouteId);
nRouteCount = viRoute.size();
if (nRouteCount <= 0) return false;
nRouteCount = 1;
}
for (int i = 0; i < nRouteCount; i++){
RouteDataInfo rdCur = GetRoute(viRoute[i]);
pProcess->nRoutePartId = rdCur.nId;
PPResult *pRes;
bool bCurRetVal = false;
if (pProcess->bIsFirstStop == true){
pRes = new PPResult();
pRes->bFinished = false;
pRes->nFirstStopId = pProcess->nFirstId;
pRes->nLastStopId = -1;
pRes->nRouteId = rdCur.nRouteId;
m_viResult.push_back(pRes);
}
else pRes = pProcess->pLastResult;
if (pRes != NULL){
PartInfo piTemp(rdCur.nId, rdCur.nLastStopId);
pRes->viPartsId.push_back(piTemp);
}
if (IsEndStop(rdCur.nLastStopId) == true){
if (pRes != NULL){
pRes->bFinished = true;
pRes->nLastStopId = rdCur.nLastStopId;
}
bRetVal = true; bCurRetVal = true;
}
if ((pProcess->IsStopExist(rdCur.nLastStopId) == false) && (bCurRetVal == false)){
if ((pProcess->nCurStep < m_nMaxStep) && (pProcess->nRouteId >= 0)){
PPProcess ppProc;
ppProc.nCurStep = pProcess->nCurStep;
ppProc.nRouteId = pProcess->nRouteId;
ppProc.nStartStopId = rdCur.nLastStopId;
ppProc.pPrevProc = pProcess;
ppProc.bIsFirstStop = false;
ppProc.nFirstId = pProcess->nFirstId;
if (pProcess->pLastResult == NULL) ppProc.pLastResult = pRes;
else ppProc.pLastResult = pProcess->pLastResult;
if (Process(&ppProc) == true) bRetVal = true;
}
else if (pProcess->nCurStep < m_nMaxStep){
PPProcess ppProc;
ppProc.nCurStep = pProcess->nCurStep;
ppProc.nRouteId = rdCur.nRouteId;
ppProc.nStartStopId = rdCur.nLastStopId;
ppProc.pPrevProc = pProcess;
ppProc.bIsFirstStop = false;
ppProc.nFirstId = pProcess->nFirstId;
if (pProcess->pLastResult == NULL) ppProc.pLastResult = pRes;
else ppProc.pLastResult = pProcess->pLastResult;
if (Process(&ppProc) == true) bRetVal = true;
}
if (pProcess->nCurStep+1 < m_nMaxStep){
PPProcess ppProc2;
ppProc2.nCurStep = pProcess->nCurStep+1;
ppProc2.nRouteId = -1;
ppProc2.nStartStopId = rdCur.nLastStopId;
ppProc2.pPrevProc = pProcess;
ppProc2.bIsFirstStop = true;
ppProc2.nFirstId = rdCur.nLastStopId;
ppProc2.pLastResult = NULL;
if (Process(&ppProc2) == true){
PPResult *pRes2;
pRes2 = new PPResult();
pRes2->bFinished = true;
pRes2->nFirstStopId = pRes->nFirstStopId;
pRes2->nLastStopId = rdCur.nLastStopId;
pRes2->nRouteId = pRes->nRouteId;
PPProcess *pProc = pProcess;
while (pProc != NULL){
PartInfo piTemp(pProc->nRoutePartId, pProc->nStartStopId);
pRes2->viPartsId.push_back(piTemp);
pProc = pProc->pPrevProc;
}
m_viResult.push_back(pRes2); bRetVal = true;
}
}
}
}
if ((bRetVal == false) && (pProcess->nRouteId < 0))
m_viExcludeStop.push_back(pProcess->nStartStopId);
return bRetVal;
}
Когда-то давно писал алгоритм поиска маршрутов, теперь удевляюсь как это все работает да еще и не виснет
+144.8
#include "stdafx.h"
#include "windows.h"
#define число int
#define если if
#define иначе else
#define начало {
#define конец }
#define НОЛЬ NULL
#define Сообщение MessageBoxA
#define КНОПКА_ОК MB_OK
#define возврат
#define присвоить =
#define равняется ==
#define больше >
#define ТочкаВхода _tmain
#define Строка _TCHAR
#define УКАЗАТЕЛЬ *
#define КонецСтроки ;
#define СлучайноеЧисло rand
#define Посев srand
#define ВзятьКоличествоТиков GetTickCount
/****************************************************************************************************/
/* */
/****************************************************************************************************/
число ТочкаВхода(число КоличествоПараметров, Строка УКАЗАТЕЛЬ Параметры[])
{
Посев(ВзятьКоличествоТиков());
число новое присвоить СлучайноеЧисло() КонецСтроки
если (новое больше 10000) начало
Сообщение(НОЛЬ, "Больше 10000", НОЛЬ, КНОПКА_ОК) КонецСтроки
конец иначе начало
Сообщение(НОЛЬ, "Меньше 10000", НОЛЬ, КНОПКА_ОК) КонецСтроки
конец
возврат 0 КонецСтроки
}
Ооо могучий C++
+129.2
new = ngx_pnalloc(cf->pool, sizeof("; domain=") - 1 + domain->len);
if (new == NULL) {
return NGX_CONF_ERROR;
}
p = ngx_cpymem(new, "; domain=", sizeof("; domain=") - 1);
ngx_memcpy(p, domain->data, domain->len);
domain->len += sizeof("; domain=") - 1;
Это, между прочим, файл nginx-0.7.62\src\http\modules\ngx_http_userid_ filter_module.c.
Такие вот разочарования случаются...
+144
List<Student> students = new List<Student>
{
new Student {LastName="Omelchenko", Scores= new List<int> {97, 72, 81, 60}},
new Student {LastName="O'Donnell", Scores= new List<int> {75, 84, 91, 39}},
new Student {LastName="Mortensen", Scores= new List<int> {88, 94, 65, 85}},
new Student {LastName="Garcia", Scores= new List<int> {97, 89, 85, 82}},
new Student {LastName="Beebe", Scores= new List<int> {35, 72, 91, 70}}
};
+144.8
A* arr = new A[size];
std::vector<A*> vec(size);
for(size_t i=0; i<size; ++i)
vec.push_back(&a[i])
// Do something with vec
delete[] arr;
−128.6
Перем Да, Нет Экспорт;
Да = 1;
Нет = 0;
и далее в кодах идет
Если <что то>=Да Тогда
....
КонецЕсли;
сразу скажу....это все пишется в 1С 7.7
походу ребятки ПЕРЕКОДИЛИ в 8-ке и снова вернулись на 7-ку
+151.6
## типа база для копипаста. изначально intval отсутствовал, но не суть важно
$sqll='select tt.title as titletag, t.id_news as id, DATE_FORMAT(n_d.data, "'.DATE_FORMAT.'") as data, n.title as titlenews, n.subject from '.T_TAGS.' as tt, '.T_NEWS_TAGS.' as t, '.T_ANALIT_DATA.' as n , '.T_ANALIT.' as n_d where t.id_news=n.news_id and n.news_id=n_d.id and t.id_tags="'.intval($_GET["param2"]).'" and t.id_tags=tt.id order by n_d.data desc';
$resultt = $DB->Execute($sqll) or DB_Error(__LINE__, $sqll, $DB);
$block='main.news';
while ($roww = $resultt->FetchRow()) {
foreach ($roww as $_key=>$_value) $xtpl->assign($_key, stripslashes($_value));
$xtpl->assign('titletag', $roww['titletag']);
$xtpl->assign('title_title', $roww['titletag']);
$xtpl->parse($block.'.newstags.row');
}
## аццкий отжиг
$sqll='select tt.descr from '.T_TAGS.' as tt, '.T_NEWS_TAGS.' as t, '.T_ANALIT_DATA.' as n , '.T_ANALIT.' as n_d where t.id_news=n.news_id and n.news_id=n_d.id and t.id_tags="'.intval($_GET["param2"]).'" and t.id_tags=tt.id order by n_d.data desc';
$resultt = $DB->Execute($sqll) or DB_Error(__LINE__, $sqll, $DB);
$roww = $resultt->FetchRow();
foreach ($roww as $_key=>$_value) $xtpl->assign($_key, stripslashes($_value));
if($roww['descr']!='') $xtpl->parse($block.'.newstags.descr');
копипаст неискореним.