- 1
- 2
- 3
- 4
- 5
// 1188 references
internal static string CombinePaths(string firstPath, string secondPath)
{
return Path.Combine(firstPath, secondPath);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
// 1188 references
internal static string CombinePaths(string firstPath, string secondPath)
{
return Path.Combine(firstPath, secondPath);
}
- Шо это было?!!
- Cэкономили точку. 1188 раз )))))
+1
public class FileStorage {
public FileStorage() {
try {
if (String.IsNullOrEmpty(Common.GlobalVariables.FileStorage)) {
throw new Exception(Common.GuiHelper.ShowErrorMessage("FileStorage", String.Empty));
}
if (!Directory.Exists(Common.GlobalVariables.FileStorage)) {
DirectoryInfo di = Directory.CreateDirectory(Common.GlobalVariables.FileStorage);
if (!di.Exists) {
throw new Exception(Common.GuiHelper.ShowErrorMessage("FileStorageDir", String.Empty));
}
}
} catch (Exception er) {
throw new Exception(er.Message);
}
}
public String CreateFileDirectory() {
try {
int iIdx = 0;
Boolean bIsCreated = false;
while (!bIsCreated && iIdx < 10) {
String sDir = Guid.NewGuid().ToString("N").ToLower();
sDir = sDir.Substring(0, 2);
if (!Directory.Exists(Common.GlobalVariables.FileStorage + sDir + @"\")) {
DirectoryInfo di = Directory.CreateDirectory(Common.GlobalVariables.FileStorage + sDir + @"\");
if (di.Exists) {
return Common.GlobalVariables.FileStorage + sDir + @"\";
}
}
iIdx++;
}
return null;
} catch (Exception er) {
throw new Exception(er.Message);
}
}
}
может я чего не понимаю, но зачем?
+4
$(document).ready(function() {
setInterval(form_check, 10);
function form_check() {
if ($("#main-order-form input[name='car-name']").attr("value") == "") {
$("#main-order-form button").attr('disabled', 'disabled');
} else {
$("#main-order-form button").removeAttr('disabled');
}
}
});
Валидация формы)))
+1
<?php if($this->config->get('UniversumControl_status') == '1'){ ?>
<style type="text/css">
body {
<?php if(( $this->config->get('UniversumControl_body_bg_pattern') != null) && ($this->config->get('UniversumControl_body_bg_pattern') != 'pattern0.png')){ ?>
background:url("catalog/view/theme/<?php echo $this->config->get('config_template'); ?>/image/backgrounds/<?php echo $this->config->get('UniversumControl_body_bg_pattern');?>") top center repeat;
<?php } ?>
background-color:#<?php echo $this->config->get('UniversumControl_body_bg_color') ?>;
font-family:<?php echo $this->config->get('UniversumControl_body_font') ?>;
color:#<?php echo $this->config->get('UniversumControl_text_color') ?>;
}
h1,h2,h3,h4,h5,h6, #menu ul li a, #column-left .box .box-heading, #column-right .box .box-heading, .htabs a, .product-info .price-old, .product-info .price-new, .product-info .cart .button, .offer_title, div.prod_hold .prod-info-fly .name a, .accordeonHolder .name a, .prod_hold .name a, #content .boxPlain .box-heading {
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_custom_font') != null)){ ?>
font-family: '<?php echo $this->config->get('UniversumControl_custom_font_family');?>';
<?php } elseif (($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_custom_font') == null) && ( $this->config->get('UniversumControl_header_font') != 'Arial')){ ?>
<?php $headerFont = $this->config->get('UniversumControl_headings_font');
$font = str_replace("+", " ", $headerFont);
?> font-family: '<?php echo $font; ?>';
<?php } else { ?>
font-family: 'Ubuntu Condensed';
<?php } ?>
}
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings_color') != null)){ ?>
h1, h2, h2.heading_title, h3, h4, h5, h6, #column-left .box .box-heading, #column-right .box .box-heading {
color:#<?php echo $this->config->get('UniversumControl_headings_color') ?>;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings1_size') != null)){ ?>
h1 {
font-size:<?php echo $this->config->get('UniversumControl_headings1_size') ?>px;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings2_size') != null)){ ?>
h2, #content .boxPlain .box-heading {
font-size:<?php echo $this->config->get('UniversumControl_headings2_size') ?>px;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings3_size') != null)){ ?>
h3 {
font-size:<?php echo $this->config->get('UniversumControl_headings3_size') ?>px;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings4_size') != null)){ ?>
h4 {
font-size:<?php echo $this->config->get('UniversumControl_headings4_size') ?>px;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_price_size') != null)){ ?>
.product-info .price {
font-size:<?php echo $this->config->get('UniversumControl_price_size') ?>px;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_module_title_size') != null)){ ?>
#content h2.heading_title span {
font-size:<?php echo $this->config->get('UniversumControl_module_title_size') ?>px;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_column_title_size') != null)){ ?>
#column-left .box .box-heading, #column-right .box .box-heading {
font-size:<?php echo $this->config->get('UniversumControl_column_title_size') ?>px;
}
И такого кода там еще на 1000 строк.
Интернет-магазин на опенкарте. Видимо кто то сделал систему настраивания css через админку))
+2
try {
$files->load($avatar);
$this->fail('Fail message');
} catch (\Exception $ex) {
//All good
}
Это авто тест на метод $files->load
$this->fail - здесь кидает исключение
All good - и не важно какое исключение кинет $files->load, а если не кинет, то вызовем fail который наверняка кинет исключение
−3
$this->strQueryText = $strQuery = trim($arParams["QUERY"]);
$this->strTags = $strTags = $arParams["TAGS"];
Из ядра.
Многобуков не любят.
+9
<ul>
<?php if($user_comment_rating == '1') { ?>
<li><span class="icon-star"></span></li>
<?php } else if($user_comment_rating == '2') { ?>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<?php } else if($user_comment_rating == '3') { ?>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<?php } else if($user_comment_rating == '4') { ?>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<?php } else if($user_comment_rating == '5') { ?>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<?php } ?>
</ul>
Из шаблона одной платной вордпрессовской темы.
+4
constexpr Fraction operator+(const Fraction& fraction) const noexcept
{
const Fraction max_fraction_by_denominator{denominator > fraction.denominator ? *this : fraction};
const Fraction min_fraction_by_denominator{denominator < fraction.denominator ? *this : fraction};
const bool is_sim_denominator = max_fraction_by_denominator.denominator %
min_fraction_by_denominator.denominator == 0;
int sim_denominator = is_sim_denominator ?
max_fraction_by_denominator.denominator : (max_fraction_by_denominator.denominator *
min_fraction_by_denominator.denominator);
const int nominator1 = is_sim_denominator ? (min_fraction_by_denominator.nominator *
max_fraction_by_denominator.denominator / min_fraction_by_denominator.denominator) :
min_fraction_by_denominator.nominator * max_fraction_by_denominator.denominator;
const int nominator2 = is_sim_denominator ? max_fraction_by_denominator.nominator :
max_fraction_by_denominator.nominator * min_fraction_by_denominator.denominator;
int nominators_sum = nominator1 + nominator2;
int while_parts_sum = while_part + fraction.while_part;
while (nominators_sum >= sim_denominator)
{
nominators_sum -= sim_denominator;
++while_parts_sum;
}
if (!nominators_sum)
sim_denominator = 0;
return {while_parts_sum, nominators_sum, sim_denominator};
}
+5
foreach ($this->diafan->select_arr("status_id") as $id => $value)
{
$first_status = $id;
break;
}
Сниппет для получения первого ключа массива.
+2
$table = (object) null;
$table->fields = array();
Повышенная хитрость