- 1
- 2
- 3
var indexes = T.Select((item, index) => new { Item = item, Index = index })
.Where(nitem => n.Item == 0).Select(nindex => n.Index).ToArray();
Console.WriteLine("Первый: {0}, последний: {1}", indexes.First(), indexes.Last());
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−2
var indexes = T.Select((item, index) => new { Item = item, Index = index })
.Where(nitem => n.Item == 0).Select(nindex => n.Index).ToArray();
Console.WriteLine("Первый: {0}, последний: {1}", indexes.First(), indexes.Last());
Не слишком много item index? index item?
+2
/***
*assert.h - define the assert macro
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
* Defines the assert(exp) macro.
* [ANSI/System V]
*
* [Public]
*
****/
/*
#include <crtdefs.h>
#undef assert
#ifdef NDEBUG
#define assert(_Expression) ((void)0)
#else
#ifdef __cplusplus
extern "C" {
#endif
_CRTIMP void __cdecl _wassert(_In_z_ const wchar_t * _Message, _In_z_ const wchar_t *_File, _In_ unsigned _Line);
#ifdef __cplusplus
}
#endif
#define assert(_Expression) (void)( (!!(_Expression)) || (_wassert(_CRT_WIDE(#_Expression), _CRT_WIDE(__FILE__), __LINE__), 0) )
#endif */
#pragma once
#ifdef NDEBUG
#define assert(expr)
#else
inline void CheckExpression_(bool expr)
{
if (!expr)
{
expr=true; // put breakpoint here, happy user;
CheckExpression_(expr);
}
}
inline void CheckExpression_(void* expr)
{
if (!expr)
{
expr=(void*)(1); // put breakpoint here, happy user;
CheckExpression_(expr);
}
}
#define assert(expr) CheckExpression_(expr);
#endif
Сука я не знаю, почему в студии-2008 родной ассерт показывает не ту строку, на которой он произошёл и в стеке вызовов хуйня какая-то, и как подключить DebugBreak я тоже не знаю, потому что в windef.h куча хуеты, выдающей 100500 ошибок компиляции. Чтобы хоть как-то можно было жить, пришлось сделать так.
+5
$temp = $this->user->get($value['user_id']);
foreach ($temp as $var) {
$temp = $var;
break;
}
Просматривал код курсвых по web-программированию, нашел новейший метод извлечения первого элемента массива
0
$l_data["comm_text"] = $mail_body;
$l_var = implode(",", $l_var);
$l_path = "root->mail->".$l_group_id."->".$l_uuid."->[".$l_var.",group_name,comm_text]";
$this->engine->smartquery->create( $l_path );
$this->engine->smartquery->setdata( $l_path, $l_data );
if ($this->engine->var->get("comm_subscribe") == 1 && defvar($this->engine->var->get("comm_email"),"") != "")
{
$l_result = $this->engine->smartquery->getdata( "root->clients->(list)->[*]"," and `comm_email`='".$this->engine->var->get("comm_email")."' ");
$l_result = $l_result->getall();
if (count($l_result) == 0)
{
//Создать группу если отсутствует
$l_data = array();
$l_data["comm_fio"] = $this->engine->var->get("comm_fio");
$l_data["comm_email"] = defvar($this->engine->var->get("comm_email"),"");
$l_data["comm_phone"] = defvar($this->engine->var->get("comm_phone"),"");
$l_data["comm_formid"] = $l_group_id;
$l_data["comm_formname"] = defvar($config["mail.communication".$l_group_id.".subj"],"");
$l_var = implode(",", array_keys($l_data));
$l_uuid = mktime();
$l_path = "root->clients->".$l_uuid."->[".$l_var."]";
$this->engine->smartquery->create( $l_path );
$this->engine->smartquery->setdata( $l_path, $l_data );
}
}
Это код из одного "супер" движка мало того что тут используется дибильный шаблонизатор, тут используется просто еб*нутый класс для работы с базой данных....
Не знаю что автор хотел оптимизировать этим классом, но простая вставка данных в таблицу тут занимает целых два метода 1-ый($this->engine->smartquery->create) создает таблицу(если ее нет и пустую строку), второй только собственно осуществляет вставку в эту строку данных($this->engine->smartquery->setdata)
+2
# Проверка массива
if ($_POST) {
# Проверка Категории
if ($_POST['category'] > 0) {
# Отображение на главной
if ($_POST['main'] == "0" || $_POST['main'] == "1") {
# Имя товара
if ($_POST['item'] != "") {
# Описание товара
if ($_POST['body'] != "") {
# Картинка товара
if ($_POST['image'] != "") {
# Цены на товар
if ($_POST['price'] != "") {
...
}
}
}
}
}
}
}
Когда ну очень хочется комментировать и оператор AND бессилен.
+1
while ((math == (math = Math)).toString() == "true") {
...
}
программист-дотер
+6
if($_GET['menu_id']==5){header("Location:index.php?link=pages_blog&menu_id=101");}
if($_GET['menu_id']==2){header("Location:index.php?link=pages_blog&menu_id=102");}
if($_GET['menu_id']==9){header("Location:index.php?link=pages&id=113");}
if($_GET['menu_id']==16){header("Location:index.php?link=pages&id=114");}
if($_GET['menu_id']==11){header("Location:index.php?link=pages&id=115");}
if($_GET['menu_id']==10){header("Location:index.php?link=pages&id=116");}
if($_GET['id']==22){header("Location:index.php?link=pages&id=129");}
if($_GET['id']==23){header("Location:index.php?link=pages&id=130");}
if($_GET['id']==27){header("Location:index.php?link=pages&id=135");}
if($_GET['id']==19){header("Location:index.php?link=pages&id=125");}
if($_GET['id']==28){header("Location:index.php?link=pages&id=127");}
if($_GET['id']==30){header("Location:index.php?link=pages&id=132");}
if($_GET['id']==29){header("Location:index.php?link=pages&id=132");}
if($_GET['id']==26){header("Location:index.php?link=pages&id=134");}
if($_GET['id']==24){header("Location:index.php?link=pages&id=103");}
if($_GET['id']==1){ header("Location:index.php");}
if($_GET['id']==32){ header("Location:index.php?link=pages&id=116#1");}
if($_GET['id']==33){ header("Location:index.php?link=pages&id=116#2");}
if($_GET['id']==34){ header("Location:index.php?link=pages&id=116#3");}
if($_GET['id']==35){ header("Location:index.php?link=pages&id=116#4");}
if($_GET['id']==36){ header("Location:index.php?link=pages&id=116#5");}
if($_GET['id']==37){ header("Location:index.php?link=pages&id=116#6");}
if($_GET['id']==38){ header("Location:index.php?link=pages&id=116#7");}
if($_GET['id']==39){ header("Location:index.php?link=pages&id=116#8");}
if($_GET['menu_id']==12){header("Location:index.php?link=pages&id=117");}
if($_GET['menu_id']==14){header("Location:index.php?link=pages&id=118");}
if($_GET['menu_id']==13){header("Location:index.php?link=pages&id=119");}
if($_GET['menu_id']==34){header("Location:index.php?link=pages&id=119");}
if($_GET['menu_id']==15){header("Location:index.php?link=pages&id=120");}
if($_GET['menu_id']==31){header("Location:index.php?link=pages&id=121");}
if($_GET['menu_id']==3){header("Location:index.php?link=pages_blog&menu_id=103");}
if($_GET['id']==17){ header("Location:index.php?link=pages&id=122");}
if($_GET['menu_id']==17){ header("Location:index.php?link=pages&id=122");}
if($_GET['menu_id']==35){header("Location:index.php?link=pages&id=123");}
if($_GET['id']==18){ header("Location:index.php?link=pages&id=124");}
if($_GET['menu_id']==18){ header("Location:index.php?link=pages&id=124");}
if($_GET['id']==19){ header("Location:index.php?link=pages&id=125");}
if($_GET['id']==20){ header("Location:index.php?link=pages&id=126");}
if($_GET['id']==28){ header("Location:index.php?link=pages&id=127");}
if($_GET['menu_id']==32){header("Location:index.php?link=pages_blog&menu_id=103");}
if($_GET['menu_id']==7){header("Location:index.php?link=pages&menu_id=104");}
if($_GET['menu_id']==36){header("Location:index.php?link=pages&menu_id=105");}
if($_GET['menu_id']==6){header("Location:index.php?link=pages_blog&menu_id=106");}
if($_GET['id']==61){ header("Location:index.php?link=pages&id=143");}
if($_GET['id']==60){ header("Location:index.php?link=pages&id=112");}
if($_GET['id']==57){ header("Location:index.php?link=pages&id=111");}
if($_GET['id']==59){ header("Location:index.php?link=pages&id=110");}
if($_GET['id']==56){ header("Location:index.php?link=pages&id=109");}
if($_GET['id']==55){ header("Location:index.php?link=pages&id=108");}
if($_GET['id']==54){ header("Location:index.php?link=pages&id=107");}
if($_GET['id']==53){ header("Location:index.php?link=pages&id=106");}
if($_GET['id']==52){ header("Location:index.php?link=pages&id=105");}
if($_GET['id']==50){ header("Location:index.php?link=pages&id=103");}
if($_GET['id']==44){ header("Location:index.php?link=pages&id=102");}
$_GET марафет
+4
<?= rand(1, 2) == 3 ? '<img src="/assets/img/icons/icon_organic.png">' : ''; ?>
+2
str.indexOf('#') === 0
Проверка что строка начинается с '#'
+2
return usort($bidsSale, function($a, $b){
return ($a->priority < $b->priority) ? -1 : 1;
});
Найдено в функции от которой ожидается возврат массива.