1. Python / Говнокод #24294

    0

    1. 1
    2. 2
    3. 3
    4. 4
    try:
            assert isinstance(tag, bs4.element.Tag)
        except AssertionError:
            raise TypeError

    syoma, 20 Мая 2018

    Комментарии (39)
  2. JavaScript / Говнокод #24290

    −2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (query) {
            searchParams.area = query.area_from && query.area_from !== 'all' && query.area_from.length !== 0 && query.area_to && query.area_to !== 'all' && query.area_to.length !== 0 ? [query.area_from, query.area_to] : ['0', '100']
            searchParams.price = query.price_from && query.price_from !== 'all' && query.price_from.length !== 0 && query.price_to && query.price_to !== 'all' && query.price_to.length !== 0 ? [query.price_from, query.price_to] : ['0', '10']
            searchParams.floor = query.floor_from && query.floor_from !== 'all' && query.floor_from.length !== 0 && query.floor_to && query.floor_to !== 'all' && query.floor_to.length !== 0 ? [query.floor_from, query.floor_to] : ['0', '100']
            searchParams.last_first = query.last_first && query.last_first !== 'all' && query.last_first.length !== 0 ? query.last_first : null
            searchParams.promo = query.promo && query.promo !== 'all' && query.promo.length !== 0 ? query.promo : null
            searchParams.assignment = query.assignment && query.assignment !== 'all' && query.assignment.length !== 0 ? query.assignment : null

    no coments

    YRTRK, 19 Мая 2018

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

    −2

    1. 1
    2. 2
    https://hsto.org/webt/ho/0r/ms/ho0rms80hfva2hnwlptdhoz4ysy.png
    https://habr.com/company/rambler-co/blog/358762/

    Всё что можно, какие есть технологии и базы данных, захуярили в одну схему. Не хватает только "PHP" для полной картины.

    minusinho, 18 Мая 2018

    Комментарии (2)
  4. bash / Говнокод #24281

    −2

    1. 1
    echo $(printf '1\xff0.0.0.0:0\0\\gamedir\\valve' |nc -u ms.xash.su 27010 -w 1 | od -j6 -t x1 -An -w6 |sed -s 's/\ /\ 0x/g'|while read line; do printf '%d.%d.%d.%d' $(echo $line|cut -d ' ' -f1-4) ; echo \ $(( $(printf %d $(echo $line|cut -d ' ' -f5))*256 + $(printf %d $(echo $line|cut -d ' ' -f6)) )); done| while read line1; do printf \\xff\\xff\\xff\\xffinfo\ 48|nc -w 1 -u $line1 |sed -e s/\\\\/\\\ /g -e "s/\xff\xff\xff\xffinfo/_br_$line1/g" & done;sleep 2s;echo)|sed -e s/_br_/\\n/g

    Работаем с бинарными протоколами однострочно

    mittorn, 17 Мая 2018

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

    −5

    1. 1
    Эмуляторы

    Объясните пожалуйста, почему пишут эмуляторы всяких там GBA, но нет ни одного транслятора в самодостаточную программу? И почему все заботься о том, что бы эмулятор работал с такой же скоростью, как и настоящий процессор?

    dm_fomenok, 17 Мая 2018

    Комментарии (50)
  6. Python / Говнокод #24279

    −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
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    import json
    import time
    import requests
    from multiprocessing.dummy import Pool as ThreadPool
    max_threads = 10
    fname = "data.json"
    headers = {"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36", "referer":"https://datmusic.xyz/?q=Home+resonance", "authority":"api-2.datmusic.xyz"}
    
    def api(url):
        while True:
            try:
                r = requests.get(url, headers=headers)
                r = r.json()
                if r['status'] == 'error':
                    pass
                else:
                    return r['data'][0]['download']
            except Exception as e:
                pass
    def download(a):
        # open in binary mode
        while True:
            try:
                with open(a[1]+".mp3", "wb") as file:
                    response = requests.get(a[0],headers=headers)
                    if not (response.status_code == 503):
                        file.write(response.content)
                        print(a[1],"downloaded")
                        break
                    else:
                        pass
            except Exception as e:
                pass
    
    songs = []
    
    with open(fname) as json_data:
        data = json.load(json_data)
        for mp3 in data['list']:
            song = []
            autor = mp3[4]
            title = mp3[3][:-5]
            song.append(autor)
            song.append(title)
            songs.append(song)
    
    links = []
    
    def linker(a):
        song = []
        link = api("https://api-2.datmusic.xyz/search?q=" + a[0] + "+" + a[1] + "&page=0")
        song.append(link)
        song.append(a[0] + ' - ' + a[1])
        links.append(song)
        print(a[1])
    
    for a in songs:
        linker(a)
        #if len(links) > 10:
        #   break
    
    pool = ThreadPool(max_threads)
    results = pool.map(download, links)
    pool.close()
    pool.join()

    #Наговнокодил загрущик плейлистов с контача. Как получить json плейлиста подумай сам (перейди в музыку, открой Network в f12 и мониторь запрос при открытии плейлиста)
    #Парсер 1 поточный, загрущик многопоточный. Работает через апи datmusic.xyz спс им
    #vk.com music downloader v1.0a
    #загрущик музыки вк
    json = https://gist.githubusercontent.com/alekxeyuk/a1ccd2c62ab56a71320a02582cfc06f9/raw/4f2622c4beeddfa7e3082c276e1c138c87478e83/data.json

    pacaw, 17 Мая 2018

    Комментарии (4)
  7. C# / Говнокод #24278

    −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
    public class Parameter
    {
      public string Name { get; }
      public int Value { get; }
    
      private Parameter(string name, int value)
      {
        Name = name;
        Value = value;
      }
    
      public static Func<int, Parameter> GetDeferredConstructor(string name)
      {
        return value => new Parameter(name, value);
      }
    }
    
    public class Program
    {
      public static void Main(string[] args)
      {
        var dc = Parameter.GetDeferredConstructor("param");
        var p = dc(5);
      }
    }

    mazhuravlev, 17 Мая 2018

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

    −2

    1. 1
    2. 2
    3. 3
    // this method is used for storing name instead of password
        @Override
        public String getPassword() { return name; }

    gbuyankin, 17 Мая 2018

    Комментарии (113)
  9. C++ / Говнокод #24276

    +3

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    using namespace std;
    #include <typeinfo>
    #include <stdlib.h>
    #include <stdio.h>
    #include <string>
    #include <math.h>
    #include <stdarg.h>
    
    template <unsigned FRA,unsigned EXP>
    struct F {
        union{
            float     f;
            unsigned ui;
            unsigned ef : FRA+EXP;	    
            struct
            {
    	        unsigned f : FRA;
    	        unsigned e : EXP;
    	        unsigned s : 1;
            } s;
        };
        F (double x){f=x;}
        F operator =(const double x) { 
            f=x; return *this;
        }    
        
    #define NOOP ;
    #define  UN(OP,BODY, RET)   float    operator OP(	) { BODY; return RET;}
    #define BIN(OP,BODY, RET)   F    operator OP(F other	) { BODY; return RET;}
    #define BINF(OP,BODY,RET)   F    operator OP(const float other) { BODY; } BIN(OP,BODY,RET)
    #define CMP(OP)        bool operator OP(const F& other) 
    
        UN ( -  ,   s.s^=1   ,     (f)       )
        BIN( += , f+=other.f , (  *this  )   )
        BIN( +  , NOOP       , { f+other.f}   )
        BIN( -  ,++other.s.s , {*this+other} )
        BIN( *  ,   NOOP    ,   fmul(f,{other})        )
        BIN( /  , div(other), (  *this  ) )
        BINF(*=, ui=fmul(*this   ,{other}).ui, (  *this  )   )  
        BINF(/=, ui=fmul(*this,rcp(other)).ui, (  *this  )   )  
    
    
        CMP(==){
            return other.ui==ui;
        }    
    
        F out(string s) const{
            printf("> %s%f\n",s.c_str(),f);
        }
        F plus(F other)
        {
            f+=other.f;
            return *this;        
        }    
        
        F div(F other)
        {
            ui=fmul(rcp(other),{f}).ui;
            return *this;        
        }    
        F sqrt()
        {
            s.e-=127;
            ui>>=1; 
            s.f-=(s.f>>4);
            s.e+=127;        
            return *this;        
        }
        F pow(int n)
        {
            s.e-=127;
            ui*=n; 
            ef+=(ef>>4);
            ef-=(ef>>9);
            s.e+=127;
            return *this;
        }    
    
    private:    
        static F rcp(F f) {
            f.s.e=(~f.s.e-2);
            f.s.f=(~f.s.f-2);
            return f;
        }
        
        static F fmul(F r,F b)
        {
            r.s.s   ^= b.s.s;
            r.ef += ((r.s.f&b.s.f)>>4);
            r.ef += b.ef ;
            r.s.e+= 129;
            return r;
        }
    
     
    };
    
    using F32 = F<23,8>;
    
    static F32 of32(float x)

    Царь был прав. Во всём.
    Патамучто это плавающий питух, который априори говно. И чем вы быстрее это поймёте, чем будет лучше.

    В соответствии со своим пониманием сделал мммаксимально простую реализацию плавающих питухов произвольного размера.
    Строго на интах.


    Пример здесь:
    uhttps://ideone.com/dDrj7s

    3.14159265, 16 Мая 2018

    Комментарии (66)
  10. Java / Говнокод #24274

    −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
    if (context instanceof Activity) {
                activity = (MainActivityMVI) context;
                try {
                    listener = (OnOfferItemClickListenerS) activity;
                } catch (ClassCastException e) {
                    throw new ClassCastException(activity.toString() + "must implement OnOfferItemClickListenerS");
                }
                try {
                    listener2 = (OnLoadDataSearchMainFragmentListener) activity;
                } catch (ClassCastException e) {
                    throw new ClassCastException(activity.toString() + "must implement OnLoadDataSearchMainFragmentListener");
                }
                App.getComponent(activity).inject(this);
            }

    makesense, 16 Мая 2018

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