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

    −89

    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
    74. 74
    75. 75
    #weather.pyw
    
    from urllib import request
    from tkinter import *
    import tkinter
    import threading
    from threading import *
    import time
    
    i = 0
    active = True
    
    def timerTick( toSleep ):
      global active
      while active:
        refreshCall(0)
        time.sleep(toSleep)
    
    
    def refreshCall(event):
      t = Thread(target = refresh)
      t.start()
    
    def refresh(*event):
      global i
      ref['text'] = str(i)
      i+=1
      r = request
      page = str(r.urlopen('http://realmeteo.ru/moscow/1/current/').read())
      temperature = page.split('</tr><tr id="num_data"><td>')[1].split(' ')[0]
      pressure = page.split('                    </td><td>')[1].split(' ')[0]
      wind = page.split('<tr id="num_data"><td></td><td>')[1].split(' ')[0]
      dest = page.split('<param name="movie" value="/.swf/wind_dir/')[1].split('.swf')[0]
      destination = ''
      for c in dest:
        if c is dest[-1]:
          destination += {'N':'Север','S':'Юг','W':'Запад','E':'Восток'}[c]
        else:
          destination += {'N':'Северо-','S':'Юго-','W':'Западо-','E':'Востоко-'}[c]
      #print( temperature, pressure, wind, destination )
      l1['text'] = 'Температура: '+temperature
      l2['text'] = 'Давление   : '+pressure
      l3['text'] = 'Сила ветра : '+wind
      l4['text'] = 'Направление: '+destination
    
    r = request
    page = str(r.urlopen('http://realmeteo.ru/moscow/1/current/').read())
    temperature = page.split('</tr><tr id="num_data"><td>')[1].split(' ')[0]
    pressure = page.split('                    </td><td>')[1].split(' ')[0]
    wind = page.split('<tr id="num_data"><td></td><td>')[1].split(' ')[0]
    dest = page.split('<param name="movie" value="/.swf/wind_dir/')[1].split('.swf')[0]
    destination = ''
    for c in dest:
      if c is dest[-1]:
        destination += {'N':'Север','S':'Юг','W':'Запад','E':'Восток'}[c]
      else:
        destination += {'N':'Северо-','S':'Юго-','W':'Западо-','E':'Востоко-'}[c]
    
    
    form = tkinter.Tk()
    l1 = Label(form,text='Температура: '+temperature,justify='left'); l1.pack()
    l2 = Label(form,text='Давление   : '+pressure,justify='left'); l2.pack()
    l3 = Label(form,text='Сила ветра : '+wind,justify='left'); l3.pack()
    l4 = Label(form,text='Направление: '+destination,justify='left'); l4.pack()
    ref = Button(form, text = 'Обновить'); ref.pack()
    
    ref.bind('<Button-1>',refreshCall)
    
    timerThread = Thread(target = timerTick, args=(5,))
    
    timerThread.start()
    
    form.mainloop()
    
    active = False

    Угадайте, с какого языка пересел автор. (не пэхапэ)

    Fai, 15 Августа 2011

    Комментарии (33)
  2. Python / Говнокод #7544

    −99

    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
    # разбираюсь с питоном, может растолкуете почему так
    >>> z = [lambda: i for i in [1,2,3]]
    # почему вот такой результат?
    >>> z[0](), z[1](), z[2]()
    (3, 3, 3) 
    
    # каждый элемент списка - отдельная функция
    >>> z[0] == z[1], z[0] is z[1]
    (False, False)
    
    # вот таким образом выходит правильно.
    >>> z = [lambda: 1, lambda: 2, lambda:3]
    >>> z[0](), z[1](), z[2]()
    (1, 2, 3)

    Автор - я. Меня действительно интересует, почему так происходит.

    Fai, 14 Августа 2011

    Комментарии (14)
  3. PHP / Говнокод #7543

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    $firstName = $_POST['firstname'];
    $secondName=$_POST['secondname'];
    $email = $_POST['email'];
    $query="insert into sportsmans values('$secondName','$firstName','$email',null)";
    $conn = mysql_connect('localhost','root','VCh3005');
    mysql_select_db('Competition');
    mysql_query("SET NAMES 'utf8'");
    mysql_query("SET CHARACTER SET 'utf8'");
    mysql_query($query);
    mysql_error();
    mysql_close();

    Классика...

    Sulik78, 14 Августа 2011

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

    +170

    1. 1
    [](){}();

    Поздравляю с новым стандартом, товарищи!

    rat4, 14 Августа 2011

    Комментарии (54)
  5. Python / Говнокод #7541

    −175

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if request.path == '/':
            thread_list = ThreadBlock.objects.all()
        else:
            thread_nomer = re.search( r'/\d*/', request.path ).group()[1:-1]
            thread_list = ThreadBlock.objects.filter(id=int(thread_nomer))

    Бидон, джанга, уеб.

    хуита, 14 Августа 2011

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

    −88

    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
    # -*- coding: utf-8 -*-
    from Tkinter import *
    import time
    import random
    import os
    def init(): #Инициалиазия, переменная root, задаём размеры окна
    	global root, widthmin, widthmax, heightmin, heightmax, geometry
    	widthmin = 400 
    	widthmax = 400
    	heightmin = 400
    	heightmax = 400
    	geometry = str(widthmax) + 'x' + str(heightmax)
    	root = Tk()
    	root.geometry(geometry)
    	root.minsize(width=widthmin,height=heightmin)
    	root.maxsize(width=widthmax,height=heightmax)
    	menu()
    	root.mainloop()
            
    def menu(): #Меню игры. С любовью, кэп
    	global btSingle, btMulti, btSetting, btQuit
    	btSingle = Button(root, text="Singleplayer", command=singleplayer)
    	btSingle.pack(padx=15,pady=15)
    	btMulti = Button(root, text="Multiplayer", command=multiplayer)
    	btMulti.pack(padx=15,pady=15)
    	btSettings = Button(root, text="Settings", command=settings)
    	btSettings.pack(padx=15,pady=15)
    	btQuit = Button(root, text="Quit", command=quit)
    	btQuit.pack(padx=15,pady=15)
    	
    
    def singleplayer(): #Функции синглплеера
        global root #Удалить после заполнения функции более полезной хренью
    
    def multiplayer(): #Функции мультплеера
    	global root #Удалить после заполнения функции более полезной хренью
    
    def settings(): #Настройки
    	global root #Удалить после заполнения функции более полезной хренью
    	
    def quit(): #Выход из игры
    	root.destroy ()
    
    init()

    Burst_in, 13 Августа 2011

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

    +166

    1. 1
    $lastID=chr(rand(ord('a'),ord('z'))).rand(1,9).chr(rand(ord('a'),ord('z'))).rand(1,9).rand(1,9).chr(rand(ord('a'),ord('z')));

    данная строка генерирует код активации для пользователя при регистрации.

    Sulik78, 13 Августа 2011

    Комментарии (15)
  8. C++ / Говнокод #7538

    +159

    1. 1
    Наконец-то http://goo.gl/SjgUj

    absolut, 13 Августа 2011

    Комментарии (13)
  9. Java / Говнокод #7537

    +147

    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
    <script type="text/javascript" >
        var str = window.location + "";
        var t = str.substr(7, 2);
        if (t=="40") {document.write("(4842)<span style=\"font-size:30px;font-weight:bold;color:white;\">562–003</span>");}
        if (t=="36") {document.write("(473)<span style=\"font-size:30px;font-weight:bold;color:white;\">233-03-20</span>");}
        if (t=="62") {document.write("(4912)<span style=\"font-size:30px;font-weight:bold;color:white;\">300-305</span>");}
        if (t=="ww") {document.write("(4872)<span style=\"font-size:30px;font-weight:bold;color:white;\">39-03-06</span>");}
        if (t=="po") {document.write("(4872)<span style=\"font-size:30px;font-weight:bold;color:white;\">39-03-06</span>");}
    </script>
    <script type="text/javascript" >
       var str = window.location + "";
       var t = str.substr(7, 2);
       if (t=="40") {document.write("Калуга");}
       if (t=="36") {document.write("Воронеж");}
       if (t=="62") {document.write("Рязань");}
       if (t=="ww") {document.write("Тула");}
       if (t=="po") {document.write("Тула");}
    </script>

    Вот так упыри меняют телефоны на сайте в зависимости от региона, при том, что сайт использует PHP на сервере.

    demitriy_, 12 Августа 2011

    Комментарии (13)
  10. PHP / Говнокод #7536

    +166

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    $text_to_check = mysql_real_escape_string ($_GET["запрос"]);
     
    $text_to_check = strip_tags($text_to_check);
             
    $text_to_check = htmlspecialchars($text_to_check);
     
    $text_to_check = stripslashes($text_to_check);
         
    $text_to_check = addslashes($text_to_check);   
     
    $_GET["запрос"] = $text_to_check;

    все защитил

    Sulik78, 12 Августа 2011

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