1. C++ / Говнокод #16737

    +64

    1. 1
    2. 2
    3. 3
    4. 4
    void GetVoid()
    {
    	return delete &"Возвращаем void";
    };

    Функция для получения void.

    maxillion, 21 Сентября 2014

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

    +73

    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
    String getFindList(StringBuffer sb, String[] src) {
    // int tid = Helper.parseType(src[2]);
    // if(tid < 1 || tid > 99) return "Error parse good type";
    int stk = Helper.parseType(src[3]);
    if(stk < 412 || stk > 416)	return "Error parse stock code";
    // --------------------------------------------------------
    IntHashtable work = new IntHashtable();
    double[] vals = null;
    Entry ent = null;
    Enumeration e=cache.getEntryElements();
    while(e.hasMoreElements()) {
    ent = (Entry)e.nextElement();
    if(ent.Credit != stk)	continue;
    if(ent.Status == 0)	continue;
    vals = (double[])work.get(ent.SubCred);
    if(vals == null) {
    vals = new double[2];
    vals[0] = ent.Value;
    work.put(ent.SubCred, vals);
    } else
    vals[0]+=ent.Value;
    }
    // ---------------------------------------------------------
    String s="SELECT  ... ";
    int id;
    String cod, gnm, uni;
    double amt,val,pack,vlr;
    double[] prcs = new double[4];
    Connection con = cache.getConnection();
    if(con == null)	return "No free conection";
    try {
    Statement stmt = con.createStatement();
    ResultSet rset = stmt.executeQuery(s);
    while(rset.next()) {
    id = rset.getInt("id");
    cod = rset.getString("code");
    gnm = rset.getString("name");
    uni = rset.getString("unit");
    pack = rset.getDouble("pack");
    amt = rset.getDouble("amount");
    val = rset.getDouble("value");
    prcs[0] = rset.getDouble("price");
    prcs[1] = rset.getDouble("price1");
    prcs[1]=(prcs[1] < 0.01) ? prcs[0] : prcs[1];
    prcs[2] = rset.getDouble("price2");
    prcs[2]=(prcs[2] < 0.01) ? prcs[1] : prcs[2];
    prcs[3] = rset.getDouble("sprice");
    prcs[3]=(prcs[3] < 0.01) ? prcs[2] : prcs[3];
    vals = (double[])work.get(id);
    vlr =(vals == null) ? 0 : vals[0];
    sb.append(id+",'"+gnm+"','"+cod+"','"+uni+"',"+pack+","+val+","+vlr+",");
    for(int i=0; i<prcs.length; i++)	sb.append(prcs[i]+",");
    sb.append((amt/val)+",\n");
    }
    rset.close();
    stmt.close();
    s = null;
    } catch (SQLException ex) {
    s=ex.getMessage();
    }
    cache.freeConnection(con);
    return s;
    }

    qw0, 21 Сентября 2014

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

    +127

    1. 1
    https://www.marshut.net/knqkut/dijkstra-s-methodology-for-secure-systems-development.html

    Учитесь троллить! (Я подписался на рассылку запостить пару багов, а тут...)

    wvxvw, 20 Сентября 2014

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

    +136

    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
    class Program
        {        
            class A
            {
    
                //-----------------------------------------------------------------------
                public static A CurrentRoot;
                public static Dictionary<object, A> RootMap = new Dictionary<object, A>();
                public static object Lock = new object();
                //-----------------------------------------------------------------------
    
                public int Test;
    
                public A()
                {
                    lock (Lock)
                    {
                        CurrentRoot = this; 
                        b = new B();
                    }   
                }   
                internal class B
                {
                    public B() { RootMap.Add(this, CurrentRoot); }
    
                    public A root { get { return RootMap[this]; } }                
    
                    ~B() { RootMap.Remove(this); }                
                }
                public B b;
            }
         
            static void Main(string[] args)
            {
    
                A a1 = new A(); a1.Test = 555;
                A a2 = new A(); a2.Test = 888;
    
                Console.WriteLine(a1.b.root.Test); Console.WriteLine(a1.Test);
                Console.WriteLine(a2.b.root.Test); Console.WriteLine(a2.Test);
    
    
                Console.WriteLine(a1.b.root.b.root.b.root.b.root.b.root.Test);
            }

    Класс создан для того чтобы вложенные структуры имели доступ к структуре родителя. Safe thread support.

    maxillion, 20 Сентября 2014

    Комментарии (33)
  5. PHP / Говнокод #16733

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    class this {
    
    public function this()
        {
    	  $this->this[$this] !==  $this->this();
       }
    }

    zadrot, 20 Сентября 2014

    Комментарии (26)
  6. C# / Говнокод #16732

    +135

    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
    private void button1_Click(object sender, EventArgs e)
            {
                if (comboBox1.Text == "Випадково")
                {
                   LoadMatrixRand(masP, dataGridView1);
                }
    
                if (comboBox1.Text == "Повна")
                {
                    LoadMatrixFull(masP, dataGridView1);
                }
    
                if (comboBox1.Text == "Пуста")
                {
                    LoadMatrixZero(masP, dataGridView1);
                }
    
                if (comboBox1.Text == "Діагональна")
                {
                    LoadMatrixDiagonal(masP, dataGridView1);
                }
    
                if (comboBox1.Text == "Антидіагональна")
                {
                    LoadMatrixAntiDiagonal(masP, dataGridView1);
                }
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                if (comboBox2.Text == "Випадково")
                {
                    LoadMatrixRand(masQ, dataGridView2);
                }
    
                if (comboBox2.Text == "Повна")
                {
                    LoadMatrixFull(masQ, dataGridView2);
                }
    
                if (comboBox2.Text == "Пуста")
                {
                    LoadMatrixZero(masQ, dataGridView2);
                }
    
                if (comboBox2.Text == "Діагональна")
                {
                    LoadMatrixDiagonal(masQ, dataGridView2);
                }
    
                if (comboBox2.Text == "Антидіагональна")
                {
                    LoadMatrixAntiDiagonal(masQ, dataGridView2);
                }
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                if (comboBox3.Text == "Випадково")
                {
                    LoadMatrixRand(masR, dataGridView3);
                }
    
                if (comboBox3.Text == "Повна")
                {
                    LoadMatrixFull(masR, dataGridView3);
                }
    
                if (comboBox3.Text == "Пуста")
                {
                    LoadMatrixZero(masR, dataGridView3);
                }
    
                if (comboBox3.Text == "Діагональна")
                {
                    LoadMatrixDiagonal(masR, dataGridView3);
                }
    
                if (comboBox3.Text == "Антидіагональна")
                {
                    LoadMatrixAntiDiagonal(masR, dataGridView3);
                }
            }

    shitty life as my code

    Nutell_a, 19 Сентября 2014

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (is_array($checked_groups)) {
        if (in_array($group['manager_group_id'], $checked_groups)) {
            $managers = $managerTelephone->getRingsReport($mode_report['report1']['manager_ids'], $date_begin, $current_date, $group['manager_group_id']);
        }
    } else {
        $managers = $managerTelephone->getRingsReport($mode_report['report1']['manager_ids'], $date_begin, $current_date, $group['manager_group_id']);
    }

    из той же серии

    howard, 19 Сентября 2014

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if(isset($r['email'])){
    	?>
    	{
    		"email": "<?=$r['email']?>",
    		"group": "<?=$r['usr_group']?>"
    	}
    	<?php
    mysql_query("DELETE FROM `usr_key` WHERE `key`='".addslashes($_GET['key'])."' LIMIT 1 ");
    }

    Отличный способ собирать JSON, это лишь один экшен из целого сервиса API...

    aspirin, 19 Сентября 2014

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (!empty($params['manager_select'])) {
                $rings = $phone_manager->getManagerRings($manager_id, $dateBegin, $dateEnd, $params['is_incoming_select'], $is_marked, $select_all_rings, $params, $managers_groups_arr, $only_not_effected, $order_params, $find_phone_number);
            } else {
                $rings = $phone_manager->getManagerRings($manager_id, $dateBegin, $dateEnd, $params['is_incoming_select'], $is_marked, $select_all_rings, NULL, $managers_groups_arr, $only_not_effected, $order_params, $find_phone_number);
            }

    Шик! Убил бы за такое

    howard, 19 Сентября 2014

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

    +64

    1. 1
    delete new T;

    убийство новорожденного

    absolut, 19 Сентября 2014

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