- 1
n IN (6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−160
n IN (6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
условие n >= 6 выполнено
+142
/* Background gallery by http://manos.malihu.gr */
//config
//set default images view mode
//$defaultViewMode="full"; //full, normal, original
$defaultViewMode="original"; //full, normal, original
$tsMargin=0; //first and last thumbnail margin (for better cursor interaction)
$scrollEasing=999888; //scroll easing amount (0 for no easing)
$scrollEasingType="easeOutCirc"; //scroll easing type
$thumbnailsContainerOpacity=0.9; //thumbnails area default opacity
$thumbnailsContainerMouseOutOpacity=0; //thumbnails area opacity on mouse out
$thumbnailsOpacity=1; //thumbnails default opacity
$nextPrevBtnsInitState="show"; //next/previous image buttons initial state ("hide" or "show")
$keyboardNavigation="on"; //enable/disable keyboard navigation ("on" or "off")
//cache vars
$thumbnails_wrapper=$("#thumbnails_wrapper");
$outer_container=$("#outer_container");
$thumbScroller=$(".thumbScroller");
$thumbScroller_container=$(".thumbScroller .container");
$thumbScroller_content=$(".thumbScroller .content");
$thumbScroller_thumb=$(".thumbScroller .thumb");
$preloader=$("#preloader");
$toolbar=$("#toolbar");
$toolbar_a=$("#toolbar a");
$bgimg=$("#bgimg");
$img_title=$("#img_title");
$nextImageBtn=$(".nextImageBtn");
$prevImageBtn=$(".prevImageBtn");
$bg=$("#bg");
$(window).load(function() {
$toolbar.data("imageViewMode",$defaultViewMode); //default view mode
if($defaultViewMode=="full"){
$toolbar_a.html("<img src='images/toolbar_n_icon.png' width='50' height='50' />").attr("onClick", "ImageViewMode('normal');return false").attr("title", "Restore");
} else {
$toolbar_a.html("<img src='images/toolbar_fs_icon.png' width='50' height='50' />").attr("onClick", "ImageViewMode('full');return false").attr("title", "Maximize");
}
/* var winWidth=$(window).width();
var winHeight=$(window).height();
$("#bg").attr("min-height",winHeight+"px"); */
ShowHideNextPrev($nextPrevBtnsInitState);
//thumbnail scroller
$thumbScroller_container.css("marginLeft",$tsMargin+"px"); //add margin
sliderLeft=$thumbScroller_container.position().left;
sliderLeft=0;
sliderWidth=$outer_container.width();
$thumbScroller.css("width",sliderWidth);
var totalContent=0;
fadeSpeed=200;
var $the_outer_container=document.getElementById("outer_container");
var $placement=findPos($the_outer_container);
$thumbScroller_content.each(function () {
var $this=$(this);
totalContent+=$this.innerWidth();
$thumbScroller_container.css("width",totalContent);
$this.children().children().children(".thumb").fadeTo(fadeSpeed, $thumbnailsOpacity);
});
$thumbScroller.mousemove(function(e){
if($thumbScroller_container.width()>sliderWidth){
var mouseCoords=(e.pageX - $placement[1]);
var mousePercentX=mouseCoords/sliderWidth;
var destX=-((((totalContent+($tsMargin*2))-(sliderWidth))-sliderWidth)*(mousePercentX));
var thePosA=mouseCoords-destX;
var thePosB=destX-mouseCoords;
if(mouseCoords>destX){
$thumbScroller_container.stop().animate({left: -thePosA}, $scrollEasing,$scrollEasingType); //with easing
} else if(mouseCoords<destX){
$thumbScroller_container.stop().animate({left: thePosB}, $scrollEasing,$scrollEasingType); //with easing
} else {
$thumbScroller_container.stop();
}
}
});
$thumbnails_wrapper.fadeTo(fadeSpeed, $thumbnailsContainerOpacity);
/* $thumbnails_wrapper.hover(
function(){ //mouse over
var $this=$(this);
$this.stop().fadeTo("slow", 1);
},
function(){ //mouse out
var $this=$(this);
$this.stop().fadeTo("slow", $thumbnailsContainerMouseOutOpacity);
}
); */
$thumbScroller_thumb.hover(
function(){ //mouse over
var $this=$(this);
$this.stop().fadeTo(fadeSpeed, 1);
},
function(){ //mouse out
var $this=$(this);
$this.stop().fadeTo(fadeSpeed, $thumbnailsOpacity);
}
);
carousel
+142
private int[] ListToArray(List<int> list)
{
try
{
int[] res = new int[list.Count];
for (int i = 0; i < list.Count; i++)
{
res[i] = list[i];
}
return res;
}
catch (Exception) { return new int[0]; }
}
А ещё он заполняет List<> в цикле for
+141
foo() ->
Du = os:cmd("du -b "++?PM_LOGS_PATH),
[DiscSize|_] = string:tokens(Du, "\t"),
case list_to_integer(DiscSize) > 10000000000 of
...
Вся мощь эрланга. В строке может быть не только число? Let it crash!
−84
BEGIN
select count(*) INTO var FROM table_name;
EXCEPTION WHEN OTHERS THEN
var:=0;
END;
Если что-то пойдет не так...
P.S.: count() всегда возвращает какое-либо значение. Ошибке не откуда взяться.
−176
and (ss_1<>'SS0001' or ss_1<>'SS0002' or ss_1<>'SS0010')
Сегодня на продакшене было обнаружено гениальное выражение в одном из запросов.
+142
public int MapToLowerPageBoundary(int rowIndex)
{
return (rowIndex / RowsPerPage) * RowsPerPage;
}
Нашел этот метод в проекте... Интересно о чем думал автор...
+142
<?php
$self=$_SERVER['PHP_SELF'];
if (isset($_GET['page'])) { $page=$_GET['page'];} else {$page=1;}
$pages=25;
$page_offset=5;
$unique_links=9;
if ($page != 1) { // Don't show back link if current page is first page.
$back_page = $page-1;
echo("<a href=\"$self?page=$back_page\">prev</a> \n");}
for ($i=1; $i <= $pages; $i++) {
if ($i == $page) {
echo("<b>$i</b>\n");// If current page don't give link, just text.
} else {
if (($i>$page-$page_offset) && ($i<$page+$page_offset) && ($page>$page_offset)) {
echo("<a href=\"$self?page=$i\">$i</a> \n");
}
elseif (($i<=$unique_links) && ($page<=$page_offset)) {
echo("<a href=\"$self?page=$i\">$i</a> \n");
}
elseif (($i>$pages-$unique_links) && ($page>$pages-$page_offset)) {
echo("<a href=\"$self?page=$i\">$i</a> \n");
}
}
}
if (!($page >= $pages) && $pages != 1) { // If last page don't give next link.
$next_page = $page + 1;
echo("<a href=\"$self?page=$next_page\">next</a>");}
?>
Адовый аромат (хоть и рабочий), понимаю, но помогите упростить, пожалуйста. Условия внутри цикла скорее всего избыточны.
Вкратце: "плавающий" пагинатор, 9 уникальных ссылок.
+143
if($scope.model.table){
if($scope.model.table.cells == null){
if($scope.model.table.cols){
$scope.model.table.cells = $scope.model.table.cols;
}
}
if($scope.model.table.heads && $scope.model.table.cols == null){
$scope.model.table.cols = [];
$scope.model.table.heads.forEach(function(head){
$scope.model.table.cols.push({head:head});
});
$scope.model.table.cells.forEach(function(cell, i){
$scope.model.table.cols[i] = {cell:cell};
});
}
}
+66
Map<Organization, Collection<IFormula>> comissionFormulasMap = getComissionFormulae(bank, service, a);
transIterator:
for (Transaction T : afterBillingMemorandum) {//для каждой транзакции
if (comissionFormulasMap.isEmpty()) {
//System.out.println("Нет формулы для комиссии");
afterComissionSet.add(T); //если нет формулы для определения комиссии транзакция попадает в список на расщепление
} else {
BigDecimal transactionStartValue = T.getStartValue();
Set<Transaction> afterComissionForCurrent = new HashSet<>();
BigDecimal fullTax = BigDecimal.ZERO;
Collection<IFormula> comissionsAKT = new LinkedList<>();
for (Map.Entry<Organization, Collection<IFormula>> comissionsByBank : comissionFormulasMap.entrySet()) {
Organization comissionBank = comissionsByBank.getKey();
for (IFormula f : comissionsByBank.getValue()) {//для каждой формулы по комиссии
GeneratedTransactionTypes transactionType = f.getGeneratedTransactionTypes(comissionBank);
if (transactionType == GeneratedTransactionTypes.AKT) {
comissionsAKT.add(f);
} else {
BigDecimal commie = f.commission(transactionStartValue);//Определяем значение комиссии
if (commie.compareTo(BigDecimal.ZERO) == 0)
continue; //Комиссия 0 нам не интересна, переходим к следующей формуле
fullTax = fullTax.add(commie);//складываем комиссии
if (fullTax.compareTo(transactionStartValue) == 1) {
log.error("Помилка зняття комісії. Сума комісій більша 100 %. Транзакція не буде оброблена. Транзакція: {}", T.toBaseString());
continue transIterator;
} else {
afterComissionForCurrent.add(T.getComissionTransaction(f.getOrganization(), commie, transactionType));
}
}
}
}
//
// afterComissionSet.addAll(afterComissionForCurrent);
// afterComissionForCurrent.clear();
//Далі зняття по акту
BigDecimal afterComissionStartValue = transactionStartValue.subtract(fullTax);
BigDecimal aktFullTax = BigDecimal.ZERO;
for (IFormula f : comissionsAKT) {
GeneratedTransactionTypes transactionType = GeneratedTransactionTypes.AKT;
BigDecimal commie = f.commission(afterComissionStartValue);
if (commie.compareTo(BigDecimal.ZERO) == 0)
continue;
BigDecimal newFullTax = aktFullTax.add(commie);
if (newFullTax.compareTo(afterComissionStartValue) > 0) {
continue;
}
aktFullTax = newFullTax;
afterComissionForCurrent.add(T.getComissionTransaction(f.getOrganization(), commie, transactionType));
}
afterComissionSet.add(T.getRestTransaction(fullTax.add(aktFullTax)));
afterComissionSet.addAll(afterComissionForCurrent);
}
}
Писал один товарещ, притом взрослый и сформировавшийся как личность )