- 1
- 2
- 3
if ( obj == null ) {
throw new IllegalArgumentException( "Value cannot be null: " + obj );
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+80
if ( obj == null ) {
throw new IllegalArgumentException( "Value cannot be null: " + obj );
}
−168
if request.user.is_superuser:
content["stuff"] = stuff_list
content["content_stuff"] = content_stuff_list
content["domain_url"] = settings.DOMAIN_URL or "http://boo.com"
if request.user.is_superuser:
content["active_hotels"] = Hotel.objects.filter(is_active=True)
долго понимал, так и не понял
−125
$new_customer = 1 if ($new_customer);
$new_customer = 0 unless ($new_customer);
# запись из весьма не малого инет-магазина.... на perl'е....
+171
include('conf.php');
$domen=strip_tags($_POST['domain']);
$descr=strip_tags($_POST['descr']);
$admin=strip_tags($_POST['admin']);
$tech=strip_tags($_POST['tech']);
$nserver1=strip_tags($_POST['nserver1']);
$nserver2=strip_tags($_POST['nserver2']);
$mail=strip_tags($_POST['changed']);
$submit=strip_tags($_POST['s']);
if($_POST['s']){
$simbol='|[^a-z0-9-]|i'; if(!preg_match($simbol, $domen)) {
if($domen){
if($descr){
if($admin){
if($tech){
if($nserver1){
if($nserver2){
if($mail){if (preg_match("|[0-9a-z^_]+@[0-9a-z_^.]+.[a-z]{2,3}|i",$mail)){
$headers = "Content-Type: text/plain; charset=windows-1251\n";
$headers .= "From: ".$_POST['changed']."\n";
$headers .= "X-Priority: 3\r\n";
$tem="ADD $domen.org.ua";
$msg ="domain: $domen.org.ua
descr: $descr
admin-c: $admin
tech-c: $tech
nserver: $nserver1
nserver: $nserver2
changed: $mail ".date("Ymd")."
source: UANIC";
mail("[email protected]", "$tem", $msg, $headers);
echo "Заявка отправлена со следующими данными:<br><br>";
echo"Название домена: <strong><font color=\"#ff0000\">$domen.org.ua</font></strong><br>";
echo"Описание домена: <strong><font color=\"#ff0000\">$descr</font></strong><br>";
echo"Администратор домена: <strong><font color=\"#ff0000\">$admin</font></strong><br>";
echo"Технический контакт домена: <strong><font color=\"#ff0000\">$tech</font></strong><br>";
echo"DNS Сервер № 1: <strong><font color=\"#ff0000\">$nserver1</font></strong><br>";
echo"DNS Сервер № 1: <strong><font color=\"#ff0000\">$nserver2</font></strong><br>";
echo"Ваш E-mail: <strong><font color=\"#ff0000\">$mail</font> ".date("Ymd")."</strong><br><br>";
echo"В течении 10 минут проверьте ваш почтовый ящчик <strong><font color=\"#00ff00\">$mail</font></strong> на наличие ссылки о подтверждении регистрации доменного имени";
exit();
}else{echo "<center>$error9<br>"; include('index.html'); die;}
}else{echo "<center>$error8<br>"; include('index.html'); die;}
}else{echo "<center>$error7<br>"; include('index.html'); die;}
}else{echo "<center>$error6<br>"; include('index.html'); die;}
}else{echo "<center>$error5<br>"; include('index.html'); die;}
}else{echo "<center>$error4<br>"; include('index.html'); die;}
}else{echo "<center>$error3<br>"; include('index.html'); die;}
}else{echo "<center>$error2<br>"; include('index.html'); die;}
}else{echo "<center>$error10<br>"; include('index.html'); die;}
}else{echo "<center>$error1<br>"; include('index.html'); die;}
ящчик :D
+158
$('div.contain p ~ a[href$="jpg"]').attr('id', 'linker');
document.getElementById('linker').style.color = 'green';
+111
/// <summary>
/// Получает IPAdress к которому нужно подключиться
/// </summary>
private int Get_IPAdress_Server()
{
string Buf = "";
for (int i = 0; i < Server_IP.Servers_IP.Length; i++ )
{
try
{
TcpClient tc = new TcpClient(Server_IP.Servers_IP[i], Server_IP.Servers_Port[i]);
byte[] buffer = new byte[19];
NetworkStream nss = tc.GetStream();
nss.Read(buffer, 0, 19);
Buf = Encoding.ASCII.GetString(buffer).Trim();
Server_IPAdress = Buf.Substring(0, Buf.IndexOf(":"));
Server_Port = int.Parse(Buf.Substring(Buf.IndexOf(":") + 1, Buf.Length - Buf.IndexOf(":") - 1));
return 0;
}
catch (SocketException)
{
}
}
return -1;
}
Получаем индекс в коллекции где хранятся список серверов Первый доступный!
+157
struct Vertex
{
float x, y, z;
float tu0, tv0;
} vertices[20000] =
{
-X, 0, Z, 0, 0,
X, 0, Z, 0, 0,
-X, 0, -Z, 0, 0,
X, 0, -Z, 0, 0,
0, Z, X, 0, 0,
0, Z, -X, 0, 0,
0, -Z, X, 0, 0,
0, -Z, -X, 0, 0,
Z, X, 0, 0, 0,
-Z, X, 0, 0, 0,
Z, -X, 0, 0, 0,
-Z, -X, 0, 0, 0,
};
+120
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
ComboBox
cb = sender as ComboBox;
TextBox
tb = new TextBox();
if (cb == comboBox1)
{
tb = textBox7;
}
if (cb == comboBox2)
{
tb = textBox6;
}
if (cb == comboBox12)
{
tb = textBox2;
}
if (cb == comboBox3)
{
tb = textBox8;
}
if (cb == comboBox4)
{
tb = textBox9;
}
if (cb == comboBox5)
{
tb = textBox10;
}
if (cb == comboBox6)
{
tb = textBox11;
}
if (cb == comboBox7)
{
tb = textBox12;
}
if (cb == comboBox8)
{
tb = textBox13;
}
if (cb == comboBox11)
{
tb = textBox14;
}
tb.Enabled = !(cb.SelectedIndex > 0);
tb.Text = (cb.SelectedIndex > 0) ? "" : tb.Text;
}
+98
procedure TfmAllParams.NInsertParamSelebrationClick(Sender: TObject);
var
str: string;
begin
str := //Новый год
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '01.01.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
' values(1,1,null,null,null) ' +
//День св. Валентина
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '14.02.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
' values(14,2,null,null,null) ' +
//8 марта
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '08.03.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
' values(8,3,' + #39 + 'жін.' + #39 + ',null,null) ' +
//1 мая
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '01.05.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
' values(1,5,null,null,null) ' +
//Пасха
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '04.04.2010' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
' values(4,4,' + #39 + 'Pasha' + #39 + ',2010) ' +
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '24.04.2011' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
' values(24,4,' + #39 + 'Pasha' + #39 + ',2011) ' +
// И 10 таких же запросов на каждый год!
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '24.04.2022' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
' values(24,4,' + #39 + 'Pasha' + #39 + ',2022) ' +
+164
if (strlen($str)>1 && substr($str,strlen($str)-2,1)=="1") {
switch(substr($str,strlen($str)-1,1)) {
case "0": $newstr="десять рублей";break;
case "1": $newstr="одиннадцать рублей";break;
case "2": $newstr="двенадцать рублей";break;
case "3": $newstr="тринадцать рублей";break;
case "4": $newstr="четырнадцать рублей";break;
case "5": $newstr="пятнадцать рублей";break;
case "6": $newstr="шестнадцать рублей";break;
case "7": $newstr="семьнадцать рублей";break;
case "8": $newstr="восемьнадцать рублей";break;
case "9": $newstr="девятьнадцать рублей";break;}}
else {
switch(substr($str,strlen($str)-1,1)) {
case "0": $newstr="рублей";break;
case "1": $newstr="один рубль";break;
case "2": $newstr="два рубля";break;
case "3": $newstr="три рубля";break;
case "4": $newstr="четыре рубля";break;
case "5": $newstr="пять рублей";break;
.......................................
case "7": $newstr="семь миллионов ".$newstr;break;
case "8": $newstr="восемь миллионов ".$newstr;break;
case "9": $newstr="девять миллионов ".$newstr;break;}
if (strlen($str)>7) {
switch(substr($str,strlen($str)-8,1)) {
case "2": $newstr="двадцать ".$newstr;break;
case "3": $newstr="тридцать ".$newstr;break;
case "4": $newstr="сорок ".$newstr;break;
case "5": $newstr="пятьдесят ".$newstr;break;
case "6": $newstr="шестьдесят ".$newstr;break;
case "7": $newstr="семьдесят ".$newstr;break;
case "8": $newstr="восемьдесят ".$newstr;break;
case "9": $newstr="девяносто ".$newstr;break;}}}}
if (strlen($str)>8) {
switch(substr($str,strlen($str)-9,1)) {
case "0": $newstr="сто ".$newstr;break;
case "1": $newstr="сто ".$newstr;break;
case "2": $newstr="двести ".$newstr;break;
case "3": $newstr="триста ".$newstr;break;
case "4": $newstr="четыреста ".$newstr;break;
case "5": $newstr="пятьсот ".$newstr;break;
case "6": $newstr="шестьсот ".$newstr;break;
case "7": $newstr="семьсот ".$newstr;break;
case "8": $newstr="восемьсот ".$newstr;break;
case "9": $newstr="девятьсот ".$newstr;break;}}
Вот так делают "сумму прописью".
Радует и форматирование, и порядок порядков чисел в if .. elseif .. else