1. PHP / Говнокод #6788

    +163

    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
    /**
       * Get or instance self object
       *
       * @return self object
       */
      public static function get_object () {
        // call as static
        static $storage;
        // check inited object
        if ( !isset($storage) ) {
          // init object
          $storage = new self();
        }
        // return object
        return is_object($storage) ? $storage : false;
      }

    NetCat не перестает удивлять.
    Вы только посмотрите на последнюю строчку метода
    :D

    miraage, 30 Мая 2011

    Комментарии (13)
  2. Куча / Говнокод #6787

    +125

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    var f,i:Integer;
    begin
    for i:=1 to 100 do
    for i:=100 downto 1 do
    writeln('I=',i);
    end.

    "ПОЧЕМУ ЭТА ТВАР СЧИТАЕТ ТОЛЬКО В 1 СТОРОНУ?!"

    grouch, 30 Мая 2011

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $sql1 = '(';
    ........
    if(!is_array($sql1))
    {
    	$sql1 = array();
    }

    А вдруг? Переменные иногда сами превращаются в массивы ...

    _tL, 30 Мая 2011

    Комментарии (11)
  4. PHP / Говнокод #6785

    +165

    1. 1
    2. 2
    return $result_rows;
    mysql_close($external_db);

    Ring, 30 Мая 2011

    Комментарии (5)
  5. Java / Говнокод #6784

    +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
    public synchronized static void reload() 
    	{
            synchronized (properties) 
    		{
                synchronized (questRewardRates)
    			{
                    synchronized (questDropRates)
    				{
                        properties = new ConcurrentHashMap<String, String>();
                        questRewardRates = new ConcurrentHashMap<Integer, Float>();
                        questDropRates = new ConcurrentHashMap<Integer, Float>();
                        load();
                    }
                }
            }
        }

    Я просто оставлю это здесь (c)

    VirtualVoid, 30 Мая 2011

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

    +115

    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
    private object[] select ( string tablename, Type type, string addict ) 
            {
                object[] returned_objects = new object[0];
                string sql = "SELECT ";
                sql += this.buildFieldNames( type );
                sql += " FROM `" + tablename + "`" + addict;
                MySqlDataReader reader = this.TryQueryReader( sql );
                while (reader.Read( ))
                {
                    var obj = Activator.CreateInstance( type );
                    FieldInfo[] fields = type.GetFields( );
                    foreach (FieldInfo finfo in fields)
                    {
                        if (finfo.FieldType == typeof( int ))
                        {
                            finfo.SetValue( obj, reader.GetInt32( finfo.Name ) );
                        }
                        else if (finfo.FieldType == typeof( bool ))
                        {
                            if (reader.GetString( finfo.Name ).Equals( "true" ))
                            {
                                finfo.SetValue( obj, true );
                            }
                            else
                            {
                                finfo.SetValue( obj, false );
                            }
                        }
                        else if (finfo.FieldType == typeof( float ))
                        {
                            finfo.SetValue( obj, reader.GetFloat( finfo.Name ) );
                        }
                        else if (finfo.FieldType == typeof( double ))
                        {
                            finfo.SetValue( obj, reader.GetDouble( finfo.Name ) );
                        }
                        else if (finfo.FieldType == typeof( string ))
                        {
                            finfo.SetValue( obj, reader.GetString( finfo.Name ) );
                        }
                    }
                    provider.IncreaseLength( ref returned_objects, 1 );
                    returned_objects.SetValue( obj, returned_objects.Length - 1 );
    
                }
                reader.Close( );
                return returned_objects;
            }

    самопальный орм, нот комментс

    glilya, 30 Мая 2011

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    //This is an optimization. We assume than no step can take more than one year.
      if($time_limit > 0)
       $end_time = time() + $time_limit;
      else
       $end_time = time() + 365*24*3600; // One year

    Источник: исходники битрикса, (/bitrix/modules/iblock/classes/general/cml2.php). Код используется при импорте из 1с.

    leonard, 30 Мая 2011

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

    +165

    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
    function func($microsoft,$corn)
    {
    	$tomato=array();
    	if(!isset($corn[$microsoft])) return NULL;
    	foreach($corn[$microsoft] as $potato=>$pizza)
    	{
    		$tomato[]=$pizza;
    		$wine=$this->func($microsoft.$pizza['name'].'/',$corn);
    		if($wine)
    			foreach($wine as $anchouses)
    				$tomato[]=$anchouses;
    	}
    	return $tomato; //Где мой тамат СУКА!
    }

    Функция выполняет рекурсивную сортировку масива по ассоциативному индексу.

    dvduser, 30 Мая 2011

    Комментарии (15)
  9. Куча / Говнокод #6780

    +124

    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
    ##### curl #####
    
    GET /api/4dabd7b3816......97 HTTP/1.1
    User-Agent: curl/7.21.0 (i686-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
    Host: deepbit.net
    Accept: */*
    
    HTTP/1.1 302 Found
    Cache-Control: no-cache
    Content-length: 0
    Location: /api/4dabd7b3816......97
    Set-Cookie: *********pRd; path=/;
    
    Connection: close
    
    ##### curl #####
    
    ##### wget #####
    
    GET /api/4dabd7b3816......97 HTTP/1.0
    User-Agent: Wget/1.12 (linux-gnu)
    Accept: */*
    Host: deepbit.net
    Connection: Keep-Alive
    
    HTTP/1.1 200 OK
    Server: nginx/1.0.0
    Date: Mon, 30 May 2011 06:45:14 GMT
    Content-Type: application/json; charset=utf-8
    Connection: keep-alive
    Cache-Control: no-cache, must-revalidate
    Last-Modified: Mon, 30 May 2011 06:45:14 GMT
    Expires: Mon, 30 May 2011 06:46:14 GMT
    Content-Length: 413
    
    {data data data}
    ##### wget #####

    Lis, 30 Мая 2011

    Комментарии (8)
  10. Куча / Говнокод #6779

    +135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <div id="pointer_div">jQuery16104518015997745993=Object { events={...}}
    <div style="display: block; background: url("http://localhost/first/coord_mouse_on_pic/3/cr.gif") repeat scroll 0% 0% transparent; position: relative; padding: 0px; width: 615px; height: 417px;">
    <map id="htmlmap_com_4" name="htmlmap_com_4">jQuery16104518015997745993=Object { events={...}}
    <div id="myCanvas" style="position: relative; margin: 0px; padding: 0px;"></div>
    <div style="position: absolute; left: 424px; top: 195px; width: 2px; height: 2px; clip: rect(0pt, 2px, 2px, 0pt); padding: 0px; margin: 0px; background-color: red; overflow: hidden; opacity: 0.8;"></div>
    <div style="position: absolute; left: 426px; top: 195px; width: 2px; height: 2px; clip: rect(0pt, 2px, 2px, 0pt); padding: 0px; margin: 0px; background-color: red; overflow: hidden; opacity: 0.8;"></div>
    <div style="position: absolute; left: 424px; top: 197px; width: 4px; height: 2px; clip: rect(0pt, 4px, 2px, 0pt); padding: 0px; margin: 0px; background-color: red; overflow: hidden; opacity: 0.8;"></div>
    <div style="position: absolute; left: 424px; top: 197px; width: 2px; height: 0px; clip: rect(0pt, 2px, 0px, 0pt); padding: 0px; margin: 0px; background-color: red; overflow: hidden; opacity: 0.8;"></div>
    </div>

    -

    vulkan, 29 Мая 2011

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