- 1
if (event.target.parent.parent.parent.profileRow.children["2"].children["1"].text != "Мухомор")
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−350
if (event.target.parent.parent.parent.profileRow.children["2"].children["1"].text != "Мухомор")
Предыдущего разработчика проекта обуял демон сложности. До некоторых сущностей пришлось добираться так. Чудеса практологии.
+157
function fakePassword() {
$(":input:password").each(
function(i) {
$("#" + this.id + "-hidden-password").attr("name", this.name);
$("#" + this.id + "-hidden-password").attr("value", this.value);
$(this).removeAttr("value");
$(this).removeAttr("name");
}
);
return true;
}
+143
#include <unistd.h>
main()
{
int i=0;
char *cmd[] = { "ls", "-l", (char *)0 };
char *env[] = { "HOME=/usr/home", "LOGNAME=home", (char *)0 };
int rr;
for(i; i<6; i++)
{
switch(rr=fork())
{
case -1:execl ("/bin/ls", "ls", "-1", (char *)0);break;
case 0:execle ("/bin/ls", "ls", "-l", (char *)0, env);break;
case 1:execlp ("ls", "ls", "-l", (char *)0);break;
case 2:execv ("/bin/ls", cmd);break;
case 3:execve ("/bin/ls", cmd, env);break;
case 4:execvp ("ls", cmd);break;
}
}
}
- Ну это работают.
И проверяющий поставил плюс.
+85
nLen = m_aRealTexts[index].m_txtString.length();
for (int iyhx = 0; iyhx < nLen; iyhx++) {
cLetter = m_aRealTexts[index].m_txtString.charAt(iyhx);
CTxtCharStyle pCharNode = new CTxtCharStyle(cLetter);
pCharNode.SetTxtFontFace(m_nFontFace);
m_aRealTexts[index].m_txtChars.add(pCharNode);
}
...
public void SetTxtFontFace(byte nType)
{
String sLine, sTemp;
int nMark;
float xValue, yValue; //笔画点位的临时坐标
byte bIsBigChar = 0; //1表示ANSI字体UserArial_ansi.uft,2表示Unicode字体UserArial_unicode.uft,3表示宋体hztxt1.shx
m_cStroke.clear(); //清空笔画路径链表
if(nType == 1)
{
if((int)m_cChar<0x7F || ((int)m_cChar>=0x2160&&(int)m_cChar<=0x2169))
{
//按Unicode编码顺序处理字符查找指定字库文件,避免读取不必要的字库文件
InputStream fInFile = this.getClass().getResourceAsStream("/TagResources/UserArial_ansi.uft");
...
fInFile.close();
}
else if((int)m_cChar>=0x007F && (int)m_cChar<0x2FFF)
{
//字符在UserArial_ansi.uft中未找到,看是否在UserArial_unicode.uft中
int nGetByte;
sLine = new String("");
sTemp = new String("");
//float xValue, yValue;
byte[] CharUnicode = new byte[2]; //一次读取两个字节,为一个字符
byte[] cBytes = new byte[2];
InputStream fInFile = this.getClass().getResourceAsStream("/TagResources/UserArial_unicode.uft");
while((nGetByte = fInFile.read(cBytes, 0, 2)) > 0)
{
...
}
fInFile.close();
}
else if((int)m_cChar>=0x3000)
{
//字符在西文字库UserArial.uft中未找到,是大字体,则在宋体文件hztxt1.shx中查找
m_cWidth = 112.0f; //对于宋体,左下角点为坐标原点,包围盒长宽皆为127,调整量为(127-112)/2=5
m_cHeight = 112.0f;
byte nMoveDown = 5;
InputStream fInFile = this.getClass().getResourceAsStream("/TagResources/hztxt1.shx");
...
fInFile.close();
}
else if(bIsBigChar == 0)
{
//仍然没有找到字符字体,则按空格处理
m_cWidth = 12.0f;
m_cHeight = 16.0f;
m_cStroke.clear();
}
}
else if(nType == 2)
{
try
{
InputStream fInFile = this.getClass().getResourceAsStream("/TagResources/hztxt1.shx");
...
fInFile.close();
}
catch(IOException e)
{
//异常处理
e.printStackTrace();
}
}
}
Ещё один отжиг господ китайцев.
Магические числа вместо энумов и закрытие файлов вне finally - это ещё полбеды. Больше всего умиляет, что при каждой отрисовке отдельно для каждой буквы файл шрифта открывается и сканируется по новой. Неудивительно, что отрисовка так тормозит. Буду переписывать это дело - загружать глифы из файла один раз и затем дёргать их из кэша.
+63
private void anyFunction (Boolean param){
if(param == null){
throw new RuntimeException("param is null");
}
if(param.toString().length() == 4){
//any code
}else{
if(param.toString().length() == 5){
//any code
}else{
throw new RuntimeException("fack");
}
}
}
булеан к строке, для проверки true или false.
Кроме того, если не true и не false то ...
+149
Ваще без понта языкю
+159
// Функция создания списка страниц типа << < 1 2 3 > >>
function PageBar($adsNum, $nowPage, $currUrl){
$maxpageinHalf = intval (MAX_PAGEIN / 2);
$maxpagein = MAX_PAGEIN;
$maxresults = MAX_RESULTS;
$pn=($adsNum%MAX_RESULTS!=0);
$pageNum = intval($adsNum / $maxresults) + $pn;
$pageNum==0?$pageNum=1:"";
if ($nowPage < $maxpageinHalf ){ // определение первой половины списка страниц.
$minPage = 0;
$maxPage = $maxpagein;
($maxPage>$pageNum)?$maxPage=$pageNum:"";
$previous10Page = 0;
$next10Page = $nowPage + $maxpagein;
}
elseif ($nowPage > $pageNum - $maxpageinHalf) {
$maxPage = $pageNum;
$minPage = $pageNum - $maxpagein;
($minPage<=0)?$minPage=0:"";
$previous10Page = $nowPage - $maxpageinHalf;
$next10Page = $pageNum;
}
else {
$minPage = $nowPage - $maxpageinHalf;
$maxPage = $nowPage + $maxpageinHalf;
$previous10Page = $nowPage - $maxpagein;
$next10Page = $nowPage + $maxpagein;
}
$next10Page >= $pageNum? $next10Page = $pageNum-1:"";
$listing = "<a href='p0,a,".$currUrl."' title=\"В начало\" class=\"ads-link1\">|<<</a> ";
$listing .= "<a href='p$previous10Page,a,".$currUrl."' title=\"Предыдущие $maxpagein страниц\" class=\"ads-link1\"><</a> ";
for ( $i = $minPage; $i < $maxPage; $i++) {
if ( $i == $nowPage )
$listing .= "<span style=\"font-size:16px; color:red;\">".($i+1)."</span> ";
else
$listing .= "<a href=\"p".$i.",a,".$currUrl."\" title=\"Страница ".($i+1)."/$pageNum\" class=\"ads-link1\">".($i+1)."</a> ";
}
$listing .= " <a href='p".($next10Page).",a,".$currUrl."' title=\"Следующие $maxpagein страниц\" class=\"ads-link1\">></a> ";
$listing .= "<a href='p".($pageNum-1).",a,".$currUrl."' title=\"В конец\" class=\"ads-link1\">>>|</a>";
return $listing;
}
Два дня ебался, но чувствую, что здесь что-то не то :D
+36
function utf8win ($strin) {
$strin = ereg_replace("а","а",$strin);
$strin = ereg_replace("б","б",$strin);
$strin = ereg_replace("в","в",$strin);
$strin = ereg_replace("г","г",$strin);
$strin = ereg_replace("д","д",$strin);
$strin = ereg_replace("е","е",$strin);
$strin = ereg_replace("ё","ё",$strin);
$strin = ereg_replace("ж","ж",$strin);
$strin = ereg_replace("з","з",$strin);
$strin = ereg_replace("и","и",$strin);
$strin = ereg_replace("й","й",$strin);
$strin = ereg_replace("к","к",$strin);
$strin = ereg_replace("л","л",$strin);
$strin = ereg_replace("м","м",$strin);
$strin = ereg_replace("н","н",$strin);
$strin = ereg_replace("о","о",$strin);
$strin = ereg_replace("п","п",$strin);
$strin = ereg_replace("р","р",$strin);
$strin = ereg_replace("с","с",$strin);
$strin = ereg_replace("т","т",$strin);
$strin = ereg_replace("у","у",$strin);
$strin = ereg_replace("ф","ф",$strin);
$strin = ereg_replace("х","х",$strin);
$strin = ereg_replace("ц","ц",$strin);
$strin = ereg_replace("ш","ш",$strin);
$strin = ereg_replace("щ","щ",$strin);
$strin = ereg_replace("ъ","ъ",$strin);
$strin = ereg_replace("ь","ь",$strin);
$strin = ereg_replace("э","э",$strin);
$strin = ereg_replace("ю","ю",$strin);
$strin = ereg_replace("я","я",$strin);
$strin = ereg_replace("ч","ч",$strin);
$strin = ereg_replace("ы","ы",$strin);
$strin = ereg_replace("А","А",$strin);
$strin = ereg_replace("Б","Б",$strin);
$strin = ereg_replace("В","В",$strin);
$strin = ereg_replace("Г","Г",$strin);
$strin = ereg_replace("Д","Д",$strin);
$strin = ereg_replace("Е","Е",$strin);
$strin = ereg_replace("Ж","Ж",$strin);
$strin = ereg_replace("З","З",$strin);
$strin = ereg_replace("И","И",$strin);
$strin = ereg_replace("Й","Й",$strin);
$strin = ereg_replace("К","К",$strin);
$strin = ereg_replace("Л","Л",$strin);
$strin = ereg_replace("М","М",$strin);
$strin = ereg_replace("Н","Н",$strin);
$strin = ereg_replace("О","О",$strin);
$strin = ereg_replace("П","П",$strin);
$strin = ereg_replace("Р","Р",$strin);
$strin = ereg_replace("С","С",$strin);
$strin = ereg_replace("Т","Т",$strin);
$strin = ereg_replace("У","У",$strin);
$strin = ereg_replace("Ф","Ф",$strin);
$strin = ereg_replace("Х","Х",$strin);
$strin = ereg_replace("Ц","Ц",$strin);
$strin = ereg_replace("Ш","Ш",$strin);
$strin = ereg_replace("Щ","Щ",$strin);
$strin = ereg_replace("Ъ","Ъ",$strin);
$strin = ereg_replace("Ь","Ь",$strin);
$strin = ereg_replace("Э","Э",$strin);
$strin = ereg_replace("Ю","Ю",$strin);
$strin = ereg_replace("Я","Я",$strin);
$strin = ereg_replace("Ч","Ч",$strin);
$strin = ereg_replace("Ы","Ы",$strin);
$strin = ereg_replace("A","Ё",$strin);
return $strin;
}
+164
$arParams["FILES_COUNT"] = intVal(intVal($arParams["FILES_COUNT"]) > 0 ? $arParams["FILES_COUNT"] : 5);
Битрикс. Количество, так сказать, файлов.
+75
try {
Method m = this.getClass().getMethod("setLayerType", int.class, Paint.class);
if (m != null) {
m.invoke(this, View.LAYER_TYPE_SOFTWARE, (Object)null);
}
} catch (NoSuchMethodException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
Моему коллеге пришлось писать _такое_ только потому, что заказчик не захотел форкнуть проект на две отдельных ветки, для Android 2.3 и для 3.2.