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

    +75

    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
    public static String ellipsizeText(String text, Context cnt) {
    		
    		int COUNT_OF_CHARACTERS_LDPI = 10;
    		int COUNT_OF_CHARACTERS_MDPI = 20;
    		int COUNT_OF_CHARACTERS_HDPI = 30;
    		
    		String ellipsizeT = "...";
    		
    		String newText = text;
    		
    		switch (cnt.getResources().getDisplayMetrics().densityDpi) {
    		case DisplayMetrics.DENSITY_LOW:
    		    if (text.length() > COUNT_OF_CHARACTERS_LDPI) {
    				newText = text.substring(0, COUNT_OF_CHARACTERS_LDPI) + ellipsizeT;
    			}
    		    break;
    		case DisplayMetrics.DENSITY_MEDIUM:
    		    if (text.length() > COUNT_OF_CHARACTERS_MDPI) {
    				newText = text.substring(0, COUNT_OF_CHARACTERS_MDPI) + ellipsizeT;
    			}
    		    break;
    		case DisplayMetrics.DENSITY_HIGH:
    		    if (text.length() > COUNT_OF_CHARACTERS_HDPI) {
    				newText = text.substring(0, COUNT_OF_CHARACTERS_HDPI) + ellipsizeT;
    			}
    		    break;
    		}
    		
    		return newText;		
    	}

    Android

    Таким нехитрым способом заменяется реализация стандартной процедуры TextView.setEllipsize(TextUtils.Truncate At.END);

    Saasha, 15 Июля 2011

    Комментарии (7)
  2. JavaScript / Говнокод #7256

    +172

    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
    <script language="JavaScript">
    
        document.write("<div class=\"rolover\">");
    
    document.write("<div id=\"photos\" class=\"galleryview\">");
    
      document.write("<div class=\"panel\">");
    
         document.write("<img class=\"gwu_image\" src=\"root/img/01.jpg\" /> ");
    
         document.write("<div class=\"panel-overlay-block\">");
    
         document.write("</div>");
    
        document.write("<div class=\"panel-overlay\">");
    
          document.write("<h2>Euro2012 in Donetsk...</h2>");
    
          document.write("<p>Donbass arena welcome guests...</a>.  More <a href=\"index.php?section_id=478\" target=\"_blank\">here</a>.</p>");
    
        document.write("</div>");
    
      document.write("</div>");
    
      document.write("<div class=\"panel\">");
    
         document.write("<img class=\"gwu_image\" src=\"root/img/02.jpg\" /> ");
    ....
       document.write("<li><img src=\"root/img/frame2-06.jpg\" alt=\"Slide\" title=\"Slide\" /></li>");
    
        document.write("<li><img src=\"root/img/frame2-05.jpg\" alt=\"Slide\" title=\"Slide\" /></li>");
    
        document.write("<li><img src=\"root/img/frame2-07.jpg\" alt=\"Slide\" title=\"Slide\" /></li>");
    
        document.write("<li><img src=\"root/img/frame2-08.jpg\" alt=\"Slide\" title=\"Slide\" /></li>");
    
      document.write("</ul>");
    
    document.write("</div>");
    
    document.write("</div>");
    
    
    и еще около 300 строк.

    Мега реализация галереи от неизвестного творца

    enemis, 15 Июля 2011

    Комментарии (22)
  3. JavaScript / Говнокод #7255

    +162

    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
    javascript:(function () {
    	var nodes = document.querySelectorAll( 'span.hidden-text' );
    	for ( var i = 0; i < nodes.length; i++ ) {
    		/* Opera suck at this
    		nodes[i].classList.remove( 'entry-comment-hidden' );
    		*/
    		var classList = nodes[i].parentNode.className.split( /\s+/ );
    		var index = classList.indexOf( 'entry-comment-hidden' );
    		if ( index != -1 ) {
    			classList.splice( index, 1 );
    		}
    		else {
    			classList.push( 'entry-comment-hidden' );
    		}
    		nodes[i].parentNode.className = classList.join( ' ' );
    	}
    })()

    Посвящается анону-полуёбку, который нашёл хаккирский скрипт.
    Олежка?

    bugmenot, 15 Июля 2011

    Комментарии (49)
  4. Java / Говнокод #7254

    +129

    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
    public static String forHTML(String aText){
         final StringBuilder result = new StringBuilder();
         final StringCharacterIterator iterator = new StringCharacterIterator(aText);
         char character =  iterator.current();
         while (character != CharacterIterator.DONE ){
           if (character == '<') {
             result.append("&lt;");
           }
           else if (character == '>') {
             result.append("&gt;");
           }
           else if (character == '&') {
             result.append("&amp;");
          }
           else if (character == '\"') {
             result.append("&quot;");
           }
           else if (character == '\t') {
             addCharEntity(9, result);
           }
           else if (character == '!') {
             addCharEntity(33, result);
           }
           else if (character == '#') {
             addCharEntity(35, result);
           }
           else if (character == '$') {
             addCharEntity(36, result);
           }
    ........................................
           else if (character == '|') {
             addCharEntity(124, result);
           }
           else if (character == '}') {
             addCharEntity(125, result);
           }
           else if (character == '~') {
             addCharEntity(126, result);
           }
           else {
             //the char is not a special one
             //add it to the result as is
             result.append(character);
           }
           character = iterator.next();
         }
         return result.toString();
      }

    Escape special characters for wiseguys.
    http://www.javapractices.com/topic/TopicAction.do?Id=96

    3.14159265, 15 Июля 2011

    Комментарии (8)
  5. Pascal / Говнокод #7253

    +94

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    var s:string;
    begin
    cs.Active:=true; //Коннектимся
    if cs.Socket.Connected=true then begin //Если подключились то
    memo1.lines.add('Соединение установленно...'); //пишим в memo
    end else //в противном случае пишим это
    memo1.lines.add('Соединение неустановленно...'); //<--вот это :)

    >теперь у формы в событии OnGreate пишим
    Это капец....
    http://forum.hackforce.ru/thread1685.html#post405879

    Govnocoder#0xFF, 15 Июля 2011

    Комментарии (22)
  6. SQL / Говнокод #7252

    −859

    1. 1
    2. 2
    3. 3
    4. 4
    SELECT 
    	InstanceID, 
    	DisplayValue AS VidDocValue 
    FROM [dvtable_{D25F1089-C63D-43E1-9FA4-864C48EECCB4}] AS [dvtable_{D25F1089-C63D-43E1-9FA4-864C48EECCB4}_1]

    HellMaster_HaiL, 15 Июля 2011

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

    +39

    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
    /// <summary>
        /// Год
        /// </summary>
        public class Year
        {
            ///<summary>
            /// Конструктор
            ///</summary>
            ///<param name="year">Год</param>
            public Year(int year)
            {
                Value = year;
            }
    
            /// <summary>
            /// Значение
            /// </summary>
            public int Value { get; set; }
        }

    qsmart, 15 Июля 2011

    Комментарии (6)
  8. Pascal / Говнокод #7250

    +154

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    type
    число=ineger;
    плюс_число=word;
    эконом=shortint;
    плюс_эконом=byte;
    моар=longint;
    граммар=real;
    йцукен=char;
    йцуукеен=string;
    холивар=boolean;

    dos, 15 Июля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function calculateBaggageFields(selectedNormalOutboundOption, selectedNormalInboundOption,
    				numOriginalNormalBagsOutboundField, numOriginalNormalBagsInboundField,
    				numAdditionalBagsField, numAdditionalBagsOutboundField, numAdditionalBagsInboundField,
    				selectedOutsizeOutboundOption, selectedOutsizeInboundOption,
    				totalForThisPassengerField,
                                    selectedExcessKilosOutboundOption,selectedExcessKilosInboundOption,
                                    numOriginalExcessKilosOutboundField,numOriginalExcessKilosInboundField,
                                    numAdditionalExcessKilos,numAdditionalExcessKilosOutbound,numAdditionalExcessKilosInbound)

    продакшн-говно за работой!

    hrls, 14 Июля 2011

    Комментарии (16)
  10. Java / Говнокод #7248

    +71

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    String[] yesno = {"Y", "Yes", "N", "No"};
    
                for (int ii = 0; ii < yesno.length; ii += 2) {
                    String[] data = new String[2];
                    data[0] = yesno[ii];
                    data[1] = yesno[ii + 1];
                    Globals.yes_no.add(data);
                }

    euee, 14 Июля 2011

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