- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
if (a == 10)
{
<какие-то действия>
}
else
{
<один в один те же самые действия>
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+152
if (a == 10)
{
<какие-то действия>
}
else
{
<один в один те же самые действия>
}
Безысходность.
+53
class CClass
{
//...
boost::shared_ptr<CTestData> mpTestData;
//...
};
void CClass::setTestData(boost::shared_ptr<CTestData> pTestData)
{
if(pTestData.use_count() == 0)
{
mpTestData.reset();
}
else
{
mpTestData = pTestData;
}
}
+156
class ChargifyNotFoundException extends ChargifyException {
var $errors;
var $http_code;
public function ChargifyNotFoundException($http_code, $error) {
$this->http_code = $http_code;
$message = '';
$this->errors = array();
foreach ($error as $key=>$value) {
if ($key == 'error') {
$this->errors[] = $value;
$message .= $value . ' ';
}
}
parent::__construct($message, intval($http_code));
}
}
Индусам платят за количество строк
+133
/*Checks whether the path exists and the path is directory, otherwise creates a new directory*/
RET_VALS check_create_directory(const char* const dir_path, void (*print_func)(int, char *,...))
{
RET_VALS ret_val;
struct stat sb;
ret_val = RET_OK;
if (NULL != dir_path)
{
if(NULL != print_func)
{
print_func(DBG_INFO, "%s - Checking %s existence\n", __FUNCTION__, dir_path);
}
else
{
dbgprintln("Checking %s existence", dir_path);
}
if (0 != stat(dir_path, &sb) || (false == S_ISDIR(sb.st_mode)))
{
ret_val |= RET_DIR_MISSING;
if(NULL != print_func)
{
print_func(DBG_INFO, "%s - %s is missing\n", __FUNCTION__, dir_path);
}
else
{
dbgprintln("%s is missing", dir_path);
}
errno = 0;
if (0 == mkdir(dir_path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH))
{
ret_val |= RET_DIR_CREATE_OK;
if(NULL != print_func)
{
print_func(DBG_INFO, "%s - %s is successfully created\n", __FUNCTION__, dir_path);
}
else
{
dbgprintln("%s is successfully created", dir_path);
}
}
else
{
char err_msg[_K];
sprintf(err_msg, "Failed to create %s, error %04d - %s", dir_path, errno, strerror(errno));
ret_val |= RET_DIR_CREATE_FAILED;
//dbg_ffln(DBG_ERROR, "Failed to create %s", dir_path);
if(NULL != print_func)
{
print_func(DBG_INFO, "%s - %s\n", __FUNCTION__, err_msg);
}
else
{
dbgprintln("%s", err_msg);
}
}
}
else
{
ret_val |= RET_DIR_ALREADY_EXIST;
if(NULL != print_func)
{
print_func(DBG_INFO, "%s - %s already exists\n", __FUNCTION__, dir_path);
}
else
{
dbgprintln("%s already exists", dir_path);
}
}
}
else
{
ret_val = RET_DIR_MISSING;
if(NULL != print_func)
{
print_func(DBG_ERROR, "%s - No directory name is provided", __FUNCTION__);
}
else
{
dbgprintln("No directory name is provided");
}
}
return ret_val;
}
Продолжаем раскопки. Вообще весь .с файл можно сюда выложить.
+158
function country_code_to_country( $code ){
$country = '';
if( $code == 'AF' ) $country = 'Afghanistan';
if( $code == 'AX' ) $country = 'Aland Islands';
if( $code == 'AL' ) $country = 'Albania';
if( $code == 'DZ' ) $country = 'Algeria';
if( $code == 'AS' ) $country = 'American Samoa';
if( $code == 'AD' ) $country = 'Andorra';
if( $code == 'AO' ) $country = 'Angola';
if( $code == 'AI' ) $country = 'Anguilla';
if( $code == 'AQ' ) $country = 'Antarctica';
if( $code == 'AG' ) $country = 'Antigua and Barbuda';
if( $code == 'AR' ) $country = 'Argentina';
if( $code == 'AM' ) $country = 'Armenia';
if( $code == 'AW' ) $country = 'Aruba';
if( $code == 'AU' ) $country = 'Australia';
if( $code == 'AT' ) $country = 'Austria';
if( $code == 'AZ' ) $country = 'Azerbaijan';
if( $code == 'BS' ) $country = 'Bahamas the';
if( $code == 'BH' ) $country = 'Bahrain';
if( $code == 'BD' ) $country = 'Bangladesh';
if( $code == 'BB' ) $country = 'Barbados';
if( $code == 'BY' ) $country = 'Belarus';
if( $code == 'BE' ) $country = 'Belgium';
if( $code == 'BZ' ) $country = 'Belize';
if( $code == 'BJ' ) $country = 'Benin';
if( $code == 'BM' ) $country = 'Bermuda';
if( $code == 'BT' ) $country = 'Bhutan';
if( $code == 'BO' ) $country = 'Bolivia';
if( $code == 'BA' ) $country = 'Bosnia and Herzegovina';
if( $code == 'BW' ) $country = 'Botswana';
if( $code == 'BV' ) $country = 'Bouvet Island (Bouvetoya)';
if( $code == 'BR' ) $country = 'Brazil';
if( $code == 'IO' ) $country = 'British Indian Ocean Territory (Chagos Archipelago)';
if( $code == 'VG' ) $country = 'British Virgin Islands';
if( $code == 'BN' ) $country = 'Brunei Darussalam';
if( $code == 'BG' ) $country = 'Bulgaria';
if( $code == 'BF' ) $country = 'Burkina Faso';
if( $code == 'BI' ) $country = 'Burundi';
if( $code == 'KH' ) $country = 'Cambodia';
if( $code == 'CM' ) $country = 'Cameroon';
if( $code == 'CA' ) $country = 'Canada';
if( $code == 'CV' ) $country = 'Cape Verde';
if( $code == 'KY' ) $country = 'Cayman Islands';
if( $code == 'CF' ) $country = 'Central African Republic';
if( $code == 'TD' ) $country = 'Chad';
if( $code == 'CL' ) $country = 'Chile';
if( $code == 'CN' ) $country = 'China';
if( $code == 'CX' ) $country = 'Christmas Island';
if( $code == 'CC' ) $country = 'Cocos (Keeling) Islands';
if( $code == 'CO' ) $country = 'Colombia';
if( $code == 'KM' ) $country = 'Comoros the';
if( $code == 'CD' ) $country = 'Congo';
if( $code == 'CG' ) $country = 'Congo the';
if( $code == 'CK' ) $country = 'Cook Islands';
if( $code == 'CR' ) $country = 'Costa Rica';
if( $code == 'CI' ) $country = 'Cote d\'Ivoire';
if( $code == 'HR' ) $country = 'Croatia';
if( $code == 'CU' ) $country = 'Cuba';
if( $code == 'CY' ) $country = 'Cyprus';
if( $code == 'CZ' ) $country = 'Czech Republic';
if( $code == 'DK' ) $country = 'Denmark';
if( $code == 'DJ' ) $country = 'Djibouti';
if( $code == 'DM' ) $country = 'Dominica';
if( $code == 'DO' ) $country = 'Dominican Republic';
if( $code == 'EC' ) $country = 'Ecuador';
if( $code == 'EG' ) $country = 'Egypt';
if( $code == 'SV' ) $country = 'El Salvador';
if( $code == 'GQ' ) $country = 'Equatorial Guinea';
if( $code == 'ER' ) $country = 'Eritrea';
if( $code == 'EE' ) $country = 'Estonia';
if( $code == 'ET' ) $country = 'Ethiopia';
if( $code == 'FO' ) $country = 'Faroe Islands';
if( $code == 'FK' ) $country = 'Falkland Islands (Malvinas)';
if( $code == 'FJ' ) $country = 'Fiji the Fiji Islands';
if( $code == 'FI' ) $country = 'Finland';
if( $code == 'FR' ) $country = 'France, French Republic';
if( $code == 'GF' ) $country = 'French Guiana';
if( $code == 'PF' ) $country = 'French Polynesia';
----------------------------------------------------------------
if( $code == 'VE' ) $country = 'Venezuela';
if( $code == 'VN' ) $country = 'Vietnam';
if( $code == 'WF' ) $country = 'Wallis and Futuna';
if( $code == 'EH' ) $country = 'Western Sahara';
if( $code == 'YE' ) $country = 'Yemen';
if( $code == 'ZM' ) $country = 'Zambia';
if( $code == 'ZW' ) $country = 'Zimbabwe';
if( $country == '') $country = $code;
return $country;
}
Кто-то очень много старался
+83
TextView v = (TextView)
((RelativeLayout)
((AbsoluteLayout)
((LinearLayout)
((RelativeLayout)(
(LinearLayout)activty.findViewById(R.id.container)).getChildAt(1))
.getChildAt(0))
.getChildAt(element))
.getChildAt(0))
.getChildAt(0);
(Android)
когда нет idшников...
+134
SDL_Rect sr = {
e->outputRect.x,
e->outputRect.y+e->lineHeight*line,
e->outputRect.w,
sr.y + e->lineHeight };
+120
/* 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
−119
select *
from ( select ... ,
case
when txn_minute >= date '2014-08-01'
and txn_minute < date '2014-08-02'
then
'1 августа'
when txn_minute >= date '2014-08-02'
and txn_minute < date '2014-08-03'
then
'2 августа'
when txn_minute >= date '2014-08-03'
and txn_minute < date '2014-08-04'
then
'3 августа'
when txn_minute >= date '2014-08-04'
and txn_minute < date '2014-08-05'
then
'4 августа'
when txn_minute >= date '2014-08-05'
and txn_minute < date '2014-08-06'
then
'5 августа'
.....
when txn_minute >= date '2014-08-31'
and txn_minute < date '2014-09-01'
then
'31 августа'
end
"Дата"
from txn
where txn_minute >= date '2014-08-01'
and txn_minute < date '2014-09-01'
group by .....
.....
end) pivot (sum (am)
for "Дата"
in ('1 августа',
.....
'29 августа',
'30 августа',
'31 августа'))
Кто-то подсказал правильное решение :-)
+159
if (!empty($params['manager_select'])) {
$rings = $phone_manager->getManagerRings($manager_id, $dateBegin, $dateEnd, $params['is_incoming_select'], $is_marked, $select_all_rings, $params, $managers_groups_arr, $only_not_effected, $order_params, $find_phone_number);
} else {
$rings = $phone_manager->getManagerRings($manager_id, $dateBegin, $dateEnd, $params['is_incoming_select'], $is_marked, $select_all_rings, NULL, $managers_groups_arr, $only_not_effected, $order_params, $find_phone_number);
}
Шик! Убил бы за такое