- 1
if ((NULL != (string_array = (0 == *length) ? malloc((*length + 1) * REG_SIZE) : realloc(string_array, (*length + 1) * REG_SIZE))))
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+138
if ((NULL != (string_array = (0 == *length) ? malloc((*length + 1) * REG_SIZE) : realloc(string_array, (*length + 1) * REG_SIZE))))
А кому-то это говно меинтейнить надо будет...
−93
function SAEController:GetPointVariableValue(WayNet,CurPoint)
local waypointVars = {};
for i = 0, WayNet:GetPointsCount() - 1 do
local Link = WayNet:GetPoint(i);
local PlaySound1 = Link:GetVariableValue("PlaySound1");
local PlaySound2 = Link:GetVariableValue("PlaySound2");
local PlaySound3 = Link:GetVariableValue("PlaySound3");
local Effect1 = Link:GetVariableValue("Effect1");
local Effect2 = Link:GetVariableValue("Effect2");
local Effect3 = Link:GetVariableValue("Effect3");
if PlaySound1 and CurPoint == Link then
waypointVars.PlaySound1 = PlaySound1;
end;
if PlaySound2 and CurPoint == Link then
waypointVars.PlaySound2 = PlaySound2;
end;
if PlaySound3 and CurPoint == Link then
waypointVars.PlaySound3 = PlaySound3;
end;
if Effect1 and CurPoint == Link then
waypointVars.Effect1 = Effect1;
end;
if Effect2 and CurPoint == Link then
waypointVars.Effect2 = Effect2;
end;
if Effect3 and CurPoint == Link then
waypointVars.Effect3 = Effect3;
end;
end;
return waypointVars;
end;
Кусок игровой логики на Lua. Функция проверяет значение переменных в текущей точке пути моба.
Мы перебираем все точки пути и сравниваем с текущей точкой моба, но это не нужно, так как именно текущая точка в функцию и передаётся!
−120
CREATE TABLE `numbers` (
`number` BIGINT(20) DEFAULT NULL
) ENGINE=InnoDB;
CREATE TABLE `numbers_small` (
`number` INT(11) DEFAULT NULL
) ENGINE=InnoDB;
-- numbers
INSERT INTO `numbers` (`number`) VALUES('0');
INSERT INTO `numbers` (`number`) VALUES('1000');
INSERT INTO `numbers` (`number`) VALUES('2000');
INSERT INTO `numbers` (`number`) VALUES('3000');
INSERT INTO `numbers` (`number`) VALUES('4000');
INSERT INTO `numbers` (`number`) VALUES('5000');
-- 10 000 lines of inserting numbers into table numbers
-- ...
INSERT INTO `numbers` (`number`) VALUES('5999');
INSERT INTO `numbers` (`number`) VALUES('6999');
INSERT INTO `numbers` (`number`) VALUES('7999');
INSERT INTO `numbers` (`number`) VALUES('8999');
INSERT INTO `numbers` (`number`) VALUES('9999');
-- numbers small
INSERT INTO `numbers_small` (`number`) VALUES('0');
INSERT INTO `numbers_small` (`number`) VALUES('1');
INSERT INTO `numbers_small` (`number`) VALUES('2');
INSERT INTO `numbers_small` (`number`) VALUES('3');
INSERT INTO `numbers_small` (`number`) VALUES('4');
INSERT INTO `numbers_small` (`number`) VALUES('5');
INSERT INTO `numbers_small` (`number`) VALUES('6');
INSERT INTO `numbers_small` (`number`) VALUES('7');
INSERT INTO `numbers_small` (`number`) VALUES('8');
INSERT INTO `numbers_small` (`number`) VALUES('9');
Сделали нам программу на java. Прислали скрипт для обновления базы данных DatabaseUpdateScript.sql на 874 KB.
+58
#include "internationalization.h"
namespace internationalization
{
QString numToString(int num, CASE padezh)
{
switch ( padezh )
{
case NOMINATIVE:
switch ( num )
{
case 0: return "ноль";
case 1: return "один";
case 2: return "два";
case 3: return "три";
case 4: return "четыре";
case 5: return "пять";
case 6: return "шесть";
case 7: return "семь";
case 8: return "восемь";
case 9: return "девять";
case 10: return "десять";
case 11: return "одиннадцать";
case 12: return "двенадцать";
case 13: return "тринадцать";
case 14: return "четырнадцать";
case 15: return "пятнадцать";
case 16: return "шестнадцать";
case 17: return "семьнадцать";
case 18: return "восемьнадцать";
case 19: return "девятнадцать";
case 20: return "двадцать";
case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: return numToString( num / 10 * 10 ) + " " + numToString( num % 10 );
case 30: return "традцать";
case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: return numToString( num / 10 * 10 ) + " " + numToString( num % 10 );
case 40: return "сорок";
case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: return numToString( num / 10 * 10 ) + " " + numToString( num % 10 );
case 50: return "пятьдесят";
case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: return numToString( num / 10 * 10 ) + " " + numToString( num % 10 );
case 60: return "шестьдесят";
case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69: return numToString( num / 10 * 10 ) + " " + numToString( num % 10 );
case 70: return "семьдесят";
case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79: return numToString( num / 10 * 10 ) + " " + numToString( num % 10 );
case 80: return "восемьдесят";
case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89: return numToString( num / 10 * 10 ) + " " + numToString( num % 10 );
case 90: return "девяносто";
case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99: return numToString( num / 10 * 10 ) + " " + numToString( num % 10 );
case 100: return "сто";
case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109: return numToString( (num / 100 % 10 ) * 100 ) + " " + numToString( num % 10 );
case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119: case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129: case 130: case 131: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139: case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149: case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159: case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169: case 170: case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179: case 180: case 181: case 182: case 183: case 184: case 185: case 186: case 187: case 188: case 189: case 190: case 191: case 192: case 193: case 194: case 195: case 196: case 197: case 198: case 199: return numToString( (num / 100 % 10 ) * 100 ) + " " + numToString( (num / 10 % 10 ) * 10 ) + " " + numToString( num % 10 );
Такой код мне встретился в моем старом проекте... Мне кажется, или из меня вышел бы неплохой программист в Китае или Индии?
И там не конец, весь файл сего перла здесь: http://pastebin.com/tpAd95fd
+66
if(version.StartsWith("Windows 9")) { /* 95 and 98 */ } else {
по слухам, именно из-за этого говна следующая windows будет 10ой
https://issues.jenkins-ci.org/secure/attachment/18777/PlatformDetailsTask.java
+133
//str will destroy
char* strdup_(char* str){
wat?
+158
if ($('ul.menu>li>ul>ul>li>a.active-trail').length == 1) {
$('ul.menu>li>ul>ul>li>a.active-trail').addClass('work-active');
if ($('ul.menu>li>ul>ul>li>a.active-trail').parent('li.hide_li').length == 1) {
$('li.active-trail').removeClass('active-trail');
} else {
$('.active-trail').removeClass('active-trail');
}
$('.work-active').addClass('active-trail');
$('.menu>.first ul').show();
$('li.first').addClass('activefirst');
$('#block-system-main-menu ul.menu>li.first a').css("border-bottom", "none");
} else if ($('ul.menu>li>ul>li>a.active-trail').length == 1) {
$('ul.menu>li>ul>li>a.active-trail').addClass('work-active');
$('.active-trail').removeClass('active-trail');
$('.work-active').addClass('active-trail');
$('.menu>.first ul').show();
$('li.first').addClass('activefirst');
$('#block-system-main-menu ul.menu>li.first a').css("border-bottom", "none");
} else {
$('#block-system-main-menu ul.menu>li.first a').css("border-bottom", "1px #E7E7E7 solid");
}
Грамотное удаление активных классов меню
−102
class GNUTranslations(NullTranslations):
# Magic number of .mo files
LE_MAGIC = 0x950412de
BE_MAGIC = 0xde120495
−93
deals = Deal.joins(:deal_locations).select("deals.id, (SELECT array(SELECT category_id FROM deal_categories WHERE deal_id = deals.id ORDER BY category_id ASC)) AS category, deals.start_date, deals.end_date, deals.address, deals.theme, deals.alias, deals.metro, deals.district, deals.discount, deals.coupon_count, deals.issued_coupons, deals.main_image, count(*) OVER() AS total_count, trunc(abs(extract(epoch FROM age(deals.end_date, clock_timestamp()))/86400)) AS days_left").where("deal_locations.deal_id = deals.id AND deal_locations.location_id = ? AND deals.category_id IN (#{categories[0...-2]}) AND deals.id NOT IN (#{ex_deals.map{|e| e}.join(", ")})", params[:location].to_i).active.in_stock.limit(limit).offset(offset).order("deals.start_date desc")
Rails. Да, да, активрекорд, я помню о тебе.
+73
for (int i = 1; i <= 3; i++) {
if (i <= arr.length) {
xmlDocumentNode.setNodeValue("P_15_" + i, arr[i - 1].getNAME());
xmlDocumentNode.setNodeValue("P_16_" + i, arr[i - 1].getSERIAL());
xmlDocumentNode.setNodeValue("P_17_1_" + i, arr[i - 1].getPLANTMANUF());
xmlDocumentNode.setNodeValue("P_17_2_" + i, arr[i - 1].getPLANTMANUFNAME());
xmlDocumentNode.setNodeValue("P_18_" + i, arr[i - 1].getDATEMANUF());
xmlDocumentNode.setNodeValue("P_19_1_" + i, arr[i - 1].getPLANTREP());
xmlDocumentNode.setNodeValue("P_19_2_" + i, arr[i - 1].getPLANTREPNAME());
xmlDocumentNode.setNodeValue("P_20_" + i, arr[i - 1].getDATEREP());
xmlDocumentNode.setNodeValue("P_21_1_" + i, arr[i - 1].getDEFECT());
xmlDocumentNode.setNodeValue("P_21_2_" + i, arr[i - 1].getDEFECTNAME());
} else {
xmlDocumentNode.setNodeValue("P_15_" + i, "");
xmlDocumentNode.setNodeValue("P_16_" + i, "");
xmlDocumentNode.setNodeValue("P_17_1_" + i, "");
xmlDocumentNode.setNodeValue("P_17_2_" + i, "");
xmlDocumentNode.setNodeValue("P_18_" + i, "");
xmlDocumentNode.setNodeValue("P_19_1_" + i, "");
xmlDocumentNode.setNodeValue("P_19_2_" + i, "");
xmlDocumentNode.setNodeValue("P_20_" + i, "");
xmlDocumentNode.setNodeValue("P_21_1_" + i, "");
xmlDocumentNode.setNodeValue("P_21_2_" + i, "");
}
}
Обработка XML-таблиц. fillTable? не, не слышал