- 1
- 2
if (isset($_GET['oneway']))
$_SESSION['oneway'] = intval($_GET['oneway']) == 1 ? 1 : 0;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+37
if (isset($_GET['oneway']))
$_SESSION['oneway'] = intval($_GET['oneway']) == 1 ? 1 : 0;
Уточню : надо именно int, а не bool для API сервиса.
На ум приходят 2 других более красивых способа нормализации. Может и ещё что-то есть.
+112
switch (materialType.MaterialClass)
{
case 1:
xtraTabControl1.SelectedTabPageIndex = 0;
gridView1.Focus();
eanSimpleButton.Enabled = true;
break;
case 2:
xtraTabControl1.SelectedTabPageIndex = 1;
gridView2.Focus();
eanSimpleButton.Enabled = false;
break;
case 3:
xtraTabControl1.SelectedTabPageIndex = 3;
gridView4.Focus();
eanSimpleButton.Enabled = false;
break;
default:
xtraTabControl1.SelectedTabPageIndex = 2;
gridView3.Focus();
eanSimpleButton.Enabled = false;
break;
}
Стандартный такой быдло-производственный код.
В зависимости от магического числа в БД, в поле material_class, показывается один из четырёх гридов. При этом в реальной базе класса 3 вообще нет - это поле принимает значения 1, 2 и NULL.
+150
(function($) {
core = {
verticalOffset: -390,
horizontalOffset: 0,
repositionOnResize: true,
overlayOpacity: 0.2,
overlayColor: '#ffffff',
draggable: true,
send: 'Отправить',
ok: 'Продолжить',
close: 'Закрыть',
save: 'Сохранить',
cancel: 'Отмена',
dialogClass: null,
alert: function(message, title, callback) {
if( title == null ) title = 'Alert';
this._show_mess(title, message, null, 'alert', function(result) {
if(callback) callback(result);
});
},
confirm: function(message, title, callback) {
if(title == null) title = 'Подтверждение действия';
this._show_mess(title, message, null, 'confirm', function(result) {
if(result) callback(result);
});
},
prompt: function(message, value, title, callback) {
if( title == null ) title = 'Prompt';
this._show_mess(title, message, value, 'prompt', function(result) {
if( callback ) callback(result);
});
},
message: function(title){
if(title == null) title = '';
this._show_mess(title, '', '', 'message');
},
box_close: function() {
$('#popup_container').fadeOut(200, function(){
$('#popup_overlay, #popup_container').remove();
});
},
_show_mess: function(title, msg, value, type, callback) {
if ($('#popup_container').length > 0) {
$('#popup_overlay, #popup_container').remove();
}
var html = "<div id='popup_container'>" +
"<table>" +
"<tbody>" +
"<tr>" +
"<td class='tl'/><td class='b'/><td class='tr'/>" +
"</tr>" +
"<tr>" +
"<td class='b'/>" +
"<td class='body'>" +
"<div class='popup_title_wrap'><div class='popup_x_button'/><div id='popup_title'/></div>" +
"<div id='popup_progress'><img src='/images/progress.gif' alt='Загрузка...' /></div>" +
"<div id='popup_content'/>" +
"<div id='popup_message'/>" +
"<div id='popup_panel'>" +
"<span class='ajax-loader'> </span>" +
"<div id='popup_info'/>" +
"<input id='popup_ok' type='button' class='button_yes' value='" + this.ok + "'/>" +
"<input id='popup_cancel' type='button' class='button_no' value='" + this.cancel + "'/>" +
"<input id='popup_close' type='button' class='button_no' value='" + this.close + "'/>" +
"</div>" +
"</td>" +
"<td class='b'/>" +
"</tr>" +
"<tr>" +
"<td class='bl'/><td class='b'/><td class='br'/>" +
"</tr>" +
"</tbody>" +
"</table>" +
"</div>";
this._overlay('show');
$('body').append(html);
$('#popup_panel input').hide();
if(this.dialogClass) {
$('#popup_container').addClass(this.dialogClass);
}
var pos = (($.browser.msie && parseInt($.browser.version) <= 6 )||(($(window).height()<480)||($(window).width()<700))) ? 'absolute' : 'fixed';
$('#popup_container').css({
position: pos,
zIndex: 999,
padding: 0,
margin: 0
});
+21
//Было:
int foo()// ;
{ ;
int a ;
float b ; //В правой части старые
typedef int testing ; //полезные комментарии
std::cout << "Ho-ho-ho" ;
a=0 ;
b=1.0f ;
if (a==b)// ;
{ ;
std::cout <<"Yet another caption";
std::cout <<"Hi-hi-hi" ;
bar() ;
;
} ;
using namespace std ;
for (int i =0;i<10;i++)// ;
{ ;
;
std::cout <<"Hello, world!" ;
std::cout <<"Yet another line" ;
} ;
return 0 ;
;
} ;
//Кто-то что-то решил поменять
//Стало:
int foo()// ;
{ ;
int a ;
float b ; //В правой части старые
typedef int testing ; //полезные комментарии
std::cout << "Ho-ho-ho" ;
a=0 ;
b=1.0f ;
if (a==b)// ;
{ ;
std::cout <<"Yet another caption";
std::cout <<"Hi-hi-hi" ;
bar() ;
;
} ;
double c;
//Слева комментарии требующие
//проверки. Wtf???Зачем здесь с???
using namespace std ;
for (int i =0;i<10;i++)// ;
{ ;
;
std::cout <<"Hello, world!" ;
std::cout <<"Yet another line" ;
} ;
return 6666 ;
;
} ;
//Быстро определили по линии из точек c
//запятой место в котором произошло изменение.
//Если согласились с ним восстанавливаем линию.
Бесплатная распределенная говносистема контроля версий. Git и SVN нервно курят в сторонке.
+123
var EditParameter = eval($('#droppable1').attr("data"));
var parameter = eval($('#droppable1').attr("data1"));
А Вам слабо ?!
+46
for($i=0;$i<=100;$i++)echo(!$i?$i:($i%3==0&&$i%5==0?'FizzBuzz':($i%3==0?'Fizz':($i%5==0?'Buzz':$i)))).'<br>';
FizzBuzz - мое решение.
−110
-(void) setEditing:(BOOL)editing animated:(BOOL)animate
{
if (indexDeleting != nil)
{
[[self.tableView cellForRowAtIndexPath:indexDeleting] willTransitionToState:UITableViewCellStateDefaultMask];
// if ([self.parentView.delegate sortArrayCount] /*dict array count*/ && [self.parentView.delegate editArrayCount:indexP.section]/*[[[dictArray objectAtIndex:section] valueForKey:@"edit"] count]*/)
// {
// [self.parentView.delegate setDeleteFlag:indexP value:@"0"];
// }
}
indexDeleting = nil;
isDeleting = NO;
isEditing = editing;
[super setEditing:editing animated:animate];
if (self.tableView.editing == editing)
{
[self.tableView setEditing:!editing animated:NO];
}
[self.tableView setEditing:editing animated:animate];
[self.tableView reloadData];
}
По выражению парней, вынужденных поддерживать это месиво, "Это еще образец чистоты и элегантности".
+137
/* ... */
HWND mywnd = NULL;
/* ... */
#ifdef WIN32
mywnd = GetForegroundWindow();
if(GetWindowLong(mywnd, GWL_WNDPROC)) {
for(i = 1; i < argc; i++) {
if(verbose_options(argv[i]) < 0) break;
switch(argv[i][1]) {
case 'f': i++; break;
case 'F': i++; break;
case 'L': i++; break;
case 'a': i++; break;
default: break;
}
}
if(i > argc) i = argc;
i = 3 - (argc - i);
if(i > 0) {
fprintf(stderr,
"- GUI mode activated, remember that the tool works also from command-line\n"
" where are available various options like folder scanning, filters and so on\n"
"\n");
/* дальше пляски с извлечением параметров из argv */
}
}
#endif
Наткнулся на утилиту, которая умеет отличать запуск из гуев и из консоли. Полез глядеть, как сделано, а там вот такие чудеса.
+117
data Pitch = Pitch Integer
pitch t o = Pitch (o*12 + t)
freq (Pitch p) = a4 * 2**(i/12) where
i = fromIntegral (p - 57)
a4 = 440
+23
typedef const AbstractParameter ConstAbstractParameter;
class Parameter: public ConstAbstractParameter{
GCC это не компилирует, но в 2008 ms vs компилируется без предупреждений. Я это как увидел, так сразу переписал на
class Parameter: public AbstractParameter{