- 1
<button type="button" class="btn blue" style="float: left; margin-bottom: 20px; margin-left: 15px;" onclick="window.location = '/cars/car/update/id/<?php echo $model->id; ?>'"></button>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+157
<button type="button" class="btn blue" style="float: left; margin-bottom: 20px; margin-left: 15px;" onclick="window.location = '/cars/car/update/id/<?php echo $model->id; ?>'"></button>
Проект работает на основе Yii framework. Тут явное пренебрежение всеми концепциями и стандартами: от размещения css в html элементе, до не понимания, как устроен веб в целом -- почему window.location, а не обычный линк, для меня остается тайной. Искренне желаю взглянуть в лицо автору кода.
+85
public final class Equality {
/**
* @param o an object
* @param a an object to be compared with {@code o} for equality
* @return true if the arguments are equal to each other and false otherwise
*/
public static <O> boolean eq(@Nullable O o, @Nullable O a) {
return Objects.equals(o, a);
}
/**
* @param o an object
* @param a an object to be compared with {@code o} for equality
* @return true if the any arguments are equal to each other and false otherwise
*/
public static <O> boolean eqAny(@Nullable O o, @Nullable O a) {
return eq(o, a);
}
/**
* @param o an object
* @param a an object to be compared with {@code o} for equality
* @param b an object to be compared with {@code o} for equality
* @return true if the any arguments are equal to each other and false otherwise
*/
public static <O> boolean eqAny(@Nullable O o, @Nullable O a, @Nullable O b) {
return eq(o, a) || eq(o, b);
}
/**
* @param o an object
* @param a an object to be compared with {@code o} for equality
* @param b an object to be compared with {@code o} for equality
* @param c an object to be compared with {@code o} for equality
* @return true if the any arguments are equal to each other and false otherwise
*/
public static <O> boolean eqAny(@Nullable O o, @Nullable O a, @Nullable O b, @Nullable O c) {
return eqAny(o, a, b) || eq(o, c);
}
/**
* @param o an object
* @param a an object to be compared with {@code o} for equality
* @param b an object to be compared with {@code o} for equality
* @param c an object to be compared with {@code o} for equality
* @param d an object to be compared with {@code o} for equality
* @return true if the any arguments are equal to each other and false otherwise
*/
public static <O> boolean eqAny(@Nullable O o, @Nullable O a, @Nullable O b, @Nullable O c, @Nullable O d) {
return eqAny(o, a, b, c) || eq(o, d);
}
/**
* @param o an object
* @param a an object to be compared with {@code o} for equality
* @param b an object to be compared with {@code o} for equality
* @param c an object to be compared with {@code o} for equality
* @param d an object to be compared with {@code o} for equality
* @param e an object to be compared with {@code o} for equality
* @return true if the any arguments are equal to each other and false otherwise
*/
public static <O> boolean eqAny(@Nullable O o, @Nullable O a, @Nullable O b, @Nullable O c, @Nullable O d, @Nullable O e) {
return eqAny(o, a, b, c, d) || eq(o, e);
}
/**
* @param o an object
* @param a an array of objects to be compared
* @return true if any the arguments are equal to each other and false otherwise
*/
public static <O> boolean eqAny(@Nullable O o, O... a) {
for(O e: a)
if(eq(o, e))
return true;
return false;
}
}
Мой любимый класс.
Когда на душе становится тяжело, я всегда открываю этот класс, и признаки депрессии улетучиваются.
И да, комментарии врут, и да, там еще столько же методов eqAll(...)
+62
void f(bool *ok = 0)
{
//тут возникла ошибка
if (ok)
*ok = false;
return;
}
//далее в коде
bool ok = false;
f(&ok);
не, ну заебок, чо
+51
#if defined(alignas) /* check C++ keywords */ \
|| defined(alignof) \
|| defined(asm) \
|| defined(auto) \
|| defined(bool) \
<...snip...>
|| defined(virtual) \
|| defined(void) \
|| defined(volatile) \
|| defined(wchar_t) \
|| defined(while)
#error keyword defined before including C++ standard header
#endif /* defined... */
Из заголовочных файлов VS 2012.
http://www.viva64.com/en/b/0146/
−113
user8@linux ~ $ python
Python 2.7.5 (default, Feb 10 2014, 02:34:23)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> 1-3*(math.exp(1)-2)/math.exp(1)
0.207276647028654
>>> 1-4*(1-3*(math.exp(1)-2)/math.exp(1))
0.17089341188538398
>>> 1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))
0.14553294057308008
>>> 1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))
0.1268023565615195
>>> 1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))
0.11238350406936348
>>> 1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))
0.10093196744509214
>>> 1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))
0.09161229299417073
>>> 1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))
0.0838770700582927
>>> 1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))
0.07735222935878028
>>> 1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))
0.07177324769463667
>>> 1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))))
0.06694777996972334
>>> 1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))))
0.06273108042387321
>>> 1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))))))
0.059033793641901866
>>> 1-16*(1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))))))
0.05545930172957014
>>> 1-17*(1-16*(1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))))))))
0.05719187059730757
>>> 1-18*(1-17*(1-16*(1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))))))))
-0.029453670751536265
Дано рекуррентное соотношение: x 1 = 1 e , x k = 1 − kx k−1 , k = 2, 3, 4, . . .
Напишите программу, которая вычисляет первые 15 чисел с точностью float и выводит их на экран
−121
If ((ind_imit_gun = 0) And _
((input_B_LA2 And shop) = shop) And _
((input_B_LA2 And loading) = loading) And _
((input_B_LA2 And lonely) = lonely) And _
(input_A_LA48 And choice_k) = choice_k) _
Or ((ind_imit_gun = 0) And _
((input_B_LA2 And shop) = shop) And _
((input_B_LA2 And loading) = loading) And _
((input_B_LA2 And mashin) = mashin) And _
(input_A_LA48 And choice_k) = choice_k) _
Or ((ind_imit_gun = 1) And _
((input_B_LA2 And shop) = shop) And _
((input_B_LA2 And loading) = loading) And _
((input_B_LA2 And lonely) = lonely) And _
(input_A_LA48 And choice_k) = choice_k) _
Or ((ind_imit_gun = 2) And _
((input_B_LA2 And loading) = loading) And _
((input_B_LA2 And lonely) = lonely) And _
(input_A_LA48 And choice_k) = choice_k) _
Or ((ind_imit_gun = 2) And _
((input_B_LA2 And loading) = loading) And _
((input_B_LA2 And mashin) = mashin) And _
(input_A_LA48 And choice_k) = choice_k) _
Or ((ind_imit_gun = 3) And _
((input_B_LA2 And loading) = loading) And _
((input_B_LA2 And mashin) = mashin) And _
(input_A_LA48 And choice_k) = choice_k) _
Or ((ind_imit_gun = 4) And _
((input_B_LA2 And loading) = loading) And _
((input_B_LA2 And lonely) = lonely) And _
(input_A_LA48 And choice_k) = choice_k) _
Or ((ind_imit_gun = 6) And _
((input_B_LA2 And loading) = loading) And _
((input_B_LA2 And lonely) = lonely) And _
(input_A_LA48 And choice_k) = choice_k) Then
Вот такая страшная проверка нужных битов битовыми масками используется в одном военном ПО xD
И на мой взгляд тут есть ошибки,но почему то работает.
+157
<?php
class smth {
protected static $MARK_UNDEFINED = 'Undefined';
protected static $MARK_F = 'ECTS-F';
protected static $MARK_FX = 'ECTS-FX';
protected static $MARK_E = 'ECTS-E';
protected static $MARK_D = 'ECTS-D';
protected static $MARK_C = 'ECTS-C';
protected static $MARK_B = 'ECTS-B';
protected static $MARK_A = 'ECTS-A';
protected function getECTSMark($rate, $current, $examRate)
{
$color = self::$MARK_UNDEFINED;
if ($current > 0) {
$percent = $rate / $current;
if ($examRate !== NULL AND $examRate < 22)
$color = self::$MARK_FX;
elseif ($percent < 0.31)
$color = self::$MARK_F;
elseif ($percent < 0.60)
$color = self::$MARK_FX;
elseif ($percent < 0.65)
$color = self::$MARK_E;
elseif ($percent < 0.71)
$color = self::$MARK_D;
elseif ($percent < 0.85)
$color = self::$MARK_C;
elseif ($percent < 0.95)
$color = self::$MARK_B;
else
$color = self::$MARK_A;
}
return $color;
}
}
Сижу и думаю, как это вообще можно как-то.. отговнокодить? О_о
+145
###
CoffeeScript
Give a fuck
###
while fuck isnt given
do give_a_fuck until orgasm
+51
#include <ppl.h>
#include <windows.h>
#include <ppltasks.h>
#include <iostream>
#include <vector>
using namespace Concurrency;
using namespace std;
CRITICAL_SECTION cs6;
int main(int argc, char* argv[])
{
size_t concurentThreadsSupported = std::thread::hardware_concurrency();
cout << concurentThreadsSupported << endl;
//deadlock hazard increased with concurentThreadsSupported decreasing
size_t taskAmountForWasteVirtualCores = concurentThreadsSupported - 1;//must be equal to (virtual processor thread amount from Concurrency::IResourceManager) - 1
vector<task<void>> t;
for (size_t i = 0; i<taskAmountForWasteVirtualCores; ++i)
t.push_back(create_task([]{
Sleep(INFINITE);//some very long IO operation or deadlocked by EnterCriticalSection or sql transaction or other
}));
Sleep(1000);
cout << "another way:" << endl;
InitializeCriticalSection(&cs6);
auto locker = create_task([]{
cout << "locker" << endl;
EnterCriticalSection(&cs6);//same as begin sql transaction
cout << "locker entered cs 6" << endl;
Concurrency::wait(500);//Deadlock by any concurrency context switching directly or indirectly by std or MFC (events, mutex, etc)
cout << "locker played" << endl;
LeaveCriticalSection(&cs6);//same as end sql transaction
cout << "~locker ok" << endl;
});
auto locked = create_task([]{
cout << "locked" << endl;
EnterCriticalSection(&cs6);//same as begin sql transaction
cout << "locked entered cs 6" << endl;
Concurrency::wait(500);
cout << "locked played" << endl;
LeaveCriticalSection(&cs6);//same as end sql transaction
cout << "~locked ok" << endl;
});
Sleep(1000);
cout << "FAIL" << endl;
return 0;
}
Нашел дидлок)
http://rextester.com/KHC72232
http://rextester.com/EMG65441
+170
public function action_ajaxlogin()
{
// Если запрос поступил не через AJAX, то шлем нахуй
if ( ! $this->request->is_ajax())
{
throw new HTTP_Exception_404(NULL);
}
// Вырубаем авто-рендер, ибо это хуев аякс запрос
$this->auto_render = false;
// Собираем информацию и пользователе в ёбанный массив
$user_data = $this->request->post('user_data');
// Если пользователь авторизирован, то заебато, и возвращаем статус 200!
if (Auth::instance()->login($user_data['username'], $user_data['password'], (bool) isset($user_data['remember_me'])))
return $this->response->status(200);
// Если нет, то "Вася, все хуйня! Давай по новой!"
return $this->response->status(400);
}
public function action_logout()
{
// Если запрос поступил не через AJAX, то шлем нахуй
if ( ! $this->request->is_ajax())
{
throw new HTTP_Exception_404(NULL);
}
// Вырубаем сучий авто-рендер, нахуй, в пизду блядь
$this->auto_render = false;
// Выходим из аккаунта, если вышли, то ахуенно, 200-ый статус)
if (Auth::instance()->logout())
return $this->response->status(200);
// Если все хуйня, то "Вася, давай по новой!"
return $this->response->status(400);
}
Kohana фреймворк, и таких комментариев по проекту тьма :)