- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
if(count($colors)>1){
if($i==2){
$col = $colors[1];
}else{
$col = $colors[0];
}
}else{
$col=$colors[0];
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+153
if(count($colors)>1){
if($i==2){
$col = $colors[1];
}else{
$col = $colors[0];
}
}else{
$col=$colors[0];
}
Вот где не надо - тьма тернарных операторов, а где их логичнее всего ожидать - вот такой огород из IF/ELSE
+158
$(document).ready(function() {
var links = $("a[href*='shop.mts.ru']");
$.each(links, function(i, val) {
$(val).attr('onclick', "_gaq.push(['_link', '" + $(val).attr('href') + "']); return false;");
});
//for ThreeSmallBanners adfox:
$('a.offer_button').removeAttr('onclick');
});
mts.ru
−165
Функция ПолучитьЧистыйКод(Код) Экспорт
//ЧистыйКод = "0";
ЧистыйКод = "";
Инд = 1;
Пока Инд < 18 Цикл
Символ = Сред(Код, Инд, 1);
Если Символ = " " ИЛИ Символ = "" ИЛИ Символ = " " Тогда // А вот это - самая фееричная строка
Инд = Инд + 1;
Продолжить;
Иначе
ЧистыйКод = ЧистыйКод + Символ;
КонецЕсли;
Инд = Инд + 1;
КонецЦикла;
Возврат ЧистыйКод;
КонецФункции
Чел видимо только что с ассемблера соскочил.
+169
var id = $('#block1').attr('id');
if( id == 'block1') {
$('.right').hide();
}else{
$('.right').show();
};
Шедевр.
−79
map_of_enemy :: [[Int]] -> [[Int]]
map_of_enemy [] = []
map_of_enemy list = (iniciar (0) (0) (list))
iniciar :: Int -> Int -> [[Int]] -> [[Int]]
iniciar a b list = if(a == (length list)-1) then [rango a 0 list]
else [rango a 0 list]++[(iniciar (a+1) 0 list)]
rango :: Int -> Int -> [[Int]] -> [Int]
rango a b list = if (b==(length list)-1 && (((list!!a!!0)==(list!!b!!0)) && ((list!!a!!1)==(list!!b!!1)) && ((list!!a!!2)==(list!!b!!2))))
then [0]
else if (b==(length list)-1 && (((list!!a!!0)/=(list!!b!!0)) || ((list!!a!!1)/=(list!!b!!1)) || ((list!!a!!2)/=(list!!b!!2))))
then (rango2 a (list!!b) list)
else if (((list!!a!!0)==(list!!b!!0)) && ((list!!a!!1)==(list!!b!!1)) && ((list!!a!!2)==(list!!b!!2)))
then [0]++(rango a (b+1) list)
else (rango2 a (list!!b) list)++(rango a (b+1) list)
rango2 :: Int -> [Int] -> [[Int]] -> [Int]
rango2 a b list = if ((verif [(list!!a!!0)+(list!!a!!2),(list!!a!!1)+(list!!a!!2)] [(list!!a!!0)-(list!!a!!2),(list!!a!!1)-(list!!a!!2)] (b))) then [1]
else [0]
verif a b c = if (((c!!0) < (a!!0)) && ((c!!0) > (b!!0)) && ((c!!1) < (a!!1)) && ((c!!1) > (b!!1))) then True
else if (((c!!0) < (a!!0)) && ((c!!0) == (b!!0)) && ((c!!1) < (a!!1)) && ((c!!1) == (b!!1))) then True
else if (((c!!0) == (a!!0)) && ((c!!0) > (b!!0)) && ((c!!1) == (a!!1)) && ((c!!1) > (b!!1))) then True
else False
Haskell
OMG mode on
+74
public final class TimeBasedRollingPolicy extends RollingPolicyBase
...
private int suffixLength = 0;
...
public void activateOptions() {
....
if (lastFileName.endsWith(".gz")) {
suffixLength = 3;
} else if (lastFileName.endsWith(".zip")) {
suffixLength = 4;
}
}
public RolloverDescription rollover(final String currentActiveFile) {
...
if (suffixLength == 3) {
compressAction =
new GZCompressAction(
new File(lastBaseName), new File(lastFileName), true);
}
if (suffixLength == 4) {
compressAction =
new ZipCompressAction(
new File(lastBaseName), new File(lastFileName), true);
}
...
}
}
Log4j
+166
function array_min_recursive($arr, &$peaks = array(), $current_key = '') {
return array_max_recursive($arr, $peaks, $current_key, true); // Неожиданно, правда?
}
+127
boolean loadPPOGroupCompleted(string customerRef, string competence, string marketArea) {
int i = 0;
table sceData = getPPOPODGroupSCEs(customerRef, competence, marketArea);
table dceData = getPPOPODGroupDCEs(customerRef, competence, marketArea);
table sbilData = getPPOPODGroupSbil(customerRef, competence, marketArea);
while (i < tableRowCount(sceData)) {
EventRec sce = convertStoredSCRtoEventRec(false, sceData, i, "", competence);
if ((string)tableGet(sceData, i, "ACTION_TYPE") == ACTION_REP) {
udrRoute(sce, "toSE_Agg_rer");
isReplaceAction = true;
} else {
udrRoute(sce, "toSE_Agg_evt");
}
i = i+ 1;
}
i = 0;
while (i < tableRowCount(dceData)) {
EventRec dce = convertStoredDCRtoEventRec(false, dceData, i, "", competence);
if ((string)tableGet(dceData, i, "ACTION_TYPE") == ACTION_REP) {
udrRoute(dce, "toSE_Agg_rer");
isReplaceAction = true;
} else {
udrRoute(dce, "toSE_Agg_evt");
}
i = i+ 1;
}
i = 0;
while (i < tableRowCount(sbilData)) {
EventRec sbilEvent = convertStoredSbiltoEventRec(sbilData, i, PPO_ZONALE, competence);
if ((string)tableGet(sbilData, i, "ACTION_TYPE") == ACTION_REP) {
udrRoute(sbilEvent, "toSE_Agg_rer");
isReplaceAction = true;
} else {
udrRoute(sbilEvent, "toSE_Agg_evt");
}
i = i + 1;
}
return true;
}
boolean loadGroupCompleted(string customerRef, string competence, date minStartDate) {
table sceData = getGroupSCEs(customerRef, competence);
table dceData = getGroupDCEs(customerRef, competence);
int i = 0;
string extPODCode, hour_date, hour_value, eventDTM, hourlyConsumption, totalF0GroupConsumption, treatmentType, consumptionType, actionType, edmID;
while (i < tableRowCount(sceData)) {
EventRec sce = convertStoredSCRtoEventRec(true, sceData, i, "", competence);
if ((string)tableGet(sceData, i, "ACTION_TYPE") == ACTION_REP) {
udrRoute(sce, "toSE_Agg_rer");
isReplaceAction = true;
} else {
udrRoute(sce, "toSE_Agg_evt");
}
i = i + 1;
}
i = 0;
while (i < tableRowCount(dceData)) {
EventRec dce = convertStoredDCRtoEventRec(true, dceData, i, "", competence);
if ((string)tableGet(dceData, i, "ACTION_TYPE") == ACTION_REP) {
udrRoute(dce, "toSE_Agg_rer");
isReplaceAction = true;
} else {
udrRoute(dce, "toSE_Agg_evt");
}
i = i + 1;
}
if (isGroupHasPPO(customerRef, minStartDate)) {
table sbilData = getPPOGroupSbil(customerRef, competence);
i = 0;
while (i < tableRowCount(sbilData)) {
EventRec sbilEvent = convertStoredSbiltoEventRec(sbilData, i, PPO_ZONALE, competence);
if ((string)tableGet(sbilData, i, "ACTION_TYPE") == ACTION_REP) {
udrRoute(sbilEvent, "toSE_Agg_rer");
isReplaceAction = true;
} else {
udrRoute(sbilEvent, "toSE_Agg_evt");
}
i = i + 1;
}
}
return true;
}
ctrl+c, ctrl+v
+158
$exp_date=$item['expiration_date'];
list($date,$time)=explode(' ',$exp_date);
list($day,$month,$year)=explode('/',$date);
echo $day.'.'.$month.'.'.$year.' '.$time;
работа с датой
преобразования из
05/12/2013 11:12:00
в
05.12.2013 11:12:00
−164
Процедура глЗагрузитьЗаказы() Экспорт
ОткрытьФорму("Отчет",,"\\SQLDSTR\1C\ExtERT\InvoiceLoader.ert");
КонецПроцедуры
Встретил в самописке в клюшках. Если поменяется имя сервера или каталога - всё рухнет).