-
Лучший говнокод
- В номинации:
-
- За время:
-
-
−160
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
QString query4="INSERT INTO `"+mb+"`.`cubes` (`user_id`, `name`) VALUES (0, '"+name+"')";
mysql.sqlQuery(query4, true);
mysql.sqlQuery("SELECT * FROM `"+mb+"`.`cubes` WHERE name='"+name+"' AND user_id="+QString::number(userID), true);
mysql.data_connection_bind(true);
mysql.getRow();
int id=mysql.getUint32(o);
mysql.sqlQuery("UPDATE `"+mb+"`.`cubes` SET user_id=1 WHERE user_id="+QString::number(userID), true);
mysql.sqlQuery("DELETE FROM `"+mb+"`.`users` WHERE `name`="+QString::number(getpid()), true);
qDebug()<<"CubeID"<<id;
Судя по словам автора: он не осилил lastInsertId, поэтому пытался вставить запись с заранее не существующим user_id, чтобы затем однозначно извлеч эту строку и получить уже долгожданое поле id.
Try,
13 Сентября 2012
-
−161
- 1
- 2
- 3
- 4
- 5
- 6
- 7
if (IDATUMS is null) then
begin
suspend;
exit;
REZULT = "Nevar importet gramatojumu id:" || :NOMER_DOC;
execute procedure TSEND_ERROR(:REZULT);
end
Гениальнейшая PSQL-конструкция в СУБД Firebird. Автор, видимо, не в курсе, что после EXIT процедура больше не выполняется :]
N21,
13 Сентября 2012
-
−100
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
def profile_edit(request, template_name='profile/subdiler/profile_edit.html'):
profile = request.profile
if request.method == "POST":
form = DilerProfileForm(request.POST, request.FILES, instance=profile)
if form.is_valid():
profile = form.save(commit=False)
try:
profile.avatar = profile.avatar[0]
except:
pass
try:
profile.sign = profile.sign[0]
except:
pass
profile.city = form.city
profile.save()
Замечательная цепочка из try-cath
Не менее замечательно то, что метод profile_edit полностью идентичный лежит в двух файлах subdiler_views.py и diler_views.py
Разница между ними только в переменной template_name='profile/(subdiler|diler)/profile_edit.html'
Для чего так сделано, мне нипанять.
хуита,
05 Сентября 2012
-
−102
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
-(void)tableView:(UITableView*)tableViewTable didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.row) {
case 0:
{
ViewControllerFavorites *contoller = [[ViewControllerFavorites alloc] initWithNibName:nil bundle:nil];
[contoller setNavigationController:navigationController];
[navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
}
break;
case 1:
{
ViewControllerMyAccount *contoller = [[ViewControllerMyAccount alloc] initWithNibName:nil bundle:nil];
[contoller setNavigationController:navigationController];
[navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
}
break;
case 2:
{
ViewControllerParts *contoller = [[ViewControllerParts alloc] initWithNibName:nil bundle:nil];
[contoller setNavigationController:navigationController];
[navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
}
break;
case 3:
{
ViewControllerFinancing *contoller = [[ViewControllerFinancing alloc] initWithNibName:nil bundle:nil];
[contoller setNavigationController:navigationController];
[navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
}
break;
case 4:
{
ViewControllerWebView *contoller = [[ViewControllerWebView alloc] initWithNibName:nil bundle:nil link:@"http://www.facebook.com"];
[contoller setNavigationController:navigationController];
[navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
}
break;
case 5:
{
ViewControllerWebView *contoller = [[ViewControllerWebView alloc] initWithNibName:nil bundle:nil link:@"http://twitter.com"];
[contoller setNavigationController:navigationController];
[navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
}
break;
case 6:
{
ViewControllerWebView *contoller = [[ViewControllerWebView alloc] initWithNibName:nil bundle:nil link:@"http://plus.google.com"];
[contoller setNavigationController:navigationController];
[navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
}
break;
case 7:
{
ViewControllerLiveChat *contoller = [[ViewControllerLiveChat alloc] initWithNibName:nil bundle:nil];
[contoller setNavigationController:navigationController];
[navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
}
break;
case 8:
{
ViewControllerGasStations *contoller = [[ViewControllerGasStations alloc] initWithNibName:nil bundle:nil];
[contoller setNavigationController:navigationController];
[navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
}
break;
case 9:
{
ViewControllerVinScanner *contoller = [[ViewControllerVinScanner alloc] initWithNibName:nil bundle:nil];
[contoller setNavigationController:navigationController];
[navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
}
break;
case 10:
{
ViewControllerQRScanner *contoller = [[ViewControllerQRScanner alloc] initWithNibName:nil bundle:nil];
[contoller setNavigationController:navigationController];
[navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
}
break;
case 11:
{
ViewControllerNewsletter *contoller = [[ViewControllerNewsletter alloc] initWithNibName:nil bundle:nil];
[contoller setNavigationController:navigationController];
[navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
}
break;
case 12:
{
ViewControllerSettings *contoller = [[ViewControllerSettings alloc] initWithNibName:nil bundle:nil];
[contoller setNavigationController:navigationController];
[navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
}
break;
default:
break;
}
Вот так в коммерческих проектах реализуют навигацию.
GK2012,
23 Августа 2012
-
+134
- 1
private static readonly Dictionary<FloorCeilingSortOptions, Func<IOrderedEnumerable<FloorCeilingSystemPage>, Func<FloorCeilingSystemPage, int>, IOrderedEnumerable<FloorCeilingSystemPage>>> DefaultSortOrder
dotnetdeveloper,
14 Августа 2012
-
+141
- 1
$exchange = $this->user_model->getFriends( $options );
Чтоб никто не догадался... )
dzen,
09 Августа 2012
-
+134
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
private void LettersOnChanged(object sender, EventArgs eventArgs)
{
this._lettersBinding.Clear();
this._lettersBinding.AddRange(this._letters);
this.MailAgentGridControl.ResetBindings();
this.MailAgentGridControl.RefreshDataSource();
_bindingSourceLetters.ResetCurrentItem();
_bindingSourceLetters.ResetBindings(false);
int pos = _bindingSourceLetters.Position;
this.MailAgentGridControl.DataSource = null;
this.MailAgentGridControl.DataSource = _bindingSourceLetters;
if (_bindingSourceLetters.Current == null)
{
_guiCtrl.CurrentLetter = null;
return;
}
if (pos > _bindingSourceLetters.Count - 1)
pos = _bindingSourceLetters.Count - 1;
if (pos < 0)
return;
_bindingSourceLetters.Position = pos;
MailAgentGridControlTableView.UnselectRow(MailAgentGridControlTableView.GetRowHandle(0));
MailAgentGridControlTableView.SelectRow(pos);
}
Все ради того,чтоб при изменении датабинда в гриде менялась строка выделения.
partizan,
09 Августа 2012
-
+75
- 1
- 2
- 3
- 4
- 5
- 6
- 7
if ( !empty($special['catalog']) ) {
if (count($special['catalog'])>0) {
if (count($special['catalog'])>1) {
...
}
}
}
Интересная конструкция...
domaster,
07 Августа 2012
-
+56
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
$cur_url=$_SERVER['REQUEST_URI'];
if ($cur_url=='/') {
$cur_url=$_SERVER['REQUEST_URI'];
if ($cur_url=='/') { // Точно-точно адрес не равен слэшу
echo '';// После всех проверок можно с уверенностью вывести пустую строку
}
}
$cur_url2=$_SERVER['REQUEST_URI'];// И ещё разок
if ($cur_url2!='/') {
echo '';
}
Из движка одного московского портала, директор которого пытается нас убедить что там нормальный код
RedMonkey,
03 Августа 2012
-
+65
- 1
- 2
- 3
- 4
- 5
- 6
- 7
function draw_text() {
// ....
/* remove background color */
imagecolortransparent($im_text, $bg_color);
return $im_text;
imagedestroy($im_text);
}
Функция вывода текста CAPTCHA в modx Evolution.
MaXL,
02 Августа 2012