1. C# / Говнокод #23593

    +1

    1. 1
    var now = DateTimeOffset.Now.AddHours(-1);

    Почти сейчас.

    vladdy-moses, 16 Декабря 2017

    Комментарии (3)
  2. Java / Говнокод #23592

    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
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    
    public class Gitis implements ActionListener{
        JFrame frame;
    
        public static void main(String[] args) {
            Gitis gitis = new Gitis();
            gitis.go();
        }
    
        public void go(){
            frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
            JButton button = new JButton("Next Color");
            button.addActionListener(this);
    
            MyDrawPanel panel = new MyDrawPanel();
    
            frame.getContentPane().add(BorderLayout.SOUTH, button);
            frame.getContentPane().add(BorderLayout.CENTER, panel);
            frame.setSize(500, 500);
            frame.setVisible(true);
            frame.setTitle("Paint Oval");
        }
        public void actionPerformed(ActionEvent event){
            frame.repaint();
        }
    }
    
    class MyDrawPanel extends JPanel{
        public void paintComponent(Graphics g){
    
            g.fillRect(0, 0, this.getWidth(),this.getHeight());
    
            int one = (int) (Math.random() * 255);
            int two = (int) (Math.random() * 255);
            int three = (int) (Math.random() * 255);
    
            Color color = new Color(one, two, three);
            g.setColor(color);
            g.fillOval(40, 70 , 50, 50);
        }
    }

    Смена цвета окружности по нажатию кнопки, Оцените код!

    babushkaAntona, 16 Декабря 2017

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

    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
    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
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package ServakPro;
     
    /**
     *
     * @author bb
     */
    import Debugger.NetDebugger;
    import Debugger.NetDebuggingInter;
    import Servak.Db.Experimental.SettingsBandit;
    import java.io.*;
    import java.net.*;
    import java.util.concurrent.ArrayBlockingQueue;
    import java.util.concurrent.BlockingQueue;
     
    public class Server extends Object implements NetDebuggingInter {
     
      static final int INITIALWORKERTHREADS = 20;// tune this!
      static final int port = SettingsBandit.SERVER_PORT;
      BlockingQueue<Socket> queue;
      private ServerSocket ss;
      private Thread internalThread;
      private volatile boolean noStopRequested;
      private NetDebugger netDebugger = new NetDebugger();
     
      private void init() {
      for (int i = 0; i < INITIALWORKERTHREADS; i++) {
      new Thread(new MultiSessionTask(ss, queue)).start();
      }
      }
     
      public Server(BlockingQueue<Socket> q) throws IOException {
      ss = new ServerSocket(port);
      noStopRequested = true;
      this.queue = q;
      this.init();
     
      Runnable r = new Runnable() {
      public void run() {
      try {
      runWorkFast();
      } catch (Exception x) {
      netDebugger.fireServerFaultEvent("SERVER: there is exception: ", x);
      x.printStackTrace();
      }
      }
      };
      internalThread = new Thread(r);
      internalThread.setName("My server Thread");
      internalThread.start();
      }
     
      private void runWorkFast() {
      for (;;) {
      try {
      Socket sock = ss.accept();
      int thr = MultiSessionTask.waitCount();
      if (thr > 0) {
      queue.add(sock);
      } else {
      queue.add(sock);
      new Thread(new DynamicMultiSessionTask(ss, queue)).start();
      }
      } catch (IOException exc) {
      exc.printStackTrace();
      }
      if (ss.isClosed()) {
      break; // for (;;)
      }
      } // catch    
      }
     
      public synchronized void stopRequest() {
      noStopRequested = false;
      //internalThread.interrupt();
      if (ss != null) {
      try {
      ss.close();
      } catch (IOException x) {
      // ignore
      } finally {
      ss = null;
      }
      }
      }
     
      public boolean isAlive() {
      return internalThread.isAlive();
      }
     
      public static void main(String[] args) {
      try {
      BlockingQueue<Socket> bq = new ArrayBlockingQueue<>(40);
      Server serv = new Server(bq);
      } catch (IOException ex) {

    Мега-сервер
    https://wasm.in/threads/skorost-obrabotki-klientov-v-servere-na-dzhava.32423/#post-395115

    SadKo, 15 Декабря 2017

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

    −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
    https://habrahabr.ru/company/mailru/blog/344696/
    
    Долбоёбы из "Mail.Ru", приобрётшие авторитет только благодаря тому, что их сайтик случайно стал одним из самых популярных, учат жизни:
    
    >>> НЕ ДЕЛАЙТЕ ТАК:
    >>> 
    >>> /* Небезопасный код: */
    >>> $query = $pdo->query("SELECT * FROM users WHERE username = '" . $_GET['username'] . "'");
    >>> 
    >>> Делайте так:
    >>> 
    >>> /* Защищено от SQL-внедрений: */
    >>> $results = $easydb->row("SELECT * FROM users WHERE username = ?", $_GET['username']);
    
    Будто переменную в первом варианте запроса нельзя пропустить через "mysql_real_escape_string" или иную экранирующую функцию.
    Зато в итоге запрос остаётся очевидным, без даунских высчитываний вида "каким по счёту является значение поля и какой по счёту вопросительный знак ему соответствует". Тьфу, блядь...

    COWuTEJIbTBOEuMAMKu, 15 Декабря 2017

    Комментарии (45)
  5. bash / Говнокод #23589

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    #!/bin/sh
    while true; do
        date "+Time is %H %M. Stop lurking and get the fuck to work" | say
        sleep 1800
    done

    Я наконец нашёл применение встроенному в OS X TTS-движку.

    CHayT, 15 Декабря 2017

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

    0

    1. 1
    http://shitcode.net/

    У говнокода появился конкурент

    j123123, 15 Декабря 2017

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

    0

    1. 1
    2. 2
    Хуй, пизда, противогаз,
    Конь, бобёр и дикобраз.

    COWuTEJIbTBOEuMAMKu, 14 Декабря 2017

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

    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
    import java.awt.event.*;
    import javax.swing.*;
    
    public class Experiment implements ActionListener{
        JFrame frame;
        JButton button;
    
        public static void main(String[] args) {
            Experiment experiment = new Experiment();
            experiment.go();
        }
    
        public void go(){
            frame = new JFrame();
            button = new JButton("You is winner!");
    
            button.addActionListener(this);
    
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(button);
            frame.setSize(400, 400);
            frame.setVisible(true);
        }
        public void actionPerformed(ActionEvent event){
            button.setText("You is loser!");
            frame.setSize(700, 700);
        }
    }

    GUI, Создание кнопки и ее изменение, а также изменение фрейма!!! ОЦЕНИТЕ КОД!

    babushkaAntona, 14 Декабря 2017

    Комментарии (0)
  9. PHP / Говнокод #23585

    +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
    function TL($a) 
    {
        $tkk = explode('.', TKK());
        $b = $tkk[0];
    
        for($d = array(), $e = 0, $f = 0; $f < mb_strlen ( $a, 'UTF-8' ); $f ++) {
            $g = charCodeAt ( $a, $f );
            if (128 > $g) {
                $d [$e ++] = $g;
            } else {
                if (2048 > $g) {
                    $d [$e ++] = $g >> 6 | 192;
                } else {
                    if (55296 == ($g & 64512) && $f + 1 < mb_strlen ( $a, 'UTF-8' ) && 56320 == (charCodeAt ( $a, $f + 1 ) & 64512)) {
                        $g = 65536 + (($g & 1023) << 10) + (charCodeAt ( $a, ++ $f ) & 1023);
                        $d [$e ++] = $g >> 18 | 240;
                        $d [$e ++] = $g >> 12 & 63 | 128;
                    } else {
                        $d [$e ++] = $g >> 12 | 224;
                        $d [$e ++] = $g >> 6 & 63 | 128;
                    }
                }
                $d [$e ++] = $g & 63 | 128;
            }
        }
        $a = $b;
        for($e = 0; $e < count ( $d ); $e ++) {
            $a += $d [$e];
            $a = RL ( $a, '+-a^+6' );
        }
        $a = RL ( $a, "+-3^+b+-f" );
        $a ^= $tkk[1];
        if (0 > $a) {
            $a = ($a & 2147483647) + 2147483648;
        }
        $a = fmod ( $a, pow ( 10, 6 ) );
        return $a . "." . ($a ^ $b);
    }
    
    function translate($sl, $tl, $q)
    {
        $tk = TL($q);
        $q = urlencode(stripslashes($q));
    
        $url = "https://translate.google.com/translate_a/t?client=webapp&sl=".$sl."&tl=".$tl."&hl=".$tl."&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1&tk=". $tk ."&q=" . $q;
    
        $output = json_decode(file_get_contents($url));
    
        return str_replace('"', '', $output);
    }

    Локализация из одного индусского проекта за 50$

    Undefined_one, 14 Декабря 2017

    Комментарии (0)
  10. Python / Говнокод #23584

    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
    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
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    import tkinter
    import random
    
    # constants
    WIDTH = 540
    HEIGHT = 480
    BG_COLOR = 'white'
    MAIN_BALL_COLOR = 'blue'
    MAIN_BALL_RADIUS = 25
    COLORS = ['aqua', 'fuchsia', 'pink', 'yellow', 'gold', 'chartreuse']
    NUM_OF_BALLS = 9
    MAX_RADIUS = 35
    MIN_RADIUS = 15
    DELAY = 8
    INIT_DX = 1
    INIT_DY = 1
    ZERO = 0
    
    # ball class
    class Ball():
        def __init__(self, x, y, r, color, dx=0, dy=0):
            self.x = x
            self.y = y
            self.r = r
            self.color = color
            self.dx = dx
            self.dy = dy
    
        def draw(self):
            canvas.create_oval(self.x - self.r, self.y - self.r, self.x + self.r, self.y + self.r, fill=self.color,
                               outline=self.color)
    
        def hide(self):
            canvas.create_oval(self.x - self.r, self.y - self.r, self.x + self.r, self.y + self.r, fill=BG_COLOR,
                               outline=BG_COLOR)
    
        def is_collision(self, ball):
            a = abs(self.x + self.dx - ball.x)
            b = abs(self.y + self.dy - ball.y)
            return (a * a + b * b) ** 0.5 <= self.r + ball.r
    
        def move(self):
            # collision with the walls
            if (self.x + self.r + self.dx >= WIDTH) or (self.x - self.r + self.dx <= ZERO):
                self.dx = -self.dx
            if (self.y + self.r + self.dy >= HEIGHT) or (self.y - self.r + self.dy <= ZERO):
                self.dy = -self.dy
    
            self.hide()
            self.x += self.dx
            self.y += self.dy
            if self.dx * self.dy != 0:
                self.draw()
    
    # process the mouse events
    def mouse_click(event):
        global main_ball
        if event.num == 1:  # left mouse button
            if 'main_ball' not in globals():  # старт
                main_ball = Ball(event.x, event.y, MAIN_BALL_RADIUS, MAIN_BALL_COLOR, INIT_DX, INIT_DY)
                if main_ball.x > WIDTH / 2:
                    main_ball.dx = -main_ball.dx
                if main_ball.y > HEIGHT / 2:
                    main_ball.dy = -main_ball.dy
                main_ball.draw()
    
    # create a list of objects-balls
    def create_list_of_balls(number):
        lst = []
        return lst
    
    # games main loop
    def main():
        if 'main_ball' in globals():
            main_ball.move()
        root.after(DELAY, main)
    
    # create a window, the canvas and start game
    root = tkinter.Tk()
    root.title("Colliding Balls")
    canvas = tkinter.Canvas(root, width=WIDTH, height=HEIGHT, bg=BG_COLOR)
    canvas.pack()
    canvas.bind('<Button-1>', mouse_click)
    canvas.bind('<Button-2>', mouse_click, '+')
    canvas.bind('<Button-3>', mouse_click, '+')
    balls = create_list_of_balls(NUM_OF_BALLS)
    if 'main_ball' in globals():  # for restarts
        del main_ball
    main()
    root.mainloop()

    Quatrix, 14 Декабря 2017

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