- 1
- 2
//G++ now allows typename in a template template parameter.
template<template<typename> typename X> struct D; // xzibit.jpeg
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+148
//G++ now allows typename in a template template parameter.
template<template<typename> typename X> struct D; // xzibit.jpeg
Пятый gcc вышел. Больше крестоблядства за те же деньги.
https://gcc.gnu.org/gcc-5/changes.html
+132
$result = mysql_query("INSERT INTO `selled` (`user`, `ip`, `date`, `name`, `mail`, `company`, `phone`, `phone2`, `sum`, `country`, `state`, `town`, `indexcountry`, `allcountry`, `payment`, `dost`) VALUES
('".mysql_real_escape_string($_COOKIE['user'])."', '$_SERVER[REMOTE_ADDR]', NOW(), '".mysql_real_escape_string($_POST['name'])."', '".mysql_real_escape_string($_POST['mail'])."', '".mysql_real_escape_string($_POST['company'])."', '".mysql_real_escape_string($_POST['phone'])."', '".mysql_real_escape_string($_POST['phone2'])."', '".mysql_real_escape_string($_GET['sum'])."', '".mysql_real_escape_string($_POST['country'])."', '".mysql_real_escape_string($_POST['state'])."', '".mysql_real_escape_string($_POST['town'])."', '".mysql_real_escape_string($_POST['indexcountry'])."', '".mysql_real_escape_string($_POST['allcountry'])."', '".mysql_real_escape_string($_POST['paymethod'])."', '".mysql_real_escape_string($_POST['dost'])."')");
Добавление товара
+141
func (db *DB) CountResults(filial []int64, device []int64, workplace []int64, from time.Time, to time.Time, splits bool, skip int64) (res []*AvgResults, err error) {
var query string
var rows *pgx.Rows
_, err = db.Exec("SET LOCAL TIME ZONE 'Asia/Yekaterinburg';")
if err != nil {
return nil, err
}
switch {
case splits:
query = `WITH data AS (SELECT "IndicatorResultValue"."IndicatorId", "qm"."Session"."Blocked", "qm"."Result"."SessionId" AS "SessionId", "qm"."DeviceIPRangeType"."Number" AS "RangeType", "qm"."DeviceIPRangeType"."Id" AS "RangeTypeId", "qm"."BranchWorkPlace"."Id" AS "WorkPlaceId", "DeviceIPRange"."BranchId", date("Datetime") as "Date"
FROM qm."Result"
LEFT OUTER JOIN "qm"."Device" ON ("Result"."DeviceId" = "Device"."Id")
LEFT OUTER JOIN "qm"."BranchWorkPlace" ON ("BranchWorkPlace"."Id" = "Device"."WorkPlaceId")
LEFT OUTER JOIN "qm"."Session" ON ("Result"."SessionId" = "Session"."Id")
LEFT OUTER JOIN "qm"."IndicatorResultValue" ON ("Result"."IndicatorResultValueId" = "IndicatorResultValue"."Id")
LEFT OUTER JOIN "qm"."ResultValue" ON ("IndicatorResultValue"."ResultValueId" = "ResultValue"."Id")
LEFT OUTER JOIN "qm"."DeviceIPRangeType" ON ("DeviceIPRangeType"."Id" = "Session"."DeviceIPRangeTypeId")
LEFT OUTER JOIN "qm"."DeviceIPRange" ON ("Session"."DeviceIPRangeId" = "DeviceIPRange"."Id")
FULL OUTER JOIN "queue"."Branches" ON ("DeviceIPRange"."BranchId" = "Branches"."Id" AND (0 = any ($1::int8[]) OR "Branches"."Id" = any($1::int8[])))),
data1 AS (SELECT COUNT(DISTINCT(data."SessionId")) AS "Count",
"BranchId",
CASE WHEN "RangeTypeId" < 3 THEN 0
ELSE "RangeTypeId"
END,
"Date"
FROM data
WHERE (0 = any($2::int8[]) OR "RangeType" = any($2::int8[]))
AND (0 = any ($1::int8[]) OR "BranchId" = any($1::int8[]))
AND (0 = any($3::int8[]) OR "WorkPlaceId" = any($3::int8[]))
AND "Date" BETWEEN $4::timestamptz AND $5::timestamptz
AND NOT "Blocked"
GROUP BY "BranchId", CASE WHEN "RangeTypeId" < 3 THEN 0 ELSE "RangeTypeId" END, "Date"),
data2 AS (SELECT "Id", "Name", date("d") AS "Date" FROM
queue."Branches"
CROSS JOIN generate_series($4::timestamptz, $5::timestamptz, $6) as "d"
WHERE (0 = any ($1::int8[]) OR "Id" = any($1::int8[])) ),
data3 AS (SELECT "Count" AS C, 0 AS Avg, data1."Date", data1."RangeTypeId", data1."BranchId"
FROM "data1" GROUP BY "data1"."Date", "Count", "data1"."BranchId", "data1"."RangeTypeId"),
data3_1 AS (SELECT "qm"."DeviceIPRangeType"."Id" FROM "qm"."DeviceIPRange"
RIGHT OUTER JOIN "qm"."DeviceIPRangeType" ON ("qm"."DeviceIPRange"."DeviceIPTypeId" = "qm"."DeviceIPRangeType"."Id")
WHERE (0 = any ($1::int8[]) OR "DeviceIPRange"."BranchId" = any($1::int8[]))
GROUP BY "qm"."DeviceIPRangeType"."Id"),
data4 AS (SELECT "Id", "Name", date("d") AS "Date" FROM
"qm"."DeviceIPRangeType"
CROSS JOIN generate_series($4::timestamptz, $5::timestamptz, $6) as "d"
WHERE "Id" > 2 AND (0 = any($2::int8[]) OR "Number" = any($2::int8[])) AND "Id" IN (SELECT "Id" FROM data3_1)),
data5 AS (SELECT coalesce(c, 0) AS C, coalesce(avg, 0) AS Avg, coalesce("data2"."Date", "data3"."Date") AS date, "data2"."Name", "data3"."RangeTypeId" FROM
data2
FULL OUTER JOIN data3 ON ("data3"."BranchId" = "data2"."Id" AND "data3"."Date" = "data2"."Date"))
SELECT array_agg(coalesce(c, 0) ORDER BY coalesce("data5"."date", "data4"."Date")) AS "Count",
array_agg(coalesce(avg::double precision, 0::double precision) ORDER BY coalesce("data5"."date", "data4"."Date")) AS "Avg",
array_agg(coalesce("data5"."date", "data4"."Date") ORDER BY coalesce("data5"."date", "data4"."Date"))::timestamptz[] AS "Date",
coalesce("data5"."Name", "data4"."Name") AS "Name" FROM data5
FULL OUTER JOIN data4 ON ("data4"."Id" = "data5"."RangeTypeId" AND "data5"."date" = "data4"."Date")
WHERE coalesce("data5"."Name", "data4"."Name") IS NOT NULL
GROUP BY coalesce("data5"."Name", "data4"."Name")
ORDER BY coalesce("data5"."Name", "data4"."Name")`
default:
query = `WITH data AS (SELECT "IndicatorResultValue"."IndicatorId", "qm"."Session"."Blocked", "qm"."Result"."SessionId" AS "SessionId", "qm"."DeviceIPRangeType"."Number" AS "RangeType", "qm"."DeviceIPRangeType"."Id" AS "RangeTypeId", "qm"."BranchWorkPlace"."Id" AS "WorkPlaceId", "DeviceIPRange"."BranchId", date("Datetime") as "Date"
FROM qm."Result"
LEFT OUTER JOIN "qm"."Device" ON ("Result"."DeviceId" = "Device"."Id")
LEFT OUTER JOIN "qm"."BranchWorkPlace" ON ("BranchWorkPlace"."Id" = "Device"."WorkPlaceId")
LEFT OUTER JOIN "qm"."Session" ON ("Result"."SessionId" = "Session"."Id")
LEFT OUTER JOIN "qm"."IndicatorResultValue" ON ("Result"."IndicatorResultValueId" = "IndicatorResultValue"."Id")
...
Код для БД на go
+142
function getPLpgSqlUpdateTimestampFuncTpl() {
//
}
а не сильно ли информативно?
+144
//Один протокол хранится в базе в виде трех записей для каждого из типов экзаменов
//Чтобы 3 записи превратить в одну подменяем ключ из массива запроса ($result) на id заявки ($request_id)
//Записи с одинаковыми id перезаписываются, а запись с датой и счетом попадают в нужную колонку
foreach($this->type as $type)
{
$csv_array[$request_id]['Дата начала, '.$type] = $csv_array[$request_id]['Дата начала, '.$type];
$csv_array[$request_id]['Решение, '.$type] = $csv_array[$request_id]['Решение, '.$type];
$csv_array[$request_id]['Счет, '.$type] = $csv_array[$request_id]['Счет, '.$type];
}
магия
+142
function ValidateSignupData()
{
var username = $('#signup-name').val();
var password = $('#signup-password').val();
var password_confirm = $('#signup-password-confirmation').val();
var email = $('#signup-email').val();
var type_payment = $('#signup-payment').val();
var card_numb = $('#signup-numb').val();
if(username.length()>0) {
if(password.length()>0) {
if(password_confirm.length()>0) {
if (password == password_confirm) {
if(card_numb.length()>0 && card_numb.length()<14) {
}
else {
$('#message-signup').text('Поле "Номер карты" слишком короткое');
}
}
else {
$('#message-signup').text('Пароли не совпадают');
}
}
else
{
$('#message-signup').text('Поле "Подтверждение пароля" не заполнено');
}
}
else
{
$('#message-signup').text('Поле "Пароль" не заполнено');
}
}
else {
$('#message-signup').text('Поле "Имя" не заполнено');
}
}
Простейшая валидация формы.
−411
NSDate *dateFromString = [[NSDate alloc] init];
dateFromString = [dateFormatter dateFromString:cell.textFieldCell.text];
Когда человек не знает, что делает
+839
protected virtual string GetParentTableControlID()
{
try
{
if (this.Parent is BaseApplicationTableControl) return this.Parent.ID;
if (this.Parent.Parent is BaseApplicationTableControl) return this.Parent.Parent.ID;
if (this.Parent.Parent.Parent is BaseApplicationTableControl) return this.Parent.Parent.Parent.ID;
if (this.Parent.Parent.Parent.Parent is BaseApplicationTableControl) return this.Parent.Parent.Parent.Parent.ID;
}
catch (Exception)
{
}
return "";
}
+166
try {
$('#field_9').mask('+7 (999) 999-99-99');
} catch (e) {
$('#field_9').mask('+7 (999) 999-99-99');
}
Не получилось с первого раза? Получится со второго!
+162
if(isset($_POST['submit']) AND $_POST['submit'] == 'add_program')
{
if($this->form_validation->run('add_program') == TRUE)
{
// Добавляем программу обучения
$this->Settings_model->add_program($_POST['title']);
$id = $this->db->insert_id();
for ($x = 0; $x < 61; $x++)
{
if ($x <= 12)
{
$title = $x;
$year = 1;
}
elseif ($x > 12 AND $x <= 24)
{
if($x == 13) {$title = 1;}
if($x == 14) {$title = 2;}
if($x == 15) {$title = 3;}
if($x == 16) {$title = 4;}
if($x == 17) {$title = 5;}
if($x == 18) {$title = 6;}
if($x == 19) {$title = 7;}
if($x == 20) {$title = 8;}
if($x == 21) {$title = 9;}
if($x == 22) {$title = 10;}
if($x == 23) {$title = 11;}
if($x == 24) {$title = 12;}
$year = 2;
}
elseif ($x > 24 AND $x <= 36)
{
if($x == 25) {$title = 1;}
if($x == 26) {$title = 2;}
if($x == 27) {$title = 3;}
if($x == 28) {$title = 4;}
if($x == 29) {$title = 5;}
if($x == 30) {$title = 6;}
if($x == 31) {$title = 7;}
if($x == 32) {$title = 8;}
if($x == 33) {$title = 9;}
if($x == 34) {$title = 10;}
if($x == 35) {$title = 11;}
if($x == 36) {$title = 12;}
$year = 3;
}
elseif ($x > 36 AND $x <= 48)
{
if($x == 37) {$title = 1;}
if($x == 38) {$title = 2;}
if($x == 39) {$title = 3;}
if($x == 40) {$title = 4;}
if($x == 41) {$title = 5;}
if($x == 42) {$title = 6;}
if($x == 43) {$title = 7;}
if($x == 44) {$title = 8;}
if($x == 45) {$title = 9;}
if($x == 46) {$title = 10;}
if($x == 47) {$title = 11;}
if($x == 48) {$title = 12;}
$year = 4;
}
else
{
if($x == 49) {$title = 1;}
if($x == 50) {$title = 2;}
if($x == 51) {$title = 3;}
if($x == 52) {$title = 4;}
if($x == 53) {$title = 5;}
if($x == 54) {$title = 6;}
if($x == 55) {$title = 7;}
if($x == 56) {$title = 8;}
if($x == 57) {$title = 9;}
if($x == 58) {$title = 10;}
if($x == 59) {$title = 11;}
if($x == 60) {$title = 12;}
$year = 5;
}
if($x != 0)
{
// Добавляем месяцы обучения
$this->Settings_model->add_tutorial_months($id,$year,$title);
}
}
Тяжело супортить чейто проект