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

    0

    1. 1
    IT Оффтоп #104

    #74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
    #75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
    #76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
    #77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
    #78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
    #79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
    #80: https://govnokod.ru/27270 https://govnokod.xyz/_27270
    #81: https://govnokod.ru/27280 https://govnokod.xyz/_27280
    #82: https://govnokod.ru/27284 https://govnokod.xyz/_27284
    #83: https://govnokod.ru/27296 https://govnokod.xyz/_27296
    #84: https://govnokod.ru/27336 https://govnokod.xyz/_27336
    #85: https://govnokod.ru/27381 https://govnokod.xyz/_27381
    #86: https://govnokod.ru/27405 https://govnokod.xyz/_27405
    #87: https://govnokod.ru/27429 https://govnokod.xyz/_27429
    #88: https://govnokod.ru/27432 https://govnokod.xyz/_27432
    #89: https://govnokod.ru/27435 https://govnokod.xyz/_27435
    #90: https://govnokod.ru/27439 https://govnokod.xyz/_27439
    #91: https://govnokod.ru/27449 https://govnokod.xyz/_27449
    #92: https://govnokod.ru/27460 https://govnokod.xyz/_27460
    #93: https://govnokod.ru/27463 https://govnokod.xyz/_27463
    #94: https://govnokod.ru/27466 https://govnokod.xyz/_27466
    #95: https://govnokod.ru/27473 https://govnokod.xyz/_27473
    #96: https://govnokod.ru/27478 https://govnokod.xyz/_27478
    #97: https://govnokod.ru/27484 https://govnokod.xyz/_27484
    #98: https://govnokod.ru/27495 https://govnokod.xyz/_27495
    #99: https://govnokod.ru/27504 https://govnokod.xyz/_27504
    #100: https://govnokod.ru/27508 https://govnokod.xyz/_27508
    #101: https://govnokod.ru/27511 https://govnokod.xyz/_27511
    #102: https://govnokod.ru/27518 https://govnokod.xyz/_27518
    #103: https://govnokod.ru/27526 https://govnokod.xyz/_27526

    nepeKamHblu_nemyx, 23 Июля 2021

    Комментарии (2039)
  2. C++ / Говнокод #27533

    +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
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    #include <iostream>
    #include <functional>
    
    #define STD_FUNCTION(a, ...) typeof( a (*) __VA_ARGS__ )
    
    template<typename T>
    T do_op_t(T a, T b, STD_FUNCTION(T,(T,T)) op)
    {
      return op(a,b);
    }
    
    template
    <
    
      typename T,
    
      STD_FUNCTION(
        T,
        (
          T,T,
          STD_FUNCTION(
            T,
            (T,T)
          )
        )
      ) F1,
    
      STD_FUNCTION(
        T,
        (T,T)
      ) F2
    
    >
    T do_op_spec(T a, T b)
    {
      return F1(a, b, F2);
    }
    
    int add(int a, int b) { return a + b; }
    
    int mul(int a, int b) { return a * b; }
    
    std::function<int(int,int)> fnc = \
      do_op_spec\
      <
        int,
        do_op_t<int>,
        add
      >;
    
    int main()
    {
      std::cout << do_op_t<int>(9, 9, add) << "\n";
      std::cout << do_op_t<int>(9, 9, mul) << "\n";
      std::cout << do_op_spec<int, do_op_t<int>,add>(9,9)  << "\n";
      std::cout << do_op_spec<int, do_op_t<int>,mul>(9,9)  << "\n";
      std::cout << fnc(9,9) << "\n";
    }

    Какая крестопараша )))

    j123123, 23 Июля 2021

    Комментарии (95)
  3. C# / Говнокод #27532

    +1

    1. 1
    Dictionary<Tuple<MapOfRestoredOwnership, bool, bool, bool>, IDictionary<PropertySqlGeography, IEnumerable<LandConsolidationData>>> villages

    Parameter for function...

    bugotrep, 21 Июля 2021

    Комментарии (11)
  4. PHP / Говнокод #27531

    +3

    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
    do {           
                $entries = $xpath->query("//div[@class='identity']/img");
                if(isset($entries[0])) break;
                $entries = $xpath->query("//h1[@class='avatared']/a/img");
                if(isset($entries[0])) break;
                $entries = $xpath->query("//div[@class='avatared']/a/img");
                if(isset($entries[0])) break;
                $entries = $xpath->query("//div[@itemtype='http://schema.org/Person']/a/img");
            } while(false);
            if(!isset($entries[0])) continue;
    
            $src = $entries[0]->getAttribute('src');
            if(!preg_match('#[/=]([0-9a-f]{32})[\?&]#', $src, $matches)) continue;
            $hash = $matches[1];
    
    // спустя несколько строк
    
            do {           
                $entries = $xpath->query("//div[@class='email']/script");
                if(isset($entries[0])) break;
                $entries = $xpath->query("//dl/dd[@class='email']/script");
            } while(false);
            if(isset($entries[0])) {
                $rawcode = $entries[0]->textContent;
                if(!preg_match("#eval\(decodeURIComponent\('(.*)'\)\)#", $rawcode, $matches)) continue;
                $rawcode2 = urldecode($matches[1]);
                if(!preg_match('#href=\\\\?"mailto:([^"\\\\]*)\\\\?"#', $rawcode2, $matches)) continue;
                $email = $matches[1];
                unset($entries);
            } else do {
                $entries = $xpath->query("//div[@class='avatared']/div[@class='details']/dl/dd/a[@data-email]");
                if(isset($entries[0])) break;
                $entries = $xpath->query("//ul[@class='vcard-details']/li[@class='vcard-detail']/a[@data-email]");
            } while(false);
            if(isset($entries[0])) {
                $email = urldecode($entries[0]->getAttribute('data-email'));
            }

    Прототип программы, вытягивающей хэш аватарки и е-мейл из архивной копии профиля в «Гитхабе».

    Nyancat, 21 Июля 2021

    Комментарии (5)
  5. Go / Говнокод #27530

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    func (c *Client) DeleteFile(filename string) {
    	_, err := s3.New(c.session).DeleteObject(&s3.DeleteObjectInput{
    		Bucket: aws.String(c.bucket),
    		Key:    aws.String(filename),
    	})
    	if err != nil {
    		return
    	}
    }

    Ошибочка обработана

    Vitanaki, 21 Июля 2021

    Комментарии (77)
  6. JavaScript / Говнокод #27529

    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
    let glb1 = 0;
    
    function doubleIt(f: (x: number) => number) {
        return f(1) - f(2);
    }
    
    function testLambdas() {
        let x = doubleIt(k => k * 108);
    
        assert(x == -108, "l0");
    }
    
    function main() {
        testLambdas();
        print("done.");
    }

    я вам еще принес новых фич.

    ASD_77, 20 Июля 2021

    Комментарии (17)
  7. Pascal / Говнокод #27528

    +4

    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
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    #!/usr/bin/env instantfpc
    
    program PrintCharTable;
    
    const
    	space = ' '; { }
    	point = '.'; {.}
    	caret = '^'; {^}
    	vline = '|'; {│}
    	hline = '-'; {─}
    	cross = '+'; {┼}
    	hex_0 = ord('0');
    	hex_a = ord('A')-10;
    
    function tohex(d: integer): char;
    begin
    	if d < 10 then
    		tohex := chr(d+hex_0)
    	else
    		tohex := chr(d+hex_a)
    end;
    
    var
    	i, j: integer;
    	code: integer;
    
    begin
    	write(space, space, vline);
    	for i := 0 to 15 do
    		write(space, point, tohex(i));
    	writeln;
    
    	write(hline, hline, cross);
    	for i := 0 to 15 do
    		write(hline, hline, hline);
    	writeln;
    	
    	for i := 0 to 15 do begin
    		write(tohex(i), point, vline);
    		for j := 0 to 15 do begin
    			code := i * 16 + j;
    			if code < 32 then
    				write(space, caret, chr(code+64))
    			else if code = 127 then
    				write(space, caret, chr(code-64))
    			else
    				write(space, space, chr(code))
    		end;
    		writeln
    	end
    end.
    
    {
    $ ./print_ascii.pas | iconv -f koi8-r
      | .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .A .B .C .D .E .F
    --+------------------------------------------------
    0.| ^@ ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O
    1.| ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^\ ^] ^^ ^_
    2.|     !  "  #  $  %  &  '  (  )  *  +  ,  -  .  /
    3.|  0  1  2  3  4  5  6  7  8  9  :  ;  <  =  >  ?
    4.|  @  A  B  C  D  E  F  G  H  I  J  K  L  M  N  O
    5.|  P  Q  R  S  T  U  V  W  X  Y  Z  [  \  ]  ^  _
    6.|  `  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o
    7.|  p  q  r  s  t  u  v  w  x  y  z  {  |  }  ~ ^?
    8.|  ─  │  ┌  ┐  └  ┘  ├  ┤  ┬  ┴  ┼  ▀  ▄  █  ▌  ▐
    9.|  ░  ▒  ▓  ⌠  ■  ∙  √  ≈  ≤  ≥     ⌡  °  ²  ·  ÷
    A.|  ═  ║  ╒  ё  ╓  ╔  ╕  ╖  ╗  ╘  ╙  ╚  ╛  ╜  ╝  ╞
    B.|  ╟  ╠  ╡  Ё  ╢  ╣  ╤  ╥  ╦  ╧  ╨  ╩  ╪  ╫  ╬  ©
    C.|  ю  а  б  ц  д  е  ф  г  х  и  й  к  л  м  н  о
    D.|  п  я  р  с  т  у  ж  в  ь  ы  з  ш  э  щ  ч  ъ
    E.|  Ю  А  Б  Ц  Д  Е  Ф  Г  Х  И  Й  К  Л  М  Н  О
    F.|  П  Я  Р  С  Т  У  Ж  В  Ь  Ы  З  Ш  Э  Щ  Ч  Ъ
    }

    Печатает таблицу нужной кодировки. Пример использования в комменте после end.

    Threadwalker, 20 Июля 2021

    Комментарии (40)
  8. JavaScript / Говнокод #27527

    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
    class XFoo {
        pin: number;
        buf: number[];
    
        constructor(k: number, l: number) {
            this.pin = k - l;
        }
    
        setPin(p: number) {
            this.pin = p;
        }
    
        getPin() {
            return this.pin;
        }
    
        init() {
            this.buf = [1, 2];
        }
    
        toString() {
            return `Foo${this.getPin()}`;
        }
    }
    
    function main() {
        let f = new XFoo(44, 2);
        let s = "" + f;
        print(s);
    }

    я вам тут хрень принес.. новая фича :)

    ASD_77, 19 Июля 2021

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

    0

    1. 1
    IT Оффтоп #103

    #73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
    #74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
    #75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
    #76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
    #77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
    #78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
    #79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
    #80: https://govnokod.ru/27270 https://govnokod.xyz/_27270
    #81: https://govnokod.ru/27280 https://govnokod.xyz/_27280
    #82: https://govnokod.ru/27284 https://govnokod.xyz/_27284
    #83: https://govnokod.ru/27296 https://govnokod.xyz/_27296
    #84: https://govnokod.ru/27336 https://govnokod.xyz/_27336
    #85: https://govnokod.ru/27381 https://govnokod.xyz/_27381
    #86: https://govnokod.ru/27405 https://govnokod.xyz/_27405
    #87: https://govnokod.ru/27429 https://govnokod.xyz/_27429
    #88: https://govnokod.ru/27432 https://govnokod.xyz/_27432
    #89: https://govnokod.ru/27435 https://govnokod.xyz/_27435
    #90: https://govnokod.ru/27439 https://govnokod.xyz/_27439
    #91: https://govnokod.ru/27449 https://govnokod.xyz/_27449
    #92: https://govnokod.ru/27460 https://govnokod.xyz/_27460
    #93: https://govnokod.ru/27463 https://govnokod.xyz/_27463
    #94: https://govnokod.ru/27466 https://govnokod.xyz/_27466
    #95: https://govnokod.ru/27473 https://govnokod.xyz/_27473
    #96: https://govnokod.ru/27478 https://govnokod.xyz/_27478
    #97: https://govnokod.ru/27484 https://govnokod.xyz/_27484
    #98: https://govnokod.ru/27495 https://govnokod.xyz/_27495
    #99: https://govnokod.ru/27504 https://govnokod.xyz/_27504
    #100: https://govnokod.ru/27508 https://govnokod.xyz/_27508
    #101: https://govnokod.ru/27511 https://govnokod.xyz/_27511
    #102: https://govnokod.ru/27518 https://govnokod.xyz/_27518

    nepeKamHblu_nemyx, 19 Июля 2021

    Комментарии (2053)
  10. Си / Говнокод #27525

    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <inttypes.h>
    
    typedef struct list list;
    
    struct list
    {
      list* next;
      uint32_t data;
    };
    
    #define ADD_LIST(ptr, val) \
    do { \
      (ptr)->next = (list *)alloca(sizeof(list)); \
      (ptr)->next->data = val; \
      (ptr)->next->next = NULL;\
    } while (0)
    
    // https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
    #define INIT_LIST(val) \
    ({ \
      list *INIT_LIST = (list *)alloca(sizeof(list)); \
      INIT_LIST->data = val; \
      INIT_LIST->next = NULL; \
      INIT_LIST; \
    })
    
    
    int main(void)
    {
      list *a = INIT_LIST(5);
      ADD_LIST(a,10);
      ADD_LIST(a->next,15);
      ADD_LIST(a->next->next,20);
      ADD_LIST(a->next->next->next,25);
      ADD_LIST(a->next->next->next->next,30);
    
      for(list *ptr = a; ptr != NULL; ptr = ptr->next)
      {
        printf("%d ", ptr->data);
      }
    
      return EXIT_SUCCESS;
    }

    А можно ли в крестоговне так сделать без Сишного Препроцессора?

    j123123, 19 Июля 2021

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