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

    +127

    1. 1
    https://www.peereboom.us/assl/assl/html/openssl.html

    laMer007, 22 Апреля 2014

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function commerce_auction_dividable($big, $small) {
      $div = $big / $small;
    
      if (!is_numeric(strpos($div, '.')) === TRUE) {
        return TRUE;
      }
      return FALSE;
    }

    https://drupal.org/node/1721568

    Int, 22 Апреля 2014

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

    +158

    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
    for (i in rates) {
       if (CheckFlightInRates(FlightStartRate, rates[i]['dirs'][0]['trips'][0]) == 2) {
          if (CheckFlightInRates(FlightSecondRate, rates[i]['dirs'][0]['trips'][1]) != 0) {
             //var flightNmSecond = rates[i]['dirs'][0]['trips'][1]['params']['airCmp']+'-'+rates[i]['dirs'][0]['trips'][1]['params']['fltNm'];
             if (CheckFlightInRates(FlightSecondRate, rates[i]['dirs'][0]['trips'][1]) == 2) {
                if (CheckFlightInRates(FlightThirdRate, rates[i]['dirs'][0]['trips'][2]) != 0) {
                   //var flightNmThird = rates[i]['dirs'][0]['trips'][2]['params']['airCmp']+'-'+rates[i]['dirs'][0]['trips'][2]['params']['fltNm'];
                   if (CheckFlightInRates(FlightThirdRate, rates[i]['dirs'][0]['trips'][2]) == 2) {
                      if (FlightBackStartRate != '') {
                         if (CheckFlightInRates(FlightBackStartRate, rates[i]['dirs'][1]['trips'][0]) == 2) {
                            if (CheckFlightInRates(FlightBackSecondRate, rates[i]['dirs'][1]['trips'][1]) != 0) {
                               //var flightNmSecond = rates[i]['dirs'][0]['trips'][1]['params']['airCmp']+'-'+rates[i]['dirs'][0]['trips'][1]['params']['fltNm'];
                               if (CheckFlightInRates(FlightBackSecondRate, rates[i]['dirs'][1]['trips'][1]) == 2) {
                                  if (CheckFlightInRates(FlightBackThirdRate, rates[i]['dirs'][1]['trips'][2]) != 0) {
                                     //var flightNmThird = rates[i]['dirs'][0]['trips'][2]['params']['airCmp']+'-'+rates[i]['dirs'][0]['trips'][2]['params']['fltNm'];
                                     if (CheckFlightInRates(FlightBackThirdRate, rates[i]['dirs'][1]['trips'][2]) == 2) {
                                        if (rates[i]['price'] != options.values.price) {
                                           FlightMinPrice3.push(rates[i]['price']);
                                           ButtonToPress3[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i
                                        }
                                        else {
                                           FlightMinPrice.push(rates[i]['price']);
                                           ButtonToPress[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i;
                                        }
                                     }
                                  }
                                  else {
                                     if (rates[i]['price'] != options.values.price) {
                                        FlightMinPrice3.push(rates[i]['price']);
                                        ButtonToPress3[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i
                                     }
                                     else {
    
                                        FlightMinPrice.push(rates[i]['price']);
                                        ButtonToPress[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i;
                                     }
                                  }
                               }
                            }
                            else {
                               if (rates[i]['price'] != options.values.price) {
                                  FlightMinPrice3.push(rates[i]['price']);
                                  ButtonToPress3[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i
                               }
                               else {
                                  FlightMinPrice.push(rates[i]['price']);
                                  ButtonToPress[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i
                               }
                            }
                         }
                         else {
                            if (rates[i]['price'] != options.values.price) {
                               FlightMinPrice3.push(rates[i]['price']);
                               ButtonToPress3[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i
                            }
                            else {
                               FlightMinPriceOther2.push(rates[i]['price']);
                               ButtonToPressOther2[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i;
                            }
                         }
                      }
                      else {
                         if (rates[i]['price'] != options.values.price) {
                            FlightMinPrice3.push(rates[i]['price']);
                            ButtonToPress3[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i
                         }
                         else {
                            FlightMinPrice.push(rates[i]['price']);
                            ButtonToPress[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i;
                         }
                      }
    
                   }

    https://www.svyaznoy.travel/avia/styles/js/Flight.js?cache=20140418-1
    весь русский онлайн-тревел такой

    tablecell, 22 Апреля 2014

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

    +153

    1. 1
    print implode('-', array_reverse(explode('-', trim(substr($project->start_date, 0, count($project->start_date) - 9)))));

    Форматирует дату с Y-m-d в d-m-Y. Альтернатива для
    date_format(new DateTime($project->start_date), 'd-m-Y');

    djumpen, 22 Апреля 2014

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

    +70

    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
    {
    	final int p = page;
    	final boolean current = p == 1;
    	this.pagercell(writer, current, 1, "<<");
    }
    for (int p = page - this.size; p < page; p++) {
    	if (p >= 1) {
    		final boolean current = p == 1;
    		this.pagercell(writer, current, p);
    	}
    }
    {
    	final int p = page;
    	final boolean current = (p - this.size) < 1;
    	this.pagercell(writer, current, p - this.size, "<");
    }
    {
    	final int p = page;
    	final boolean current = p == page;
    	this.pagercell(writer, current, p);
    }
    {
    	final int p = page;
    	final boolean current = (p + this.size) > pages;
    	this.pagercell(writer, current, p + this.size, ">");
    }
    for (int p = page + 1; p <= (page + this.size); p++) {
    	if (p <= pages) {
    		final boolean current = p == pages;
    		this.pagercell(writer, current, p);
    	}
    }
    {
    	final int p = page;
    	final boolean current = p == pages;
    	this.pagercell(writer, current, pages, ">>");
    }

    веселый вывод постраничной навигации (кусок метода)

    Lure Of Chaos, 22 Апреля 2014

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

    +64

    1. 1
    short someShort = (short) (someBoolean ? 15 : 42);

    такая удобная Java

    evg_ever, 21 Апреля 2014

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

    +157

    1. 1
    setcookie('password', $passHash , time() + $this::TIME_COOKIE * 1000 +  $remember ? $this::TIME_COOKIE_REMEMBER : 0  * 1000 );

    И я то думал, почему кука не появляется...

    Dart_Sergius, 21 Апреля 2014

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

    +143

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

    Brainfuck, задача - вывести
    1
    2-1
    1-2-3
    4-3-2-1
    1-2-3-4-5
    6-5-4-3-2-1

    Из этой ветки: http://habrahabr.ru/post/116842/#comment_3794462

    gost, 21 Апреля 2014

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

    +141

    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
    ...
    else if ( (!BG_InSpecialJump( legsAnim )//not in a special jump anim 
    						||BG_InReboundJump( legsAnim )//we're already in a rebound
    						||BG_InBackFlip( legsAnim ) )//a backflip (needed so you can jump off a wall behind you)
    					//&& pm->ps->velocity[2] <= 0 
    					&& pm->ps->velocity[2] > -1200 //not falling down very fast
    					&& !(pm->ps->pm_flags&PMF_JUMP_HELD)//have to have released jump since last press
    					&& (pm->cmd.forwardmove||pm->cmd.rightmove)//pushing in a direction
    					//&& pm->ps->forceRageRecoveryTime < pm->cmd.serverTime	//not in a force Rage recovery period
    					&& pm->ps->fd.forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_2//level 3 jump or better
    					//&& WP_ForcePowerAvailable( pm->gent, FP_LEVITATION, 10 )//have enough force power to do another one
    					&& BG_CanUseFPNow(pm->gametype, pm->ps, pm->cmd.serverTime, FP_LEVITATION)
    					&& (pm->ps->origin[2]-pm->ps->fd.forceJumpZStart) < (forceJumpHeightMax[FORCE_LEVEL_3]-(BG_ForceWallJumpStrength()/2.0f)) //can fit at least one more wall jump in (yes, using "magic numbers"... for now)
    					//&& (pm->ps->legsAnim == BOTH_JUMP1 || pm->ps->legsAnim == BOTH_INAIR1 ) )//not in a flip or spin or anything
    					)
    			{//see if we're pushing at a wall and jump off it if so
    				if ( allowWallGrabs )
    				{
    					//FIXME: make sure we have enough force power
    					//FIXME: check  to see if we can go any higher
    					//FIXME: limit to a certain number of these in a row?
    					//FIXME: maybe don't require a ucmd direction, just check all 4?
    					//FIXME: should stick to the wall for a second, then push off...
    ...

    Больше условий богу условий!
    Jedi Academy source, 2003

    gost, 21 Апреля 2014

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

    +148

    1. 1
    2. 2
    3. 3
    var attr_class = document.createAttribute("class");
    attr_class.nodeValue="th_tr";
    th.setAttributeNode(attr_class);

    И нет, attr_class больше нигде не используется. Кто-то из наших сотрудников экспериментировал, похоже.

    torbasow, 21 Апреля 2014

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