- 1
- 2
- 3
- 4
- 5
// Count how many rows are in the table.
for (var x = 0; x < tableRows.length; ++x)
{
rowCount += 1;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+190
// Count how many rows are in the table.
for (var x = 0; x < tableRows.length; ++x)
{
rowCount += 1;
}
+149
// get info from db
$results = $this->datadb->dataForIndex();
$data_['mainResult'] = $results['mainResult'];
$data_['pics'] = $results['pics'];
$data_['com'] = $results['com'];
$data_['huuInvert'] = $results['huuInvert'];
$data_['dateInvert'] = $results['dateInvert'];
$data_['type'] = $results['type'];
Кусок со своего CMS. Да я знаю что можно объединить массивы, но иногда не все требуется из функции.
+168
function UploadAvatar($FILE_tmp, $FILE_name){
/*куча тупого кода*/
if($width >= $height)
$kf = (float) $width/$height;
if($width < $height)
$kf = (float) $height/$width;
//Проверка на квадратность! ппц идиотизм, идея не моя.
if($kf>1.1){
$error = "Аватар неквадратен. Пожалуйста выберите квадратный или обрежьте текущий в графическом редакторе.";
return 0;
}
/*еще куча тупого кода*/
}
Вырезал кусок из собственного старого сайта. Комменты оставил уникальными.
Когда дизайнер потребовал чтоб аватары были только квадратны, я наваял такое.
Допуск в 1,1 - это поблажка юзерам)))
+151
<?php
function test_menu() {
// $menu['test'] = array(
// 'page callback' => 'test_page',
// 'access callback' => TRUE,
// );
$menu['test/%user_uid_optional'] = array(
'page callback' => 'test_view',
'page arguments' => array(1),
'access callback' => 'test_access',
'access arguments' => array(1),
);
$menu['test/%user/view'] = array(
'title' => 'View',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$menu['test/%user/edit'] = array(
'title' => 'Edit',
'page callback' => 'test_edit',
'page arguments' => array(1),
'access callback' => 'test_access',
'access arguments' => array(1),
'type' => MENU_LOCAL_TASK,
);
return $menu;
}
function test_page() {
global $user;
if ($user->uid) {
menu_set_active_item("test/$user->uid");
return menu_execute_active_handler();
}
else {
drupal_goto('user/login');
}
}
function test_view($account) {
module_load_include('pages.inc', 'user');
return user_view($account);
}
function test_edit($account) {
module_load_include('pages.inc', 'user');
return user_edit($account);
}
function test_access($account) {
dpm($account);
return TRUE;
}
+150
<?php
function test_menu() {
$menu['test'] = array(
'page callback' => 'test_page',
'access callback' => TRUE,
);
$menu['test/%user'] = array(
'page callback' => 'test_view',
'page arguments' => array(1),
'access callback' => TRUE,
);
$menu['test/%user/view'] = array(
'title' => 'View',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$menu['test/%user/edit'] = array(
'title' => 'Edit',
'page callback' => 'test_edit',
'page arguments' => array(1),
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
);
return $menu;
}
function test_page() {
global $user;
if ($user->uid) {
menu_set_active_item("test/$user->uid");
return menu_execute_active_handler();
}
else {
drupal_goto('user/login');
}
}
function test_view($account) {
module_load_include('pages.inc', 'user');
return user_view($account);
}
function test_edit($account) {
module_load_include('pages.inc', 'user');
return user_edit($account);
}
+150
<?php
function test_menu() {
$menu['test'] = array(
'page callback' => 'test_page',
'access callback' => TRUE,
);
$menu['test/%user'] = array(
'page callback' => 'test_view',
'page arguments' => array(1),
'access callback' => TRUE,
);
return $menu;
}
function test_page() {
global $user;
if ($user->uid) {
menu_set_active_item("test/$user->uid");
return menu_execute_active_handler();
}
else {
drupal_goto('user/login');
}
}
function test_view($account) {
module_load_include('pages.inc', 'user');
return user_view($account);
}
+167
<?php
$nidPage_storage = 64578; // нид страницы "Магазины и склады" - хранится отдельно, потому что контент-менеджеры удаляют страницу "Магазинов" и нид всё время меняется
Изначально это это был drupal.
+78
public Boolean isEqual(RepJoinCondition targetJoin )
{
if (targetJoin == null) return false;
Boolean isLeftSideEqual ;
Boolean isRightSideEqual ;
isLeftSideEqual = ((this.leftJoinFiled.fieldTableName.toUpperCase() == targetJoin.leftJoinFiled.fieldTableName.toUpperCase()) &&
(this.leftJoinFiled.fieldName.toUpperCase() == targetJoin.leftJoinFiled.fieldName.toUpperCase()));
isRightSideEqual = ((this.rightJoinFiled.fieldTableName.toUpperCase() == targetJoin.rightJoinFiled.fieldTableName.toUpperCase()) &&
(this.rightJoinFiled.fieldName.toUpperCase() == targetJoin.rightJoinFiled.fieldName.toUpperCase()));
if (isLeftSideEqual && isRightSideEqual) return true;
isLeftSideEqual = ((this.leftJoinFiled.fieldTableName.toUpperCase() == targetJoin.rightJoinFiled.fieldTableName.toUpperCase()) &&
(this.leftJoinFiled.fieldName.toUpperCase() == targetJoin.rightJoinFiled.fieldName.toUpperCase()));
isRightSideEqual = ((this.rightJoinFiled.fieldTableName.toUpperCase() == targetJoin.leftJoinFiled.fieldTableName.toUpperCase()) &&
(this.rightJoinFiled.fieldName.toUpperCase() == targetJoin.leftJoinFiled.fieldName.toUpperCase()));
if (isLeftSideEqual && isRightSideEqual) return true;
return false;
}
Весьма сложнная проверка равенства, изпользуется некорректно ==
+76
package somepackage;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
public class proxyClass {
URL url = new URL("http://someserver/somepath/output?wsdl");
QName qname = new QName("http://someserver/", "someservice");
Service service = Service.create(url, qname);
test someVar = service.getPort(test.class);
}
И почему же Eclipse ругается?
+159
<?php
$z=0;
$ti=0;
$ti2=0;
$res=array();
$txt="";
$res=array();
if($argc<2)exit(0);
$fn=$argv[1];
$pt='/(^|\b|\s)((\w|[а-я]|\d)+(?:\.|\,)?)(\b|\.|,|-)/i';
if(isset($fn)){
$fc=file($fn);
foreach($fc as $nl=>$str){
preg_match_all($pt,$str,$res,PREG_PATTERN_ORDER);
foreach($res[0] as $key=>$per){
# $per=trim($per);
$sz=iconv_strlen($per);
$tz=iconv_strlen($per);
echo "Per $per key $key sz $sz\n";
while($sz>=2){
$eb = substr($per,0,$sz-1);
echo "eb $eb\n";
$res=system("cat -b dict.txt | grep ' ".$eb." ' | head -n1 | gawk '{ print $1 }'");
#echo "$res\n";
if($res!=""){
echo "res $res\n";
$oc=substr($per,$sz-1,$tz);
$fd=fopen("$argv[1].txt","a");
if($fd<0){echo "fopen";exit(0);};
fseek($fd,SEEK_END,0);
fwrite($fd,"$res$oc ");
fclose($fd);
$sz=1;
sleep(3);
};
$sz--;
};
if($sz==1){
$fd=fopen("$argv[1].txt","a");
if($fd<0){echo "fopen";exit(0);};
fseek($fd,SEEK_END,0);
fwrite($fd,"$per ");
fclose($fd);
};
};
};
$str="";
$res="";
}
?>
Замена слова кодом из словаря, по номеру слова в словаре.