- 1
- 2
- 3
Если Не КВыгрузке Тогда
КВыгрузке = НЕ КВыгрузке;
КонецЕсли;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−179
Если Не КВыгрузке Тогда
КВыгрузке = НЕ КВыгрузке;
КонецЕсли;
−3
sscanf_s(buf,
"%f%f%f%f%f%d%d%d%d%d%d"
"%f%f%f%f%f%d%d%d%d%d%d"
"%f%f%f%f%f%d%d%d%d%d%d"
"%f%f%f%f%f%d%d%d%d%d%d",
&_race_state._car[0]._x, &_race_state._car[0]._y, &_race_state._car[0]._vx,
&_race_state._car[0]._vy, &_race_state._car[0]._angle, &_race_state._car[0]._nitro_time,
&_race_state._car[0]._oiled_bus, &_race_state._car[0]._nirtos, &_race_state._car[0]._bonus,
&_race_state._car[0]._lap, &_race_state._car[0]._next_seg,
&_race_state._car[1]._x, &_race_state._car[1]._y, &_race_state._car[1]._vx,
&_race_state._car[1]._vy, &_race_state._car[1]._angle, &_race_state._car[1]._nitro_time,
&_race_state._car[1]._oiled_bus, &_race_state._car[1]._nirtos, &_race_state._car[1]._bonus,
&_race_state._car[1]._lap, &_race_state._car[1]._next_seg,
&_race_state._car[2]._x, &_race_state._car[2]._y, &_race_state._car[2]._vx,
&_race_state._car[2]._vy, &_race_state._car[2]._angle, &_race_state._car[2]._nitro_time,
&_race_state._car[2]._oiled_bus, &_race_state._car[2]._nirtos, &_race_state._car[2]._bonus,
&_race_state._car[2]._lap, &_race_state._car[2]._next_seg,
&_race_state._car[3]._x, &_race_state._car[3]._y, &_race_state._car[3]._vx,
&_race_state._car[3]._vy, &_race_state._car[3]._angle, &_race_state._car[3]._nitro_time,
&_race_state._car[3]._oiled_bus, &_race_state._car[3]._nirtos, &_race_state._car[3]._bonus,
&_race_state._car[3]._lap, &_race_state._car[3]._next_seg );
парсим строчку...
+91
//Постраничная навигация
$result77 = mysql_query("SELECT str FROM ...");
$myrow77 = mysql_fetch_array($result77);
$num = $myrow77["str"];
// Извлекаем из URL текущую страницу
@$page = $_GET['page'];
// Определяем общее число сообщений в базе данных
$result00 = mysql_query("SELECT COUNT(*) FROM ...");
$temp = mysql_fetch_array($result00);
$posts = $temp[0];
// Находим общее число страниц
$total = (($posts - 1) / $num) + 1;
$total = intval($total);
// Определяем начало сообщений для текущей страницы
$page = intval($page);
// Если значение $page меньше единицы или отрицательно
// переходим на первую страницу
// А если слишком большое, то переходим на последнюю
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
// Вычисляем начиная с какого номера
// следует выводить сообщения
$start = $page * $num - $num;
// Выбираем $num сообщений начиная с номера $start
$result_gb1 = mysql_query("SELECT * FROM . ORDER BY id DESC LIMIT $start, $num");
$myrow_gb1 = mysql_fetch_array($result_gb1);
$list = 1;
switch($page)
{
case "2":
$list = $num + 1;
break;
case "3":
$list = $num * 2 + 1;
break;
case "4":
$list = $num * 3 + 1;
break;
case "5":
$list = $num * 4 + 1;
break;
case "6":
$list = $num * 5 + 1;
break;
case "7":
$list = $num * 6 + 1;
break;
case "8":
$list = $num * 7 + 1;
break;
}
Навигация по страницам, написанная человеком с гуманитарным складом ума...
+71
public class ... {
public Double toDoubleValue(String s){
Double value;
if (s!=""){
value = Double.valueOf(s);
return value;
}
else {
value = 0.00;
return value;
}
....
toDoubleValue(row.getColumnValue(col.getId()).toString());
}
1. На null не проверяется
2. Можно было тоже самое написать короче, не объявляя дополнительный метод, с помощью ?:
+90
if(!empty($_POST))
{
include("dbconnect.php");
$shown_name=$_POST['shown_name'];
$username=$_POST['username'];
$header=$_POST['header'];
$text=$_POST['text'];
$date_array=getdate(time());
$date=$date_array['hours'].":".$date_array['minutes'].":".$date_array['seconds']." ".$date_array['weekday']." ".$date_array['mday']." ".$date_array['month']." ".$date_array['year'];
$filename=$date_array['hours']."-".$date_array['minutes']."-".$date_array['seconds']."-".$date_array['mday'].$date_array['month']."-".$date_array['year']."-".$username.".php";
$path="posts/".$filename;
$addpost="INSERT INTO posts(author, header, text, date, path) VALUES ('$shown_name', '$header', '$text', '$date', '$path')";
$add=$db->prepare($addpost);
$add->execute();
$file=fopen($path, 'w');
$content="<?php \$shown_name=\"".$shown_name."\"; \$header=\"".$header."\"; \$text=\"".$text."\"; include(\"template.html\"); ?>";
$write=fwrite($file, $content);
fclose($file);
header('Location: index.php');
$db=null;
}
Добавление поста в блог. Радует каждая строчка.
+88
if ( ($cache = isset($this->cache[0]) ? $this->cache[0] : null) != null ) {
$isNeedCache = $cache->isNeedCache($plug);
}
if ( !$isNeedCache || !$cache->getPlugCache($plug, $plugInfo) ) {
/** processing: running plug */
$this->dispatcher->processPlug($request, $response);
if ($isNeedCache)
$cache->setPlugCache($plug, $plugInfo);
}
−204
// avm+ specific utility method
public static function throwError(type:Class, index:uint, ... rest)
{
// This implements the same error string formatting as the native
// method PrintWriter::formatP(...) any changes to this method should
// also be made there to keep the two in sync.
var i=0;
var f=function(match, pos, string)
{
var arg_num = -1;
switch(match.charAt(1))
{
case '1':
arg_num = 0;
break;
case '2':
arg_num = 1;
break;
case '3':
arg_num = 2;
break;
case '4':
arg_num = 3;
break;
case '5':
arg_num = 4;
break;
case '6':
arg_num = 5;
break;
}
if( arg_num > -1 && rest.length > arg_num )
return rest[arg_num];
else
return "";
}
throw new type(Error.getErrorMessage(index).replace(/%[0-9]/g, f), index);
}
http://hg.mozilla.org/tamarin-redux/file/fdf1416a3536/core/Error.as
Проблемы с устным счетом, да и не только...
+129
inline uint32 pow(uint32 arg1, int agr2)
{
for (int i = 0; i < agr2; ++i)
arg1 *= arg1;
return arg1;
}
Возведение в степень.
−20
void MainWindow::justDoIt(){
ui->textEdit->clear();
bool b[16];
for (int i = 0; i < 16; ++i) {
b[i] = false;
}
ui->textEdit->append("$$ \n \\begin{cases}");
QString a;
a += (ui->lineEdit->text().toDouble() == 0 ? "": (b[0] = true, ui->lineEdit->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_1" :ui->lineEdit->text().remove("+") + "x_1"));
a += (ui->lineEdit_2->text().toDouble() == 0 ? "" : (b[1] = true,ui->lineEdit_2->text().toDouble() < 0 || (!b[0])? "":"+") +(ui->lineEdit_2->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_2" : ui->lineEdit_2->text().remove("+")+"x_2"));
a += (ui->lineEdit_3->text().toDouble() == 0 ? "" : (b[2] = true,ui->lineEdit_3->text().toDouble() < 0 || (!b[0] && !b[1]) ? "":"+") +(ui->lineEdit_3->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_3" :ui->lineEdit_3->text().remove("+")+"x_3"));
a += (ui->lineEdit_4->text().toDouble() == 0 ? "" : (b[3] = true,ui->lineEdit_4->text().toDouble() < 0 || (!b[0] && !b[1] && !b[2])? "":"+") +(ui->lineEdit_4->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_4" :ui->lineEdit_4->text().remove("+")+"x_4"));
if(b[0] || b[1] || b[2] || b[3]){
a += "=";
a += ui->lineEdit_5->text();
a += "\\\\\n";
}
/*еще такой же код*/
a += (ui->lineEdit_24->text().toDouble() == 0 ? "" : (b[12] = true,ui->lineEdit_24->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_1" :ui->lineEdit_24->text()+"x_1"));
a += (ui->lineEdit_21->text().toDouble() == 0 ? "" : (b[13] = true,ui->lineEdit_21->text().toDouble() < 0 || (!b[13])? "":"+") +(ui->lineEdit_21->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_2" :ui->lineEdit_21->text().remove("+")+"x_2"));
a += (ui->lineEdit_23->text().toDouble() == 0 ? "" : (b[14] = true,ui->lineEdit_23->text().toDouble() < 0 || (!b[13]&&!b[14])? "":"+") +(ui->lineEdit_23->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_3" :ui->lineEdit_23->text().remove("+")+"x_3"));
a += (ui->lineEdit_22->text().toDouble() == 0 ? "" : (b[15] = true,ui->lineEdit_22->text().toDouble() < 0 || (!b[13]&&!b[14]&&!b[15])? "":"+") +(ui->lineEdit_22->text().toDouble() == 1 && ui->checkBox->isChecked() ? "x_4" :ui->lineEdit_22->text().remove("+")+"x_4"));
if(b[12] || b[13] || b[14] || b[15]){
a += "=";
a += ui->lineEdit_25->text();
}
ui->textEdit->append(a);
ui->textEdit->append("\\end{cases} \n$$");
}
Превращает матрицу 4х5 в СЛАР на LaTeX
+90
$obj_type = $blog->getType();
$obj_id = $blog->getIdentity();
$obj_task ="add";
if ($obj_type && $obj_id && $obj_task == 'add') {
...
}
$obj_task - та так... на всякий случай...