- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
public List<OrderGeneralVWJ> GetAll()
{
var q = from og in Context.OrderGeneralVWJs
select new {
og
};
return q.Select(r => r.og).ToList();
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+100.4
public List<OrderGeneralVWJ> GetAll()
{
var q = from og in Context.OrderGeneralVWJs
select new {
og
};
return q.Select(r => r.og).ToList();
}
+76.3
Long orgId = 0L;
try {
orgId = Long.valueOf(textOrgId);
} catch (Exception e) {
orgId = 0L;
}
// ...
Organization org = orgDAO.findById(orgId);
if (org == null) {
// не найдено? создать новую
org = new Organization();
// ...
}
Если с веба в поле textOrgId пришёл мусор, то создать новую организацию. Но перед этим всё равно поискать в базе несуществующий orgId=0.
+83.5
for (Person p : c) {
return p;
}
−49.7
/**
* Pause length in milliseconds.
*/
private static final int _100000 = 100000;
/**
* Summary pause length in milliseconds.
*/
private static final int _500000 = _100000 * 5;
Автор творения сказал, что так удобнее читать код:)
+94.5
/// Из aspx файла
//<asp:Repeater ID="Repeater1" runat="server">
// <HeaderTemplate>
// <table width="100%" cellspacing="5">
// </HeaderTemplate>
// <ItemTemplate>
// <tr>
// <td>
// ...
// </td>
// <asp:Label runat="server" Visible='<%# DataBinder.Eval(Container.DataItem, "visibleCol2") %>'>
// <td>
// ...
// </td>
// </asp:Label>
// <asp:Label ID="LCol3" runat="server" Visible='<%# DataBinder.Eval(Container.DataItem, "visibleCol3") %>'>
// <td>
// ...
// </td>
// </asp:Label>
// </tr>
// </ItemTemplate>
// <FooterTemplate>
// </table>
// </FooterTemplate>
//</asp:Repeater>
// Из cs файла
DataTable dtres = // получаем товары
if (dtres != null && dtres.Rows.Count > 0)
{
DataTable dt = new DataTable();
/*...*/
for (int i=0;i<dtres.Rows.Count;)
{
DataRow dr=dtres.Rows[i];
/*...*/
int col2Index = i + 1;
if (col2Index < dtres.Rows.Count)
{
/*...*/
i++;
int col3Index = i + 1;
if (col3Index < dtres.Rows.Count)
{
/*...*/
i++;
}
else { /*...*/ }
}
else { /*...*/ }
dt.Rows.Add(newRow);
i++;
}
/*...*/
}
Человеку нужно было сделать товары в сетке 3x6.
От того что он сделал у меня пропал дар речи. (Чтобы тут очень много кода не бы большую (не нужную для понимания) часть заменил на "...")
Вобщем, в двух словах, он поместил вторую и третью ячейки таблицы в серверные контролы (причем в Label), а в коде берёт по три товара и засовывает в один RepeaterItem, ну а если количество товаров не делится нацело на три, то в последний RepeaterItem засовываются пустые данные, а Label делается невидимым.
Как-то так.
И самое главное, я не знаю, как человеку объяснить, что так нехорошо делать, т.к он главный программист...
+64.1
<?php
echo "<br><br>";
echo "<a href='index.php'>На главную</a> |
<a href='reg.php'>Регистрация</a> |
<a href='stat.php'>Статистика</a><br><hr width=80%>
<div class=info>Создано при участии gxcreator и kuprik17. Все права у них и ниипёт!<br>
Кто спиздит код, тому просто пиздец будет,<br>
руки оторвем и в жопу вставим!! Ясно, бля?!</div>";
?>
Еще много интересного кода: http://www.google.com/codesearch?hl=ru&lr=&q=%D0%B6%D0%BE%D0%B F%D1%83&sbtn=%D0%9F%D0%BE%D0%B8%D1%81%D0 %BA
+130.5
if (!passFlag)
{
switch (GetTreeNodeName)
{
case "group":
{
if (GetTreeNode.Parent.Parent.Parent.Parent.Name != "StudySchedule")
{
StudentCard studentCard = new StudentCard(ExploreTree.SelectedNode.Text,
ExploreTree.SelectedNode.Parent.Parent.
Text,
ExploreView.SelectedItems[0]);
studentCard.MdiParent = this.MdiParent;
studentCard.Show();
break;
}
else
{
StudySchedule schedule=new StudySchedule(ExploreView.SelectedItems[0], ExploreTree.SelectedNode.Parent.Nodes);
schedule.MdiParent = this.MdiParent;
schedule.Show();
break;
}
}
Это мой говнокод, не знаю как строчку if (GetTreeNode.Parent.Parent.Parent.Parent .Name != "StudySchedule")
написать по-нормальному)))
+62.3
void func(const char* str)
{
std::map<std::string, int>::iterator = my_map.find(str);
.....
}
std::string str = "key";
func(str.c_str());
Уверен что это может найти каждый из вас в своих проектах, но может не в таком очевидном виде...
+151
<?php
require_once ("../inc/core.php");
require_once ("../inc/header.php");
//
require_once ("../inc/classAudioFile.php");
require_once ("../inc/func.php");
/// Форма загрузки файла
if (!isset ($_POST['upload'])){
echo '<form action="upload.php" method="post" enctype="multipart/form-data">';
echo '<input type="file" name="fname"><br>';
echo '<input type="submit" name="upload" value="Загрузить"><br></form>';
}
//
$date = DATE ("Y-m-d");
$scriptdir = "$siteurl/mp3/";
$dir = "files/$date/";
$tmpfilename = $_FILES['fname']['tmp_name'];
$filename = $_FILES['fname']['name'];
$nfilename = trans ("MixON.mobi_".$filename);
$ext = explode (".",$filename);
$size = $_FILES['fname']['size'];
$adrfile = $dir.$nfilename;
$mp3url = $scriptdir.$adrfile;
//////////////
if (!is_dir ("files/$date")) mkdir ("files/$date", 0770);
if (isset($_POST['upload'])){
if (count($ext) !=2) {
echo "Файлы с двойным расширением запрещены. <br /> Должно быть так: <br /> filename.ext";
exit;
}
if ($ext[1] != 'mp3' ){
echo 'Разрешена загрузка только mp3 файлов.';
exit;
}
if (file_exists ($tmpfilename)){
copy ($tmpfilename, $adrfile);
//// Получаем теги файла
echo "Название файла: $filename <br />";
$AF = new AudioFile;
$AF->loadFile($adrfile);
//$AF -> printSampleInfo();
$channels = $AF -> wave_channels;
$framerate = $AF -> wave_framerate;
$byterate = $AF -> wave_byterate;
$length = $AF -> wave_length;
$title = $AF -> id3_title;
$title = trim(iconv('windows-1251','UTF-8',$title));
$artist = $AF -> id3_artist;
$artist = trim (iconv('windows-1251','UTF-8',$artist));
$album = $AF -> id3_album;
$album = trim (iconv('windows-1251','UTF-8',$album));
$year = $AF -> id3_year;
$year = trim (iconv('windows-1251','UTF-8',$year));
$genre = $AF -> id3_genre;
$genre = trim (iconv('windows-1251','UTF-8',$genre));
$comment = $AF -> id3_comment;
$comment = trim (iconv('windows-1251','UTF-8',$comment));
///Выводим мп3 теги
echo "Каналы: $channels <br /> Частота: $framerate <br /> Битрейт: $byterate <br /> ";
echo "Продолжительность: ".date('i:s', mktime(0,0,round($length))). "мин. <br /> ";
echo "Название: $title <br />";
echo "Исполнитель: $artist <br />";
echo "Стиль: $genre <br />";
if ($album != null) echo "Альбом: $album <br />";
if ($year != null) echo "Год: $year <br />";
}// Если файл закачалься и удачно скопирован
echo "<a href=\"http://$siteurl/$scriptdir/index.php?do=add\">Все верно</a>";
$do = isset($_GET['do']) ? $_GET['do'] : '';
switch ($do)
{
case 'admview':
$sql = "INSERT INTO `files` ( `id` , `title` , `artist` , `genre` , `album` , `year` , `mp3url` )
VALUES (
'', '$title', '$artist', '$genre', '$album', '$year', '$mp3url'
);";
csql ($sql);
mysql_query($sql);
echo "<a href=\"http://$siteurl/$scriptdir/index.php?do=edit\">Нужно изменить</a>";
}//switch do
}// Если нажата кнопка
require_once ("../inc/footer.php");
?>
+150
var currentDate = new Date();
var currentDay = currentDate.getDay();
var currentMonth = currentDate.getMonth();
var currentYear = currentDate.getYear();
var currentHour = currentDate.getHours();
var currentMinute = currentDate.getMinutes();
var currentSecond = currentDate.getSeconds();
if (currentMonth < 10) {
currentMonth = '0' + currentMonth;
}
if (currentDay < 10) {
currentDay = '0' + currentDay;
}
if (currentHour < 10) {
currentHour = '0' + currentHour;
}
if (currentMinute < 10) {
currentMinute = '0' + currentMinute;
}
if (currentSecond < 10) {
currentSecond = '0' + currentSecond;
}
говно