1. Куча / Говнокод #8859

    +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
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    body {
      background-image: url("linux.jpg");
      background-color: yellow;
      /*background-repeat: no-repeat;*/
      background-position: 25% 25%;
      background-attachment: fixed !important;
      color: #FF0000;
      font-family: Arial,"New Arial",fantasy;
      font-style: normal;
    }
    
    p  {
      color: #000000;
      font-family: Arial;
      font-style: normal;
    }
    
    a {
      color: #ff0000;
    
    }
    
    table, textarea:focus, input:focus {
      outline-style: double;
      outline-color: #17f400;
      outline-size: 3px;
    
    }

    CSS from my site.

    AliceGoth, 17 Декабря 2011

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

    +171

    1. 1
    $link = mysql_connect("$DBSERVER", "$DBUSER", "$DBPASS","$DB_COLLATE");

    Гениально

    LiteError, 17 Декабря 2011

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

    +159

    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
    //так было до
    <?php
        // дневной/ночной фон
        $now=date("G");
        if (($now > 8) and ($now<21))
            {echo "странице задаётся дневной фон";}
        else
    	{echo "странице задаётся ночной фон";}
    
        //время на сервере	        
        echo date("Время на сервере H:i");
    
        //Выводятся знаменательные события в истории за этот день (ps: просто из папки events берётся фйл с названием $today
        $today=date("d_M");
        $event=file("event/$today");
        $line=count($event);
        echo "<center>",$event[rand(0,$line-1)],"</center>";
        $mon=explode("_",$today);
        $rus=array("Dec"=>"декабря");
        echo "<a href=\"http://ru.wikipedia.org/wiki/",$mon[0],"_",$rus[$mon[1]]>Подробнее о этом дне в Истории</a>";
    
        //история посещений
        $ip=$_SERVER['REMOTE_ADDR']." | ".date("d M H:i:s")."\n";
    ?>
    
    //так стало после
    <?php
        // дневной/ночной фон
        $now=date("d_M_G:i:s");
        $time=explode("_",$now);
        $hour=explode(":",$time[2]);
        if (($hour[0] > 8) and ($hour[0]<21))
            {echo "странице задаётся дневной фон";}
        else
            {echo "странице задаётся ночной фон";}
    
        //время на сервере
        echo "Время на сервере ",$hour[0],":",$hour[1];
    
        //Выводятся знаменательные события в истории за этот день (ps: просто из папки events берётся фйл с названием $today
        $today=$time[0]." ".$time[1];
        $event=file("event/$today");
        $line=count($event);
        echo "<center>",$event[rand(0,$line-1)],"</center>";
        $rus=array("Dec"=>"декабря");
        echo "<a href=\"http://ru.wikipedia.org/wiki/",$time[0],"_",$rus[$time[1]]>Подробнее о этом дне в Истории</a>"; 
    
        //история посещений
        $ip=$_SERVER['REMOTE_ADDR']." | ".$now."\n";
    ?>

    Так сказать попытка оптимизировать код. Был первый вариант, где функция date использовалась 4 раза с разными параметрами.
    Ну и я решил свести всё к одной date... уж и не знаю... был ли смысл) быстрее ли от этого всё будет работать...))

    Vladis_s, 17 Декабря 2011

    Комментарии (4)
  4. JavaScript / Говнокод #8856

    +157

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function profilesFormat(cellvalue,options,rowObject){
        //newValue = '<a href="/profiles?name='+encodeURIComponent(cellvalue)+'">'+cellvalue+'</a>';
        //return newValue
        return cellvalue
    }
    function clientFormat(cellvalue,options,rowObject){
        //newValue = '<a href="/clients?name='+encodeURIComponent(cellvalue)+'">'+cellvalue+'</a>';
        //return newValue
        return cellvalue
    }

    JqGrid, это для каждой строки которых в таблицах проекта тысячи.

    Afftamat, 17 Декабря 2011

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

    +159

    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
    <?php
    $lst=array();
    $ip_list="http://netelis.hmsite.net/loc.txt";
    $list_ip = file_get_contents($ip_list);
    if($list_ip==FALSE){ printf("Can't open file<br>\n");exit(1);}
    preg_match_all("|(?:[1-9][0-9]{0,2})\.(?:\d{1,3})\.(?:\d{1,3})\.(?:\d{1,3})|",$list_ip,$ipl);
    $i=0;
    foreach($ipl[0] as $address){
            $lst[$i++]=$address;
            $lst[$i-1].="<br />";
    }
    $lst=array_unique($lst);
    printf("Max element %d<br>\n",sizeof($lst));
    $slst=natsort($lst);
    print_r($lst);
    ?>

    Извлекает список IP-адресов, сортирует и удаляет повторяющиеся

    AliceGoth, 17 Декабря 2011

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

    +146

    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
    class Car<T>{
        public T type;
        public String name;
        public int speed;
        public double price;
        private Car cr;
        public Car(Car cr){ this.cr=cr;}
        public Car(){ this.cr=new Car<T>(this);}
        public String toString(){
            return "type "+type+" name "+name;
        }
        public T toStringCar(){
            return (T) this.cr.toString();
        }
        public void printing(){
            Car cr1=this.cr;
            for(;;){
               cr1=cr1.cr;
               System.out.println(cr1);
               
            }
        }
    }
    public class HoldA<T> {
        private Car cr;
        public static void main(String[] str){
            HoldA<Car> c1=new HoldA<Car>(new Car<Double>());
            Tag ht1=HTML.getTag(null);
        }
    
        private HoldA(T car) {
            cr=(Car) car;
            cr.name="fluffy";
            cr.type=45.43;
            System.out.println(cr);
            System.out.println(cr.toStringCar());
            cr.printing();
        }
    }

    Просто так, код

    AliceGoth, 17 Декабря 2011

    Комментарии (0)
  7. C++ / Говнокод #8853

    +997

    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
    Can you think of an algorithm that performs the below:
    “The Big Brown Fox”    	     => “Fox Brown Big The”
    “How are you?”                 => “you? are How”
    
    std::string reverse_words( const std::string& str )
    {
      std::string result;
      result.reserve( str.length() );
      
      size_t word_begin = 0;
      while( word_begin < str.length() )
      {
        const size_t pos = str.find_first_of( ' ', word_begin );
        pos = (pos != string::npos) ? pos : str.length();
        std::string word = str.substr( word_begin, pos-word_begin );
        word_begin = pos + 1;
    
        if (result.length() > 0)
        {
          word.append( 1, ' ');
        }
        result.insert( 0, word );
      }
      return result;
    }

    высрал буквально 5 минут назад
    inplace версию чего-то влом писать для домашнего теста, да и кода в ней будет больше, но работать она должна быстрее за счет отсутствия аллокаций
    но писать надо, так как отправлять такое как-то стыдно

    pushkoff, 17 Декабря 2011

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

    +166

    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
    /*** The following methods are NOT functional
    	        They're just there to detect coding errors at compilation time ***/
    	    inline KgeRGBAVector operator + (const KgeRGBAVector &/*pVector*/) const {KgeRGBAVector lNullVector; return lNullVector;}
            inline KgeRGBAVector operator - (const KgeRGBAVector &/*pVector*/) const {KgeRGBAVector lNullVector; return lNullVector;}
            inline KgeRGBAVector operator * (const KgeRGBAVector &/*pVector*/) const {KgeRGBAVector lNullVector; return lNullVector;}
            inline double  operator ^ (const KgeRGBAVector &/*pVector*/) const {return 0.0;}
            inline KgeRGBAVector &operator += (const KgeRGBAVector &/*pVector*/) {return *this;}
            inline KgeRGBAVector &operator -= (const KgeRGBAVector &/*pVector*/) {return *this;}
            inline KgeRGBAVector &operator *= (const KgeRGBAVector &/*pVector*/) {return *this;}
    
            inline KgeRGBAVector operator * (double /*pScalar*/) const {KgeRGBAVector lNullVector; return lNullVector;}
            inline KgeRGBAVector operator / (double /*pScalar*/) const {KgeRGBAVector lNullVector; return lNullVector;}
            inline KgeRGBAVector &operator *= (double /*pScalar*/) {return *this;}
            inline KgeRGBAVector &operator /= (double /*pScalar*/) {return *this;}

    Говнокод или гениально? Дискас.

    makc3d, 17 Декабря 2011

    Комментарии (9)
  9. JavaScript / Говнокод #8851

    +163

    1. 1
    $('.eTag').attr('href',$('.eTag').attr('href').replace('/search/','/searchq?='));

    http://usite.su/forum/3-1806-18538-16-1324092570

    substr, 17 Декабря 2011

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

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php /*
    host=localhost
    db_name=db
    user=db_user
    password=db_pass
    charset=utf8
    */ ?>

    Совершенно гениальный и единственно верный способ хранить конфиги в PHP.
    Имя файла тоже, должно быть именно таким - db.ini.php

    Starkua, 16 Декабря 2011

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