- 1
private ExportDataToCSV() { } //don't use this one!
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+146
private ExportDataToCSV() { } //don't use this one!
No comments)))
+170
if(SCREEN_WIDTH==800)
{
fm1 = 62;
fm2 = 61;
top = 86;
}
if(SCREEN_WIDTH==1024){
fm1 = 27;
fm2 = 26;
top = 78;
}
if(SCREEN_WIDTH==1680||SCREEN_WIDTH==1920){
fm1 = 72;
fm2 = 73;
top = 81;
}
if(SCREEN_WIDTH==1280 || SCREEN_WIDTH == 2560){
fm1 = 76;
fm2 = 75;
top = 77;
}
if(SCREEN_WIDTH == 1366 || SCREEN_WIDTH == 1440){
fm1= 67;
fm2= 66;
top = 79;
}
Это капля в море гавнокода одного из проектов на который меня посадили.
Чуть менее 1000 багов открыто только по GUI.
Все это дело рук одной девушки))
+167
$select = $db->select()
->from('advertisement AS a', $columns)
->joinLeft('resid_apt_secondary AS ras', 'ras.resid_apartment_residental_advertisement_id=a.id', array())
->joinLeft('resid_apt_newly_unready AS ranu', 'ranu.resid_apartment_residental_advertisement_id=a.id', array())
->joinLeft('resid_apt_newly_ready AS ranr', 'ranr.resid_apartment_residental_advertisement_id=a.id', array())
->joinLeft('resid_house_house AS rh', 'rh.resid_house_residental_advertisement_id=a.id', array())
->joinLeft('resid_house_cottage AS rc', 'rc.resid_house_residental_advertisement_id=a.id', array())
->joinLeft('resid_house_dacha AS rd', 'rd.resid_house_residental_advertisement_id=a.id', array())
->joinLeft('resid_garage AS rg', 'rg.residental_advertisement_id=a.id', array())
->joinLeft('sec_residental AS sr', 'sr.section_advertisement_id=a.id', array())
->joinLeft('bld_prod_common AS bpc', 'bpc.bld_production_commercial_advertisement_id=a.id', array())
->joinLeft('bld_prod_food AS bpf', 'bpf.bld_production_commercial_advertisement_id=a.id', array())
->joinLeft('bld_prod_restaurant AS bpr', 'bpr.bld_production_commercial_advertisement_id=a.id', array())
->joinLeft('bld_prod_warehouse AS bpw', 'bpw.bld_production_commercial_advertisement_id=a.id', array())
->joinLeft('bld_prod_garage AS bpg', 'bpg.bld_production_commercial_advertisement_id=a.id', array())
->joinLeft('bld_prod_service_station AS bpss', 'bpss.bld_production_commercial_advertisement_id=a.id', array())
->joinLeft('bld_prod_other AS bpo', 'bpo.bld_production_commercial_advertisement_id=a.id', array())
->joinLeft('bld_office_any AS boa', 'boa.bld_office_commercial_advertisement_id=a.id', array())
->joinLeft('bld_office_admin AS boad', 'boad.bld_office_commercial_advertisement_id=a.id', array())
->joinLeft('bld_office_sales AS bos', 'bos.bld_office_commercial_advertisement_id=a.id', array())
->joinLeft('bld_office_kiosk AS bok', 'bok.bld_office_commercial_advertisement_id=a.id', array())
->joinLeft('bld_farm_cowshed AS bfc', 'bfc.bld_farm_commercial_advertisement_id=a.id', array())
->joinLeft('bld_farm_workshop AS bfw', 'bfw.bld_farm_commercial_advertisement_id=a.id', array())
->joinLeft('bld_farm_chicken_house AS bfch', 'bfch.bld_farm_commercial_advertisement_id=a.id', array())
->joinLeft('bld_farm_other AS bfo', 'bfo.bld_farm_commercial_advertisement_id=a.id', array())
->joinLeft('gas_station AS gs', 'gs.commercial_advertisement_id=a.id', array())
->joinLeft('rm_prod_common AS rpc', 'rpc.room_production_commercial_advertisement_id=a.id', array())
->joinLeft('rm_prod_food AS rpf', 'rpf.room_production_commercial_advertisement_id=a.id', array())
->joinLeft('rm_prod_restaurant AS rpr', 'rpr.room_production_commercial_advertisement_id=a.id', array())
->joinLeft('rm_prod_warehouse AS rpw', 'rpw.room_production_commercial_advertisement_id=a.id', array())
->joinLeft('rm_prod_garage AS rpg', 'rpg.room_production_commercial_advertisement_id=a.id', array())
->joinLeft('rm_prod_service_station AS rpss', 'rpss.room_production_commercial_advertisement_id=a.id', array())
->joinLeft('rm_prod_other AS rpo', 'rpo.room_production_commercial_advertisement_id=a.id', array())
->joinLeft('rm_office_any AS roa', 'roa.rm_office_commercial_advertisement_id=a.id', array())
->joinLeft('rm_office_sales AS ros', 'ros.rm_office_commercial_advertisement_id=a.id', array())
->joinLeft('rm_office_off AS roo', 'roo.rm_office_commercial_advertisement_id=a.id', array())
->joinLeft('rm_office_admin AS road', 'road.rm_office_commercial_advertisement_id=a.id', array())
->joinLeft('rm_office_hall_rental AS roh', 'roh.rm_office_commercial_advertisement_id=a.id', array())
->where('is_recycled = ?', 'no')
->where('is_published = ?', 'yes')
->group(array('a.type', 'a.in_archive'));
Переделываем проект. В старой версии нашел следующие строчки.
+177
int arr[100][100];
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
if (i == j) arr[i][j] = 0;
}
}
Когда-то работал в универе и увидел у одной девочки в лабораторном отчете.
Код обнуляет диагональ массива, если кто сразу не понял)
+164
if(isset( $out[1][2]) && trim($out[1][2]) !='') $arr['ns'].=', '. $out[1][2];
if(isset( $out[1][3]) && trim($out[1][3]) !='') $arr['ns'].=', '. $out[1][3];
if(isset( $out[1][4]) && trim($out[1][4]) !='') $arr['ns'].=', '. $out[1][4];
if(isset( $out[1][5]) && trim($out[1][5]) !='') $arr['ns'].=', '. $out[1][5];
if(isset( $out[1][6]) && trim($out[1][6]) !='') $arr['ns'].=', '. $out[1][6];
if(isset( $out[1][7]) && trim($out[1][7]) !='') $arr['ns'].=', '. $out[1][7];
Нашел на фри-ланс.ру
−132
Запрос = Новый Запрос;
Запрос.УстановитьПараметр("ин_Кодификатор",Кодификатор);
Запрос.Текст = "ВЫБРАТЬ
| СтатьиДвиженияДенежныхСредств.Ссылка
|ИЗ
| Справочник.СтатьиДвиженияДенежныхСредств КАК СтатьиДвиженияДенежныхСредств
|ГДЕ
| СтатьиДвиженияДенежныхСредств.ин_Кодификатор = &ин_Кодификатор
|";
Выборка = Запрос.Выполнить().Выбрать();
Если Выборка.Следующий() Тогда
Если Выборка.Ссылка.Наименование <> Наименование Тогда
СтатьяДДСОбъект = Выборка.Ссылка.ПолучитьОбъект();
СтатьяДДСОбъект.Наименование = Наименование;
СтатьяДДСОбъект.Записать();
КонецЕсли;
Если Выборка.Ссылка.ин_Кодификатор <> Кодификатор Тогда
СтатьяДДСОбъект = Выборка.Ссылка.ПолучитьОбъект();
СтатьяДДСОбъект.ин_Кодификатор = Кодификатор;
СтатьяДДСОбъект.Записать();
КонецЕсли;
Отбор в запросе ин_Кодификатор = &ин_Кодификатор.
Потом идет проверка Выборка.Ссылка.ин_Кодификатор <> Кодификатор
+146
http://dl.dropbox.com/u/24195734/gets/govnoget7333.png
Гет, нах
+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);
}
}
}