- 1
- 2
- 3
- 4
- 5
- 6
- 7
a=[1,2,3,1,2,1,4]
for i in a:
if i is 1:
zzz=222
else:
print zzz
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−102
a=[1,2,3,1,2,1,4]
for i in a:
if i is 1:
zzz=222
else:
print zzz
http://ideone.com/nhqqRU
Сегодня весь день чинил странный баг, смысл которого сводится вот к такой синтетки.
Притом если условие не выполниться на первой итерации http://ideone.com/G3Uf7V , то будет эксепшен.
+16
// Lock the write mutex, to provide consistency of data
#define LOCK \
if (_ugb) { \
if (pthread_mutex_lock(&_write_mutex) == EINVAL) \
ASSERT(0); \
}
// Unlock write mutex when data sent
#define UNLOCK \
if (_ugb) { \
if (pthread_mutex_unlock(&_write_mutex) == EINVAL) \
ASSERT(0); \
}
// Пример использования
void socket::add_var(uint16_t code, const void *buffer, uint32_t length)
{
LOCK
try
{
DEBUG_I(Vblock, "Sending code 0x%X of size 0x%X\n", code, length);
send(&code, sizeof(code));
send(&length, sizeof(length));
send(buffer, length);
}
catch (const error & ve)
{
UNLOCK
DEBUG_E(Vblock, "Caught an exception!\n");
throw;
}
catch (...)
{
UNLOCK
}
UNLOCK
}
OK_BOOST_LOCK_A_MUTEX
+140
innotracOrder.OrderShipTo = new PostOrderBatchRequestOrderBatchCustomerOrderOrderShipTo[] { innotracShipTo };
var innotracPayment = new PostOrderBatchRequestOrderBatchCustomerOrderPayment();
var innotracCreditCard = new PostOrderBatchRequestOrderBatchCustomerOrderPaymentCreditCard();
Код древних ацтеков
+164
$res = mysql_query('select `date` from `pic`');
while($data = mysql_fetch_row($res)){
if(date('d.m.y') != date('d.m.y',$data[0])) continue;
$countPicToday++;
}
Не понятно. Почему нельзя было использовать COUNT() и WHERE
+16
for(int i=0;i<World::size;i++)
{
for(int u=0;u<World::size;u++)
{
//Задаётся зерно для генерации случайных чисел
srand(GetTickCount()*i*u);
//Задаются случайные значения всем точкам от 0*0.1-10, до 100*0.1-10
World::data[i][u]=(rand()%100)*0.1f-10.0f;
}
}
http://habrahabr.ru/post/183986/
+20
#include <iostream>
enum Quiet { LOG };
template<typename T>
Quiet operator <<(Quiet o, T) {
return o;
}
static inline Quiet operator <<(Quiet o, std::ostream &(*)(std::ostream &)) {
return o;
}
int main() {
LOG << "Hello world!" << std::endl;
return 0;
}
Измыслил сегодня вот такую вот затычку для выключения логгирования
+21
class socket_exception
{
public:
char *buf;
int ret;
socket_exception()
{
buf=new char[10000];
ret=RET_OK;
}
socket_exception(char *b, int r)
{
buf=new char[10000];
snprintf(buf,9999,"%s",b);
ret=r;
}
socket_exception(vsocket_exception &ex)
{
buf=new char[10000];
snprintf(buf, 9999, "%s", ex.buf);
ret=ex.ret;
}
const char * what (){return buf;}
int get_ret(){return ret;}
~socket_exception(){delete[] buf;}
};
фрактал
+144
class Model_Task extends Model_Base {
const STATUS_CHECK = 0;
const STATUS_REWORK = 1;
const STATUS_COMPLETED = 2;
const STATUS_INVALID = 99999;
...
Видимо чтобы всегда последним был в случае чего...
−171
КоличествоСтрокТоваров = Документы.РеализацияТоваровУслуг.ПолучитьСсылку(ЭтотОбъект.Ссылка.УникальныйИдентификатор()).Товары.Количество();
программист-снайпер, убивает одной строкой кода.
+154
......................
if (isset ($_POST['cell121'])) {$cell121 = $_POST['cell121'];}
else {
$cell121 = 0;
}
if (isset ($_POST['cell122'])) {$cell122 = $_POST['cell122'];}
else {
$cell122 = 0;
}
if (isset ($_POST['cell123'])) {$cell123 = $_POST['cell123'];}
else {
$cell123 = 0;
}
if (isset ($_POST['cell124'])) {$cell124 = $_POST['cell124'];}
else {
$cell124 = 0;
}
if (isset ($_POST['cell125'])) {$cell125 = $_POST['cell125'];}
else {
$cell125 = 0;
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/style.css"/> <!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]--><head>
<body>
<div class="container">
<header>
<?php include("page/header.php"); ?>
</header>
<title>Документ без названия</title>
<?php include("page/right.php"); ?>
<article class="content">
<h1>Входящие</h1>
<section>
<?php
$result = mysql_query
("INSERT INTO fuckingbox (cell1,cell2,cell3,cell4,cell5,cell6,cell7,cell8,cell9,cell10,cell11,cell12,cell13,cell14,cell15,cell16,cell17,cell18,cell19,cell20,cell21,cell22,cell23,cell24,cell25,cell26,cell27,cell28,cell29,cell30,cell31,cell32,cell33,cell34,cell35,cell36,cell37,cell38,cell39,cell40,cell41,cell42,cell43,cell44,cell45,cell46,cell47,cell48,cell49,cell50,cell51,cell52,cell53,cell54,cell55,cell116,cell117,cell118,cell119,cell120,cell121,cell122,cell123,cell124,cell125)
VALUES ('$cell1', '$cell2', '$cell3', '$cell4', '$cell5', '$cell6', '$cell7', '$cell8', '$cell9', '$cell10', '$cell11', '$cell12', '$cell13', '$cell14', '$cell15', '$cell16', '$cell17', '$cell18', '$cell19', '$cell20', '$cell21', '$cell22', '$cell23', '$cell24', '$cell25', '$cell26', '$cell27', '$cell28', '$cell29', '$cell30', '$cell31', '$cell32', '$cell33', '$cell34', '$cell35', '$cell36', '$cell37', '$cell38', '$cell39', '$cell40', '$cell41', '$cell42', '$cell43', '$cell44', '$cell45', '$cell46', '$cell47', '$cell48', '$cell49', '$cell50', '$cell51', '$cell52', '$cell53', '$cell54', '$cell55', '$cell116', '$cell117', '$cell118', '$cell119', '$cell120', '$cell121', '$cell122', '$cell123', '$cell124', '$cell125')");
if ($result == 'true') { echo "Ваше письмо добавлено" ;}
else { echo "Ошибка какая то" ;}
?>
это из реального проекта который еще умудрились продать