- 1
- 2
- 3
- 4
- 5
- 6
- 7
private string fEmail;
...
public string Email
{
get {return fEmail = fEmail != null ? fEmail: string.Empty;}
set {fEmail=value;}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+129
private string fEmail;
...
public string Email
{
get {return fEmail = fEmail != null ? fEmail: string.Empty;}
set {fEmail=value;}
}
чтобы проверить на нулл переменную fEmail, ее нужно зачем то присвоить самой же себе, долго вкуривал, но менять не стал. Наверное это заморочки с энхибернэйт
З.Ы. версия фреймворка для которого было написано это чудо 1.1
+156
<?
define ("PROXY_HOST", "10.4.4.4");
define ("PROXY_PORT", 3128);
define ("POP3_HOST", "pop3.yandex.ru");
define ("POP3_PORT", 110);
define ("POP3_USER","-------");
define ("POP3_PASSWORD","---------");
global $Ipc_Device;
/**
* Trying to create process...
**/
module_start();
$Dev_Data = null;
function device_ready (&$device, &$dd)
{
if ( $dd==null )
{
syslog ( "hell_php_client: Device IS READY." ); //Девица готова:)
return true;
}else{
syslog ( "hell_php_client: Device NOT READY." ); //Девица не готова:)
return false;
}
}
function device_write ($data )
{
if ( !dio_write ( $GLOBALS["Ipc_Device"], $data, strlen ( $data )))
{
syslog (1, "hell_php_client: Unable to write to device");
exit(-1);
}
}
function register_device ()
{
//Trying to create IPC Device IF NOT EXISTS
$Device_Name = "/dev/mail";
$IPC_DEVICE = null;
if ( file_exists ($Device_Name) )
{
syslog ( 1, " Device already created." );
}else{
$IPC_DEVICE = posix_mknod ( $Device_Name, POSIX_S_IFIFO);
if ( !$IPC_DEVICE )
{
syslog (1, "hell_php_client: Can't create device. Unknown problem.");
exit (1);
}
syslog (1, "hell_php_client: Device $Device_Name created.");
}
$dev = dio_open ($Device_Name, O_RDWR);
$GLOBALS["Ipc_Device"] = $dev;
return $dev;
}
function device_read($r)
{
return dio_read ($GLOBALS["Ipc_Device"], $r);
}
function device_close ( )
{
dio_close ( $GLOBALS["Ipc_Device"]);
}
/**
* CHAPTER 2: Networking. :))
* Connecting to mailserver
**/
//И еще куча кода с сокетами
Сие творение я написал прошлой ночью в нетрезвом состоянии.
Это - устройство сбора почты. Да, именно устройство. И оно работает. Но, блин, я теперь не могу разобраться КАК именно?
Там около 800 строк кода с сокетами, вызовами read/write/lock и даже fcntl!
+135.1
private string[] months = new string[12] {"Январь","Февраль","Март", "Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"};
безусловно сильный ход. особенно для .NET
+141
function isBrowserUeban()
{
if (navigator.userAgent.match(/MSIE 6/i) != null) return 1;
else if (navigator.userAgent.match(/MSIE 7/i) != null) return 2;
else return 0;
}
кратко и по сути
PS код писался когда ie8 не было
+159
if(isset($_GET['o']) and $_GET['o']>0) {$id_psub = $_GET['o'];} else { exit(); }
$result = mysql_query("SELECT * FROM psub WHERE id_psub='$id_psub'",$db);
$myrow = mysql_fetch_array($result);
$id_prepod = $myrow['id_prepod']; $type_psub = $myrow['type_psub']; $id_sub = $myrow['id_sub'];
$re = mysql_query("SELECT * FROM sub JOIN set_sub ON sub.id_sub = set_sub.id_sub WHERE sub.id_sub='$id_sub'", $db);
$m = mysql_fetch_array($re); $id_spec = $m['id_spec']; $n_cours = $m['n_cours'];
$r = mysql_query("SELECT t_spec, id_fac, n_spec, id_sett FROM spec WHERE id_spec = '$id_spec'", $db);
$yr = mysql_fetch_array($r); $t_spec = $yr['t_spec']; $id_fac = $yr['id_fac']; $n_spec = $yr['n_spec']; $id_sett = $yr['id_sett'];
$l = mysql_query("SELECT t_fac FROM fac WHERE id_fac='$id_fac'", $db);
if(mysql_num_rows($l) == 0) { $l = mysql_query("SELECT t_fac, id_ins FROM faci WHERE id_fac='$id_fac'", $db);
$o = mysql_fetch_array($l); $i = $o['id_ins'];
$rl = mysql_query("SELECT t_ins FROM ins WHERE id_ins = '$i'", $db); $ml = mysql_fetch_array($rl);
echo "<div class='s_sfu'>".$ml['t_ins']."</div><p align='center' class='f'>Факультет:</p>";
echo "<div class='s_sfu'>".$o['t_fac']."</div>";}
оттуда же
+176.4
if($n==1 or $n==3 or $n==3 or $n==4 or $n==5) {
if($n ==1 ) {$result = mysql_query("SELECT * FROM spec WHERE id_fac='$id_fac' and 1c='1' and id_sett='1'");}
if($n ==2 ) {$result = mysql_query("SELECT * FROM spec WHERE id_fac='$id_fac' and 2c='1' and id_sett='1'");}
if($n ==3 ) {$result = mysql_query("SELECT * FROM spec WHERE id_fac='$id_fac' and 3c='1' and id_sett='1'");}
if($n ==4 ) {$result = mysql_query("SELECT * FROM spec WHERE id_fac='$id_fac' and 4c='1' and id_sett='1'");}
if($n ==5 ) {$result = mysql_query("SELECT * FROM spec WHERE id_fac='$id_fac' and 5c='1' and id_sett='1'");}}
кусок из примера кода, который чувак прислал к нам в контору вместе с резюме
+144
<?php
$db = mysql_connect("localhost","user","passwd");
mysql_select_db("magistr", $db);
mysql_query("set names cp1251");
?>
безопасный стиль написания кода
+135.1
if ((Owner as Form1).ZakazdataGrid.Columns.Count == 0)
{
(Owner as Form1).ZakazdataGrid.Columns.Add("KodTov", "");
(Owner as Form1).ZakazdataGrid.Columns.Add("NazvaTov", "Товар");
(Owner as Form1).ZakazdataGrid.Columns.Add("Kolvo", "Кол-во");
(Owner as Form1).ZakazdataGrid.Columns.Add("NazvaEd", "Ед.");
(Owner as Form1).ZakazdataGrid.Columns.Add("Suma", "Сумма");
(Owner as Form1).ZakazdataGrid.Columns.Add("KolEd", "");
(Owner as Form1).ZakazdataGrid.Columns.Add("Sostavnoy", "");
(Owner as Form1).ZakazdataGrid.Columns.Add("Sostav", "");
(Owner as Form1).ZakazdataGrid.Columns["Sostavnoy"].Visible = false;
(Owner as Form1).ZakazdataGrid.Columns["Sostav"].Visible = false;
(Owner as Form1).ZakazdataGrid.Columns["KodTov"].Visible = false;
(Owner as Form1).ZakazdataGrid.Columns["KolEd"].Visible = false;
(Owner as Form1).ZakazdataGrid.Columns["NazvaTov"].Width = (int)((Owner as Form1).ZakazdataGrid.Width * 0.5);
(Owner as Form1).ZakazdataGrid.Columns["NazvaTov"].SortMode = DataGridViewColumnSortMode.NotSortable;
(Owner as Form1).ZakazdataGrid.Columns["Kolvo"].Width = (int)((Owner as Form1).ZakazdataGrid.Width * 0.15);
(Owner as Form1).ZakazdataGrid.Columns["Kolvo"].SortMode = DataGridViewColumnSortMode.NotSortable;
(Owner as Form1).ZakazdataGrid.Columns["NazvaEd"].Width = (int)((Owner as Form1).ZakazdataGrid.Width * 0.15);
(Owner as Form1).ZakazdataGrid.Columns["NazvaEd"].SortMode = DataGridViewColumnSortMode.NotSortable;
(Owner as Form1).ZakazdataGrid.Columns["Suma"].Width = (int)((Owner as Form1).ZakazdataGrid.Width * 0.2);
(Owner as Form1).ZakazdataGrid.Columns["Suma"].SortMode = DataGridViewColumnSortMode.NotSortable;
(Owner as Form1).ZakazdataGrid.RowsDefaultCellStyle.Font = new Font("Times New Roman", FontSize - 5);
(Owner as Form1).ZakazdataGrid.ColumnHeadersDefaultCellStyle.Font = new Font("Times New Roman", FontSize - 5);
(Owner as Form1).ZakazdataGrid.AlternatingRowsDefaultCellStyle.BackColor = Color.PowderBlue;
(Owner as Form1).ZakazdataGrid.RowsDefaultCellStyle.BackColor = Color.LightSkyBlue;
}
Отсюда: http://sql.ru/forum/actualthread.aspx?tid=688754
:-)
+129.7
[StructLayout(LayoutKind.Explicit, Size=264)]
public struct STRRET
{
[FieldOffset(0)]
public UInt32 uType; // One of the STRRET_* values
[FieldOffset(4)]
public IntPtr pOleStr; // must be freed by caller of GetDisplayNameOf
[FieldOffset(4)]
public IntPtr pStr; // NOT USED
[FieldOffset(4)]
public UInt32 uOffset; // Offset into SHITEMID
[FieldOffset(4)]
public IntPtr cStr; // Buffer to fill in (ANSI)
}
Обертка над структурой STRRET. Доставляет тут http://www.pinvoke.net/default.aspx/Structures/STRRET.html
+160
$query="SHOW COLUMNS FROM ".$table;
$result_field=mysql_query($query);
$num_field=mysql_num_rows($result_field);
for ($i = 0; $i<$num_field; $i++)
{
$row=mysql_fetch_array($result_field);
$field_array[$i]=$row[0];
}
foreach ($field_array as $field)
$select_field.=$field.',';
$select_field=substr($select_field,0,-1);
$query='select '.$select_field.' from '.$table;
...
Аналог $query='select * from '.$table;