1. ActionScript / Говнокод #7705

    −124

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if(!flashVarsPriority) //Если данные из конфига приоритетнее флешварсов
    	saveFlashVars(flashVars);
    
    //Тут парсим XML конфиг
    ...
    //много строк
    
    if(flashVarsPriority) //если флешварсы приоритетнее
    	saveFlashVars(flashVars);

    Werdn, 30 Августа 2011

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

    +168

    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  
    //Маты записываёте в antmat.dat 
    function antimat($msg) {  
    if (file_exists("antimat.dat")) {  
    $mat = file_get_contents("antimat.dat");  
    $arr_mat = explode("|",$mat);  
    foreach($arr_mat as $value) {  
    if($value != "") {  
    $msg = preg_replace("|$value|iu","***",$msg);  
    }}}  
    return $msg;  
    }  
    ?>

    И заходишь на любой форум про похапе
    @
    И копируешь на говнокод всю тему "полезные функции"

    7ion, 30 Августа 2011

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

    +154

    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
    <?php 
    function crypt_apr1_md5($plainpasswd) { 
        $salt = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz0123456789"), 0, 8); 
        $len = strlen($plainpasswd); 
        $text = $plainpasswd.'$apr1$'.$salt; 
        $bin = pack("H32", md5($plainpasswd.$salt.$plainpasswd)); 
        for($i = $len; $i > 0; $i -= 16) { $text .= substr($bin, 0, min(16, $i)); } 
        for($i = $len; $i > 0; $i >>= 1) { $text .= ($i & 1) ? chr(0) : $plainpasswd{0}; } 
        $bin = pack("H32", md5($text)); 
        for($i = 0; $i < 1000; $i++) { 
            $new = ($i & 1) ? $plainpasswd : $bin; 
            if ($i % 3) $new .= $salt; 
            if ($i % 7) $new .= $plainpasswd; 
            $new .= ($i & 1) ? $bin : $plainpasswd; 
            $bin = pack("H32", md5($new)); 
        } 
        for ($i = 0; $i < 5; $i++) { 
            $k = $i + 6; 
            $j = $i + 12; 
            if ($j == 16) $j = 5; 
            $tmp = $bin[$i].$bin[$k].$bin[$j].$tmp; 
        } 
        $tmp = chr(0).chr(0).$bin[11].$tmp; 
        $tmp = strtr(strrev(substr(base64_encode($tmp), 2)), 
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 
        "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); 
        return "$"."apr1"."$".$salt."$".$tmp; 
    } 
    ?>

    Кручу-верчу, запутать хочу!

    7ion, 30 Августа 2011

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

    −117

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public function loadFromDecString(colorData:String, splitter:String = " "):void
    {
    	var colorArray:Array = colorData.split(splitter);
    	if(colorArray.length != 3)
    		return;
    	mRed = colorArray[0] * 0x1;
    	mGreen = colorArray[1] * 0x1;
    	mBlue = colorArray[2] * 0x1;
    }

    Чудеса в решете

    Werdn, 30 Августа 2011

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

    −91

    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
    def delta( listToDelta ):
      result = []
      lastItem = listToDelta[0]
      for i, item in enumerate(listToDelta):
        if i == 0:
          result.append(item)
        else:
          result.append(item-lastItem)
        lastItem = item
      return result
    
    l = [2, 4, 6, 9, 7]
    print(l)
    l = delta(l)
    print(l)

    Всеми любимый Дениска (автор некоторых прошлых ГК на питоне) пошёл на поправку и написал не такое вонючее говно.
    Комментировать код до сих пор отказывается, но зато стал выбирать имена для переменных получше.

    Fai, 30 Августа 2011

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

    +169

    1. 1
    if (!document.getElementById) return;

    Официальный сайт города Сочи

    Connor, 30 Августа 2011

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

    +161

    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
    public function get($module, $fields, $options=null) {
            $results = $this->get_with_related($module, array($module => $fields), $options);
            $records = array();
            if ($records) {
                foreach ($results['entry_list'] as $entry) {
                    $record = array();
                    foreach ($entry['name_value_list'] as $field) {
                        $record[$field['name']] = $field['value'];
                    }
                    $records[] = $record;
                }
            }
            return $records;
        }

    SugarCRM REST API Class https://github.com/asakusuma/SugarCRM-REST-API-Wrapper-Class/blob/master/sugar_rest.php

    stark, 30 Августа 2011

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

    +105

    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
    procedure TForm2.FormCreate(Sender: TObject);
    begin
      SpeedButton1.Left := Form2.ClientWidth div 2 - SpeedButton1.Width;
      SpeedButton1.Top := Form2.ClientHeight div 2 - SpeedButton1.Height;
     
      SpeedButton2.Left := Form2.ClientWidth div 2;
      SpeedButton2.Top := Form2.ClientHeight div 2 - SpeedButton2.Height;
     
      SpeedButton3.Left := Form2.ClientWidth div 2 - SpeedButton3.Width;
      SpeedButton3.Top := Form2.ClientHeight div 2;
     
      SpeedButton4.Left := Form2.ClientWidth div 2;
      SpeedButton4.Top := Form2.ClientHeight div 2;
    end;

    Fai, 30 Августа 2011

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

    +168

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    var command = 'var p = new Object();';
             command +='p.adId = "' + params.adId + '";';
             command +='p.campaignId = "' + params.campaignId + '";';
             command +='p.parentPositionId="' + params.parentPositionId + '";';
             command +='p.childPositionIds = "' + params.childPositionIds + '";';
             command +='oneAdSkyscraperLoaded(p);';
      setTimeout(command, 0);

    Латвийский eval

    jQuery, 30 Августа 2011

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

    +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
    /**
     * форматирование даты - преобразует дату в формат ДД-ММ-ГГГГ
     *
     * @param unknown_type $inDate - дата
     * @return unknown
     */
    public static function getDateFormatted($inDate, $forView = false, $inTime = '') {
    	//2011-05-03 20:27:26
    	
    	$a_tmp = explode(' ', $inDate);
    	if ($forView) {
    		$time = substr($a_tmp[1], 0, 5);
    		if ($a_tmp[0] == date('Y-m-d')) {
    			if ($time == '') {
    				$time = substr($inTime, 11, 5);
    				if ($time == '') {
    					$time = $inTime;
    				}
    			}
    			if ($time != '') {
    				return 'Сегодня, ' . $time;
    			}
    		}
    
    		$a_tmp = explode('-', $a_tmp[0]);
    
    		return $a_tmp[2] . '-' . $a_tmp[1] . '-' . $a_tmp[0];
    	}
    
    	$inDate = substr($inDate, 0 , 10);
    	$inDate = str_replace(' ', '', $inDate);
    	$inDate = str_replace('.', '-', $inDate);
    
    	$a_tmp = explode('-', $inDate);
    	if (strlen($a_tmp[0]) == 4) {
    		$inDate = str_pad($a_tmp[2], 2, '0', STR_PAD_LEFT) . '-' . $a_tmp[1] . '-' . $a_tmp[0];
    	}
    	return $inDate;
    }

    Sers, 30 Августа 2011

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