- 1
. ldd
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−118
. ldd
Роняет bash
−165
SELECT `score` FROM `score`
WHERE `score` = (SELECT DISTINCT `score` FROM `score`
ORDER BY `score` DESC LIMIT 1,1)
Про именование таблиц и полей...
+157
$inp[] = implode("-", array_reverse(explode(".",$input['from-date']))).' '.$input['from-time'].'+0400';
От платины отличается магическим '+0400' (ISO-8601, лол).
+156
function form_xml_items( $sXML, $reserve, $exchange ){
foreach ($exchange as $in => $outs) {
$currency_in = taxonomy_term_load($in);
switch ($in) {
case 6:
$currency_in->name = 'CASHUAH';
break;
case 18:
$currency_in->name = 'CASHUSD';
break;
// ...
$currency_in->name = 'TBRUB';
break;
case 161:
$currency_in->name = 'OPB';
break;
}
foreach ($outs as $out => $param) {
$currency_out = taxonomy_term_load($out);
switch ($out) {
case 11:
$currency_out->name ='CASHUAH';
break;
case 19:
$currency_out->name ='CASHUSD';
break;
// ...
case 155:
$currency_out->name = 'CARDRUB';
$currency_out->second_name = 'WIRERUB';
break;
case 162:
$currency_out->name = 'OPB';
break;
}
$sXML .= "<item>\n";
$sXML .= "<from>" . $currency_in->name . "</from>\n";
$sXML .= "<to>" . $currency_out->name . "</to>\n";
$sXML .= "<in>1</in>\n";
$sXML .= "<out>" . $param["rate"] . "</out>\n";
$sXML .= "<amount>" . $param["reserve"] . "</amount>\n";
$sXML .= "</item>\n";
//wire and card in
if (isset( $currency_in->second_name)){
$sXML .= "<item>\n";
$sXML .= "<from>" . $currency_in->second_name . "</from>\n";
$sXML .= "<to>" . $currency_out->name . "</to>\n";
$sXML .= "<in>1</in>\n";
$sXML .= "<out>" . $param["rate"] . "</out>\n";
$sXML .= "<amount>" . $param["reserve"] . "</amount>\n";
$sXML .= "</item>\n";
}
//wire and card out
if (isset($currency_out->second_name)){
$sXML .= "<item>\n";
$sXML .= "<from>" . $currency_in->name . "</from>\n";
$sXML .= "<to>" . $currency_out->second_name . "</to>\n";
$sXML .= "<in>1</in>\n";
$sXML .= "<out>" . $param["rate"] . "</out>\n";
$sXML .= "<amount>" . $param["reserve"] . "</amount>\n";
$sXML .= "</item>\n";
}
}
}
return $sXML;
}
Если не взирать на магические числа, кажеться этот код должен занимать строк 20, а не 130
+160
var hgh = $(document).height() - 320 - 180 - 440;
$(".message-form").height( hgh );
шта?
+53
{
...
_tswfstring contentID = fileName;
_tswfstring::size_type index = fileName.find_last_of ( _T("\\") );
if ( index != -1 )
contentID.erase(0, index + 1);
TCHAR name[10] = {0};
memcpy(name, contentID.c_str() + contentID.length() - 9, 9 * sizeof(TCHAR));
if(name[6] == _T('B') || name[6] == _T('b')) //to upper case if .bmp
{
name[6] = _T('B');
name[7] = _T('M');
name[8] = _T('P');
}
}
−109
if form.cleaned_data.has_key('replace_id') and type(form.cleaned_data['replace_id']) == type(32):
...
Логично, чо
+55
uint8_t const Q_ROM QF_div8Lkup[65] = {
static_cast<uint8_t>(0), // unused location
static_cast<uint8_t>(0), static_cast<uint8_t>(0), static_cast<uint8_t>(0),
static_cast<uint8_t>(0), static_cast<uint8_t>(0), static_cast<uint8_t>(0),
static_cast<uint8_t>(0), static_cast<uint8_t>(0),
static_cast<uint8_t>(1), static_cast<uint8_t>(1), static_cast<uint8_t>(1),
static_cast<uint8_t>(1), static_cast<uint8_t>(1), static_cast<uint8_t>(1),
static_cast<uint8_t>(1), static_cast<uint8_t>(1),
static_cast<uint8_t>(2), static_cast<uint8_t>(2), static_cast<uint8_t>(2),
static_cast<uint8_t>(2), static_cast<uint8_t>(2), static_cast<uint8_t>(2),
static_cast<uint8_t>(2), static_cast<uint8_t>(2),
static_cast<uint8_t>(3), static_cast<uint8_t>(3), static_cast<uint8_t>(3),
static_cast<uint8_t>(3), static_cast<uint8_t>(3), static_cast<uint8_t>(3),
static_cast<uint8_t>(3), static_cast<uint8_t>(3),
static_cast<uint8_t>(4), static_cast<uint8_t>(4), static_cast<uint8_t>(4),
static_cast<uint8_t>(4), static_cast<uint8_t>(4), static_cast<uint8_t>(4),
static_cast<uint8_t>(4), static_cast<uint8_t>(4),
static_cast<uint8_t>(5), static_cast<uint8_t>(5), static_cast<uint8_t>(5),
static_cast<uint8_t>(5), static_cast<uint8_t>(5), static_cast<uint8_t>(5),
static_cast<uint8_t>(5), static_cast<uint8_t>(5),
static_cast<uint8_t>(6), static_cast<uint8_t>(6), static_cast<uint8_t>(6),
static_cast<uint8_t>(6), static_cast<uint8_t>(6), static_cast<uint8_t>(6),
static_cast<uint8_t>(6), static_cast<uint8_t>(6),
static_cast<uint8_t>(7), static_cast<uint8_t>(7), static_cast<uint8_t>(7),
static_cast<uint8_t>(7), static_cast<uint8_t>(7), static_cast<uint8_t>(7),
static_cast<uint8_t>(7), static_cast<uint8_t>(7)
};
// ....
//! the function evaluates to TRUE if the priority set has the element n.
bool hasElement(uint_fast8_t const n) const {
uint_fast8_t const m =
static_cast<uint_fast8_t>(Q_ROM_BYTE(QF_div8Lkup[n]));
return ((m_bits[m]
& static_cast<uint_fast8_t>(Q_ROM_BYTE(QF_pwr2Lkup[n])))
!= static_cast<uint_fast8_t>(0));
}
//! insert element \a n into the set, n = 1..64
void insert(uint_fast8_t const n) {
uint_fast8_t m =
static_cast<uint_fast8_t>(Q_ROM_BYTE(QF_div8Lkup[n]));
m_bits[m] |= static_cast<uint_fast8_t>(Q_ROM_BYTE(QF_pwr2Lkup[n]));
m_bytes |=
static_cast<uint_fast8_t>(Q_ROM_BYTE(QF_pwr2Lkup[m
+ static_cast<uint_fast8_t>(1)]));
}
делим на 8 в индустриальном С++. это такой специальный вариант крестов где пользователям сначала лоботомию делают.
из реализации bitset'а. insert() приведен в качестве примера.
+155
if (in_array ($v["field_currency_out"]["und"][0]["tid"], array(20, 21, 26, 27,153,157,154,152,155,162)) || in_array ($v["field_currency_in"]["und"][0]["tid"], array(22, 23, 24, 25,151,156,150,149,148,161))) {
$v["field_payment"]["und"][0]["tid"] = 28;
} else {
$v["field_payment"]["und"][0]["tid"]= 13;
}
Представте что весь сайт написан в этом же духе.
Причем мы имеем дело с двома наборами констант для обозначения валют - для входа и выхода перевода.
+156
$dateStart = "2015-01-01";
$dateEnd = date("Y-m-d", strtotime(date("Y-m-01", strtotime(date("Y-m-d", strtotime("+1 month", strtotime($dateStart))))) . " -1 day"));
Вычисляем последний день месяца