- 1
- 2
- 3
- 4
section.static > div[style="display:block; border: solid 1px #cfcfcf; padding : 10px"]{
border: none !important;
padding: 0 !important;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
section.static > div[style="display:block; border: solid 1px #cfcfcf; padding : 10px"]{
border: none !important;
padding: 0 !important;
}
css-костыль!)
+1
function getQuarter(month) {
if (0 <= month && month <= 2) return "Q1 ";
if (3 <= month && month <= 5) return "Q2 ";
if (6 <= month && month <= 8) return "Q3 ";
return "Q4 ";
};
function getDate(lastActionDate) {
var dateString = lastActionDate.split(/\-|\s/);
var date = new Date(dateString.slice(0, 2));
var month = date.getMonth();
var year = date.getFullYear();
var quarter = getQuarter(month);
return "<span>Last Action Plan: <br> " + quarter + year + "</span>";
}
на проекте активно используется momentjs
+1
<?php
$gudir = opendir("../text/$book");
$guarray = Array();
while(false != ($gufile = readdir($gudir)))
{
if(strstr($gufile, "gu@"))
{
$guarray[count($guarray)] = $gufile;
}
}
closedir($gudir);
if(count($guarray))
{
rsort($guarray);
foreach($guarray as $gucomment)
{
/*Здесь движок отображения комментариев*/
include "../text/$book/$gucomment";
}
}
?>
Я не знаю, что делает этот код. Никаких файлов с символами gu@ в каталогах не осталось. Лет 8 назад с другом книгу писали, решили замутить сайт. Ту книгу мы потом посчитали фигней и забросили. Про БД я тогда и не подозревал. Все хранилось в таких файлах:
chapter#prae#prae#Предисловие#previous#0 #0#next#1#1
chapter#1#1#Глава 1.1#previous#prae#prae#next#1#2
chapter#1#2#Глава 1.2#previous#1#1#next#0#0
+1
$dbh = new PDO("mysql:host=$this->dbHost;dbname=$this->dbName", $this->dbUser, $this->dbPassword);
$dbh->exec("set names utf8");
$street = $streetPart.'%';
if (isset($arChooseCity[$cityIndex])) {
$condition =
"(city_az LIKE '$city'"
." OR city_az LIKE '$arChooseCity[$cityIndex]'"
." OR city_ru LIKE '$arChooseCity[$cityIndex]'"
." OR city_en LIKE '$arChooseCity[$cityIndex]'"
." OR city_ru LIKE '$city'"
." OR city_en LIKE '$city')"
." AND (geo_az LIKE '$street'"
." OR geo_ru LIKE '$street'"
." OR geo_en LIKE '$street'"
." OR geo_az LIKE '% $street'"
." OR geo_en LIKE '% $street'"
." OR geo_ru LIKE '% $street')"
;
}
else {
$condition =
"(city_az LIKE '$city'"
." OR city_ru LIKE '$city'"
." OR city_en LIKE '$city')"
." AND (geo_az LIKE '$street'"
." OR geo_ru LIKE '$street'"
." OR geo_en LIKE '$street'"
." OR geo_az LIKE '% $street'"
." OR geo_en LIKE '% $street'"
." OR geo_ru LIKE '% $street')"
;
}
$condition_type = " AND type = 'geo_object'";
$condition_street = " AND type = 'street'";
$query_street = $dbh->prepare("SELECT * from `addresses_new_new` WHERE $condition $condition_street GROUP BY street_{$lang}, city_{$lang} ORDER BY weight DESC LIMIT 0, {$maxLimit}");
$query_type = $dbh->prepare("SELECT * from `addresses_new_new` WHERE $condition $condition_type LIMIT 0, {$maxLimit}");
$query_street->execute();
$query_type->execute();
match - against никому не нужен! пользуйся только like.
+1
$(".lucky-card-divforCheck").hover(
function () {
if (document.getElementById('lucky-card-p-mail').getElementsByTagName('input')[0].value=="" &&
document.getElementById('lucky-card-p-phone').getElementsByTagName('input')[0].value==""
) {
$(document.getElementById("lucky-card-butt1")).hide();
$(document.getElementById("lucky-card-butt2")).show();
/*document.getElementById('lucky-card-err_fio').innerHTML='Не работает элс';*/
} else {
/*document.getElementById('lucky-card-err_fio').innerHTML='Работает элс';*/
};
}
,
function () {
$(document.getElementById("lucky-card-butt2")).hide();
$(document.getElementById("lucky-card-butt1")).show();
}
);
$('#lucky-card-empty-butt').click(function(){
document.getElementById('lucky-card-err_fio').innerHTML='Напишите хотя бы почту или телефон';
});
изящная валидация
+1
class CBaseEntity {
// ...
void (CBaseEntity ::*m_pfnThink)(void);
virtual void Think( void ) { if (m_pfnThink) (this->*m_pfnThink)(); };
// ...
// Ugly code to lookup all functions to make sure they are exported when set.
#ifdef _DEBUG
void FunctionCheck( void *pFunction, char *name )
{
if (pFunction && !NAME_FOR_FUNCTION((uint32)pFunction) )
ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING(pev->classname), name, (uint32)pFunction );
}
BASEPTR ThinkSet( BASEPTR func, char *name )
{
m_pfnThink = func;
FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnThink)))), name );
return func;
}
// ...
};
// Ugly technique to override base member functions
// Normally it's illegal to cast a pointer to a member function of a derived class to a pointer to a
// member function of a base class. static_cast is a sleezy way around that problem.
#ifdef _DEBUG
#define SetThink( a ) ThinkSet( static_cast <void (CBaseEntity::*)(void)> (a), #a )
// ...
#else
#define SetThink( a ) m_pfnThink = static_cast <void (CBaseEntity::*)(void)> (a)
// ...
#endif
https://github.com/ValveSoftware/halflife/blob/5d761709a31ce1e71488f2668321de05f791b405/dlls/cbase.h
> it's illegal
В крестах всё легально, главное - попросить прощения в комментах...
+1
private readonly Dictionary<BuildType, string> mProductBuildPrefix = new Dictionary<BuildType, string>
{
{ BuildType.iOS, "appstore" },
{ BuildType.iOSHD, "appstore" },
{ BuildType.iOS_INT, "appstore" },
{ BuildType.iOS_INT_HD, "appstore" },
{ BuildType.Alpha, "appstore" },
{ BuildType.Develop, "appstore" },
{ BuildType.Android, "appstore" },
{ BuildType.Android_INT, "appstore" },
{ BuildType.Web, "appstore" },
{ BuildType.Amazon, "appstore" }
};
> не понимаю смысловой нагрузки в этом...
+1
<?
//Выводим картинку производителя и его описание в каталоге при условии выбора одного производителя из списка
if(isset($_GET['mids'])) { if(isset($_GET['mids'][1]) {} else{ //Если один производитель
!isset? count? - не, неслышал
+1
public void CreateTable(ref string text)
{
List<S> list = new List<S>();
list.Add(new S('о', 9.28));
list.Add(new S('а', 8.66));
list.Add(new S('е', 8.10));
list.Add(new S('и', 7.45));
list.Add(new S('н', 6.35));
list.Add(new S('т', 6.30));
list.Add(new S('р', 5.53));
list.Add(new S('с', 5.45));
list.Add(new S('л', 4.32));
list.Add(new S('в', 4.19));
list.Add(new S('к', 3.47));
list.Add(new S('п', 3.35));
list.Add(new S('м', 3.29));
list.Add(new S('у', 2.90));
list.Add(new S('д', 2.56));
list.Add(new S('я', 2.22));
list.Add(new S('ы', 2.11));
list.Add(new S('ь', 1.90));
list.Add(new S('з', 1.81));
list.Add(new S('б', 1.51));
list.Add(new S('г', 1.41));
list.Add(new S('й', 1.31));
list.Add(new S('ч', 1.27));
list.Add(new S('ю', 1.03));
list.Add(new S('х', 0.92));
list.Add(new S('ж', 0.78));
list.Add(new S('ш', 0.77));
list.Add(new S('ц', 0.52));
list.Add(new S('щ', 0.49));
list.Add(new S('ф', 0.40));
list.Add(new S('э', 0.17));
list.Add(new S('ъ', 0.04));
}
И как от этого отойти?
+1
//~200 строк сбора статистики
...
detail.AppendLine(" Обработано кодом \"1\" (Готово - полная идентификация) " + kolvostrok.ToString() + " (" + getProc + "%)" + "");
detail.AppendLine("");
proc = (((kolvostrok_1 + kolvostro1) / kolvostrok) * 100).ToString();
getProc = proc.Substring(0, proc.IndexOf(",") + 3);
detail.Append("Обработано данных с кодом \"-1\" и \"1\" , Всего " + (kolvostrok_1 + kolvostrok).ToString() + " (" + getProc + "%)");
msgBody += str.ToString();
msgBody += detail.ToString();
msgBody = msgBody.Normalize();
}
catch (Exception e)
{
}
finally
{
ocon.Close();
SendEmail.SendEmail.SendMessage(msgSubject, msgBody, msgFrom, msgTo, msgCopy);
}
}
потрясающе