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

    +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
    @servers(['web' => '[email protected]'])
     
    <?php
    $repo = '[email protected]:webbox/lb.git';
    $release_dir = '/home/admin/web/releases';
    $app_dir = '/home/admin/web/likebox-dev/public_html';
    $release = 'release_' . date('YmdHis');
    ?>
     
    @macro('deploy', ['on' => 'web'])
    fetch_repo
    run_composer
    update_permissions
    update_symlinks
    @endmacro
     
    @task('fetch_repo')
    [ -d {{ $release_dir }} ] || mkdir {{ $release_dir }};
    cd {{ $release_dir }};
    git clone {{ $repo }} {{ $release }};
    @endtask
     
    @task('run_composer')
    cd {{ $release_dir }}/{{ $release }};
    composer install --prefer-dist;
    @endtask
     
    @task('update_permissions')
    cd {{ $release_dir }};
    chgrp -R www-data {{ $release }};
    chmod -R ug+rwx {{ $release }};
    @endtask
     
    @task('update_symlinks')
    ln -nfs {{ $release_dir }}/{{ $release }} {{ $app_dir }};
    chgrp -h www-data {{ $app_dir }};
    @endtask

    Гит не нужен =)

    Rijen, 11 Февраля 2015

    Комментарии (0)
  2. bash / Говнокод #17624

    −118

    1. 1
    . ldd

    Роняет bash

    Abbath, 11 Февраля 2015

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

    −165

    1. 1
    2. 2
    3. 3
    SELECT `score` FROM `score`
    WHERE `score` = (SELECT DISTINCT `score` FROM `score`
      ORDER BY `score` DESC LIMIT 1,1)

    Про именование таблиц и полей...

    smart, 11 Февраля 2015

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

    +157

    1. 1
    $inp[] = implode("-", array_reverse(explode(".",$input['from-date']))).' '.$input['from-time'].'+0400';

    От платины отличается магическим '+0400' (ISO-8601, лол).

    heyzea1, 11 Февраля 2015

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

    +156

    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
    74. 74
    75. 75
    76. 76
    function form_xml_items( $sXML, $reserve, $exchange ){
    	foreach ($exchange as $in => $outs) {
    
    		$currency_in = taxonomy_term_load($in);
    		switch ($in) {
    			case 6:
    				$currency_in->name = 'CASHUAH';
    				break;
    			case 18:
    				$currency_in->name = 'CASHUSD';
    				break;
    
    // ...
    
    				$currency_in->name = 'TBRUB';
    				break;
    			case 161:
    				$currency_in->name = 'OPB';
    				break;
    		}
    
    		foreach ($outs as $out => $param) {
    
    			$currency_out = taxonomy_term_load($out);
    
    			switch ($out) {
    				case 11:
    					$currency_out->name ='CASHUAH';
    					break;
    				case 19:
    					$currency_out->name ='CASHUSD';
    					break;
    
    // ...
    
                                   case 155:
    					$currency_out->name = 'CARDRUB';
    					$currency_out->second_name = 'WIRERUB';
    					break;
    				case 162:
    					$currency_out->name = 'OPB';
    					break;
    			}
    
    			$sXML .= "<item>\n";
    			$sXML .= "<from>" . $currency_in->name . "</from>\n";
    			$sXML .= "<to>" . $currency_out->name  . "</to>\n";
    			$sXML .= "<in>1</in>\n";
    			$sXML .= "<out>" . $param["rate"] . "</out>\n";
    			$sXML .= "<amount>" . $param["reserve"] . "</amount>\n";
    			$sXML .= "</item>\n";
    			//wire and card in
    			if (isset( $currency_in->second_name)){
    				$sXML .= "<item>\n";
    				$sXML .= "<from>" . $currency_in->second_name . "</from>\n";
    				$sXML .= "<to>" . $currency_out->name  . "</to>\n";
    				$sXML .= "<in>1</in>\n";
    				$sXML .= "<out>" . $param["rate"] . "</out>\n";
    				$sXML .= "<amount>" . $param["reserve"] . "</amount>\n";
    				$sXML .= "</item>\n";
    			}
    			//wire and card out 
    			if (isset($currency_out->second_name)){
    				$sXML .= "<item>\n";
    				$sXML .= "<from>" . $currency_in->name . "</from>\n";
    				$sXML .= "<to>" . $currency_out->second_name  . "</to>\n";
    				$sXML .= "<in>1</in>\n";
    				$sXML .= "<out>" . $param["rate"] . "</out>\n";
    				$sXML .= "<amount>" . $param["reserve"] . "</amount>\n";
    				$sXML .= "</item>\n";
    			}
    		}
    
    	}
    	return $sXML;
    }

    Если не взирать на магические числа, кажеться этот код должен занимать строк 20, а не 130

    kissarat, 11 Февраля 2015

    Комментарии (0)
  6. JavaScript / Говнокод #17620

    +160

    1. 1
    2. 2
    var hgh = $(document).height() - 320 - 180 - 440;
    $(".message-form").height(  hgh );

    шта?

    heyzea1, 11 Февраля 2015

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

    +53

    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
    {
       ...
       _tswfstring contentID = fileName;
       _tswfstring::size_type index = fileName.find_last_of ( _T("\\")  );
       if ( index != -1 )
          contentID.erase(0, index + 1);
    
       TCHAR name[10] = {0};
       memcpy(name, contentID.c_str() + contentID.length() - 9, 9 * sizeof(TCHAR));
       if(name[6] == _T('B') || name[6] == _T('b')) //to upper case if .bmp
       {
          name[6] = _T('B');
          name[7] = _T('M');
          name[8] = _T('P');
       }
    }

    blackhearted, 11 Февраля 2015

    Комментарии (1)
  8. Python / Говнокод #17617

    −109

    1. 1
    2. 2
    if form.cleaned_data.has_key('replace_id') and type(form.cleaned_data['replace_id']) == type(32):
        ...

    Логично, чо

    larikov, 11 Февраля 2015

    Комментарии (1)
  9. C++ / Говнокод #17616

    +55

    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
    uint8_t const Q_ROM QF_div8Lkup[65] = {
        static_cast<uint8_t>(0), // unused location
        static_cast<uint8_t>(0), static_cast<uint8_t>(0), static_cast<uint8_t>(0),
        static_cast<uint8_t>(0), static_cast<uint8_t>(0), static_cast<uint8_t>(0),
        static_cast<uint8_t>(0), static_cast<uint8_t>(0),
        static_cast<uint8_t>(1), static_cast<uint8_t>(1), static_cast<uint8_t>(1),
        static_cast<uint8_t>(1), static_cast<uint8_t>(1), static_cast<uint8_t>(1),
        static_cast<uint8_t>(1), static_cast<uint8_t>(1),
        static_cast<uint8_t>(2), static_cast<uint8_t>(2), static_cast<uint8_t>(2),
        static_cast<uint8_t>(2), static_cast<uint8_t>(2), static_cast<uint8_t>(2),
        static_cast<uint8_t>(2), static_cast<uint8_t>(2),
        static_cast<uint8_t>(3), static_cast<uint8_t>(3), static_cast<uint8_t>(3),
        static_cast<uint8_t>(3), static_cast<uint8_t>(3), static_cast<uint8_t>(3),
        static_cast<uint8_t>(3), static_cast<uint8_t>(3),
        static_cast<uint8_t>(4), static_cast<uint8_t>(4), static_cast<uint8_t>(4),
        static_cast<uint8_t>(4), static_cast<uint8_t>(4), static_cast<uint8_t>(4),
        static_cast<uint8_t>(4), static_cast<uint8_t>(4),
        static_cast<uint8_t>(5), static_cast<uint8_t>(5), static_cast<uint8_t>(5),
        static_cast<uint8_t>(5), static_cast<uint8_t>(5), static_cast<uint8_t>(5),
        static_cast<uint8_t>(5), static_cast<uint8_t>(5),
        static_cast<uint8_t>(6), static_cast<uint8_t>(6), static_cast<uint8_t>(6),
        static_cast<uint8_t>(6), static_cast<uint8_t>(6), static_cast<uint8_t>(6),
        static_cast<uint8_t>(6), static_cast<uint8_t>(6),
        static_cast<uint8_t>(7), static_cast<uint8_t>(7), static_cast<uint8_t>(7),
        static_cast<uint8_t>(7), static_cast<uint8_t>(7), static_cast<uint8_t>(7),
        static_cast<uint8_t>(7), static_cast<uint8_t>(7)
    };
    
    // ....
    
        //! the function evaluates to TRUE if the priority set has the element n.
        bool hasElement(uint_fast8_t const n) const {
            uint_fast8_t const m =
                static_cast<uint_fast8_t>(Q_ROM_BYTE(QF_div8Lkup[n]));
            return ((m_bits[m]
                      & static_cast<uint_fast8_t>(Q_ROM_BYTE(QF_pwr2Lkup[n])))
                   != static_cast<uint_fast8_t>(0));
        }
    
        //! insert element \a n into the set, n = 1..64
        void insert(uint_fast8_t const n) {
            uint_fast8_t m =
                static_cast<uint_fast8_t>(Q_ROM_BYTE(QF_div8Lkup[n]));
            m_bits[m] |= static_cast<uint_fast8_t>(Q_ROM_BYTE(QF_pwr2Lkup[n]));
            m_bytes   |=
                static_cast<uint_fast8_t>(Q_ROM_BYTE(QF_pwr2Lkup[m
                                              + static_cast<uint_fast8_t>(1)]));
        }

    делим на 8 в индустриальном С++. это такой специальный вариант крестов где пользователям сначала лоботомию делают.

    из реализации bitset'а. insert() приведен в качестве примера.

    Dummy00001, 11 Февраля 2015

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

    +155

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (in_array ($v["field_currency_out"]["und"][0]["tid"], array(20, 21, 26, 27,153,157,154,152,155,162)) || in_array ($v["field_currency_in"]["und"][0]["tid"], array(22, 23, 24, 25,151,156,150,149,148,161))) {
        $v["field_payment"]["und"][0]["tid"] = 28;
    } else {
        $v["field_payment"]["und"][0]["tid"]= 13;
    }

    Представте что весь сайт написан в этом же духе.
    Причем мы имеем дело с двома наборами констант для обозначения валют - для входа и выхода перевода.

    kissarat, 10 Февраля 2015

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