- 1
- 2
- 3
- 4
- 5
- 6
$c=count($arr1);
for($i=0;$i<$c;$i++){
$key=key($arr1);
ksort($arr1[$key]);
next($arr1);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+156
$c=count($arr1);
for($i=0;$i<$c;$i++){
$key=key($arr1);
ksort($arr1[$key]);
next($arr1);
}
foreach() чем-то не угодил
−153
eval {
my $from = $class->get_env_sender($message);
$smtp->mail($from)
|| croak("Email::Send::Gmail: error sending 'from' $from");
my @to = $class->get_env_recipients($message);
my @ok = $smtp->to( @to, { SkipBad => 1 } )
|| croak("Email::Send::Gmail: error sending 'to' @to");
if ( @to != @ok ) {
my %to;
@to{@to} = (1) x @to;
delete @to{@ok};
@bad = keys %to;
}
croak("Email::Send::Gmail: no valid recipients") if @bad == @to;
};
Думаю понятно, какой это модуль с CPAN. Убило незнание приоритетов, в результате чего "|| croak" всегда возвращало в @ok число вместо результата выполнения $smtp->to
−99
def str_to_float(i):
return int (i) + 0.0
Так надо!
+52
double cCompositeBlock::determinant4x4(double *d){ // WARNING It's not logically connected with class.
return d[3]*d[6]*d[9]*d[12] -d[2]*d[7]*d[9]*d[12]-
d[3]*d[5]*d[10]*d[12] +d[1]*d[7]*d[10]*d[12]+
d[2]*d[5]*d[11]*d[12] -d[1]*d[6]*d[11]*d[12]-
d[3]*d[6]*d[8]*d[13] +d[2]*d[7]*d[8]*d[13]+
d[3]*d[4]*d[10]*d[13] -d[0]*d[7]*d[10]*d[13]-
d[2]*d[4]*d[11]*d[13] +d[0]*d[6]*d[11]*d[13]+
d[3]*d[5]*d[8]*d[14] -d[1]*d[7]*d[8]*d[14]-
d[3]*d[4]*d[9]*d[14] +d[0]*d[7]*d[9]*d[14]+
d[1]*d[4]*d[11]*d[14] -d[0]*d[5]*d[11]*d[14]-
d[2]*d[5]*d[8]*d[15] +d[1]*d[6]*d[8]*d[15]+
d[2]*d[4]*d[9]*d[15] -d[0]*d[6]*d[9]*d[15]-
d[1]*d[4]*d[10]*d[15] +d[0]*d[5]*d[10]*d[15];
}
+73
public static <T extends Comparable<T>> boolean isLessThan(T a, T b, double numericTolerance) {
if (a == null) {
return b != null;
}
boolean isLessThan = a.compareTo(b) < 0;
if (!isLessThan && a instanceof Number && b instanceof Number) {
isLessThan = ((Comparable) (((Number) a).doubleValue() - numericTolerance)).compareTo(((Number) b).doubleValue()) < 0;
}
return isLessThan;
}
Один из методов сравнения значений в пределах допустимой погрешности (последняя только для чисел).
Вроде бы и проще никак, но чувство говна не покидает. Советы по упрощению приветствуются.
+155
<?php
$data = file_get_contents("/path/to/photo.jpg"); // Read the file's contents
$name = 'myphoto.jpg';
force_download($name, $data);
Я знаю конечно что это не говнокод, но последствия будут ужасными если не передать сразу же в функцию данные (т.к. PHP будет копировать содержимое дважды), представьте себе файл в 2МБ и много запросов, сервер капут в два раза быстрее.
- https://ellislab.com/codeigniter/user-guide/helpers/download_helper.html
−126
&НаСервере
Процедура ПриСозданииНаСервере(Отказ, СтандартнаяОбработка)
НовыйДокумент = Документы.ДокументПредЗаявка.СоздатьДокумент();
НовыйДокумент.Дата = ТекущаяДата();
НовыйДокумент.Записать(РежимЗаписиДокумента.Проведение);
СПД = НовыйДокумент.Ссылка;
//Открываем документ
ОткрытьЗначение(СПД);
КонецПроцедуры
Я не вкурил, но полагаю, что ЭТО новый способ создания документа на основании...
+151
//...
<script>splashRadar('leftcol', 1);</script>
<script>splashRadar('baseStyles');</script>
//...
На мейл.сру.
+157
$('#id_accept_eula').click(function () {
// код аффтара
try {
var v = 1 - this.getAttribute('value');
this.setAttribute('value', v);
if (v == 1) {
$('#submit_button').removeAttr('disabled');
} else {
$('#submit_button').attr('disabled', 'disabled');
}
} catch (e) {
alert('exc: ' + e);
}
// заменил на
$("#submit_button").prop('disabled', !this.checked);
});
Когда платят за строки кода...
+131
/*
* Copyright (C) 2007-2012 Allwinner Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef __DISP_DISPLAY_I_H__
#define __DISP_DISPLAY_I_H__
#include "ebios_de.h"
#include "ebios_lcdc_tve.h"
#include "drv_disp_i.h" /* For DISP_XXXXXX status codes */
#define DE_INF __inf
#define DE_WRN __wrn
#define OSAL_IRQ_RETURN IRQ_HANDLED
#define HANDTOID(handle) ((handle) - 100)
#define IDTOHAND(ID) ((ID) + 100)
#define INTC_IRQNO_SCALER0 SW_INT_IRQNO_DEFEBE0
#define INTC_IRQNO_SCALER1 SW_INT_IRQNO_DEFEBE1
#define INTC_IRQNO_LCDC0 SW_INT_IRQNO_LCDCTRL0
#define INTC_IRQNO_LCDC1 SW_INT_IRQNO_LCDCTRL1
#define MAX_SPRITE_BLOCKS 32
/*basic data information definition*/
enum {
FALSE = 0,
TRUE
};
#define DIS_NULL 0
#define BIT0 0x00000001
#define BIT1 0x00000002
#define BIT2 0x00000004
#define BIT3 0x00000008
#define BIT4 0x00000010
#define BIT5 0x00000020
#define BIT6 0x00000040
#define BIT7 0x00000080
#define BIT8 0x00000100
#define BIT9 0x00000200
#define BIT10 0x00000400
#define BIT11 0x00000800
#define BIT12 0x00001000
#define BIT13 0x00002000
#define BIT14 0x00004000
#define BIT15 0x00008000
#define BIT16 0x00010000
#define BIT17 0x00020000
#define BIT18 0x00040000
#define BIT19 0x00080000
#define BIT20 0x00100000
#define BIT21 0x00200000
#define BIT22 0x00400000
#define BIT23 0x00800000
#define BIT24 0x01000000
#define BIT25 0x02000000
#define BIT26 0x04000000
#define BIT27 0x08000000
#define BIT28 0x10000000
#define BIT29 0x20000000
#define BIT30 0x40000000
#define BIT31 0x80000000
#endif
Нашёл в драйвере дисплея. Вместо 1<<N.