- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
// Дополняем недостающие данные товаров
foreach($product_data as $p_key => $p_dat) {
if(!isset($p_dat['product_id'])) {
unset($product_data[$p_key]);
$this->remove($p_dat['def_key']);
continue;
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+58
// Дополняем недостающие данные товаров
foreach($product_data as $p_key => $p_dat) {
if(!isset($p_dat['product_id'])) {
unset($product_data[$p_key]);
$this->remove($p_dat['def_key']);
continue;
}
}
Фееричный комментарий!
+106
function ReplaceUrl(txt: WideString): WideString;
var
i, j: integer;
tmp, Url: WideString;
begin
Result := '';
I := 1;
while I <= Length(txt) do
begin
tmp := '';
if WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3]+txt[i+4]+txt[i+5]+txt[i+6], 'http://') or
WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3]+txt[i+4]+txt[i+5]+txt[i+6], 'ed2k://') or
WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3]+txt[i+4]+txt[i+5], 'ftp://') or
WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3], 'www.') or
WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3]+txt[i+4]+txt[i+5]+txt[i+6]+txt[i+7], 'https://') then
begin
Url := '';
for j := I to Length(txt) do
begin
if (txt[j] <> ' ') and (ord(txt[j]) < 255) then
Url := Url + txt[J]
else
Break;
end;
Result := Result + Format(C_HTML_URL, [Url, Url]);
I := J;
end else
begin
Result := Result + txt[I];
Inc(I);
end;
end;
end;
http://www.bvbcode.com/code/vhk2e8rb-1638045
+153
if ((this.formType.urlParam === 'sell1') || (this.formType.urlParam === 'supply1')) {
url = 'sell-return-list';
} else if ((this.formType.urlParam === 'sell2') || (this.formType.urlParam === 'supply2')) {
url = 'buy-return-list';
} else if ((this.formType.urlParam === 'service1') || (this.formType.urlParam === 'service2')) {
url = 'get-service-list';
} else {
url = 'provide-service-list';
}
Ниньзя стайл
+15
//file systeminfo.cpp
#include "../SystemInfoManager.h"
struct : public SystemInfoManager
{
//some atriburtes
//some methods
void setSomeparametrs()///
{
/*....*/
}
///ect...
} System;
SystemInfoManager * instance()
{
return &System;
}
Мое имя затрет история, но мои славные дела будут жить, пытайте меня дальше гниды из гестапо!
+106
IDictionary activeProcesses = (IDictionary)(new Hashtable());
По мотивам
http://govnokod.ru/11512
Код встречен в книге http://tinyurl.com/eai-patterns
Можно объяснить человеку, не знакомому с тонкостями C#, зачем это нужно, если Hashtable : IDictionary?
+138
int getRandomNumber(){
return 4; //chosen by fair dice roll.
//guaranteed to be random.
}
−111
lv.onData = function(data:String):Void{
htmlData = data;
xml.parseXML(htmlData);
trace(xml.firstChild.lastChild.firstChild.lastChild.lastChild.lastChild.childNodes[1].childNodes[1].childNodes[0]);
trace(xml.firstChild.lastChild.firstChild.lastChild.lastChild.lastChild.childNodes[1].childNodes[2].childNodes[1].firstChild);
}
С демиарта.
+161
function timer() {
var t=new Date();
var sec=t.getSeconds();
var min=t.getMinutes();
var h=t.getHours();
var day=t.getDate();
var month=t.getMonth();
var year=t.getFullYear();
var d, y, m, allday, allhour, allmin, allsec;
if (year>2010) {
if (month===8) {
if (day===14) {
if (h===13) {
if (min<7) {y=year - 2011}
if (min>6) {y=year - 2010}
} else {
if (h<13) {y=year - 2011}
if (h>13) {y=year - 2010}
}
} else {
if (day<14) {y=year - 2011}
if (day>14) {y=year - 2010}
}
} else {
if (month<8) {y=year - 2011}
if (month>8) {y=year - 2010}
}
}
if (month===8) {
if (day===14) {
if (h===13) {
if (min===7) {
m=''
} else {
if (min<7) {m=month + 3}
if (min>7) {m=''}
}
} else {
if (h<13) {m=month + 3}
if (h>13) {m=''}
}
} else {
if (day<14) {m=month + 3}
if (day>14) {m=''}
}
} else {
if (month>-1 && month<8) {
if (day===14) {
if (h===13) {
if (min===7) {
m=month + 4
} else {
if (min<7) {m=month + 3}
if (min>7) {m=month + 4}
}
} else {
if (h<13) {m=month + 3}
if (h>13) {m=month + 4}
}
} else {
if (day<14) {m=month + 3}
if (day>14) {m=month + 4}
}
} else {
if (day===14) {
if (h===13) {
if (min===7) {
m=month - 8
} else {
if (min<7) {m=month - 9}
if (min>7) {m=month - 8}
}
} else {
if (h<13) {m=month - 9}
if (h>13) {m=month - 8}
}
} else {
if (day<14) {m=month - 9}
if (day>14) {m=month - 8}
}
}
}
if (day===14) {
if (h===13) {
if (min<7) {d=''}
if (min>6) {d=''}
} else {
if (h<13) {d=''}
if (h>13) {d=''}
}
}
if (day>14 && day<32) {
if (h===13) {
if (min<7) {d=day - 15}
if (min>6) {d=day - 14}
} else {
Счетчик к определённой дате, ну код естественно не весь) Писалось при изучении js почти 2 года назад)
−52
require_once '/usr/share/php/smarty/Smarty.class.php';
class SmartyMegaAPI extends Smarty{
public function __construct()
{
$this->Smarty();
$this->template_dir = './smarty/templates';
$this->config_dir = './smarty/config';
$this->compile_dir = './smarty/templates_c';
$this->cache_dir = './smarty/cache';
}
}
ООП такое ООП
+118
decimal retValue = <...>
var span = TimeSpan.FromMinutes(double.Parse(retValue.ToString()));
Почему бы просто не (double) retValue...