1. Куча / Говнокод #27878

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    EXAMPLE
    
    To specify what kind of authorization is needed to execute the program /usr/bin/pk-example-frobnicate as another user, simply write an action definition file like this
    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE policyconfig PUBLIC
      "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
      "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
    <policyconfig>
    
      <vendor>Examples for the PolicyKit Project</vendor>
      <vendor_url>http://hal.freedesktop.org/docs/PolicyKit/</vendor_url>
    
      <action id="org.freedesktop.policykit.example.pkexec.run-frobnicate">
        <description>Run the PolicyKit example program Frobnicate</description>
        <description xml:lang="da">Kør PolicyKit eksemplet Frobnicate</description>
        <message>Authentication is required to run the PolicyKit example program Frobnicate (user=$(user), program=$(program), command_line=$(command_line))</message>
        <message xml:lang="da">Autorisering er påkrævet for at afvikle PolicyKit eksemplet Frobnicate (user=$(user), program=$(program), command_line=$(command_line))</message>
        <icon_name>audio-x-generic</icon_name>
        <defaults>
          <allow_any>no</allow_any>
          <allow_inactive>no</allow_inactive>
          <allow_active>auth_self_keep</allow_active>
        </defaults>
        <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/pk-example-frobnicate</annotate>
      </action>
    
    </policyconfig>

    Simply write an action definition file like this, they said...

    bormand, 17 Декабря 2021

    Комментарии (13)
  2. Куча / Говнокод #27872

    −4

    1. 1
    2. 2
    Гритингс, мои будущие жертвы!..
    Лысое Хуйло пытается насильно колоть и пичкать лекарствами своих агнцев - то есть, Вас, в надежде спасти свою жопу от импичмента - а он неминуем.

    Странно, но с началом вакцинации мор только усилился.

    OMuKPOH, 12 Декабря 2021

    Комментарии (0)
  3. Куча / Говнокод #27870

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    Хрюкни #21
                 ._     __,
                  |\,../'\
                ,'. .     `.
               .--         '`.
              ( `' ,          ;
              ,`--' _,       ,'\
             ,`.____            `.
            /              `,    |
           '                \,   '
           |                /   /`,
           `,  .           ,` ./  |
           ' `.  ,'        |;,'   ,@
     ______|     |      _________,_____jv______
            `.   `.   ,'
             ,'_,','_,
             `'   `'

    #1: (vanished) https://govnokod.xyz/_26863
    #2: (vanished) https://govnokod.xyz/_26868
    #3: https://govnokod.ru/26881 https://govnokod.xyz/_26881
    #4: https://govnokod.ru/26896 https://govnokod.xyz/_26896
    #5: https://govnokod.ru/26928 https://govnokod.xyz/_26928
    #6: (vanished) https://govnokod.xyz/_26952
    #7: https://govnokod.ru/26955 https://govnokod.xyz/_26955
    #8: https://govnokod.ru/27043 https://govnokod.xyz/_27043
    #9: https://govnokod.ru/27175 https://govnokod.xyz/_27175
    #10: https://govnokod.ru/27472 https://govnokod.xyz/_27472
    #11: https://govnokod.ru/27517 https://govnokod.xyz/_27517
    #12: https://govnokod.ru/27636 https://govnokod.xyz/_27636
    #13: (vanished) https://govnokod.xyz/_27711
    #14: https://govnokod.ru/27713 https://govnokod.xyz/_27713
    #15: https://govnokod.ru/27721 https://govnokod.xyz/_27721
    #16: https://govnokod.ru/27722 https://govnokod.xyz/_27722
    #17: https://govnokod.ru/27723 https://govnokod.xyz/_27723
    #18: https://govnokod.ru/27724 https://govnokod.xyz/_27724
    #19: https://govnokod.ru/27726 https://govnokod.xyz/_27726
    #20: https://govnokod.ru/27727 https://govnokod.xyz/_27727

    nepeKamHblu_nemyx, 12 Декабря 2021

    Комментарии (474)
  4. Куча / Говнокод #27868

    0

    1. 1
    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

    JaneBurt, 12 Декабря 2021

    Комментарии (24)
  5. Куча / Говнокод #27861

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    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

    ISO, 07 Декабря 2021

    Комментарии (21)
  6. Куча / Говнокод #27860

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Можно ли считать говнокодом (говноAPI) правильно работающую, но незадокументированную особенность API?
    Например у вьюхи есть свойство isOpen, которое может быть задано (true/false) а может быть не задано (undefined). 
    Первое нужно для управления видимостью в реактивном стиле, второе предполагает что разработчик будет
    управлять видимостью через хендлы вьюхи. И оно так и работает - если isOpen=undefined, то этот проп просто игнорируется
    при обновлении вьюхи (чтобы не допустить конфликта source truth). Но этого нет в документации, отчего неосторожное 
    использование булеана и значения которое может быть undefined в качестве значения isOpen, приводит к забавному
    косяку - вьюха должна исчезнуть, но она не исчезает! И тут по-началу грешишь на забагованное API. Но в нем нет бага!

    JaneBurt, 06 Декабря 2021

    Комментарии (26)
  7. Куча / Говнокод #27851

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Ltac2 make_match fields :=
      destruct x;
      iter (fun a => focus 1 1 (fun () =>
                               let a := a ()
                               in refine (fun () => '((w_rep $a) _)))
             ) fields.

    Итерация по конструкторам индуктивного типа данных.

    CHayT, 03 Декабря 2021

    Комментарии (6)
  8. Куча / Говнокод #27847

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    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);}
    
    А теперь попробуйте реализовать тоже самое на Си++ с использованием шаблонов и посмотрите, насколько
    сильно они вам «помогут».

    Крестобляди соснули

    j123123, 01 Декабря 2021

    Комментарии (51)
  9. Куча / Говнокод #27844

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    * 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"

    j123123, 30 Ноября 2021

    Комментарии (324)
  10. Куча / Говнокод #27842

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    <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, но такое...

    rotoeb, 26 Ноября 2021

    Комментарии (138)