- 1
Я заебался жать на рефреш весь долбанный день со всех устройств, чтобы запостить гет
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+146
Я заебался жать на рефреш весь долбанный день со всех устройств, чтобы запостить гет
+147
public class Matrix {
private float matrix[][];
private int dim;
public Matrix(int dim) {
this.dim = dim;
this.matrix = new float[dim][dim];
}
public void productOfTwo(Matrix src, Matrix dest) {
if (src.dim == this.dim) {
dest.dim = this.dim;
Matrix[] temp = new Matrix[this.dim];
for (int i = 0; i < this.dim; i++) {
temp[i] = new Matrix(this.dim);
}
for (int i = 0; i < this.dim; i++) {
for (int j = 0; j < this.dim; j++) {
for (int k = 0; k < this.dim; k++) {
temp[k].matrix[i][j] = this.matrix[i][k] * src.matrix[k][j];
}
}
}
for (int i = 0; i < this.dim; i++) {
dest.sum(temp[i]);
}
} else {
System.out.println(" An error occured: Dimensions of matrices do not match");
}
}
public float findDet() {
if (this.dim == 1) {
return this.matrix[0][0];
} else if (this.dim == 2) {
return this.matrix[0][0] * this.matrix[1][1] - this.matrix[0][1] * this.matrix[1][0];
} else {
float result = 0;
Matrix minor = new Matrix(this.dim - 1);
for (int i = 0; i < this.dim; i++) {
for (int j = 1; j < this.dim; j++) {
System.arraycopy(this.matrix[j], 0, minor.matrix[j - 1], 0, i);
System.arraycopy(this.matrix[j], i + 1, minor.matrix[j - 1], i, this.dim - (i + 1));
}
result += Math.pow(-1, i) * this.matrix[0][i] * minor.findDet();
}
return result;
}
}
Всем доброго времени суток! Прошу к Вашему вниманию алгоритм нахождения произведения двух матриц(умножаем слева направо) и нахождения детерминанта разложением по столбцу(рекурсия). Прошу оценить, по всей строгости.
Заранее спасибо!
+958
namespace sortFiles
{
public partial class Form1 : Form
{
private void listBox1_DragDrop(object sender, DragEventArgs e)
{
this.listBox1.Items.AddRange((string[])e.Data.GetData(DataFormats.FileDrop, false));
}
private void listBox1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = (e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None);
}
private void listBox1_MouseDown(object sender, MouseEventArgs e)
{
var files = new List<OrderByMyCamera>();
foreach (string i in listBox1.Items)
files.Add(new OrderByMyCamera(i));
if(files.Count==0)
return;
files.Sort();
var filesArray = files.Select(item=>item.ToString()).ToArray();
DoDragDrop(new DataObject(DataFormats.FileDrop, filesArray), DragDropEffects.Copy);
}
}
internal class OrderByMyCamera : IComparable<OrderByMyCamera>
{
private readonly string _filePath;
private readonly int _fileNumber;
public OrderByMyCamera(string filePath)
{
_filePath = filePath;
var fileName = Path.GetFileNameWithoutExtension(filePath);
if(fileName.Count()!=6)
throw new Exception("Имя файла должно быть 6+4 символов вида MOVXXX.mpg. Возможно вы попытались вставить не те файлы в программу");
if (!filePath.Trim().ToLower().EndsWith(".mpg"))
throw new Exception("Файлы должны заканчиваться на расширение .mpg. Сконвертируете файлы в mpeg, прежде чем вставите их в программу");
int fileNumber = int.Parse(fileName.Substring(3), NumberStyles.HexNumber);
_fileNumber = fileNumber;
}
public override string ToString()
{
return _filePath;
}
public int CompareTo(OrderByMyCamera other)
{
if (_fileNumber == other._fileNumber)
return 0;
return (_fileNumber > other._fileNumber ? 1 : -1);
}
}
}
+155
jQuery.each(elems, function(i, elem) {
if (typeof elem === "number") {
elem += "";
}
if (!elem) {
return;
}
if (typeof elem === "string" && !rhtml.test(elem)) {
elem = context.createTextNode(elem);
} else if (typeof elem === "string") {
elem = elem.replace(rxhtmlTag, fcloseTag);
var tag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase(),
wrap = wrapMap[tag] || wrapMap._default,
depth = wrap[0],
div = context.createElement("div");
div.innerHTML = wrap[1] + elem + wrap[2];
while (depth--) {
div = div.lastChild;
}
if (!jQuery.support.tbody) {
var hasBody = rtbody.test(elem),
tbody = tag === "table" && !hasBody ? div.firstChild && div.firstChild.childNodes : wrap[1] === "<table>" && !hasBody ? div.childNodes : [];
for (var j = tbody.length - 1; j >= 0; --j) {
if (jQuery.nodeName(tbody[j], "tbody") && !tbody[j].childNodes.length) {
tbody[j].parentNode.removeChild(tbody[j]);
}
}
}
if (!jQuery.support.leadingWhitespace && rleadingWhitespace.test(elem)) {
div.insertBefore(context.createTextNode(rleadingWhitespace.exec(elem)[0]), div.firstChild);
}
elem = jQuery.makeArray(div.childNodes);
}
if (elem.nodeType) {
ret.push(elem);
} else {
ret = jQuery.merge(ret, elem);
}
});
+975
switch (Game1.mus)
{
case false: sb.Draw(disabled, new Vector2(ScrW - 256, 90), Color.White); break;
case true: sb.Draw(enabled, new Vector2(ScrW - 256, 90), Color.White); break;
}
switch (Game1.bloooom)
{
case false: sb.Draw(disabled, new Vector2(ScrW - 256, 180), Color.White); break;
case true: sb.Draw(enabled, new Vector2(ScrW - 256, 180), Color.White); break;
}
switch (Game1.part)
{
case false: sb.Draw(disabled, new Vector2(ScrW - 256, 270), Color.White); break; //420
case true: sb.Draw(enabled, new Vector2(ScrW - 256, 270), Color.White); break;
}
switch (Game1.eff)
{
case false: sb.Draw(disabled, new Vector2(ScrW - 256, 360), Color.White); break; //510
case true: sb.Draw(enabled, new Vector2(ScrW - 256, 360), Color.White); break;
}
switch (Game1.shad)
{
case false: sb.Draw(disabled, new Vector2(ScrW - 256, 450), Color.White); break;
case true: sb.Draw(enabled, new Vector2(ScrW - 256, 450), Color.White); break;
}
Оттуда же, откуда и #5199. Случайно обнаружил...
+161
if (window.ActiveXObject) window.ie = window[window.XMLHttpRequest ? 'ie7' : 'ie6'] = true;
else if (document.childNodes && !document.all && !navigator.taintEnabled) window.webkit = window[window.xpath ? 'webkit420' : 'webkit419'] = true;
else if (document.getBoxObjectFor != null) window.gecko = true;
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
+164
<a href="?page=news" <?php if (isset($_GET['page'])) if ($_GET['page']=='news') echo 'class="active"' ?> >Новости</a>
<a href="?page=photo" <?php if (isset($_GET['page'])) if ($_GET['page']=='photo') echo 'class="active"' ?> >Фото</a>
<a href="/" <?php if (isset($_GET['page'])); else echo ' class="active"'?> >Главная</a>
Подсветка той ссылки, на которой сейчас находишься (присвоение класса active).
Проверка if (isset($_GET['page'])) сделана для того, чтобы PHP не ругался на то, что page не передан (такое происходит при переходе на главную).
+154
$sections = array_chunk($items, $this->item_limit, true);
$k = 0;
foreach($sections as $key => $items) {
/*.........*/
$name = 'sitemap' . $k . '.xml';
$index['sitemap%'.$k] = array(
'loc' => BASE_URL . $name,
'lastmod' => date('c')
);
/*.........*/
$k++;
}
Видимо я чем-то здорово накидался кода писал это T_T
−86
{% if field.help_text %}
<tr>
<td></td>
<td colspan="2" style="padding-top: 0px; padding-bottom: 10px;">{{ field.help_text|safe }}</td>
<td>
<img id="captcha_img" src="<?php echo $absolute_page_path; ?>captcha/captcha.php?ref=register"/>
</td>
{% endif %}
Вот такую веселую хрень встретил в джанговских темплейтах =)
+166
for($i=0,$n=count($vars);$i<$n;$i++){
eval(' $'.$vars[$i].'=isset($_POST["'.$vars[$i].'"])? addslashes(trim($_POST["'.$vars[$i].'"])) : ""; ');
}
В недрах самописной crm)