- 1
- 2
- 3
- 4
- 5
public class XmlSettings
{
XDocument x = XDocument.Load(@"...Settings.xml");
public XDocument Settings { get { return x; } }
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+114
public class XmlSettings
{
XDocument x = XDocument.Load(@"...Settings.xml");
public XDocument Settings { get { return x; } }
}
Manager настроек из предудыщего проекта
+108
private void InitializeUser()
{
textBoxFirstname.Text = _user.FirstName;
textBoxLastname.Text = _user.LastName;
textBoxPassword.Text = _user.Password;
textBoxUsername.Text = _user.UserName;
textBoxMail.Text = _user.Mail;
comboBoxRoles.Text = _user.UserRole.Id>0 ? _user.UserRole.RoleName : "";
comboBoxRoles.Enabled = true;
if(User.CurrentUser.isLoanOfficer || User.CurrentUser.isVisitor || User.CurrentUser.isCashier)
{
comboBoxRoles.Enabled = false;
}
else if(User.CurrentUser.isAdmin)
{
if(_user.isAdmin || _user.isSuperAdmin) comboBoxRoles.Enabled = false;
}
else if(User.CurrentUser.isSuperAdmin)
{
if(_user.isSuperAdmin) comboBoxRoles.Enabled = false;
}
}
Код взят из реального open source проекта. Реализация многоуровневой проверки прав текущего пользователя :).
+144
program test;
var i : boolean;
begin
i := true;
if i then while true do Writeln('WAR IS TRUE!!!')
else Writeln('FALSE');
end.
Pascal...
−112
--Вариант 1:
SELECT round(term/2::real::integer)
--Вариант 2:
SELECT term/2+term%2
Цель: определить номер курса от номера семестра (term).
Просим выбрать лучший вариант.
+161
function fill(){ //
document.getElementById('email1').value = "Введіть ваш e-mail";
document.getElementById('u_name2').value = "Введіть ваше імя";
document.getElementById('u_adress1_1').value = "Введіть вашу адресу";
}
// Перевірка імен, імейла та адреси в полі
function check_name(){if (document.getElementById('u_name2').value == "Введіть ваше імя" || document.getElementById('u_name2').value.length < 3 ) {error_name();}else{checked_name();}}
function check_email(){if (document.getElementById('email1').value == "Введіть ваш e-mail") {error_email();}else{checked_email();}}
function check_adress(){if (document.getElementById('u_adress1_1').value == "Введіть вашу адресу") {error_adress();}else{checked_adress()};}
// Якщо імя .. введене неправильно
function error_name(){document.getElementById('d_name').innerHTML = "Невірно вказане імя (мінімум 3 символа)"; document.getElementById('d_name').style.color="red";}
function error_email(){document.getElementById('d_email').innerHTML = "Невірно вказаний email"; document.getElementById('d_email').style.color="red";}
function error_adress(){document.getElementById('d_adress').innerHTML = "Невірно вказана адреса"; document.getElementById('d_adress').style.color="red";}
// Якщо імя .. введене правильно
function checked_name(){document.getElementById('d_name').innerHTML = "Імя вказане вірно"; document.getElementById('d_name').style.color="green";}
function checked_email(){document.getElementById('d_email').innerHTML = "email вказаний вірно"; document.getElementById('d_email').style.color="green"}
function checked_adress(){document.getElementById('d_adress').innerHTML = "Адреса вказана вірно"; document.getElementById('d_adress').style.color="green"}
Сорри за украинский язык, думаю понятно. Сказали 30 минут писать джаваскрипт, вот и писали... :))
+173
// app/code/Core/Mage/Catalog/Model/Resource/Eav/Attribute.php:68
Mage::throwException('0_o');
Из Magento 1.4.1.0.
Когда вылетело при дебаге, решил, что пора на дурку двигать...
+144
http://nemolaboratory.ru/blog/about_a_miscellaneous/Nemo-Laboratory-About
Напишите здесь все свои замечания, буду благодарен
+129
if (obj == null)
return 0;
if (obj == DBNull.Value)
return 0;
return int.Parse (obj.ToString ());
в столбце хранится Integer...
+169
<?php
$res = "-1";
if($num>0) {
for($d=1;$d<=$num;$d++) {
$res.=",".$data[$d-1];
}
$res=substr($res,3,100000);
$res=str_replace(",",", ", $res);
}
?>
+165
$res = explode(" ", $price);
$price = trim(str_replace(".", "", str_replace(",", "", substr(trim($res[0]), 0, strlen(trim($res[0])) - 2))));
Изначально в переменной $price строка такого вида: 144.07 РУБ.
Судя по всему автор хотел таким образом получить из нее целое значение