- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
// Код на Qt
QStringList list;
...
if (0 == QString::compare(list[i].data()[0],' ',Qt::CaseInsensitive))
{
...
}
..
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+68.3
// Код на Qt
QStringList list;
...
if (0 == QString::compare(list[i].data()[0],' ',Qt::CaseInsensitive))
{
...
}
..
Сравнение нулевого символа i-той строки с пробелом)))
+158.9
// Эта функция автоматически обработает все текстовые поля (text,password).
// Если у вас изначально задано значение для поля, то при фокусировании поля - значение пропадёт, если пользователь не введёт новое значение, то вернётся первоначальное.
// Это jQuery версия
$("input:text, textarea, input:password").each(function () {
if (this.value == '') this.value = this.title;
});
$("input:text, textarea, input:password").focus(function () {
if (this.value == this.title) this.value = '';
});
$("input:text, textarea, input:password").blur(function () {
if (this.value == '') this.value = this.title;
});
$("input:image, input:button, input:submit").click(function () {
$(this.form.elements).each(function () {
if (this.type == 'text' || this.type == 'textarea' || this.type == 'password') {
if (this.value == this.title && this.title != '') {
this.value = '';
}
}
});
});
Не зря Джонни Рейсиг говорил, что jQuery детям не игрушка.
+128.8
public static T Parse<T>(string txt)
{
if (string.IsNullOrEmpty(txt))
return default(T);
txt = txt.Trim();
Type[] typeArray = new Type[] {
typeof(string),
typeof(T).MakeByRefType()};
MethodInfo mi = typeof(T).GetMethod("TryParse", typeArray);
T value = default(T);
if (mi != null)
{
object[] prms = new object[]{
txt,
value};
if ((bool)mi.Invoke(null, prms) && prms[1] != null)
value = (T)prms[1];
}
return value;
}
Не скажу что это такой уж говнокод, но что то говнистое в нем есть =)
+156
if(strstr($username, '**')) {
$admin = 1;
$username = str_replace('**', '', $username);
$_SESSION['admin'] = 1;
} else {
$admin = 0;
}
Вот нашел случайно... Судя по всему этот кусок в каком-то коммерческом проекте
"Actually, it turns out there’s an even simpler way, and that Adam P’s predecessor discovered and implemented it for their client’s fairly large ecommerce website."
+60.3
std::string basic::_gettime(time_t t)
{
string res;
string tt;
//must be Wdy, DD-Mon-YYYY HH:MM:SS GMT
struct tm *tm_res;
tm_res=gmtime(&t);
switch(tm_res->tm_wday)
{
case 0:
res+="Sun";
break;
case 1:
res+="Mon";
break;
case 2:
res+="Tue";
break;
case 3:
res+="Wed";
break;
case 4:
res+="Thu";
break;
case 5:
res+="Fri";
break;
case 6:
res+="Sat";
break;
default:
throw "Internal error: cgi_app::_gettime(): Day num>6!";
}
res+=", ";
tt=itoa(tm_res->tm_mday);
if(tt.length()==1)
tt="0"+tt;
res+=tt;
res+="-";
switch(tm_res->tm_mon)
{
case 0:
res+="Jan";
break;
case 1:
res+="Feb";
break;
case 2:
res+="Mar";
break;
case 3:
res+="Apr";
break;
case 4:
res+="May";
break;
case 5:
res+="Jun";
break;
case 6:
res+="Jul";
break;
case 7:
res+="Aug";
break;
case 8:
res+="Sep";
break;
case 9:
res+="Oct";
break;
case 10:
res+="Nov";
break;
case 11:
res+="Dec";
break;
default:
throw "Internal error: cgi_app::_gettime(): Month num>11!";
}
res+="-";
tt=itoa(tm_res->tm_year+1900);
res+=tt;
res+=" ";
tt=itoa(tm_res->tm_hour);
if(tt.length()==1)
tt="0"+tt;
res+=tt;
res+=":";
tt=itoa(tm_res->tm_min);
if(tt.length()==1)
tt="0"+tt;
res+=tt;
res+=":";
tt=itoa(tm_res->tm_sec);
if(tt.length()==1)
tt="0"+tt;
res+=tt;
res+=" GMT";
}
Делаю класс для работы с CGI. Сначала хотел использовать какое-нибудь готовое решение, но ничего подходящего не нашел. По общей концепции понравилась библиотека "CGI C++ Library v0.30a". До тех пор, пока не посмотрел исходники более внимательно... Это функция, которая формирует строку для поля заголовка HTTP "Last-Modified".
+156.3
$this->DB->query("SELECT * FROM ol_objects WHERE id='{$id}'");
$object = $this->DB->fetch_row();
if ($id=='') {
$object['title']='';
$object['address']='';
$object['type_home']='';
$object['finish']='';
$object['process']='';
$object['breif']='';
$object['type_home']='';
$object['project']='';
$object['floors']='';
$object['flats']='';
$object['square']='';
$object['price']='';
$object['desc']='';
$object['height']='';
$object['facing']='';
$object['walls']='';
$object['wiring']='';
$object['screed_floor']='';
$object['window']='';
$object['heating']='';
$object['balconies']='';
$object['grants_text']='';
$object['id']='';
$object['image']='no_foto';
}
Код рабочего сайта о недвижимости.
+163.5
$amount=100;
$amount2=20;
while( strlen($amount)<12) {$amount="0".$amount;}
while( strlen($amount2)<12) {$amount2="0".$amount;}
sprintf для лошар
+48.5
while(!pVec.empty())
{
pVec.pop_back();
}
Сей артефакт остался в коде ввиду лености переписывать его в 100 файлах сразу после удаления того, ради чего собственно затевался while(!pVec.empty()) ... прямо скажем - отлов ЭТОГО занял немало времени и нервов... тк на первый взгляд оно должно... а что ты видишь в этом коде, %юзернейм% ?
+105.3
public class ImportService : System.Web.Services.WebService
{
private const string KEY = "*******";
[WebMethod]
public void AddFileInQueue(string aKey, ..., out String error)
{
...
if (KEY == aKey)
...
else
{
error = "Invalid key";
}
}
}
Мне предложили использовать эту же авторизацию для нового веб-сервиса в том же проекте со словами "there is normal login implemented somewhere"
+148.5
//создание своих бб кодов
$.get == [
if dacumetn innerhtm l -body == [b]
replace==<b>
else
recplae==<\ b>
<?pxp endif #>
ыыы