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

    +86

    1. 1
    2. 2
    int memory = (int)Runtime.getRuntime().freeMemory();
    if (memory < 163840) bydlophone = true;

    Встретил в коде одного мидлета.

    odd, 28 Мая 2010

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

    +170

    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
    struct Obect: public AbsractPrimitiv
    {
    	float X,Y; 
    	Obect(float x, float y)
    	{
    		X=x;
    		Y=x;
    	};
    	
    	Obect(void)
    	{
    		new(this) Obect(0,0);
    	};
    
    	//...
    	//...
    	//...
    
    private://Требование конвенции. Блок private обязан быть в каждом классе.
    };

    Не вру. Вот вам крест! Написано именно так.

    Говногость, 28 Мая 2010

    Комментарии (170)
  3. Java / Говнокод #3341

    +74

    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
    public class HoldMe implements Lock {
      public static Lock          canHas                            = maybeGetLock( );
      public static boolean       reuse                             = true;
    
      @Override
      public void lock( ) {}
    
      private static Lock maybeGetLock( ) {
        if ( reuse ) {
    //      return new ReentrantLock( );
          return new HoldMe( );
        } else {
          return new HoldMe( );
        }
      }
    
      @Override
      public void lockInterruptibly( ) throws InterruptedException {}
    
      @Override
      public Condition newCondition( ) {
        return null;
      }
    
      @Override
      public boolean tryLock( ) {
        return true;
      }
    
      @Override
      public boolean tryLock( long arg0, TimeUnit arg1 ) throws InterruptedException {
        return true;
      }
    
      @Override
      public void unlock( ) {}
    }
    
    // Пример использования:
    
    HoldMe.canHas.lock( );
    try {
      // Код
    } finally {
      HoldMe.canHas.unlock( );
    }

    Суровые калифорнийцы суровы. Впрочем, я это уже говорил.

    raorn, 28 Мая 2010

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

    +144

    1. 1
    2. 2
    3. 3
    void method() {
        if(true) return;
    }

    только что встретилось, всем коллективом ржали

    немного классики, что бы не забывали.
    однозначно поле для действий, но все равно забавно

    Lure Of Chaos, 28 Мая 2010

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

    +152

    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
    $data = curl_init('http://'.$site.'/index/sub/'); 
    curl_setopt($data, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($data, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt($data, CURLOPT_POST, 1); 
    curl_setopt($data, CURLOPT_POSTFIELDS, $post); 
    curl_setopt($data, CURLOPT_HTTPHEADER, $headers); 
    curl_setopt($data, CURLOPT_COOKIEJAR, $cookie); 
    curl_setopt($data, CURLOPT_CONNECTTIMEOUT,$timeout); 
    curl_setopt($data, CURLOPT_TIMEOUT,$timeout); 
    //curl_setopt($data, CURLOPT_COOKIEFILE, $cookie); 
    $data2 = curl_exec($data); 
    curl_close($data); 
    $return = iconv('utf-8','cp1251',$data2); 
    if (preg_match('/Неправильный логин или пароль/Ui',$return)) return FALSE; else return TRUE;

    eval, 28 Мая 2010

    Комментарии (14)
  6. C# / Говнокод #3338

    +126

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    public partial class Form1 : Form
        {
            string str;
            int количество;
            public Form1(string str, int количество)
            {
                InitializeComponent();
                str = this.str;
                количество = this.количество;
            }

    Классный конструктор, ничего не скажешь.
    А потом сидишь и удивляешься, почему же у тебя пустая строка и количество не прописалось...

    alexanika, 28 Мая 2010

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

    +157

    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
    <?php
    set_time_limit(0);
    Error_Reporting(E_ALL & ~E_NOTICE);
    
    $mail = "@rambler.ru"; //e-mail или логин от контакта
    $pass = ""; //пароль от контакта
    $uids = "3,5,7,8,10,15,1955,54665,233254"; //кого проверяем
    
    function get($link,$cookie){ 
    
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL,$link); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    
    $otvet = curl_exec($ch); 
    curl_close($ch); 
    return $otvet; 
    }
    
    $aut=file_get_contents('http://login.vk.com/?act=login&email='.urlencode($mail).'&pass='.urlencode($pass).'&expire=&vk=');
    preg_match("/id=\'s\' value=\'(.*?)\'/",$aut,$sid);
    $cookie="remixsid=$sid[1];";
    
    $res=get("http://vkontakte.ru/feed2.php",$cookie);
    $feed=json_decode($res);
    $id=$feed->user->id;
    
    $count = substr_count($uids,",");
    $count = $count+1;
    
    $sig=md5(''.$id.'api_id=35569fields=has_mobileformat=JSONmethod=getProfilesuids='.$uids.'v=2.0SRkM2ws8NQ');
    
    $res=get("http://api.vkontakte.ru/api.php?api_id=35569&fields=has_mobile&format=JSON&method=getProfiles&uids=$uids&v=2.0&sig=$sig",$cookie);
    preg_match_all("/uid\":(.*?),\"first_name\":\"(.*?)\",\"last_name\":\"(.*?)\",\"has_mobile\":(.*?)\}/",$res,$info);
    
    for($i=0;$i<$count;$i) { 
    
    $qwe=$i++;
    
    $uidx=$info[1][$qwe];
    $first_name=$info[2][$qwe];
    $last_name=$info[3][$qwe];
    $has_mobile=$info[4][$qwe];
    
    print iconv('utf-8', '866', "\n--------id$uidx: $first_name $last_name [$has_mobile]--------\n\n\n"); }
    
    ?>

    http://volk.hx0.ru

    r00t, 27 Мая 2010

    Комментарии (29)
  8. Java / Говнокод #3336

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (digitsStr.length() < 7) {
    	return "+" + digitsStr.substring(0, 1) + "-" + digitsStr.substring(1, 2) + "-" + digitsStr.substring(2);
    } else {
    	return "+" + digitsStr.substring(0, 3) + "-" + digitsStr.substring(3, 6) + "-" + digitsStr.substring(6);
    }

    свежий кал коллеги

    Lure Of Chaos, 27 Мая 2010

    Комментарии (17)
  9. Python / Говнокод #3335

    −115

    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
    import xml.parsers.expat
    
    text = 'lol'
    booltext = 'false'
    
    subs_temp = open('subs_temp.txt','w')
    
    def start_element(name, attrs):
    	if (name == 'rectRegion' and attrs['h']=='7.222' and attrs['y']=='92.778'):
    		subs_temp.write(attrs['t'] + '\n')
    		global text
    		subs_temp.write(text + '\n')
    	elif (name == 'TEXT'):
    		global booltext
    		booltext = 'true'
    		
    	#subs.write(name+'\n')
    	#print(attrs)
    
    def char_data(data):
    	global text
    	global booltext
    	if (booltext == 'true'):
    		text = data
    		booltext = 'false'
    
    p = xml.parsers.expat.ParserCreate("UTF-8")
    
    p.StartElementHandler = start_element
    p.CharacterDataHandler = char_data
    
    p.ParseFile(open("yt.xml", 'rb'))
    
    subs_temp.close()
    
    subs_temp = open('subs_temp.txt','r')
    subs = open('subs.txt','w')
    
    num = 1
    
    while num <= 44:
    	time1 = subs_temp.readline()
    	text = subs_temp.readline()
    	time2 = subs_temp.readline()
    	text = subs_temp.readline()
    
    	subs.write(str(num))
    	subs.write('\n0')
    	subs.write(time1[:-1])
    	subs.write('00 --> ')
    	subs.write(time2[:-1])
    	subs.write('00\n')
    	subs.write(text)
    	subs.write('\n')
    	
    	num+=1

    Нус, зацените мой первый опыт с питоном. Говнецо редкое, жаль просто так смывать. Так что пусть полежит здесь.

    dageru, 27 Мая 2010

    Комментарии (29)
  10. C# / Говнокод #3334

    +124

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    char arr[] = ... // Здесь происходит чтение массива, неважно как
    string result = "";
    for(int i = 0; i < arr.Length; i++) 
    {
        result += Char.ToString(arr[i]);
    }
    
    Console.WriteLine(result);

    Что интересно, автор уже пол года на C# пишет, до этого 2 года на Java. Решение ко всему прочему еще и очевидно с квадратичной сложностью. А должно быть, естественно Console.WriteLine(new String(array));

    theos, 27 Мая 2010

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