- 1
private string[] months = new string[12] {"Январь","Февраль","Март", "Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"};
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+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;
−55.1
#Пример раз
my %parse_hash = (
$sub_dir => $dir,
$sub_style_dir => $style_dir,
$sub_image_dir => $image_dir
);
#Пример два
...
elsif ($event eq $Event_View_Par){
print &ViewPar(%Query);
}
elsif ($event eq $Event_View_All){
print &ViewPar(%Query);
}
elsif ($event eq $Event_View_Asset){
print &ViewAsset(%Query);
}
Пример 1: В качестве ключей хэша переменные, которые определены в другом файле.
Пример 2: переменные $Event_View* определены в другом, используются только здесь и больше нигде
И так по всему коду
Задалбывает всё время переключаться alt-табом на файл, смотреть на определение переменных
+154
<?
function clearComma($str)
{
$str = preg_replace("#(,|\.|-|\/|:|;|\"|'|\?|\(|\)|\\|*)#", '', $str);
return $str;
}
function generate($bold_o, $bold_c)
{
$art = file_get_contents('article.txt');
$voc_str_mass = file('voc.txt');
$key = file('key.txt');
foreach ($key as $word)
{
$keys[] = trim($word);
}
foreach ($voc_str_mass as $voc_str)
{
$voc[] = explode("\t", trim($voc_str));
}
$words_massive = explode(' ', clearComma($art));
foreach ($words_massive as $word)
{
if (strlen($word) > 3)
{
foreach ($voc as $check)
{
if (in_array($word, $check) && $word != 'keyword')
{
$c = count($check);
$art = str_replace($word, $check[rand(0, $c - 1)], $art);
}
}
}
}
$art_mass = explode(' ', $art);
foreach ($art_mass as $string)
{
$art_out .= str_replace('keyword', $bold_o . $keys[rand(0, count($keys) - 1)] . $bold_c, $string) . ' ';
}
return $art_out;
}
//echo(generate('<b>', '</b>'));
//exit();
$tpl_mass = file("tpl.tpl");
foreach ($tpl_mass as $tpl_string)
{
$template .= str_replace('{GENERATE}', generate('<b>', '</b>'), $tpl_string);
}
//$date = date(d).'-'.date(m).'-'.date(Y).'_'.date(H).'-'.date(i).'-'.date(s);
$handle = fopen($date . '_generated.html', "w");
fwrite($handle, $template);
fclose($handle);
?>
ну тут тока матом если...