- 1
https://250bpm.com/blog:36/
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
https://250bpm.com/blog:36/
> At that point every semi-decent programmer curses spaghetti code in general and the author of the function in particular and embarks on the task of breaking it into managable chunks, trying to decompose the problem into orthogonal issues, layer the design properly, move the common functionality into base classes, create convenient and sufficiently generic extension points et c.
<…>
It turns out that the 1500-line function was parsing a network protocol. It is a 30-year old, complex and convoluted Behemoth of a protocol, defined by many parties fighting over the specification, full of compromises and special cases, dragged through multiple standardisation bodies and then anyway slightly customised by each vendor.
<...>
Unfortunately, it turns out that the tweak intersects the boundary between two well-defined components in the implementation. The right thing to do would be to re-think the architecture of the parser and to re-factor the codebase accordingly. <
Вот так вот. Не стоит спешить любую портянку из 100+ строк кода называть "спагетти-кодом". Код может быть функцией микроконтроллера в котором вызов функции достаточно дорогой по памяти/времени, сложным алгоритмом и пр. Спагетти - это про организацию кода. Монолитный (но хорошо мапящийся на домен) код понять проще, чем солянку из функций, классов и пр. которые решают непонятно какую задачу (это и есть спагетти-код). Алсо https://en.wikipedia.org/wiki/Wikipedia:Chesterton%27s_fence
+2
RUN apt install -y apache2
RUN apt install -y php
RUN apt install -y php-mysql
RUN apt install -y libapache2-mod-php
RUN apt install -y curl
RUN apt install -y php-mbstring
RUN apt install -y php-mysql
RUN apt install -y php7.4-sqlite3
RUN apt install -y php-gd
RUN apt install -y php-intl
RUN apt install -y php-xml
RUN apt install -y php-curl
#RUN apt install -y php7.0-ffmpeg
RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.4/apache2/php.ini
RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.4/cli/php.ini
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
RUN echo "IncludeOptional /var/www/*.conf" >> /etc/apache2/apache2.conf
#RUN sed -i "s/<\/VirtualHost>/Проверка\n<\/VirtualHost>" /etc/apache2/apache2.conf
RUN sed -i "s/<\/VirtualHost>/\n\t<Directory \/var\/www\/html>\n\t<\/Directory>\n<\/VirtualHost>/g" /etc/apache2/sites-available/000-default.conf
RUN sed -i "s/<\/Directory>/\tOptions Indexes FollowSymLinks MultiViews\n\t<\/Directory>/g" /etc/apache2/sites-available/000-default.conf
RUN sed -i "s/<\/Directory>/\tAllowOverride All\n\t<\/Directory>/g" /etc/apache2/sites-available/000-default.conf
RUN sed -i "s/<\/Directory>/\tOrder allow,deny\n\t<\/Directory>/g" /etc/apache2/sites-available/000-default.conf
RUN sed -i "s/<\/Directory>/\tAllow from all\n\t<\/Directory>/g" /etc/apache2/sites-available/000-default.conf
RUN sed -i "s/<\/Directory>/\tRequire all granted\n\t<\/Directory>/g" /etc/apache2/sites-available/000-default.conf
RUN mv /etc/apache2/sites-enabled/000-default.conf /tmp
RUN cd /etc/apache2/sites-enabled/; ln -s ../sites-available/000-default.conf 000-default.conf
RUN a2enmod php7.4
RUN a2enmod rewrite
#RUM apt install -y certbot
#RUN a2enmod python-certbot-apache
#RUN a2enmod ssl
EXPOSE 80
EXPOSE 22
# <Directory /var/www/html>
# Options Indexes FollowSymLinks MultiViews
# AllowOverride All
# Order allow,deny
# Allow from all
# Require all granted
# </Directory>
RUN wget -O /var/www/html/index.phar https://github.com/mpak2/mpak.su/raw/master/phar/index.phar
RUN wget -O /var/www/html/.htaccess https://github.com/mpak2/mpak.su/raw/master/.htaccess
RUN wget -O /var/www/html/.htdb https://github.com/mpak2/mpak.su/raw/master/.htdb
RUN chown www-data /var/www/html/.htdb
RUN chown www-data /var/www/html
RUN mkdir /var/www/html/include
RUN mkdir /var/www/html/include/images
RUN chmod 0777 /var/www/html/include/images
RUN rm /var/www/html/index.html
https://github.com/mpak2/mpak.su/blob/654b7daf0b7d4f3c83385c0ca35fcab6a1ec45f7/phar/docker/www/Dockerfile
+1
Можно ли считать говнокодом (говноAPI) правильно работающую, но незадокументированную особенность API?
Например у вьюхи есть свойство isOpen, которое может быть задано (true/false) а может быть не задано (undefined).
Первое нужно для управления видимостью в реактивном стиле, второе предполагает что разработчик будет
управлять видимостью через хендлы вьюхи. И оно так и работает - если isOpen=undefined, то этот проп просто игнорируется
при обновлении вьюхи (чтобы не допустить конфликта source truth). Но этого нет в документации, отчего неосторожное
использование булеана и значения которое может быть undefined в качестве значения isOpen, приводит к забавному
косяку - вьюха должна исчезнуть, но она не исчезает! И тут по-началу грешишь на забагованное API. Но в нем нет бага!
+2
Ltac2 make_match fields :=
destruct x;
iter (fun a => focus 1 1 (fun () =>
let a := a ()
in refine (fun () => '((w_rep $a) _)))
) fields.
Итерация по конструкторам индуктивного типа данных.
0
https://www.evilfingers.com/publications/research_RU/oldnewlang.pdf языки, которые мы потеряли
...
Кстати, тот, кто считает, метапрограммирование достижением последних десятилетий, — жестоко
ошибается. Да, в языке Си++ оно появилось совсем недавно и в полном объеме (описанном в
последних редакциях Стандарта) не реализовано ни в одном реально существующем компиляторе, a
Nemerle и R# (языки программирования для платформы .Net со встроенной поддержкой
метапрограммирования) — вообще младенцы, но на самом деле концепция метапрограммирования
возникла еще во времена палеолита. Lisp, появившийся в далеком 1958 г., — хороший пример
языка, естественным образом поддерживающий метапрограммирование, одной из задач которого
является создание программы, выводящей точную копию своего собственного исходного текста — так
называемый куин (англ, quine). На Lisp'e он записывается так:
(funcall (lambda (x)
(append x (list (list 'quote x))))
'(funcall (lambda (x)
(append x (list (list 'quote x))))))
Листинг 1 программа на Lisp'е, распечатывающая сама себя
На Си так:
#include<stdio.h>
char*i="\\#include<stdio.h>",n='\n',q='"',*p=
"%s%cchar*i=%c%c%s%c,n='%cn',q='%c',*p=%c%c%s%c,*m=%c%c%s%c%c;%s%c",*m=
"int main(){return!printf(p,i+1,n,q,*i,i,q,*i,q,n,q,p,q,n,q,m,q,n,m,n);}"
;int main(){return!printf(p,i+1,n,q,*i,i,q,*i,q,n,q,p,q,n,q,m,q,n,m,n);}
А теперь попробуйте реализовать тоже самое на Си++ с использованием шаблонов и посмотрите, насколько
сильно они вам «помогут».
Крестобляди соснули
+1
* https://github.com/nwchemgit/nwchem/blob/8ac6bc6856d50954029cad01a751006851682398/src/nwpw/pspw/lib/psi/psi.F#L324
subroutine psi_sort_f_orb()
implicit none
#include "errquit.fh"
#include "bafdecls.fh"
#include "psi.fh"
logical value
integer i,j,ii,jj,ms
integer r1(2)
real*8 ei,ej
value = BA_push_get(mt_dcpl,npack1,'r1',r1(2),r1(1))
if (.not. value) call errquit(
> 'psi_sort_f_orb: out of stack memory',0,MA_ERR)
do ms=1,ispin
!*** Bubble sort ***
do ii=1,ne(ms)
do jj=ii+1,ne(ms)
i = ii + (ms-1)*ne(1)
j = jj + (ms-1)*ne(1)
ei = dbl_mb(eig(1)+i-1)
ej = dbl_mb(eig(1)+j-1)
!*** swap ***
if (ej.lt.ei) then
dbl_mb(eig(1)+i-1) = ej
dbl_mb(eig(1)+j-1) = ei
call Pack_c_Copy(1,dcpl_mb(psi1(1)+(i-1)*npack1),
> dcpl_mb(r1(1)))
call Pack_c_Copy(1,dcpl_mb(psi1(1)+(j-1)*npack1),
> dcpl_mb(psi1(1)+(i-1)*npack1))
call Pack_c_Copy(1,dcpl_mb(r1(1)),
> dcpl_mb(psi1(1)+(j-1)*npack1))
end if
end do
end do
end do
value = BA_pop_stack(r1(2))
if (.not. value) call errquit(
> 'psi_sort_f_orb: popping stack memory',1, MA_ERR)
return
end
Сортировка пузырьком на фортране из пакета квантовохимических вычислений "NWChem"
0
<style type="text/css" media="all">
html.cms a[href^="https://www.who.int"][href$="/en"] {background-color:#ffcc00;}
html.cms a[href^="https://www.who.int"][href$="/en/"] {background-color:#ffcc00;}
html.cms a[href^="http://www.who.int"][href$="/en"] {background-color:#ffcc00;}
html.cms a[href^="http://www.who.int"][href$="/en/"] {background-color:#ffcc00;}
html.cms a[href^="/"][href$="/en"] {background-color:#ffcc00;}
html.cms a[href^="/"][href$="/en/"] {background-color:#ffcc00;}
html.cms a[href="/"] {background-color:inherit !important;}
html.cms a[href="/en"] {background-color:inherit !important;}
html.cms a[href="/en/"] {background-color:inherit !important;}
html.cms a[href$="http://www.who.int/en"] {background-color:inherit !important;}
html.cms a[href$="http://www.who.int/en/"] {background-color:inherit !important;}
html.cms a[href$="https://www.who.int/en"] {background-color:inherit !important;}
html.cms a[href$="https://www.who.int/en/"] {background-color:inherit !important;}
html.cms a[href^="https://www.who.int"][href$="/ar"] {background-color:#ffcc00;}
html.cms a[href^="https://www.who.int"][href$="/ar/"] {background-color:#ffcc00;}
html.cms a[href^="http://www.who.int"][href$="/ar"] {background-color:#ffcc00;}
html.cms a[href^="http://www.who.int"][href$="/ar/"] {background-color:#ffcc00;}
html.cms a[href^="/"][href$="/ar"] {background-color:#ffcc00;}
html.cms a[href^="/"][href$="/ar/"] {background-color:#ffcc00;}
html.cms a[href="/ar"] {background-color:inherit !important;}
html.cms a[href="/ar/"] {background-color:inherit !important;}
html.cms a[href$="http://www.who.int/ar"] {background-color:inherit !important;}
html.cms a[href$="http://www.who.int/ar/"] {background-color:inherit !important;}
html.cms a[href^="https://www.who.int"][href$="/zh"] {background-color:#ffcc00;}
html.cms a[href^="https://www.who.int"][href$="/zh/"] {background-color:#ffcc00;}
html.cms a[href^="http://www.who.int"][href$="/zh"] {background-color:#ffcc00;}
html.cms a[href^="http://www.who.int"][href$="/zh/"] {background-color:#ffcc00;}
html.cms a[href^="/"][href$="/zh"] {background-color:#ffcc00;}
html.cms a[href^="/"][href$="/zh/"] {background-color:#ffcc00;}
html.cms a[href="/zh"] {background-color:inherit !important;}
html.cms a[href="/zh/"] {background-color:inherit !important;}
html.cms a[href$="http://www.who.int/zh"] {background-color:inherit !important;}
html.cms a[href$="http://www.who.int/zh/"] {background-color:inherit !important;}
html.cms a[href$="https://www.who.int/zh"] {background-color:inherit !important;}
html.cms a[href$="https://www.who.int/zh/"] {background-color:inherit !important;}
html.cms a[href^="https://www.who.int"][href$="/fr"] {background-color:#ffcc00;}
html.cms a[href^="https://www.who.int"][href$="/fr/"] {background-color:#ffcc00;}
html.cms a[href^="http://www.who.int"][href$="/fr"] {background-color:#ffcc00;}
html.cms a[href^="http://www.who.int"][href$="/fr/"] {background-color:#ffcc00;}
html.cms a[href^="/"][href$="/fr"] {background-color:#ffcc00;}
html.cms a[href^="/"][href$="/fr/"] {background-color:#ffcc00;}
html.cms a[href="/fr"] {background-color:inherit !important;}
html.cms a[href="/fr"] {background-color:inherit !important;}
html.cms a[href="/fr/"] {background-color:inherit !important;}
html.cms a[href$="http://www.who.int/fr"] {background-color:inherit !important;}
html.cms a[href$="http://www.who.int/fr/"] {background-color:inherit !important;}
html.cms a[href$="https://www.who.int/fr"] {background-color:inherit !important;}
html.cms a[href$="https://www.who.int/fr/"] {background-color:inherit !important;}
html.cms a[href^="https://www.who.int"][href$="/ru"] {background-color:#ffcc00;}
html.cms a[href^="https://www.who.int"][href$="/ru/"] {background-color:#ffcc00;}
</style>
Сайт ВОЗ. Многое можно ожидать от frontend, но такое...
0
Как вы думаете, что может делать функция getAlabamaTimezone(now: Date) ?
+2
IT Оффтоп #135
#105: https://govnokod.ru/27544 https://govnokod.xyz/_27544
#106: https://govnokod.ru/27552 https://govnokod.xyz/_27552
#107: https://govnokod.ru/27554 https://govnokod.xyz/_27554
#108: https://govnokod.ru/27557 https://govnokod.xyz/_27557
#109: https://govnokod.ru/27581 https://govnokod.xyz/_27581
#110: https://govnokod.ru/27610 https://govnokod.xyz/_27610
#111: https://govnokod.ru/27644 https://govnokod.xyz/_27644
#112: https://govnokod.ru/27648 https://govnokod.xyz/_27648
#113: https://govnokod.ru/27652 https://govnokod.xyz/_27652
#114: https://govnokod.ru/27659 https://govnokod.xyz/_27659
#115: https://govnokod.ru/27665 https://govnokod.xyz/_27665
#116: https://govnokod.ru/27671 https://govnokod.xyz/_27671
#117: https://govnokod.ru/27675 https://govnokod.xyz/_27675
#118: https://govnokod.ru/27685 https://govnokod.xyz/_27685
#119: https://govnokod.ru/27701 https://govnokod.xyz/_27701
#120: https://govnokod.ru/27703 https://govnokod.xyz/_27703
#121: https://govnokod.ru/27710 https://govnokod.xyz/_27710
#122: https://govnokod.ru/27728 https://govnokod.xyz/_27728
#123: https://govnokod.ru/27729 https://govnokod.xyz/_27729
#124: https://govnokod.ru/27730 https://govnokod.xyz/_27730
#125: https://govnokod.ru/27732 https://govnokod.xyz/_27732
#126: https://govnokod.ru/27733 https://govnokod.xyz/_27733
#127: https://govnokod.ru/27737 https://govnokod.xyz/_27737
#128: https://govnokod.ru/27742 https://govnokod.xyz/_27742
#129: https://govnokod.ru/27747 https://govnokod.xyz/_27747
#130: https://govnokod.ru/27755 https://govnokod.xyz/_27755
#131: https://govnokod.ru/27766 https://govnokod.xyz/_27766
#132: https://govnokod.ru/27790 https://govnokod.xyz/_27790
#133: https://govnokod.ru/27828 https://govnokod.xyz/_27828
#134: https://govnokod.ru/27834 https://govnokod.xyz/_27834
0
Disk /dev/sdc: 14,46 GiB, 15523119104 bytes, 30318592 sectors
Disk model: Storage Device
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/sdc1 1009664 7802879 6793216 3,2G b W95 FAT32
/dev/sdc2 * 73728 139263 65536 32M 6 FAT16
/dev/sdc3 1 1009664 1009664 493M 85 Linux extended
/dev/sdc5 139264 172031 32768 16M 83 Linux
/dev/sdc6 172032 204799 32768 16M 83 Linux
/dev/sdc7 204800 275455 70656 34,5M 83 Linux
/dev/sdc8 275456 776191 500736 244,5M 83 Linux
/dev/sdc9 776192 976895 200704 98M 83 Linux
/dev/sdc10 976896 1009663 32768 16M 83 Linux
Изначально хотел запихнуть в старый PocketBook515 флешку побольше. Она там хитрая, с линуксом, просто так поменять нельзя. Столкнулся с тем, что не могу parted подвинуть границы раздела, потому что overlapping partitions запрещены. Что делать? вот
fdisk -l