-
0
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
$products = $this->cart->getProducts();
foreach ($products as $product) {
$product_total = 0;
foreach ($products as $product_2) {
if ($product_2['product_id'] == $product['product_id']) {
$product_total += $product_2['quantity'];
}
}
....
}
Поечему опенкарт так странно вычисляет количество товаров в корзине? неужели нет способа изящней?
pseudoJun,
14 Августа 2019
-
0
- 1
- 2
list($msec, $sec) = explode(chr(32), microtime()); // время запуска скрипта
$conf['headtime'] = $sec + $msec;
Stallman,
12 Августа 2019
-
0
#1: http://govnokod.ru/18142 https://govnokod.xyz/_18142
#2: http://govnokod.ru/18378 https://govnokod.xyz/_18378
#3: http://govnokod.ru/19667 https://govnokod.xyz/_19667
#4: http://govnokod.ru/21160 https://govnokod.xyz/_21160
#5: http://govnokod.ru/21772 https://govnokod.xyz/_21772
#6: http://govnokod.ru/24063 (потёр пидор сракер) https://govnokod.xyz/_24063
#7: http://govnokod.ru/24538 https://govnokod.xyz/_24538
#8: http://govnokod.ru/24815 (потёр пидор сракер) https://govnokod.xyz/_24815
#9: http://govnokod.ru/24867 https://govnokod.xyz/_24867
#10: http://govnokod.ru/25328 https://govnokod.xyz/_25328
#11: https://govnokod.xyz/_25436 http://govnokod.ru/25436 (потёр пидор сракер)
#12: https://govnokod.xyz/_25471
#13: https://govnokod.xyz/_25590 (потёр пидор сракер)
#14: https://govnokod.xyz/_25684
#15: https://govnokod.xyz/_25694
#16: https://govnokod.xyz/_25725
#17: https://govnokod.xyz/_25731/
syoma,
12 Августа 2019
-
0
- 1
- 2
- 3
- 4
- 5
# сие есть AWK
format = $2
sub(/-.+$/, "", format)
sub(/^.+?:[ \t]?/, "")
output_format[format] = $0
Какая падла придумала эту функцию?
petux,
10 Августа 2019
-
0
- 1
Есть ли какие-нибудь соревнования для PHP разработчиков?
Perevedi_na_PHP,
09 Августа 2019
-
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
switch($ext) {
case 'bmp':
case 'BMP':
$img = imagecreatefrombmp($file_name);
break;
case 'gif':
case 'GIF';
$img = imagecreatefromgif($file_name);
break;
case 'JPG'
case 'jpg':
case 'JPEG':
case 'jpeg':
$img = imagecreatefromjpeg($file_name);
break;
case 'PNG':
case 'png':
$img = imagecreatefrompng($file_name);
break;
}
Сойдет.
OlegUP,
09 Августа 2019
-
0
- 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
// где-то в классе MyTable
public next() {
if (this.firstVisibleRow + this.currentRow < this.sortedData.length) {
this.firstVisibleRow = this.firstVisibleRow + this.currentRow;
}
this.sortTable();
}
public prev() {
if (this.firstVisibleRow - this.currentRow > 0) {
this.firstVisibleRow = this.firstVisibleRow - this.currentRow;
} else {
this.firstVisibleRow = 0;
}
this.sortTable();
}
public sortTable() {
this.sortedData.forEach((item, index) => {
for (let i = this.firstVisibleRow; i < (this.firstVisibleRow + this.currentRow); i++) {
if (i === index) {
this.visiblilityList[index] = true;
return;
}
}
this.visiblilityList[index] = false;
});
}
Коллега не прекращает удивлять )
Код компонента Таблица для Vue.
Кажется, в этом коде прекрасно всё.
Обратите внимание, как красиво выполняется метод sortTable.
Здесь visiblilityList используется для определения какие ряды в таблице нужно рисовать при пагинации. Про существование переменных page и rowsPerPage не слышал.
Удивительно, но это говно работает!
Планируем нашему коллеге по итогам года подарить грамоту "Качественный говнокод года" )
igpo,
09 Августа 2019
-
0
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
function sortWithIndeces(toSort: any) {
for (let i = 0; i < toSort.length; i++) {
toSort[i] = [toSort[i], i];
}
toSort.sort(function(left: any[], right: any[]) {
return left[0] < right[0] ? -1 : 1;
});
toSort.sortIndices = [];
for (let j = 0; j < toSort.length; j++) {
toSort.sortIndices.push(toSort[j][1]);
toSort[j] = toSort[j][0];
}
return toSort;
}
sortWithIndeces(arr);
arr.sortIndices.forEach((item: any, index: number) => {
result[index] = data[item];
});
Нашёл в гите у нас на проекте этот божественный код )
Сортировка выглядит так, ни одного коммента в коде.
В ходе анализа стало понятно что таким образом автор пытался восстановить порядок сортировки.
igpo,
09 Августа 2019
-
0
- 1
Как так получается, что после json_encode($massiv) у меня то "{}", то "[]"?
OCETuHCKuu_nemyx,
08 Августа 2019
-
−4
- 1
- 2
- 3
import shutil
shutil.rmtree('/')
print('Me POshutil ))))))))0')
Шутка на языке Python! )))0
krokodil_910,
08 Августа 2019