1. Си / Говнокод #16775

    +120

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /* Writing: cosine = (double (*)(double)) dlsym(handle, "cos");
           would seem more natural, but the C99 standard leaves
           casting from "void *" to a function pointer undefined.
           The assignment used below is the POSIX.1-2003 (Technical
           Corrigendum 1) workaround; see the Rationale for the
           POSIX specification of dlsym(). */
    
    *(void **) (&cosine) = dlsym(handle, "cos");

    Сишкопроблемы.

    http://linux.die.net/man/3/dlsym

    someone, 28 Сентября 2014

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

    +138

    1. 1
    2. 2
    3. 3
    4. 4
    for (int i = 1; i != chars.Length; i++ )
                    {
                        charlist.Items.Add(chars[i]);
                    }

    http://kn1fe-zone.ru/index.php?threads/Лаунчер-с-автовходом-на-аккаунт-и-перса.430/

    DesmondHume, 28 Сентября 2014

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

    +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
    for($i = 1; $i < $conf->nb_images + 1; $i++)
    {
    	$ext_name = chr(ord('a')+$i-1);
    	?>
    	<label for="ad_picture<?php echo $i;?>"><?php echo ADSMANAGER_FORM_AD_PICTURE." ".$i; ?></label>
    	<input id="ad_picture<?php echo $i;?>" type="file" name="ad_picture<?php echo $i;?>" />
    	<?php
    	if ($isUpdateMode) {
    		$pic = $mosConfig_absolute_path."/images/$option/projects/".$ad_id.$ext_name."_t.jpg";
    		if ( file_exists( $pic)) {
    			echo "<img src='".$mosConfig_live_site."/images/$option/projects/".$ad_id.$ext_name."_t.jpg' align='top' border='0' alt='image$ad_id' />";
    			echo "<input type='checkbox' name='cb_image$i' value='delete' />".ADSMANAGER_AD_DELETE_IMAGE;
    		}
    	}
    	echo "<br />";
    }

    Угадайте что за CMS :)))

    mishanon, 27 Сентября 2014

    Комментарии (25)
  4. bash / Говнокод #16771

    −118

    1. 1
    set -xexexe

    из тестового скрипта. началось все с очепятки.

    в дурмане тупого писания тупых тестов, не мог остановится хихикать.

    Dummy00001, 27 Сентября 2014

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

    +57

    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
    class C3D
    {
    public:
      //C3D()  {}  // Constructor
      //~C3D()  {}  // Destructor
    
      void(*init)(float R, float A, float B, float Rmin, float Rmax, float Bmin, float Bmax);  // Initialize work with 3D standard camera
      void(*setCamera)(int iType);  // Set type of camera
      void(*setPosition)(float x, float y, float z);  // Set position
      void(*setRender3D)();
      UINT(*addMesh)(LPCWSTR sMesh);  // Add Mesh
      void(*renderMesh)(UINT idMesh, float x, float y, float z);
      void(*renderMeshSubset)(UINT idMesh, UINT idSubset, float x, float y, float z);
      void(*renderMeshSubsetRotateX)(UINT idMesh, UINT idSubset, float x, float y, float z, float a);
    // простыня указателей на функции урезана
    
      void setHModule(HMODULE hLib)
      {
        m_hLib = hLib;
    
        (FARPROC &)init = GetProcAddress(m_hLib, "init3D");  // Initialize work with 3D standard camera
        (FARPROC &)setCamera = GetProcAddress(m_hLib, "setCamera");  // Set type of camera
        (FARPROC &)setPosition = GetProcAddress(m_hLib, "setPosition");  // Set position
        (FARPROC &)setRender3D = GetProcAddress(m_hLib, "setRender3D");
        (FARPROC &)addMesh = GetProcAddress(m_hLib, "addMesh");  // Add Mesh
        (FARPROC &)renderMesh = GetProcAddress(m_hLib, "renderMesh");
        (FARPROC &)renderMeshSubset = GetProcAddress(m_hLib, "renderMeshSubset");
        (FARPROC &)renderMeshSubsetRotateX = GetProcAddress(m_hLib, "renderMeshSubsetRotateX");
    // простыня GetProcAddress урезана
      }
    
    protected:
      HMODULE  m_hLib;  // NetWars.dll
    };

    Некий SDK для MMO-игр за авторством одного известного разработчика.

    bazhenovc, 25 Сентября 2014

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

    +80

    1. 1
    2. 2
    3. 3
    if (!driver.findElement(By.id(DD_LAUNCH_ID)).equals(null)) {
        pause(1000);
    }

    Тогда уж почему не null.equals(...)?

    Actine, 25 Сентября 2014

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

    +60

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    vector <float> items; 
    float *x;
    for(int i = 0; i<100; i++) { 
      x = new float; 
      *x = 1.0f; 
      items.push_back(*x); 
    };

    оттуда...

    Try, 25 Сентября 2014

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

    +138

    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
    public List<string> AutoPublishProjectDepartmentNames { get; private set; }
            public string AutoPublishProjectDepartments
            {
                get { return _projectDepartments; }
                set
                {
                    _projectDepartments = value;
    
                    AutoPublishProjectDepartmentNames.Clear();
                    var departments = _projectDepartments.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    //Get EPT Names
                    foreach (var department in departments)
                    {
                        try
                        {
                            if (department.Length == 36 || department.Length == 38)
                            {
                                var departmentUid = new Guid(department);
                                AutoPublishProjectDepartmentNames.Add(SqlInstance.GetDepartmentName(departmentUid));
                                continue;
                            }
                        }
                        catch (FormatException)
                        {
                        }
    
                        //Not a guid
                        AutoPublishProjectDepartmentNames.Add(department);
                    }
                }
            }

    Очень хитрая пропертя, пока не засетишь одну пропертю - другая не будет работать. А еще она с гуидами работает. Ооочень хитрая. Юсфуль-туль.

    boades, 25 Сентября 2014

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

    +118

    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
    import static com.google.gwt.query.client.GQuery.*;
    import com.google.gwt.query.client.Function;
    
    public void onModuleLoad() {
      //Hide the text and set the width and append an h1 element
      $("#text").hide()
        .css("width", "400px")
        .prepend("<h1>GwtQuery Rocks !</h1>");
        
        //add a click handler on the button
        $("button").click(new Function(){
          public void f() {
            //display the text with effects and animate its background color
            $("#text").as(Effects)
              .clipDown()
              .animate("backgroundColor: 'yellow'", 500)
              .delay(1000)
              .animate("backgroundColor: '#fff'", 1500);
          }
        });
    }

    Не ГК, но мне показалось забавно.

    https://code.google.com/p/gwtquery/

    someone, 25 Сентября 2014

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    var shops=new Array();
    shops[shops.length] = new Array('',' ');
    shops[shops.length] = new Array(' The Jewel Box', '135956406_923');
    shops[shops.length] = new Array(' Склад 1', '135956406_923');

    И таких вызовов порядка 2к

    via http://pickpoint.ru/monitoring/

    kopoBko, 24 Сентября 2014

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