- 1
[\s\S]+?
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
[\s\S]+?
+5
float data1[16];
float data2[16];
for (unsigned i = 0; i < 4; ++i)
for (unsigned j = 0; j < 4; ++j)
*(data1 + 4 * i + j) = *(data2 + 4 * i + j);
−161
CREATE TABLE [dbo].[Images](
[id] [int] IDENTITY(1,1) NOT NULL,
[category] [int] NOT NULL,
[tag] [nvarchar](16) NOT NULL,
[description] [nvarchar](128) NOT NULL,
[comment] [nvarchar](1024) NULL,
[code01] [nvarchar](max) NULL,
[code02] [nvarchar](max) NULL,
[code03] [nvarchar](max) NULL,
[code04] [nvarchar](max) NULL,
[code05] [nvarchar](max) NULL,
[code06] [nvarchar](max) NULL,
[code07] [nvarchar](max) NULL,
[code08] [nvarchar](max) NULL,
[code09] [nvarchar](max) NULL,
[code10] [nvarchar](max) NULL,
[code] AS (rtrim(((((((((((((((((((((((((((((rtrim(replace(replace(coalesce([code01],''),char((13)),' '),char((10)),' '))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code02],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code03],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code04],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code05],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code06],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code07],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code08],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code09],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code10],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10))))
)
10 нормальная форма (_*_)
+153
if(!empty($this->aActions))
$sMenuItems = htmlspecialcharsbx(CAdminPopup::PhpToJavaScript($this->aActions));
?>
<tr class="adm-list-table-row<?=(isset($this->aFeatures["footer"]) && $this->aFeatures["footer"] == true? ' footer':'')?><?=$this->bEditMode?' adm-table-row-active' : ''?>"<?=($sMenuItems <> ""? ' oncontextmenu="return '.$sMenuItems.';"':'');?><?=($sDefAction <> ""? ' ondblclick="'.$sDefAction.'"'.(!empty($sDefTitle)? ' title="'.GetMessage("admin_lib_list_double_click").' '.$sDefTitle.'"':''):'')?>>
<?
if(count($this->pList->arActions)>0 || $this->pList->bCanBeEdited):
$check_id = RandString(5);
?>
<td class="adm-list-table-cell adm-list-table-checkbox adm-list-table-checkbox-hover<?=$this->bReadOnly? ' adm-list-table-checkbox-disabled':''?>"><input type="checkbox" class="adm-checkbox adm-designed-checkbox" name="ID[]" id="<?=$this->table_id."_".$this->id."_".$check_id;?>" value="<?=$this->id?>" autocomplete="off" title="<?=GetMessage("admin_lib_list_check")?>"<?=$this->bReadOnly? ' disabled="disabled"':''?><?=$this->bEditMode ? ' checked="checked" disabled="disabled"' : ''?> /><label class="adm-designed-checkbox-label adm-checkbox" for="<?=$this->table_id."_".$this->id."_".$check_id;?>"></label></td>
<?
endif;
if($this->pList->bShowActions):
if(!empty($this->aActions)):
?>
<td class="adm-list-table-cell adm-list-table-popup-block" onclick="BX.adminList.ShowMenu(this.firstChild, this.parentNode.oncontextmenu(), this.parentNode);"><div class="adm-list-table-popup" title="<?=GetMessage("admin_lib_list_actions_title")?>"></div></td>
<?
else:
?>
<td class="adm-list-table-cell"></td>
<?
endif;
endif;
bitrix
Лапша PHP кода, с подливкой из HTML. Присутствуют специи из альтернативного синтаксиса оператора if для шаблонов
+156
$query_result = mysql_query("SELECT parking FROM `cat_info` WHERE is_sold = 0");
$numpark = array();
$numpark[2]=0;
$numpark[3]=0;
$numpark[5]=0;
$numpark[6]=0;
if($query_result)
{
while ($row = mysql_fetch_array($query_result))
{
switch ($row["parking"]){
case 2:
$numpark[2]++;
break;
case 3:
$numpark[3]++;
break;
case 5:
$numpark[5]++;
break;
case 6:
$numpark[6]++;
break;
}
}
}
Этот код считает количество записей в таблице, в зависимости от числа в колонке parking.
+158
<?php
$month = date("m", strtotime($model->order->created));
if($month==01){
$month = "января";
}elseif($month==02){
$month = "февраля";
}elseif($month==03){
$month = "марта";
}elseif($month==04){
$month = "апреля";
}elseif($month==05){
$month = "мая";
}elseif($month==06){
$month = "июня";
}elseif($month==07){
$month = "июля";
}elseif($month==08){
$month = "августа";
}elseif($month==09){
$month = "сентября";
}elseif($month==10){
$month = "октября";
}elseif($month==11){
$month = "ноября";
}elseif($month==12){
$month = "декабря";
}
?>
Это facepalm!
+140
$('img.avatar').attr("src", "http://upload.wikimedia.org/wikipedia/commons/a/a4/Human_penis_2_by_Yiyi1394.jpg")
= http://prntscr.com/36l35i
+27
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <utility>
#include <sstream>
#include <assert.h>
using namespace std;
struct PeriodDescription{
size_t length, repeat_amount, last_items_amount;
/*friend ostream& operator<<(ostream& os, const PeriodDescription& s){
os<<" (PeriodDescription){"<<s.length<<", "<<s.repeat_amount<<", "<<s.last_items_amount<<"} ";
return os;
}*/
};
/*template<class C>
string co(C&& c){
ostringstream r;
r<<" (C) {";
copy(c.begin(), c.end(), ostream_iterator<typename C::value_type>(r, ", "));
r<<"}; ";
return move(r.str());
}*/
vector<PeriodDescription> find_repeat_sequences_since_begin(const string& sequence){
vector<PeriodDescription> result;
if(sequence.empty())
return result;
auto position_at_last_period=sequence.begin();
const char first_item = *position_at_last_period;
const auto after_last=sequence.end();
auto position_at_current_period = position_at_last_period;
while(true){
position_at_last_period=sequence.begin();
position_at_current_period = find(next(position_at_current_period), after_last, first_item);
PeriodDescription new_period {size_t(distance(position_at_last_period, position_at_current_period)), 1, 0};
while(position_at_current_period!=after_last && *position_at_last_period==*position_at_current_period){
++position_at_last_period; ++position_at_current_period;
if(++new_period.last_items_amount>=new_period.length){
new_period.last_items_amount = 0;
++new_period.repeat_amount;
}
}
if(new_period.repeat_amount==1 && new_period.last_items_amount==0)
return result;
result.push_back(new_period);
if(position_at_current_period==after_last)
return result;
}
}
vector<size_t> generate_FSM_failJumpIndices(const vector<PeriodDescription>& periodDescriptions, const size_t stringLength){
vector<size_t> r(stringLength+1);
for(const auto& pd : periodDescriptions){
for(size_t periodIndex=1; periodIndex<pd.repeat_amount; ++periodIndex)
for(size_t indexAtPeriod=0; indexAtPeriod<pd.length; ++indexAtPeriod)
r[(periodIndex*pd.length)+indexAtPeriod]=(periodIndex-1)*pd.length + indexAtPeriod;
for(size_t indexAtAfterPeriods=0; indexAtAfterPeriods<pd.last_items_amount; ++indexAtAfterPeriods)
r[pd.length*pd.repeat_amount+indexAtAfterPeriods]=pd.length*(pd.repeat_amount-1)+indexAtAfterPeriods;
}
return r;
}
vector<size_t> make_FSM_failJumpIndices(const string& sequence){
return generate_FSM_failJumpIndices(find_repeat_sequences_since_begin(sequence), sequence.size());
}
class FSM_for_find_equal_ranges{
size_t state;
vector<size_t> failJumpIndices;
string sequence;
string::const_iterator find_next(string::const_iterator checkPosition, const string::const_iterator last){
struct atReturn{
size_t& state;
~atReturn(){state = 0;}
}nullify{state};
if(checkPosition==last)
return last;
if(sequence.empty())
return next(checkPosition);
if(size_t(distance(checkPosition, last))<sequence.size())
return last;
while(true){
if(checkPosition==last)
return last;
if(*checkPosition==sequence[state])
++state;
else
state=failJumpIndices[state];
++checkPosition;
if(state>=sequence.size())
return prev(checkPosition, sequence.size());
}
}
public:
template<class T>
FSM_for_find_equal_ranges(T&& sequence):
Очередное собеседование. Пригласили на должность дельфина. Но оп отказался проходить собеседование на дельфи.
http://ideone.com/zp5CRb
+167
gl.drawArrays(gl.QUADS, 0, 4);
// WebGL рисует черный экран с четырьмя точками.
bormand vs WebGL. Акт второй.
Как оказалось, в OpenGL ES выпилили GL_QUADS и GL_POLYGON.
Но т.к. в js несуществующее поле это null, а null это 0, а 0 это GL_POINTS, то рисуются 4 точки ;)
+155
//users.php
public function search_()
{
// --- Поиск по пользователям
$sql_search = mysql_query($this->sql);
$folder = $this->folder;
if (mysql_num_rows($sql_search)>0)
{
$row_search = mysql_fetch_assoc($sql_search);
do
{
$user_id = $row_search["id"];
$sql = mysql_query("SELECT SOCIAL_fotos.picture_mini FROM SOCIAL_fotos WHERE fotoalbum_id = '0' and user_id = '$user_id' LIMIT 1");
if (mysql_num_rows($sql)>0)
{
$row_sql = mysql_fetch_assoc($sql);
$picture_mini = $row_sql["picture_mini"];
}
else
$picture_mini = "picture/empty_mini.jpg";
printf("<p><a href=\"%s\" target=\"_blank\"><img src=\"$folder/%s\">%s</a><br>%s", $row_search["alias"], $picture_mini, $row_search["lfm"], $row_search["city"]);
}
while($row_search = mysql_fetch_assoc($sql_search));
}
}
//funct_prover.php
function prover($con)
{
$element = array("'");
$con = str_replace($element, ";appost;", $con);
return htmlspecialchars(trim($con));
}
//conf_connect.php
$server_con = 'localhost'; // Адрес сервера mysql
$username_con = ''; // Имя пользователя
$password_con = ''; // Пароль
$dbname_con = 'socialdb';
$url = $_SERVER["HTTP_HOST"];
$site1 = 'panzins.ru';
$site2 = 'www.panzins.ru';
if ($url != $site1 and $url != 'localhost' and $url != $site2)
exit();
$url_path = $_SERVER["REQUEST_URI"];
if ($url == $site2)
{
header("Location: http://panzins.ru$url_path");
exit();
}
mysql_connect($server_con, $username_con, $password_con) or die("No connection");
mysql_query('SET NAMES utf8') or die("Set names error");
mysql_select_db($dbname_con) or die("No database");
header('Content-Type:text/html; charset=utf-8');
$table_log = "SOCIAL_log";
$table_alias = "SOCIAL_alias";
$table_user = "SOCIAL_user";
// И еще много няшек
MVC, PDO, Framework, для лохов ибо там избыточный код. Написать свою соц сеть за 30 дней легко. Знакомьтесь, Сергей Панзин, скромный адепт Жопова. http://rutracker.org/forum/viewtopic.php?t=4619804
Сам шидевр. http://panzins.ru/