1. Java / Говнокод #8513

    +71

    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
    public class AuthorizedUserObservervable implements Runnable {
    
        private long sleepTime = 1000;
        private HashMap<AuthorizedUserObserver, HashMap<AuthorizedUser, Integer>> observers = new HashMap<AuthorizedUserObserver, HashMap<AuthorizedUser, Integer>>();
        
        
        private void setSleepTime(long sleepTime) {
            this.sleepTime = sleepTime;
        }
        
        
        public void add(AuthorizedUserObserver auo) {
            HashMap<AuthorizedUser, Integer> userCache = new HashMap<AuthorizedUser, Integer>();
            for (AuthorizedUser user : auo.getUsers()) {
                userCache.put(user, null);
            }
            observers.put(auo, userCache);
        }
    
        public void beginObservation() {
            new Thread(this).start();
        }
    
        @Override
        public void run() {
            while (true) {
                try {
                    for (Map.Entry<AuthorizedUserObserver, HashMap<AuthorizedUser, Integer>> observer : observers.entrySet()) {
                        for (Map.Entry<AuthorizedUser, Integer> user : observer.getValue().entrySet()) {
                            int newPostsCount = user.getKey().getNewPostsCount();
                            if (user.getValue() == null || newPostsCount != user.getValue()) {
                                HashMap<AuthorizedUser, Integer> userCache = new HashMap<AuthorizedUser, Integer>();
                                userCache.put(user.getKey(), newPostsCount);
                                observers.put(observer.getKey(), userCache);
                                observer.getKey().notify(user.getKey(), newPostsCount);
                            }
                        }
                    }
    
    
                    Thread.sleep(sleepTime);
                } catch (InterruptedException ex) {
                    Logger.getLogger(UserObservervable.class.getName()).log(Level.SEVERE, null, ex);
                } catch (AuthenticationException e) {
                    Thread.currentThread().stop(e);
                }
            }
        }
    }

    Чего стоит гибкость.

    manyrus, 13 Ноября 2011

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

    +125

    1. 1
    ++[>+++++[>++++++<-]<-]++[>+++++<-]>>+++<<+[[,----------]>>.<.<+]

    ed на brainfuck'е

    rat4, 13 Ноября 2011

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

    +131

    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
    string[] strArray1 = new string[6];
              string[] strArray2 = strArray1;
              int index1 = 0;
              DateTime now = DateTime.Now;
              string str1 = now.Month.ToString();
              strArray2[index1] = str1;
              string[] strArray3 = strArray1;
              int index2 = 1;
              now = DateTime.Now;
              string str2 = now.Day.ToString();
              strArray3[index2] = str2;
              string[] strArray4 = strArray1;
              int index3 = 2;
              now = DateTime.Now;
              string str3 = now.Year.ToString();
              strArray4[index3] = str3;
              string[] strArray5 = strArray1;
              int index4 = 3;
              now = DateTime.Now;
              string str4 = now.Hour.ToString();
              strArray5[index4] = str4;
              string[] strArray6 = strArray1;
              int index5 = 4;
              now = DateTime.Now;
              string str5 = now.Minute.ToString();
              strArray6[index5] = str5;
              string[] strArray7 = strArray1;
              int index6 = 5;
              now = DateTime.Now;
              string str6 = now.Second.ToString();
              strArray7[index6] = str6;
              Program.zipName = string.Concat(strArray1);

    jabacrack, 13 Ноября 2011

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

    +133

    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
    public static string FristChar(this string input)
        {
            if (!string.IsNullOrEmpty(input))
            {
                if (input.Length >= 1)
                {
                    return input.Substring(0, 1);
                }
                else
                {
                    return input;
                }
            }
            else
            {
                return null;
            }
        }

    http://www.extensionmethod.net/Details.aspx?ID=170

    Author: Mehrdad Ghasemi

    Killster, 13 Ноября 2011

    Комментарии (31)
  5. C++ / Говнокод #8509

    +1000

    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
    int *element_iskomoi_posledovatelnosti;
     int tempNum = 1;
    element_iskomoi_posledovatelnosti = new int [maxim];
       
        int k=index_pervogo_elementa_posledovatelnosti;
        element_iskomoi_posledovatelnosti[0]=arr[k];
        printf(" element_iskomoi_posledovatelnosti[%i]=%i\n ",1, element_iskomoi_posledovatelnosti[0]);
     
        for (int j=index_pervogo_elementa_posledovatelnosti; j< n ; j++ )
        if (arr[k]<arr[j]) 
        {
           element_iskomoi_posledovatelnosti[tempNum]=arr[j];
           printf(" element_iskomoi_posledovatelnosti[%i]=%i\n ",tempNum+1, element_iskomoi_posledovatelnosti[tempNum++]);
           k=j;
         }
    }

    Crazy_penguin, 13 Ноября 2011

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

    +150

    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
    <?php
    class sql extends sleshs{
    	//Выборка из баззы
    	//Напоминалочка
    	//$select =Што ищим \\//$from= Где ищим\\//$where=Где именно\\//$param = Допалнительные параметры
    	function select($select,$from,$where=NULL,$param=NULL){
    		$myrow = mysql_query("SELECT ".$select." FROM ".$from." ".$where." ".$param."");
    		if(!(mysql_error())){
    			if(mysql_num_rows($myrow)){
    				return $myrow;
    				}else{return FALSE;}}else{return FALSE;}
    		}
    		
    		
    	//Запись в базу
    	function update($from,$array,$where,$param=NULL){
    		//Формируем запрос и слэшируем
    		for($i=0,$col=count($array)-1;$i<=$col;$i++){
    			$zap .=",`".key($array[$i])."`='".$this->slesh($array[$i][key($array[$i])],$array[$i]['slesh'])."'";
    			}
    		//Удоляем лишнию запятую
    		$zap{0}=' ';
    		//Отпровляем запрос
    		if(mysql_query("UPDATE `".$from."` SET ".$zap." ".$where." ".$param."")){return true;}else{return false;}
    		}
    		
    		
    	//Добавление записи в бд	
    	function insert($from,$array){
    		//Формируем запрос
    		for($i=0,$col=count($array)-1;$i<=$col;$i++){
    			$into .=",`".key($array[$i])."`";
    			$value .=",'".$this->slesh($array[$i][key($array[$i])],$array[$i]['slesh'])."'";
    			
    		}
    		$into{0}=' ';
    		$value{0}=' ';
    		if(mysql_query("INSERT INTO `".$from."` (".$into.") VALUE (".$value.")")){echo'good';}else{echo mysql_query();}
    		}
    	
    	//Удаление
    	function delete($from,$where){return mysql_query("DELETE FROM `".$from."` ".$where."");}
    	}
    ?>

    oop mysql

    lans8097, 13 Ноября 2011

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

    +152

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $time=12843;
     
    echo $hours = floor($time/3600);
    echo '<br />';
    echo floor($minutes = ($time/3600 - $hours)*60);
    echo '<br />';
    echo $seconds = ceil(($minutes - floor($minutes))*60);

    Пых даты ...

    Sulik78, 13 Ноября 2011

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if ($row['num']) $rating = round(($row['rating'] /  $row['num']), 0); else $rating = 0;
     $rating = $rating;
    
     $rated = <<<HTML
    {$rating}
    HTML;
    
     return $rated;

    Увидел это чудо программистской мысли, когда приступал к выполнению заказа.

    blide, 13 Ноября 2011

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

    +146

    1. 1
    http://macton.smugmug.com/gallery/8936708_T6zQX#593426709_ZX4pZ

    AnimeGovno-_-, 13 Ноября 2011

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

    +152

    1. 1
    <form action="/orders/saveorder/?act=update&order=<?php echo $this->order['id'];?>&plan_id=<?php echo $this->treatment_plan['id'];?>&plan=<?php echo $this->treatment_plan['treatment_plan_number'];?>" method="post" name="formas" class="order_form">

    Говнокод "среднего программиста" - как он сам себя назвал

    SuperChel, 12 Ноября 2011

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