- 1
- 2
- 3
- 4
- 5
if (collection == null) collection = Rows.Where(r => r.ParentId == 0);
foreach (var row in collection.Where(r => r.ParentId > 0))
{
//немного кода
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
if (collection == null) collection = Rows.Where(r => r.ParentId == 0);
foreach (var row in collection.Where(r => r.ParentId > 0))
{
//немного кода
}
Сам писал. Вчера. Трезвый.
Сейчас вот думаю, а чо эта оно не работает?
+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);
}
}
}
может я чего не понимаю, но зачем?
+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 через админку))
+1
<?php
class Controller_Messages extends Controller {
function __construct() {
$this->log = new Log;
if(!defined('SECURITY_CONST')) {
$this->log->log('[controller_messages.php:'.__LINE__.'] SECURITY_CONST is undefined');
exit;
}
$this->user = new User;
$this->lang = new Lang;
$this->view = new View;
$this->model = new Model_Messages;
if(!$this->user->isAuth()) {
header('Location: /not_auth');
}
$this->user_lang = $this->user->getLang();
$this->lang->setLang($this->user_lang);
}
Открыл исходник и тут такое....
+1
Что за мемчик про вореции?
Желательно со ссылками на лурк.
+1
private int GetSroOper(MiscTransactionParams param)
{
if (param.ExpenseItem != null)
{
switch (param.ContractType)
{
case Entities.AT.ContractType.Undefined:
case Entities.AT.ContractType.TimeAndMaterials:
case Entities.AT.ContractType.Retainer:
switch ((int)param.ExpenseItem.ExpenseCategory)
{
case 2:
case 3:
case 29684252:
case 29684285:
case 29684805:
return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation600 : Helper.SLServiceOrderOperation900;
default:
throw new InvalidOperationException("Unsupported Expense Category value");
}
case Entities.AT.ContractType.RecurringService:
switch ((int)param.ExpenseItem.ExpenseCategory)
{
case 2:
case 3:
case 29684252:
case 29684285:
case 29684805:
return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation550 : Helper.SLServiceOrderOperation950;
default:
throw new InvalidOperationException("Unsupported Expense Category value");
}
case Entities.AT.ContractType.FixedPrice:
switch ((int)param.ExpenseItem.ExpenseCategory)
{
case 2:
case 3:
case 29684252:
case 29684285:
case 29684805:
return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation500 : Helper.SLServiceOrderOperation950;
default:
throw new InvalidOperationException("Unsupported Expense Category value");
}
case Entities.AT.ContractType.Incident:
switch ((int)param.ExpenseItem.ExpenseCategory)
{
case 2:
case 3:
case 29684252:
case 29684285:
case 29684805:
return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation600 : Helper.SLServiceOrderOperation950;
default:
throw new InvalidOperationException("Unsupported Expense Category value");
}
default:
throw new InvalidOperationException("Unsupported ContractType value");
}
}
else
{
switch (param.ContractType)
{
case Entities.AT.ContractType.Undefined:
case Entities.AT.ContractType.TimeAndMaterials:
case Entities.AT.ContractType.Retainer:
return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation600 : Helper.SLServiceOrderOperation900;
case Entities.AT.ContractType.RecurringService:
return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation550 : Helper.SLServiceOrderOperation950;
case Entities.AT.ContractType.FixedPrice:
case Entities.AT.ContractType.Incident:
int sroOper = (int)param.OrderOperation.EntityRow()[Constants.ServiceOrderOperation.Field.SroOper];
switch (sroOper)
{
case 500:
case 600:
case 800:
case 850:
case 950:
return sroOper;
default:
throw new InvalidOperationException("Unsupported Operation value");
}
default:
throw new InvalidOperationException("Unsupported ContractType value");
}
}
}
Это наш сеньор написал
+1
[DllImport("quickusb.dll", CharSet = CharSet.Ansi)]
static extern int QuickUsbWriteData(IntPtr Handle, byte[] outData, int length);
// ...
public bool Write(byte[] data)
{
// ...
int result = QuickUsbWriteData(handle, data, data.Length);
if (result != 0)
return true;
else if (result == 0)
{
LastError = "QUSB returned 0";
return false;
}
else
{
LastError = "Unknown error inside WriteData";
return false;
}
// ...
}
Видимо, последняя ветка - на случай зомби-апокалипсиса или особо сильных глюков после передоза.
+1
template < typename CType >
void list < CType >::sorted_push(CType val, long int key)
{
if (head) {
// Создаём контейнер и помещаем в него полученное значение
container < CType > *new_cont;
container < CType > *tmp = head;
new_cont = new container < CType >;
new_cont->set_key(key);
new_cont->set_cargo(val);
while ((tmp != tail) && (key > (tmp->get_key())))
tmp = tmp->get_next();
if ((tmp == tail) && (key > (tmp->get_key()))) { // Если выполнились одновременно два условия в цикле
new_cont->set_next(tmp->get_next()); // Вставляем в самый конец
new_cont->set_past(tmp);
tmp->set_next(new_cont);
tail = new_cont;
} else {
new_cont->set_next(tmp);
new_cont->set_past(tmp->get_past());
if ((tmp->get_past()) != NULL)
tmp->get_past()->set_next(new_cont);
if (tmp == head)
head = new_cont;
tmp->set_past(new_cont);
}
if (empty) {
empty = false;
tail = head;
}
} else {
container < CType > *new_cont;
new_cont = new container < CType >;
new_cont->set_key(key);
new_cont->set_cargo(val);
new_cont->set_next(head);
tail = head = new_cont;
empty = false;
}
}
template < typename CType > CType queue < CType >::pop()
{
container < CType > *tmp = list<CType>::head;
if (tmp == NULL) {
std::cerr <<
"Стек пуст! Стек возвращает мусор! ";
list<CType>::empty = true;
} else {
CType tmpval = list<CType>::head->get_cargo();
// Переходим к следующему элементу
list<CType>::head = list<CType>::head->get_next();
if (list<CType>::head == NULL)
list<CType>::empty = true;
delete tmp;
return tmpval;
}
}
template < typename CType > CType stack < CType >::pop()
{
container < CType > *tmp = list<CType>::tail;
if (tmp == NULL) {
std::cerr <<
"Очередь пуста! Возвращается мусор! ";
list<CType>::empty = true;
} else {
CType tmpval = list<CType>::tail->get_cargo();
// Переходим к предыдущему элементу
if (list<CType>::tail != list<CType>::head)
list<CType>::tail = list<CType>::tail->get_past();
else
list<CType>::empty = true;
delete tmp;
return tmpval;
}
}
пострелял себе в ногу
+1
document.getElementById('order').addEventListener('submit', function(e){
document.getElementById('order').addEventListener('keyup', function(e){
var appBtns = document.getElementsByClassName('btn'), i;
for (var i = 0; i < appBtns.length; i ++)
appBtns[i].style.disabled = false;
form.submit.disabled = false;
});
var appBtns = document.getElementsByClassName('btn'), i;
for (var i = 0; i < appBtns.length; i ++)
appBtns[i].style.disabled = true;
form.submit.disabled = true;
});
без комментариев