1. PHP / Говнокод #17225

    +159

    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
    public function asSize($value, $decimals = null, $options = [], $textOptions = [])
        {
            if ($value === null) {
                return $this->nullDisplay;
            }
            list($params, $position) = $this->formatSizeNumber($value, $decimals, $options, $textOptions);
            if ($this->sizeFormatBase == 1024) {
                switch ($position) {
                    case 0:  return Yii::t('yii', '{nFormatted} {n, plural, =1{byte} other{bytes}}', $params, $this->locale);
                    case 1:  return Yii::t('yii', '{nFormatted} {n, plural, =1{kibibyte} other{kibibytes}}', $params, $this->locale);
                    case 2:  return Yii::t('yii', '{nFormatted} {n, plural, =1{mebibyte} other{mebibytes}}', $params, $this->locale);
                    case 3:  return Yii::t('yii', '{nFormatted} {n, plural, =1{gibibyte} other{gibibytes}}', $params, $this->locale);
                    case 4:  return Yii::t('yii', '{nFormatted} {n, plural, =1{tebibyte} other{tebibytes}}', $params, $this->locale);
                    default: return Yii::t('yii', '{nFormatted} {n, plural, =1{pebibyte} other{pebibytes}}', $params, $this->locale);
                }
            } else {
                switch ($position) {
                    case 0:  return Yii::t('yii', '{nFormatted} {n, plural, =1{byte} other{bytes}}', $params, $this->locale);
                    case 1:  return Yii::t('yii', '{nFormatted} {n, plural, =1{kilobyte} other{kilobytes}}', $params, $this->locale);
                    case 2:  return Yii::t('yii', '{nFormatted} {n, plural, =1{megabyte} other{megabytes}}', $params, $this->locale);
                    case 3:  return Yii::t('yii', '{nFormatted} {n, plural, =1{gigabyte} other{gigabytes}}', $params, $this->locale);
                    case 4:  return Yii::t('yii', '{nFormatted} {n, plural, =1{terabyte} other{terabytes}}', $params, $this->locale);
                    default: return Yii::t('yii', '{nFormatted} {n, plural, =1{petabyte} other{petabytes}}', $params, $this->locale);
                }
            }
        }

    Yii продолжает свой крестовый поход против логики. Вам нужно немного другое форматирование, получить именно килобайты вместо кибибайтов? Выставьте какую-то ссаную внутреннюю переменную в значение, отличное от 1024. Да, двойка подойдет, не ссы, ставь.

    Fike, 30 Ноября 2014

    Комментарии (1)
  2. Objective C / Говнокод #17224

    −407

    1. 1
    http://habrahabr.ru/post/244487/

    Очень жаль всех этих людей, которые вынуждены писать на этом выхлопе от Apple.
    "Мыши плакали, кололись, но продолжали грызть кактус."

    cyperh, 30 Ноября 2014

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

    +160

    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
    <script language=php>
    
    use function yolo\y;
    
    yolo\yolisp(y('yolo\yolo',
        y('lambda', y('request'), 
            y('new', YoLo\resPONsE::clASS, y(
                y('quote', 'yolo')
            ))
        )
    ));
    
    %>

    Микрофреймворк будущего: https://github.com/igorw/yolo

    volter9, 30 Ноября 2014

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

    +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
    15. 15
    16. 16
    17. 17
    18. 18
    function kevinTheNumberMentioner(_){
      l=[]
      /* mostly harmless --> */ with(l) {
      	
      	//Sorry about all this, my babel fish has a headache today...
      	for (ll=!+[]+!![];ll<_+(+!![]);ll++) {
      	  lll=+!![];
      	  while (ll%++lll);
      	  //I've got this terrible pain in all the semicolons down my right-hand side
      	  (ll==lll)&&push(ll);
      	}
      	forEach(alert);
      	
      }
      
      //You're really not going to like this...
      return [!+[]+!+[]+!+[]+!+[]]+[!+[]+!+[]];
    }

    Открыл твитор, а там - это.

    http://arstechnica.com/information-technology/2014/11/holiday-reading-for-a-certain-sort-if-hemingway-wrote-javascript/

    Xom94ok, 30 Ноября 2014

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

    +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
    <?
    
    class user
    {
    function login($name, $password)
    {
    $name = mysql_real_escape_string($name);
    $name = htmlspecialchars($name);
    $password = mysql_real_escape_string($password);
    $password = htmlspecialchars($password);
    $sql = mysql_query("SELECT id FROM students WHERE Names='$name' AND Pass='$password'");
    if (mysql_num_rows($sql) == 1)
    {
    $_SESSION['Name'] = $name;
    return 1;
    }
    else
    {
    return 0;
    }
    }

    Код от ТЫЖпрограммиста.

    Mobac, 29 Ноября 2014

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

    +80

    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
    procedure TInventory.removeItem(userid: integer; invid: integer;amount: integer = 1);
    var
      MyRes: TInvItemArray;
      CurrItem: TInvItem;
      I,len: integer;
    begin
      if (amount <= 0) then
        exit;
      if (amount = 1) then
        begin
         db.removeItemFromUserInventory(GetItems(GetIndexByInvId(invid)),userid);
         FInventoryList.Remove(GetIndexByInvId(invid));
        end else
        begin
          if (amount >= finventorylist.Size) then
            exit;
          MyRes:=GetResources(invid);
          len:=length(myres);
          if (len = 0) then
            exit;
          if (amount > len) then
            exit;
          for i:=0 to len - 1 do
           begin
             curritem:=MyRes[i];
             db.removeItemFromUserInventory(GetItems(GetIndexByInvId(curritem.InvId)),userid);
             FInventoryList.Remove(GetIndexByInvId(curritem.invid));
           end;
         Setlength(myres,0);
        end;
    
    end;
    
    function TInventory.GetResources(invid: integer): TInvItemArray;
    function ToResult(var Return: TInvItemArray; const Item: TInvItem): Integer;
    begin
      Result := Length(Return);
      SetLength(Return, Result + 1);
      Return[Result] := Item;
    end;
    var
      item,sameitem: TInvItem;
      Resource: TItem;
      i: integer;
    begin
      SetLength(result,0);
      item:=GetItem(invid);
      if (item = nil) then
        exit;
      if (item.item <> nil) then
        begin
         // if (item.itemю = 30) then
         //   begin
              for i:=0 to FInventoryList.Size - 1 do
               begin
                 sameitem:=TInvItem(FInventoryList.Items[i]);
                  if (sameitem = nil) then
                    continue;
                 resource:=sameitem.item;
                  if (resource = nil) then
                    continue;
                  if (item.item.itemid = resource.itemid) then
                    ToResult(result,sameitem);
               end;
           // end;
        end;
    end;

    По сути - удалить объект из списка. OMG!

    Cynicrus, 29 Ноября 2014

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

    +154

    1. 1
    var coutryOption = commonSettings.parent().parent().parent().find("tr:contains('Country')");

    очень поиск...

    fess, 29 Ноября 2014

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

    +134

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    private bool CompareLvlCats(string[] cat,List<string[]> cats, int lvl)
    {
        if (lvl == 1) return cats.Find(x => x[0] == cat[0] && (x[1] != cat[1] ||x[1]!="")) != null;
        if (lvl == 2) return cats.Find(x => x[0] == cat[0] && x[1] == cat[1] && (x[2] != cat[2] || x[2] != "")) != null;
        if (lvl == 3) return cats.Find(x => x[0] == cat[0] && x[1] == cat[1] && x[2] == cat[2] && (x[3] != cat[3] || x[3] != "")) != null;
        if (lvl == 4) return cats.Find(x => x[0] == cat[0] && x[1] == cat[1] && x[2] == cat[2] && x[3] == cat[3] && (x[4] != cat[4] || x[4] != "")) != null;
        if (lvl == 5) return cats.Find(x => x[0] == cat[0] && x[1] == cat[1] && x[2] == cat[2] && x[3] == cat[3] && x[4] == cat[4] && (x[5] != cat[5] || x[5] != "")) != null;
        if (lvl == 6) return false;
        return false;
    }

    Здесь мы идём снова.

    pushistayapodmyshka, 29 Ноября 2014

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

    +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
    var firstpostime = 1417254005;var numpos = 1; //номер посещения
    var sredvrem  = 0; //среднее время на каждой странице
    var lasdo15sek = 0;
    
    function debug444(ff) {
    	console.log(ff);
    	//alert(ff);
    }
    var newTxt="!!";
    var oldTxt=document.title;
    function migalka(){
        if(document.title==oldTxt){
            document.title=newTxt;
        }else{
            document.title=oldTxt;
        }
    } 
    function neuspeli() {
    	var element55577 = document.createElement('div');
    	element55577.innerHTML = '<img style="width:1px;height:1px;" src="http://rbcall.com/neuspeli.php?&tel='+document.getElementById('wi_tele233').value+'&site=47&user=159">', 
    	element55577.id = 'wi_r223';
    	document.body.appendChild(element55577);
    	document.getElementById("superjalobal").style.display='block';
    } 
    
    function jduzvonka() {
    	if (zvonim == 1) { return true; }
    	if(document.getElementById("wi_tele233").value.length>=8 || document.getElementById("wi_tele233").value == 400){
    		wiyacall();
    		
    		insertscript(document.getElementById("wi_tele233").value);
    		
    	} else { 
    		document.getElementById("wi_tele233").style.border="1px solid red"; 
    	}
    }
    
    ...... и весь скрипт такой

    http://rbcall.com/ ROBOCALL - технологии будущего (они же: технологии ИИ)

    xjester0, 29 Ноября 2014

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    (strrev "hello")                #=> "olleh"
    (array_sum [array 1 2 3])       #=> 6
    (array-product [array 4 5 6])   #=> 120
    (substring "world" 2)           #=> "rld"

    Теперь ваш Lisp и в PHP: https://github.com/lisphp/lisphp

    volter9, 29 Ноября 2014

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