1. JavaScript / Говнокод #14101

    +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
    $(document).ready(function () {
    		$("#FollowingChoicesWebpart-ProjectsAndCommunities").hide();
    		$("#FollowingChoicesWebpart-Sites").hide();
    		$("#FollowingChoicesWebpart-News").show();
    	});
    	$("#FChoices_tab1").click(function () {
    		$("#FollowingChoicesWebpart-ProjectsAndCommunities").hide();
    		$("#FollowingChoicesWebpart-Sites").hide();
    		$("#FollowingChoicesWebpart-News").show();
    		$("#FChoices_tab1").addClass("active-button_FChoices");
    		$("#FChoices_tab2").removeClass("active-button_FChoices");
    		$("#FChoices_tab3").removeClass("active-button_FChoices");
    	});
    	$("#FChoices_tab2").click(function () {
    		$("#FollowingChoicesWebpart-ProjectsAndCommunities").hide();
    		$("#FollowingChoicesWebpart-Sites").show();
    		$("#FollowingChoicesWebpart-News").hide();
    		$("#FChoices_tab1").removeClass("active-button_FChoices");
    		$("#FChoices_tab2").addClass("active-button_FChoices");
    		$("#FChoices_tab3").removeClass("active-button_FChoices");
    	});
    	$("#FChoices_tab3").click(function () {
    		$("#FollowingChoicesWebpart-ProjectsAndCommunities").show();
    		$("#FollowingChoicesWebpart-Sites").hide();
    		$("#FollowingChoicesWebpart-News").hide();
    		$("#FChoices_tab1").removeClass("active-button_FChoices");
    		$("#FChoices_tab2").removeClass("active-button_FChoices");
    		$("#FChoices_tab3").addClass("active-button_FChoices");
    	});
    	$("#FChoices_tab3").click(function () {
    		$("#FollowingChoicesWebpart-ProjectsAndCommunities").hide();
    		$("#FollowingChoicesWebpart-Sites").hide();
    		$("#FollowingChoicesWebpart-News").hide();
    		$("#FChoices_tab1").removeClass("active-button_FChoices");
    		$("#FChoices_tab2").removeClass("active-button_FChoices");
    		$("#FChoices_tab3").addClass("active-button_FChoices");
    	});

    Голландский джаваскриптик для реализации функционала Tabs. Видимо, написано под кумаром)))

    RomashkaPro, 15 Ноября 2013

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

    +68

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    // setting simple fields that couldn't be null
            if (firstOperDay != null) {
                dto.setFirstClosedDay(firstOperDay);
            } else {
                dto.setFirstClosedDay(null);
            }
            if (lastOperDay != null) {
                dto.setLastClosedDay(lastOperDay);
            } else {
                dto.setLastClosedDay(null);
            }

    ingenuus, 15 Ноября 2013

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

    +70

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    private boolean isVincodeDisabled() {
            if (Long.valueOf(PaymentValidationStatus.vin_code_incorrect.getValue()).equals(paymentDTO.getErrorCode())) {
                return false;
            } else if (paymentDTO.getVincode() == null) {
                return true;
            } else {
                return false;
            }
        }

    ingenuus, 15 Ноября 2013

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

    +115

    1. 1
    2. 2
    3. 3
    #define TEN    10
    #define TEEN   100
    #define TEEEN  1000

    glook, 15 Ноября 2013

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

    +137

    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
    int memcmp (const void* v1, const void* v2, size_t n)
    {
       uint32_t *s1;
       uint32_t *s2;
       size_t  i;
    
       s1 = (uint32_t*) v1;
       s2 = (uint32_t*) v2;
    
       for (i = 0; i < n; i++) {
                    if (*s1 != *s2) {
                            return *(const uint32_t *)s1 >
                                   *(const uint32_t *)s2 ? 1 : -1;
                    }
                    s1++;
                    s2++;
            }
       return 0;
    }

    Реализация memcmp в библиотеке одной малоизвестной "учебной" ОС реального времени. Учебной в том смысле, что по этой системе разве что доклады, презентации и статьи делали, где-то реально она вряд ли использовалась.
    Для интересующихся http://pok.safety-critical.net/

    WGH, 14 Ноября 2013

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

    −122

    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
    - (void)_syncThread:(NSDictionary*)args
    {
    	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    	ERFeedStatusDB *feedStatusDB;
    	NSError *error = nil;
    	
    	[self retain];
    	
    	// Open FeedStatusDB
    	feedStatusDB = [[ERFeedStatusDB alloc] init];
    	if (![feedStatusDB openWithPath:[args objectForKey:ERFeedStatusDBSyncFilePathKey] error:&error])
    		goto error;
    		
    	// Perform the sync
    	NSAutoreleasePool *pool2 = [[NSAutoreleasePool alloc] init];	// workaround for SQLITE_BUSY issue during -[feedStatusDB close] call
    																	// (autoreleased objects are sticking around that keep the DB locked) 
    	[self performSyncOnBackgroundThreadWithParams:[args objectForKey:ERFeedStatusDBSyncParamsDictKey] feedStatusDB:feedStatusDB];
    	[pool2 release];
    	
    	[feedStatusDB close];
    	[feedStatusDB release];
    	feedStatusDB = nil;
    	
    	[self _setExecuting:NO];
    	[_executingCondition lock];
    	[_executingCondition signal];
    	[_executingCondition unlock];
    	
    	[self release];
    	[pool release];
    	return;
    	
    error:
    	[self notifyDelegateOfFailureWithError:error];
    
    	[feedStatusDB close];
    	[feedStatusDB release];
    	feedStatusDB = nil;
    
    	[self _setExecuting:NO];
    	[_executingCondition lock];
    	[_executingCondition signal];
    	[_executingCondition unlock];
    	
    	[self release];
    	[pool release];
    }

    Авторелиз пулы. Goto. [self retain] и [self release]. NSLock. Все это в кастомной реализации NSOperation.

    Код выносит прогулки по базе в бэкграунд. Другого способа, видать, не нашлось.

    Headless, 13 Ноября 2013

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

    +80

    1. 1
    new

    TarasB, 13 Ноября 2013

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

    +65

    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
    private HandlerRegistration historyChangeHandlerRegistration;
    
    @Override
    protected void onLoad() 
    {
           super.onLoad();
           if(historyChangeHandlerRegistration == null)
           {
                historyChangeHandlerRegistration = History.addValueChangeHandler(historyHandler);
           }
    }
    	
    @Override
    protected void onUnload()
    {
            super.onUnload();
    	    
            if (historyChangeHandlerRegistration != null)
            {
                historyChangeHandlerRegistration.removeHandler();
                historyChangeHandlerRegistration = null;
            }
    }
    
    private ValueChangeHandler<String> historyHandler = new ValueChangeHandler<String>()
    {
            @Override
            public void onValueChange(ValueChangeEvent<String> event)
            {
                if(historyChangeHandlerRegistration != null)
                {
                       //some work with history token
                }
                else
                {
                       // и сюда возможно попасть
                }
            }
    };

    GWT работа с site history

    Lennis, 12 Ноября 2013

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

    +143

    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
    VariableValue *locVars;
    locVars = new VariableValue;
    locVars->variable = "r";
    locVars->value = mTaskParameters.rNodes[0]; //x_low;
    locVars->link = new VariableValue;
    locVars->link->variable = "theta";
    locVars->link->value = mTaskParameters.thetaNodes[0]; //y_low;
    locVars->link->link = new VariableValue;
    locVars->link->link->variable = "r_min";
    locVars->link->link->value = mTaskParameters.rNodes[0]; //this->x_low;
    locVars->link->link->link = new VariableValue;
    locVars->link->link->link->variable = "r_max";
    locVars->link->link->link->value = mTaskParameters.rNodes[mTaskParameters.rNodes.size()-1]; //this->x_high;
    locVars->link->link->link->link = NULL;

    Построение связного списка

    xredor, 12 Ноября 2013

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

    +165

    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
    // comparison arrays - quadruple nesting
        public function comparisonArrays(array $newOptions, array $prevOptions) {
            $diffOptions = array();
            foreach ($newOptions as $key=>$op) {
                if (isset($prevOptions[$key])) {
                    if (is_array($op)) {
                        foreach ($op as $kkk=>$ooo) {
                            if (isset($prevOptions[$key][$kkk])) {
                                if (is_array($ooo)) {
                                    foreach ($ooo as $kk=>$oo) {
                                        if (isset($prevOptions[$key][$kkk][$kk])) {
                                            if (is_array($oo)) {
                                                foreach ($oo as $k=>$o) {
                                                    if (isset($prevOptions[$key][$kkk][$kk][$k])) {
                                                        if ($prevOptions[$key][$kkk][$kk][$k]!=$o) $diffOptions[$key][$kkk][$kk][$k] = $o;
                                                    } else {
                                                        $diffOptions[$key][$kkk][$kk][$k] = $o;
                                                    }
                                                }
                                            } else {
                                                if ($prevOptions[$key][$kkk][$kk]!=$oo) $diffOptions[$key][$kkk][$kk] = $oo;
                                            }    
                                        } else {
                                            $diffOptions[$key][$kkk][$kk] = $oo;
                                        }
                                    }
                                } else {
                                    if ($prevOptions[$key][$kkk]!=$ooo) $diffOptions[$key][$kkk] = $ooo;
                                }
                            } else {
                                $diffOptions[$key][$kkk] = $ooo;
                            }
                        }
                    } else {
                        if ($prevOptions[$key]!=$op) $diffOptions[$key] = $op;
                    }
                } else {                    
                    $diffOptions[$key] = $op;
                }    
            }        
            return $diffOptions;        
        }

    crook, 11 Ноября 2013

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