- 1
- 2
- 3
- 4
- 5
- 6
public function indexAction()
{
if (Zend_Auth::getInstance()->hasIdentity()) {
Zend_Auth::getInstance()->getIdentity();
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+153
public function indexAction()
{
if (Zend_Auth::getInstance()->hasIdentity()) {
Zend_Auth::getInstance()->getIdentity();
}
}
+152
app.service('CarService', function () {
this.dealer = "Bad";
this.numCylinder = 4;
});
app.factory('CarFactory', function () {
return function (numCylinder) {
this.dealer = "Bad";
this.numCylinder = numCylinder
};
});
app.provider('CarProvider', function () {
this.dealerName = 'Bad';
this.$get = function () {
return function (numCylinder) {
this.numCylinder = numCylinder;
this.dealer = this.dealerName;
}
};
this.setDealerName = function (str) {
this.dealerName = str;
}
});
http://habrahabr.ru/post/220631/
+138
int _ZN12LoggersChain2DoE10LogLevel_tPKcPv(){printf("_ZN12LoggersChain2DoE10LogLevel_tPKcPv\n");}
int _ZN12LoggersChain10AddLogFuncERK7FunctorIv8TypeListIK10LogLevel_tS1_IPKcS1_IPv8NullTypeEEEE(){printf("_ZN12LoggersChain10AddLogFuncERK7FunctorIv8TypeListIK10LogLevel_tS1_IPKcS1_IPv8NullTypeEEEE\n");}
int _ZN12LoggersChainC1Ev(){printf("_ZN12LoggersChainC1Ev\n");}
int _Z22SetLoggerForExceptionsR7FunctorIv8TypeListIK10LogLevel_tS0_IPKcS0_IPv8NullTypeEEEE(){printf("_Z22SetLoggerForExceptionsR7FunctorIv8TypeListIK10LogLevel_tS0_IPKcS0_IPv8NullTypeEEEE\n");}
int _Z19SetLoggerForSignalsR7FunctorIv8TypeListIK10LogLevel_tS0_IPKcS0_IPv8NullTypeEEEE(){printf("_Z19SetLoggerForSignalsR7FunctorIv8TypeListIK10LogLevel_tS0_IPKcS0_IPv8NullTypeEEEE\n");}
int _Z24GetCppSigHandlerInstancev(){printf("_Z24GetCppSigHandlerInstancev\n");}
int _ZN13CppSigHandler11set_handlerERKSt6vectorIiSaIiEERK7FunctorIv8TypeListIi8NullTypeEE(){printf("_ZN13CppSigHandler11set_handlerERKSt6vectorIiSaIiEERK7FunctorIv8TypeListIi8NullTypeEE\n");}
int _ZN7OSErrorC1EPFPKciE(){printf("_ZN7OSErrorC1EPFPKciE\n");}
int osso_initialize(){printf("osso_initialize\n");}
con_ic_connection_new(){
printf("con_ic_connection_new\n");
return 0;
}
int osso_get_dbus_connection()
{
return 0;
}
int osso_get_sys_dbus_connection()
{
return 0;
}
}
int dbus_connection_add_filter ()
{
return 0;
}
int dbus_connection_send_with_reply_and_block ()
{
return 0;
}
int _dbus_header_get_message_type()
{
return 0;
}
int hildon_gtk_entry_set_input_mode(){printf("hildon_gtk_entry_set_input_mode\n");}
int hildon_gtk_im_context_hide()
{
}int url_label_new()
{
return 0;
}
int url_label_set_text()
{
return 0;
}
int url_label_get_type()
{
return 0;
}
int hildon_uri_get_scheme_from_uri()
{
return 0;
}
int gtk_widget_tap_and_hold_setup()
{
printf("gtk_widget_tap_and_hold_setup\n");
return 0;
}
int message_view_new_with_content()
{
printf("message_view_new_with_content\n");
return 0;
}
int message_view_get_type()
{
printf("message_view_get_type\n");
return 0;
}
int message_view_hide_content(){printf("message_view_hide_conteny\n");return 0;}
Врапперы для запуска maemo-приложений на других платформах. Убого, но skype запускается.
+155
$q=mysql_query($que.$limit)or die(mysql_error());
$numr=mysql_num_rows($q);
$q2 = mysql_query($que)or die(mysql_error());
$numrows = mysql_num_rows ($q2);
$pages = ceil($numrows/$step);
Здесь: $que - тяжелый SQL-запрос, который собирался в течение предыдущих сотен строк (десятки IF... ELSE...). $limit - лимит: выбрать 30 записей с такой по этакую. Чтобы орагнизовать на сайте пагинацию, автор выполняет запрос $que дважды. Во второй раз - чтобы просто посчитать общее число записей. При этом в MySQL второй запрос убивается парой SELECT SQL_CALC_FOUND_ROWS... / SELECT FOUND_ROWS().
+153
/**
* Компиляция плейсхолдера
*/
private function sql_compile_placeholder($tmpl)
{
$compiled = array();
$p = 0; // текущая позиция в строке
$i = 0; // счетчик placeholder-ов
$has_named = false;
while(false !== ($start = $p = strpos($tmpl, "?", $p)))
{
// Определяем тип placeholder-а.
switch ($c = substr($tmpl, ++$p, 1))
{
case '%': case '@': case '#':
$type = $c; ++$p; break;
default:
$type = ''; break;
}
// Проверяем, именованный ли это placeholder: "?keyname"
if (preg_match('/^((?:[^\s[:punct:]]|_)+)/', substr($tmpl, $p), $pock))
{
$key = $pock[1];
if ($type != '#')
$has_named = true;
$p += strlen($key);
}
else
{
$key = $i;
if ($type != '#')
$i++;
}
// Сохранить запись о placeholder-е.
$compiled[] = array($key, $type, $start, $p - $start);
}
return array($compiled, $tmpl, $has_named);
}
/**
* Выполнение плейсхолдера
*/
private function sql_placeholder_ex($tmpl, $args, &$errormsg)
{
// Запрос уже разобран?.. Если нет, разбираем.
if (is_array($tmpl))
$compiled = $tmpl;
else
$compiled = $this->sql_compile_placeholder($tmpl);
list ($compiled, $tmpl, $has_named) = $compiled;
// Если есть хотя бы один именованный placeholder, используем
// первый аргумент в качестве ассоциативного массива.
if ($has_named)
$args = @$args[0];
// Выполняем все замены в цикле.
$p = 0; // текущее положение в строке
$out = ''; // результирующая строка
$error = false; // были ошибки?
foreach ($compiled as $num=>$e)
{
/* .. тут куча кода .. */
}
$out .= substr($tmpl, $p);
// Если возникла ошибка, переделываем результирующую строку
// в сообщение об ошибке (расставляем диагностические строки
// вместо ошибочных placeholder-ов).
if ($error)
{
$out = '';
$p = 0; // текущая позиция
foreach ($compiled as $num=>$e)
{
list ($key, $type, $start, $length) = $e;
$out .= substr($tmpl, $p, $start - $p);
$p = $start + $length;
if (isset($e['error']))
{
$out .= $e['error'];
}
else
{
$out .= substr($tmpl, $start, $length);
}
}
// Последняя часть строки.
$out .= substr($tmpl, $p);
$errormsg = $out;
return false;
}
else
{
$errormsg = false;
return $out;
}
}
Вот такой велосипед у симплы, типа о PDO не слышали?
Файл api/database.php, SimplaCMS.
+156
if(!$_SESSION['id'])
{?>
<ul class="login"><?php
}
elseif($_SESSION['id'])
{?>
<ul class="login"><?php
}?>
// всякий код подобный тому что выше
</ul>
История одного проекта
+139
typedef unsigned char uint8_t;
/* . . . */
uint8_t someFunction (void)
{
uint8_t endp;
/* . . . */
res = (endp >= 0);
/* . . . */
return res;
}
Больше ли нуля беззнаковое целое?
+154
for ($i = 0; $i < count($total_data); $i++) {
if ($total_data[$i]['title'] == "Сумма") {
$sum = (float) $total_data[$i]['value'];
$tdata = array();
$tdata[count($total_data)]['title'] = "Сумма со скидкой";
$tdata[count($total_data)]['code'] = "discount_total";
$tdata[count($total_data)]['value'] = $sum;
$tdata[count($total_data)]['text'] = $this->currency->format($sum);
$tdata[count($total_data)]['sort_order'] = "2";
$total_data = array_merge($total_data, $tdata);
$id_sum = $i;
$sub_total = $sum;
}
if ($total_data[$i]['title'] == "Итого") {
$id_discount = count($total_data) - 1;
$total_data[$i]['value'] = (float) $total_data[$i]['value'] - (float) $total_data[$id_sum]['value'] + (float) $total_data[$id_discount]['value'];
$total_data[$i]['text'] = $this->currency->format($total_data[$i]['value']);
}
}
+145
var mySetTitleOriginal = setTitle;
var setTitle = function (el) {
if (!el.getAttribute('myDownloadButtonAdded')) {
var songName = el.getElementsByTagName('b')[0].innerText + ' – ' + el.getElementsByClassName('title')[0].innerText.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/[<>|\\\/:"]/g, '');
var songUrl = el.parentNode.parentNode.getElementsByTagName('*')[0].getElementsByTagName('input')[0].value.replace(/,.*$/, '') + '?';
var audio_download_wrap = document.createElement('div');
audio_download_wrap.setAttribute('class', 'audio_download_wrap fl_r');
audio_download_wrap.setAttribute('onmouseover', 'Audio.rowActive(this, \'Скачать аудиозапись\', [9, 5, 0]);');
audio_download_wrap.setAttribute('onmouseout', 'Audio.rowInactive(this);');
el.parentNode.getElementsByClassName('actions')[0].appendChild(audio_download_wrap);
var audio_download = document.createElement('a');
audio_download.setAttribute('class', 'audio_download');
audio_download.setAttribute('onclick', 'event.stopPropagation();');
audio_download.setAttribute('href', songUrl);
audio_download.setAttribute('download', songName + '.mp3');
el.parentNode.getElementsByClassName('audio_download_wrap')[0].appendChild(audio_download);
el.setAttribute('myDownloadButtonAdded', 'true');
}
mySetTitleOriginal(el);
};
Только при наведение на название показывает иконку на скачивание, подскажите как сделать что бы он автаматом это делал, спасибо
+27
@@ -50,9 +50,6 @@ void AreaTrigger::RemoveFromWorld()
///- Remove the AreaTrigger from the accessor and from all lists of objects in world
if (IsInWorld())
{
- if (!IsInWorld())
- return;
-
WorldObject::RemoveFromWorld();
sObjectAccessor->RemoveObject(this);
}
"Core/AreaTrigger: Remove useful check"
https://github.com/TrinityCore/TrinityCore/commit/d920463fe5fe6eee7c4a8e2d777720fcfbe6f08f