- 1
- 2
- 3
- 4
- 5
- 6
// for cdio:
#include <cdio.h>
#include <cdio_unconfig.h> # remove *all* symbols libcdio defines
// Add back in the ones you want your program
#include <config.h>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+133
// for cdio:
#include <cdio.h>
#include <cdio_unconfig.h> # remove *all* symbols libcdio defines
// Add back in the ones you want your program
#include <config.h>
But now what about the problem that there are common preprocessor symbols in config_cdio.h that an application may want to define in a different manner, like PACKAGE_NAME?
For this, there is yet another header, <cdio/cdio_unconfig.h>.
+109
private IEnumerable<CharacteristicValue> GetCharacteristicValues(IQueryable<CharacteristicValue> allCharacteristicValues, int characteristicId)
{
var characteristicValues = new CharacteristicValue[userIds.Length];
for (var i = 0; i < userIds.Length; i++)
{
characteristicValues[i] = allCharacteristicValues.FirstOrDefault(cv => cv.UserId == userIds[i] && cv.CharacteristicId == characteristicId); // Todo: Try to replace with a single query.
}
return characteristicValues;
}
Драсьте, нашёл в коде такую вот какашку. Как видите параметр allCharacteristicsValues реализует интерфейс IQuarable из EF. То бишь каждый раз, когда будет вызываться метод FirstOrDefault будет делаться запрос к базе. В идеале это должно было бы выглядеть так:
var characteristicValues = allCharacteristicValues.Where(cv => cv.CharacteristicId == characteristicId && userIds.Contains(cv.UserId));
Но при такой реализации размер масива пользователей и значение может разниться:
Values:
val1
val2
val3
Users:
1
2
3
4
5
Для первого же варианта результат будет выглядеть так:
Values:
val1
val2
val3
null
null
Users:
1
2
3
4
5
Собственно всё )))) Надеюсь подсоветуете чего-нибудь хорошего ;)
+158
<?php
class User
{
protected $_user_id;
protected $_user_email;
protected $_user_password;
public function __construct($user_id)
{
$user_record = self::_getUserRecord($user_id);
$this->_user_id = $user_record['id'];
$this->_user_email = $user_record['email'];
$this->_user_password = $user_record['password'];
}
public function __get($value) {}
public function __set($name, $value) {}
private static function _getUserRecord($user_id)
{
$user_record = array();
switch($user_id) {
case 1:
$user_record['id'] = 1;
$user_record['email'] = '[email protected]';
$user_record['password'] = 'i like croissants';
break;
case 2:
$user_record['id'] = 2;
$user_record['email'] = '[email protected]';
$user_record['password'] = 'me too!';
break;
case 'error':
throw new Exception('Ошибка библиотеки SQL!');
break;
}
return $user_record;
}
}
?>
PHP исключения...
+113
if ((label1.Text == "O") & (label2.Text == "O") & (label3.Text == "O") | ((label1.Text == "X") & (label2.Text == "X") & (label3.Text == "X")))
{
label1.ForeColor = Color.Red;
label2.ForeColor = Color.Red;
label3.ForeColor = Color.Red;
win = false;
}
if ((label4.Text == "O") & (label5.Text == "O") & (label6.Text == "O") | ((label4.Text == "X") & (label5.Text == "X") & (label6.Text == "X")))
{
label4.ForeColor = Color.Red;
label5.ForeColor = Color.Red;
label6.ForeColor = Color.Red;
win = false;
}
if ((label7.Text == "O") & (label8.Text == "O") & (label9.Text == "O") | ((label7.Text == "X") & (label8.Text == "X") & (label9.Text == "X")))
{
label4.ForeColor = Color.Red;
label5.ForeColor = Color.Red;
label6.ForeColor = Color.Red;
win = false;
}
if ((label1.Text == "O") & (label4.Text == "O") & (label7.Text == "O") | ((label1.Text == "X") & (label4.Text == "X") & (label7.Text == "X")))
{
label1.ForeColor = Color.Red;
label4.ForeColor = Color.Red;
label7.ForeColor = Color.Red;
win = false;
}
if ((label2.Text == "O") & (label5.Text == "O") & (label8.Text == "O") | ((label2.Text == "X") & (label5.Text == "X") & (label8.Text == "X")))
{
label2.ForeColor = Color.Red;
label5.ForeColor = Color.Red;
label8.ForeColor = Color.Red;
win = false;
}
if ((label3.Text == "O") & (label6.Text == "O") & (label9.Text == "O") | ((label3.Text == "X") & (label6.Text == "X") & (label9.Text == "X")))
{
label3.ForeColor = Color.Red;
label6.ForeColor = Color.Red;
label9.ForeColor = Color.Red;
win = false;
}
if ((label1.Text == "O") & (label5.Text == "O") & (label9.Text == "O") | ((label1.Text == "X") & (label5.Text == "X") & (label9.Text == "X")))
{
label1.ForeColor = Color.Red;
label5.ForeColor = Color.Red;
label9.ForeColor = Color.Red;
win = false;
}
if ((label3.Text == "O") & (label5.Text == "O") & (label7.Text == "O") | ((label3.Text == "X") & (label5.Text == "X") & (label7.Text == "X")))
{
label3.ForeColor = Color.Red;
label5.ForeColor = Color.Red;
label7.ForeColor = Color.Red;
win = false;
}
}
private void label7_MouseDown(object sender, MouseEventArgs e)
{
if (win)
for (int i = 0; i < 1; i++)
{
if (label7.Text == "")
{
label7.Text = "X";
if ((label1.Text == "O") & (label2.Text == "O") & (label3.Text == ""))
{
label3.Text = "O"; break;
}
if ((label1.Text == "O") & (label2.Text == "") & (label3.Text == "O"))
{
label2.Text = "O"; break;
}
if ((label1.Text == "") & (label2.Text == "O") & (label3.Text == "O"))
{
label1.Text = "O"; break;
}
Крестики-нолики с одного форума. Полная версия: http://pastebin.com/59W3547n
+150
<?php
if ($_GET['type']) $link = 'type='.$_GET['type'];
if ($_GET['cat']) $link = 'cat='.$_GET['cat'];
if ($_GET['param']) $link = 'param='.$_GET['param'];
+72
/**
* @return node with values
*/
public FQNode getValueGetter() {
return data;
}
accessor c повышенной энтропией, хуле
+109
namespace ChemicalLabs
{
public partial class MediaViewer : Form
{
public static string XPath;
public MediaViewer(string ObjectMediaRef, string ObjectMediaName)
{
InitializeComponent();
try
{
this.Text = ObjectMediaName;
axWindowsMediaPlayer.settings.volume = 100;
ObjectMediaRef = (Convert.ToInt16(ObjectMediaRef) + 1).ToString();
XPath = ObjectMediaRef;
StreamReader DataStream = new StreamReader("c://ChemicalData/" + ObjectMediaRef + "/" + ObjectMediaRef + ".txt", Encoding.GetEncoding(1251));
_MEDIA_DATA_AREA.Text = DataStream.ReadToEnd();
object[] MediaFiles = Directory.GetFiles(
@"c://ChemicalData/" + ObjectMediaRef + "/" + "Media", "*.mp4", SearchOption.TopDirectoryOnly);
for (int i = 0; i < MediaFiles.Length; i++)
{FileInfo a = new FileInfo(MediaFiles[i].ToString());MediaFilesList.Items.Add(a.Name.Remove(a.Name.Length - 4));}
}
catch (Exception Ex)
{MessageBox.Show(Ex.ToString(),(Ex.Message).ToString(),buttons: MessageBoxButtons.OK,icon: MessageBoxIcon.Information);}
}
private void MD_Click(object sender, EventArgs e)
{
if (MediaFilesList.SelectedItem == null)
{MessageBox.Show("Вы не выбрали материал! Просмотр невозможен.","Сами не знаете, что хотите...",buttons: MessageBoxButtons.OK,icon: MessageBoxIcon.Information);}
else
{
string MediaPath;
MediaPath = MediaFilesList.SelectedItem.ToString();
MediaPath = "c://ChemicalData/" + XPath + "/" + "Media" + "/" + MediaPath + ".mp4";
axWindowsMediaPlayer.close();
axWindowsMediaPlayer.URL = MediaPath;
}
}
private void MediaStreamClose_Click(object sender, EventArgs e)
{this.axWindowsMediaPlayer.close();}
private void _MediaForm_Close_Click(object sender, EventArgs e)
{this.axWindowsMediaPlayer.close(); MediaViewer.ActiveForm.Close();}
private void MediaViewer_FormClosed(object sender, FormClosedEventArgs e)
{this.axWindowsMediaPlayer.close();MediaViewer.ActiveForm.Close();}
private void axWindowsMediaPlayer_MouseDownEvent(object sender, AxWMPLib._WMPOCXEvents_MouseDownEvent e)
{MessageBox.Show("MediaPlayer - ver 0.0.1 for .NET Platform (By Kirill Sancharov)","MediaPlayer for Windows .NET",buttons: MessageBoxButtons.OK,icon: MessageBoxIcon.Information);}
}
}
Удивляй меня полностью.
+72
LOG.error(msg);
Writer writer = new StringWriter();
e.printStackTrace(new PrintWriter(writer, true));
LOG.error(writer.toString());
Паранойя... А вдруг LOG неправильно стэк трейс напечатает при передаче эксепшена вторым параметром.
+105
//батон ЗАНЕСТИ
private void btnOk_Click(object sender, EventArgs e)
{
if (SaveData())
{
this.Tag = _tParams.Id;
this.DialogResult = DialogResult.OK;
this.Close();
}
}
+150
<?php
#Подключаем все модули
include ("$_SERVER[DOCUMENT_ROOT]/engine/engine.php");
//Берём из бд статьи
$select = mysql_query("SELECT * FROM articles");
$result = mysql_fetch_array($select);
$num_rows = mysql_num_rows($select);
//Берём из бд инфу о сайте
$select_site = mysql_query("SELECT * FROM site");
$result_site = mysql_fetch_array($select_site);
// Переменные с $site
$ID = $result_site['id'];
$TITLE = $result_site['title'];
$keywords = $result_site['keywords'];
$description = $result_site['description'];
#Подключаем шаблон
include ("$server/template/main.php"); // Главный файл с title
include ("$server/template/body.php"); // <body> всё что находится там
if ($num_rows > 0){
// В цикле прокручиваем все статьи из БД - $result
do
{
$title = $result['title']; // Заголовок
$id = $result['id']; // ID
$full_text = $result['text']; // Весь текст
$view = $result['view']; // Просмотры у топика
$author = $result['author']; // Автор
$date = $result['date']; // Дата добавления
$short_text = $result['cat']; // Краткий текст (cat)
$category_art = $result['category']; // Категория топика
$select_category = mysql_query("SELECT * FROM category WHERE id = '".$category_art."'");
$result_category = mysql_fetch_array($select_category);
$category = $result_category['title'];
$url = $result_category['url'];
include ("$server/template/short_news.php"); #Берём (шаб)краткую версию топика
}
while ($result = mysql_fetch_array($select));
}
else
{
echo 'Нет ни одной статьи!';
}
include ("$server/template/footer.php");#Наконец подгружаем футер
?>
Изобретение говно-велосипеда