1. Список говнокодов пользователя storvus

    Всего: 6

  2. Python / Говнокод #28520

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    from db.session import DB
    
    session = DB.session()
    session.query(Prefix).filter(Prefix.user_id==user_id, Prefix.prefix.ilike('%your persona:%')).delete()
    session.commit()

    storvus, 21 Декабря 2022

    Комментарии (4)
  3. Python / Говнокод #23328

    −9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    class SimilarCardIsShown(ZenAndroidTest):
        def test_similar_show(self):
            cards = self.swipe_and_find_elements(By.ID, "com.yandex.zensample.app:id/card_title", 7)
            for card in cards:
                card.click()
                self.driver.back()
            assert self.driver.find_element_by_id("com.yandex.zensample.app:id/card_helper_sim_head"), "Нет похожих"

    хуй

    storvus, 05 Сентября 2017

    Комментарии (0)
  4. ActionScript / Говнокод #23198

    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
    set-executionpolicy unrestricted
    
    set /p name="set name: "
    set fullname=%name%.mp4
    set /p time="set time: "
    set /p path="set path: "
    
    
    adb shell screenrecord --bit-rate 8000000 --time-limit %time% %fullname%
    echo "Recording finished. Pulling %fullname% into current folder:"
    
    adb pull %fullname% %path%
    adb shell rm %fullname%
    set /p DUMMY="Press Enter to continue"

    storvus, 20 Июля 2017

    Комментарии (1)
  5. ActionScript / Говнокод #23197

    +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
    set-executionpolicy unrestricted
    
    set /p name
    set fullname=%name%.mp4
    set /p time = "set time"
    set /p path = "set path"
    
    
    adb shell screenrecord --bit-rate 8000000 --time-limit $time $fullname &> $null
    echo "Recording finished. Pulling $fullname into current folder:"
    adb pull $fullname $path /С/ # $fullname
    adb shell rm $fullname

    storvus, 20 Июля 2017

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

    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
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    import csv
    import json
    
    import requests
    
    from io import StringIO
    
    from lxml import etree
    
    
    class DayPicParser(object):
        url = 'урл_до_сайта'
    
        def get_info(self):
            handler = open('daypic.csv', 'w+')
            page = 1
            rows = []
            tags = set()
            while page <= 1077:
                response = requests.get('{}/page/{}'.format(self.url, page))
                response.connection.close()
                parser = etree.HTMLParser()
                tree = etree.parse(StringIO(response.text), parser)
                posts = tree.xpath('//div[@class="posts"]/div[@class="post"]')
                for i, post in enumerate(posts):
                    title = post.find('./h2/a')
                    link_to_fulltext = title.attrib['href']
    
                    short_text = post.find('./div[@class="text"]//p[1]')
                    response = requests.get(link_to_fulltext)
                    full_parser = etree.HTMLParser()
                    full_tree = etree.parse(StringIO(response.text), full_parser)
                    full_post = full_tree.xpath('//div[@class="text"]//p')
    
                    main_image = None
                    full_text = []
                    for inner in full_post:
                        if inner.find('.//noindex') is not None:
                            continue
                        if inner.find('.//img') is not None:
                            src = inner.find('.//img').attrib['src']
                            if not main_image:
                                main_image = src
                            full_text.append({'image': src})
                        for paragraph in etree.tostring(inner, method="text", encoding='utf-8').decode('utf-8').strip().split("\n"):
                            if paragraph:
                                full_text.append({'text': paragraph})
                    rows.append({'title': title.text.strip(),
                                 'preview': main_image if main_image else '',
                                 'short_text': short_text.text.strip(),
                                 'full_text': full_text})
                    print('Post {} of {}'.format(i, len(posts)))
                page += 1
                print(page)
            handler.write(json.dumps(rows))
            handler.close()
            print(tags)
    
    
    DayPicParser().get_info()

    storvus, 10 Июля 2017

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

    −49

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    import unittest
    
    class TestStringMethods(unittest.TestCase):
    
      def test_upper(self):
          self.assertEqual('foo'.upper(), 'FOO')
    
    if __name__ == '__main__':
        unittest.main()

    storvus, 17 Сентября 2016

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