- 1
$(this).parents('li:first').parents('li:first').parents('li:first').parents('li:first').parents('li:first').attr('class', 'Node ExpandOpen IsLast');
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+163.4
$(this).parents('li:first').parents('li:first').parents('li:first').parents('li:first').parents('li:first').attr('class', 'Node ExpandOpen IsLast');
ну как прикажите до 8го элемента вверх по DOM прогуляться иначе? О_о
ЗЫ период владение Jquery = 1 дьень и 24 часа из суток
+166
$limit = (isset($this->params['pass'][1]) == 'news')?null:5;
балина, и это работает :D
+67.4
Apache POI
The apache project has a library which called POI that can read and write the HSSF (Horrible Spread Sheet Format)
Не говнокод, но официальное название формата доставляет :)
+144.8
/**
* Helper classes for computing window query on rectangles
*/
class VerticalSegmentIntersect : public std::unary_function < PRGlyph, ptrdiff_t > {
ptrdiff_t m_Lhs;
ptrdiff_t m_Rhs;
public:
VerticalSegmentIntersect ( ptrdiff_t top, ptrdiff_t bottom ) throw() : m_Lhs(top+top), m_Rhs(bottom+bottom) {}
ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
QRect const* area = inpGlyph->GetGlyphArea();
ptrdiff_t x = area->bottom() + area->top(), y = area->bottom() - area->top();
if (y < x - m_Rhs ) return 0;
if (y < m_Lhs - x ) return 0;
return 1;
}
};
class HorisontalSegmentIntersect : public std::unary_function < PRGlyph, ptrdiff_t > {
ptrdiff_t m_Lhs;
ptrdiff_t m_Rhs;
public:
HorisontalSegmentIntersect ( ptrdiff_t left, ptrdiff_t right ) throw() : m_Lhs(left+left), m_Rhs(right+right) {}
ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
QRect const* area = inpGlyph->GetGlyphArea();
ptrdiff_t x = area->right() + area->left(), y = area->right() - area->left();
if (y < x - m_Rhs ) return 0;
if (y < m_Lhs - x ) return 0;
return 1;
}
};
/**
* Helper classes for computing containment query on rectangles
*/
class VerticalSegmentContains : public std::unary_function < PRGlyph, ptrdiff_t > {
ptrdiff_t m_Lhs;
ptrdiff_t m_Rhs;
public:
VerticalSegmentContains ( ptrdiff_t top, ptrdiff_t bottom ) throw() : m_Lhs(top+top), m_Rhs(bottom+bottom) {}
ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
QRect const* area = inpGlyph->GetGlyphArea();
ptrdiff_t x = area->bottom() + area->top(), y = area->bottom() - area->top();
if ( y > x - m_Lhs ) return 0;
if ( y > m_Rhs - x ) return 0;
return 1;
}
};
class HorisontalSegmentContains : public std::unary_function < PRGlyph, ptrdiff_t > {
ptrdiff_t m_Lhs;
ptrdiff_t m_Rhs;
public:
HorisontalSegmentContains ( ptrdiff_t left, ptrdiff_t right ) throw() : m_Lhs(left+left), m_Rhs(right+right) {}
ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
QRect const* area = inpGlyph->GetGlyphArea();
ptrdiff_t x = area->right() + area->left(), y = area->right() - area->left();
if ( y > x - m_Lhs ) return 0;
if ( y > m_Rhs - x ) return 0;
return 1;
}
};
// compute the window query on m_GlyphData rectangles
QVector<PRGlyph> :: iterator windowq = m_Selection.isValid() ?
std::partition ( m_GlyphData.begin(),
std::partition ( m_GlyphData.begin(), m_GlyphData.end(), VerticalSegmentIntersect ( m_Selection.top(), m_Selection.bottom() ) ),
HorisontalSegmentIntersect ( m_Selection.left(), m_Selection.right() )
) : m_GlyphData.begin();
// compute the containment query on window query rectangles (the containment query resuls is always subset of window query )
QVector<PRGlyph> :: iterator containq = std::partition ( m_GlyphData.begin(),
std::partition ( m_GlyphData.begin(), windowq, VerticalSegmentContains ( m_Selection.top(), m_Selection.bottom() ) ),
HorisontalSegmentContains ( m_Selection.left(), m_Selection.right() )
);
Способ быстренько находить прямоугольники, пересекающиеся с входным и содержимые им же. Применимо для прямоугольных параллелепипедов любой размерности.
+912.2
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
if(n==1) cout<<"A";
if(n==2) cout<<"B";
if(n==3) cout<<"AB";
if(n==4) cout<<"BAB";
if(n==5) cout<<"ABBAB";
if(n==6) cout<<"BABABBAB";
if(n==7) cout<<"ABBABBABABBAB";
if(n==8) cout<<"BABABBABABBABBABABBAB";
if(n==9) cout<<"ABBABBABABBABBABABBABABBABBABABBAB";
if(n==10) cout<<"BABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
if(n==11) cout<<"ABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
if(n==12) cout<<"BABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
if(n==13) cout<<"ABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
if(n==14) cout<<"BABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
if(n==15) cout<<"ABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB";
return 0;
}
строки Фибаначи. (=
+169.4
if (!jQuery) $('<scr' + 'ipt src="/jquery.js" type="text/javascript"></scr' + 'ipt>');
−857
SELECT * FROM [dbo].[Publications]
where [UserId] not like 'NULL'
UserId, естественно, int
+148.2
var tbl = order.group != 0 ?
(order.group != 1 ?
limit :
closed) :
open;
+162.6
<?php
if($_GET['id'] == 10 ){
$location = "/articles/lyustry/lustra-na-kuhne/";
}elseif($_GET['id'] == 13 and $_GET['id_type'] == 17){
$location = "/market/interernye_svetilniki/lyustry/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 22 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/bolshie_lyustry/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 34 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/lyustry/bolee_6_rozhkov/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 2 ){
$location = "/market/interernye_svetilniki/podvesnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 40 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/podvesnye/odinochnyj_podves/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 41 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/podvesnye/trojnoj_i_bolee/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 5 ){
$location = "/market/interernye_svetilniki/nastenno-potolochnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 35 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/potolochnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 52 ){
$location = "/market/interernye_svetilniki/vlagozawitnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 51 ){
$location = "/market/interernye_svetilniki/podsvetka_kartin/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 7 ){
$location = "/market/interernye_svetilniki/bra/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 37 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/bra/odnorozhkovye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 38 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/bra/dvuhrozhkovye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 39 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/bra/treh_i_bolee_rozhkovye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 1 ){
$location = "/market/interernye_svetilniki/tochechnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 42 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/tochechnye/odinochnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 43 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/tochechnye/dvojnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 44 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/tochechnye/tri_i_bolee/";
}
elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 8){
$location = "/market/interernye_svetilniki/nastolnye_lampy/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 46 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/nastolnye_lampy/ofisnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 47 and $_GET['act'] == 'sub_
type'){
$location = "/market/interernye_svetilniki/nastolnye_lampy/prikrovatnye_domashnie_ili_interernye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 6 ){
$location = "/market/interernye_svetilniki/torshery/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 9 ){
$location = "/market/ulichnye_svetilniki/";
}...
И так далее..
Клиент поставил нашу CMS, на старой были ссылки типа /?id=10 и т.д. Сделал ему для примера скрипт редиректа с использованием switch case и вот что я увидел через две недели 0_0 Неприкрытый говнокод.
+122.6
string[] mas_param = a.Split('_');
this.s_sw_neraspred = mas_param[15];
s_neraspred.Text = this.s_sw_neraspred;
int i = a.IndexOf("_", 0, a.Length);
sw_id = a.Substring(0, i);
int j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
mf_id = a.Substring(j, i - j);
//mf1=a.Substring(j);
j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
ta_ed = a.Substring(j, i - j);
j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
this.s_op = a.Substring(j, i - j);
j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
s_rm = a.Substring(j, i - j);
j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
s_tm = a.Substring(j, i - j);
j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
s_sw = a.Substring(j, i - j);
j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
ta_sd = a.Substring(j, i - j);
j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
sw_sd = a.Substring(j, i - j);
j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
sw_ed = a.Substring(j, i - j);
//mf_topsw
j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
mf_topsw = a.Substring(j, i - j);
//s_op_topsw
j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
s_op_topsw = a.Substring(j, i - j);
//s_rm_topsw
j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
s_rm_topsw = a.Substring(j, i - j);
//s_tm_topsw
j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
s_tm_topsw = a.Substring(j, i - j);
//s_sw_topsw
j = i + 1;
i = a.IndexOf("_", j, a.Length - j);
s_sw_topsw = a.Substring(j, i - j);
//ta
ta_id = a.Split('_')[mas_param.Length-1];
a - строка вида
{0}_{1}_{2}_{3}_{4}_{5}_{6}_{7}_{8}_{9}_ {10}_{11}_{12}_{13}_{14}_{15}_{16}