- 1
- 2
- 3
if (request.equals("") || request == null) {
Response.status(Response.Status.NO_CONTENT).build();
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+81
if (request.equals("") || request == null) {
Response.status(Response.Status.NO_CONTENT).build();
}
ну сколько можно...
+156
this.start = function() {
// Инициализирует парсинг выгрузки из Агента Плюс.
if (this.open()) {
this.catalogs = this.getTags("catalogs", true)[0].childs;
this.subdocuments = this.getTags("documents", true)[1].childs;
this.guids = this.document.childs[0].childs[0].childs;
this.sellhistory = this.getCatalog("ИсторияПродаж").childs[0].childs;
this.sellpoints = this.getCatalog("ТорговыеТочки").childs[0].childs;
this.contragents = this.getCatalog("Контрагенты").childs[1].childs;
this.deals = this.getCatalog("Договоры").childs[0].childs;
this.nomenclature = this.getCatalog("Номенклатура").childs;
this.measure = this.getCatalog("ЕдиницыИзмерения").childs[0].childs;
this.route = this.getDocument("Маршрут").childs[0].childs[0].childs[0].childs[0]
this.names = {deals: [], catalog: [], nomenclature: [], measure: [], contragents: [], sellpoints: []};
this.info = {deals: [], catalog: [], nomenclature: [], measure: [], contragents: [], sellpoints: []};
this.hash = {deals: {}, nomenclature: {}, consts: {}, contragents: {}, sellpoints: [], measure: {}};
for (var i = 0; i < this.catalogs.length; i++) {
this.names.catalog.push(this.catalogs[i].attrib.Comment.replace(/Справочник\./g, ""));
this.info.catalog.push(this.catalogs[i].attrib);
}
for (var i = 0; i < this.nomenclature[1].childs.length; i++) {
this.names.nomenclature.push(this.nomenclature[1].childs[i].attrib.Name);
this.info.nomenclature.push(this.nomenclature[1].childs[i].attrib);
this.hash.nomenclature[this.nomenclature[1].childs[i].attrib.GUID] = this.nomenclature[1].childs[i].attrib;
}
for (var i = 0; i < this.deals.length; i++) {
this.names.deals.push(this.deals[i].attrib.Name);
this.info.deals.push(this.deals[i].attrib);
this.hash.deals[this.deals[i].attrib.GUID] = this.deals[i].attrib;
}
for (var i = 0; i < this.measure.length; i++) {
this.names.measure.push(this.measure[i].attrib.Name);
this.info.measure.push(this.measure[i].attrib);
this.hash.measure[this.measure[i].attrib.GUID] = this.measure[i].attrib;
}
for (var i = 0; i < this.contragents.length; i++) {
this.names.contragents.push(this.contragents[i].attrib.Name);
this.info.contragents.push(this.contragents[i].attrib);
this.hash.contragents[this.contragents[i].attrib.GUID] = this.contragents[i].attrib;
}
for (var i = 0; i < this.sellpoints.length; i++) {
this.names.sellpoints.push(this.sellpoints[i].attrib.Name);
this.info.sellpoints.push(this.sellpoints[i].attrib);
this.hash.sellpoints[this.sellpoints[i].attrib.GUID] = this.sellpoints[i].attrib;
}
for (var i = 0; i < this.guids.length; i++) {
this.hash.consts[this.guids[i].attrib.GUID] = this.guids[i].attrib.VALUE;
}
this.dynamic.routes = new Array();
for (var i = 0; i < this.route.childs.length; i++) {
var sp = this.getSPointByGUID(this.route.childs[i].attrib.A02);
var adr = sp.Name;
var ca = this.getCAgentByGUID(this.route.childs[i].attrib.A01);
var ptypeguid = this.hash.deals[ca.A08].A06;
var cagent = ca.Name;
var dealguid = ca.A08;
var exists = false;
for (var j = 0; j < this.dynamic.routes.length; j++) if (this.dynamic.routes[j].address.trim().toLowerCase() == adr.trim().toLowerCase()) exists = exists || true;
if (!exists) this.dynamic.routes.push({ptypeguid: ptypeguid, spointguid: sp.GUID, address: adr, dealguid: dealguid, cagent: cagent, cagentguid: ca.GUID, datestamp: this.convRouteDate(this.route.childs[i].attrib.A03)});
}
} else return;
};
Маленькая часть нашего скрипта для работы с 1С - Node.JS - WebClient.
+91
procedure RecursiveVisibility(e : PCreature; oct, depth : integer; slopeA, slopeB : single);
var
x, y : integer;
begin
case oct of
1 : begin
y := e^.y - depth; { initialize y }
x := round(e^.x - slopeA * depth); { initialize z }
while GetSlopeStd(x, y, e^.x, e^.y) >= slopeB do begin { while in octant }
if GetVisDistance(x, y, e^.x, e^.y) <= mw then begin { if within max visual range }
if WorldSurface[x, y].entity^.obstruct then begin { if obstruction }
if not WorldSurface[x - 1, y].entity^.obstruct then begin { if no prior obstruction }
RecursiveVisibility(e, 1, depth + 1, slopeA, GetSlopeStd(x - 0.5, y + 0.5, e^.x, e^.y));
end; { ^create recursive scan }
end else begin { no obstruction }
if WorldSurface[x - 1, y].entity^.obstruct then begin { if prior obstruction }
slopeA := GetSlopeStd(x - 0.5, y - 0.5, e^.x, e^.y); { adjust slope for later recursion }
end;
end;
WorldSurface[x, y].visibility := 3; { set block visible }
end;
inc(x);
end;
dec(x)
end;
2 : begin
y := e^.y - depth; { initialize y }
x := round(e^.x + slopeA * depth); { initialize z }
while GetSlopeStd(x, y, e^.x, e^.y) <= slopeB do begin { while in octant }
if GetVisDistance(x, y, e^.x, e^.y) <= mw then begin { if within max visual range }
if WorldSurface[x, y].entity^.obstruct then begin { if obstruction }
if not WorldSurface[x + 1, y].entity^.obstruct then begin { if no prior obstruction }
RecursiveVisibility(e, 2, depth + 1, slopeA, GetSlopeStd(x + 0.5, y + 0.5, e^.x, e^.y));
end; { ^create recursive scan }
end else begin { no obstruction }
if WorldSurface[x + 1, y].entity^.obstruct then begin { if prior obstruction }
slopeA := -GetSlopeStd(x + 0.5, y - 0.5, e^.x, e^.y); { adjust slope for later recursion }
end;
end;
WorldSurface[x, y].visibility := 3; { set block visible }
end;
dec(x);
end;
inc(x)
end;
// Далее всё в таком же духе.
Отсюда: http://roguebasin.roguelikedevelopment.org/index.php?title=FOV_using_recursive_shad owcasting_-_improved
Можно было сделать менее говнокодистей?
+15
LambdaVar<1> X;
LambdaVar<2> Y;
// The next line prints 10:
cout << lambda(X,Y)[ plus[ multiplies[3,X], Y ] ] (3,1) << endl;
cout << lambda(X,Y)[ (3 %multiplies% X) %plus% Y ] << endl;
//...
lambda(X)[ X %plus% getCurrentTime[_*_] ]
//...
let[ X == someLambdaExp,
Y == someOtherLambdaExpWhichMayInvolveX ]
.in[ someLambdaExpInvolvingXandY ]
//...
lambda(X)[
letrec[ F == lambda(Y)[ if1[ Y %equals% 0,
1,
Y %multiplies% F[Y %minus% 1] ] ] ]
.in[ F[X] ] ]
//...
Maybe<int> mx = just(2);
Maybe<int> my = just(3);
mx = lambda()[ compM<MaybeM>()[ plus[X,Y] | X<=mx, Y<=my, guard[false] ] ]();
cout << mx << endl; // Nothing
//...
compM<ListM>()[ makePair[X,Y] | X<=list_with(1,2), guard[true],
Y<=list_with(3,4), guard[ (Y %divides% X) %equal% 3 ] ] ]
Грибки отсюда:
http://people.cs.umass.edu/~yannis/fc++/
+79
private static String dbl2str(Object obj) {
String value;
String str = obj.toString();
if (str.indexOf('E') != -1) {
//System.out.print("1 ");
String[] qwe = str.split("E");
String newstr = "";
int step = Integer.parseInt(qwe[1]);
for (int ind = 0; ind < qwe[0].length(); ind++) {
if (step > 0) {
if ((ind == (step + 2)) && (ind != qwe[0].length())) {
newstr = newstr + '.';
}
if (str.charAt(ind) != '.') {
newstr = newstr + str.charAt(ind);
}
if ((ind == qwe[0].length() - 1) && (ind <= step)) {
for (int ind2 = 0; ind2 < (step + 1 - ind); ind2++) {
newstr = newstr + "0";
}
}
} else {
if (ind == 0) {
newstr = newstr + "0.";
for (int ind3 = 0; ind3 > step + 1; ind3--) {
newstr = newstr + "0";
}
}
if (str.charAt(ind) != '.') {
newstr = newstr + str.charAt(ind);
}
}
}
value = newstr;
} else {
value = obj.toString();
}
return value;
}
жгем, товарищи! Double to String!
−121
Для каждого СтрГотИзд Из ГотовыеИзделия Цикл
СсылкаДСЕ = ОпределитьДСЕГотовоеИзделиеПоНаименованию(СтрГотИзд.Значение);
СсылкаЗаписьРС = НайтиПервуюЗаписьРС_ПоДСЕ(СсылкаДСЕ, ЭтотОбъект.НаДату);
Если СсылкаЗаписьРС = Неопределено Тогда
Предупреждение("На эту дату данных не существует!");
Иначе
ФормаИндикатора.КомментарийОбработкиДанных = "Построение отчета: " + СсылкаДСЕ.ВидПредмета + " - " + СсылкаДСЕ.Наименование + "";
ОбластьДанныеДобавить(ПолеТабДок, ОбластьДанные1, 1, СсылкаДСЕ, СсылкаЗаписьРС.Применяемость, Неопределено, ФормаИндикатора);
Выборка2Ур = НайтиЗаписиРС_ПоКодуДСЕГл(СсылкаЗаписьРС.НомерЗаписиРСДСЕВх, НаДату).Выбрать();
Пока Выборка2Ур.Следующий() цикл
ОбластьДанныеДобавить(ПолеТабДок, ОбластьДанные2, 2, Выборка2Ур.ДСЕВходящий, Выборка2Ур.Применяемость, Выборка2Ур, ФормаИндикатора);
Выборка3Ур = НайтиЗаписиРС_ПоКодуДСЕГл(Выборка2Ур.НомерЗаписиРСДСЕВх, НаДату).Выбрать();
Пока Выборка3Ур.Следующий() цикл
ОбластьДанныеДобавить(ПолеТабДок, ОбластьДанные3, 3, Выборка3Ур.ДСЕВходящий, Выборка3Ур.Применяемость, Выборка3Ур, ФормаИндикатора);
Выборка4Ур = НайтиЗаписиРС_ПоКодуДСЕГл(Выборка3Ур.НомерЗаписиРСДСЕВх, НаДату).Выбрать();
Пока Выборка4Ур.Следующий() цикл
ОбластьДанныеДобавить(ПолеТабДок, ОбластьДанные4, 4, Выборка4Ур.ДСЕВходящий, Выборка4Ур.Применяемость, Выборка4Ур, ФормаИндикатора);
Выборка5Ур = НайтиЗаписиРС_ПоКодуДСЕГл(Выборка4Ур.НомерЗаписиРСДСЕВх, НаДату).Выбрать();
Пока Выборка5Ур.Следующий() цикл
ОбластьДанныеДобавить(ПолеТабДок, ОбластьДанные5, 5, Выборка5Ур.ДСЕВходящий, Выборка5Ур.Применяемость, Выборка5Ур, ФормаИндикатора);
Выборка6Ур = НайтиЗаписиРС_ПоКодуДСЕГл(Выборка5Ур.НомерЗаписиРСДСЕВх, НаДату).Выбрать();
Пока Выборка6Ур.Следующий() цикл
ОбластьДанныеДобавить(ПолеТабДок, ОбластьДанные6, 6, Выборка6Ур.ДСЕВходящий, Выборка6Ур.Применяемость, Выборка6Ур, ФормаИндикатора);
Выборка7Ур = НайтиЗаписиРС_ПоКодуДСЕГл(Выборка6Ур.НомерЗаписиРСДСЕВх, НаДату).Выбрать();
Пока Выборка7Ур.Следующий() цикл
ОбластьДанныеДобавить(ПолеТабДок, ОбластьДанные7, 7, Выборка7Ур.ДСЕВходящий, Выборка7Ур.Применяемость, Выборка7Ур, ФормаИндикатора);
Выборка8Ур = НайтиЗаписиРС_ПоКодуДСЕГл(Выборка7Ур.НомерЗаписиРСДСЕВх, НаДату).Выбрать();
Пока Выборка8Ур.Следующий() цикл
ОбластьДанныеДобавить(ПолеТабДок, ОбластьДанные8, 8, Выборка8Ур.ДСЕВходящий, Выборка8Ур.Применяемость, Выборка8Ур, ФормаИндикатора);
Выборка9Ур = НайтиЗаписиРС_ПоКодуДСЕГл(Выборка8Ур.НомерЗаписиРСДСЕВх, НаДату).Выбрать();
Пока Выборка9Ур.Следующий() цикл
ОбластьДанныеДобавить(ПолеТабДок, ОбластьДанные9, 9, Выборка9Ур.ДСЕВходящий, Выборка9Ур.Применяемость, Выборка9Ур, ФормаИндикатора);
КонецЦикла;
КонецЦикла;
КонецЦикла;
КонецЦикла;
КонецЦикла;
КонецЦикла;
КонецЦикла;
КонецЦикла;
КонецЕсли;
КонецЦикла;
Функция НайтиЗаписиРС_ПоКодуДСЕГл(КодДСЕГл, НаДату, ДопустимаяЗамена = 0) Экспорт
Запрос = Новый Запрос;
Запрос.Текст =
"ВЫБРАТЬ
| СтруктураПриборов1СрезПоследних.ДСЕГлавный,
| СтруктураПриборов1СрезПоследних.ДСЕВходящий КАК ДСЕВходящий,
| СтруктураПриборов1СрезПоследних.Прибор,
| СтруктураПриборов1СрезПоследних.НомерЗаписиРСДСЕВх,
| СтруктураПриборов1СрезПоследних.НомерЗаписиРСДСЕГл,
| СтруктураПриборов1СрезПоследних.ДопустимаяЗамена,
| СтруктураПриборов1СрезПоследних.Применяемость,
| СтруктураПриборов1СрезПоследних.ДСЕВходящий.Ссылка,
| СтруктураПриборов1СрезПоследних.ДСЕВходящий.ВидПредмета КАК ВидПредмета,
| СтруктураПриборов1СрезПоследних.ДСЕВходящий.ВидПредмета.Порядок КАК ДСЕВходящийВидПредметаПорядок,
| СтруктураПриборов1СрезПоследних.ДСЕВходящий.Код КАК Код,
| СтруктураПриборов1СрезПоследних.Заимствованные,
| СтруктураПриборов1СрезПоследних.Период,
| СтруктураПриборов1СрезПоследних.ДатаОкончанияИспользования,
| СтруктураПриборов1СрезПоследних.ВводНового,
| СтруктураПриборов1СрезПоследних.ИзменениеСоставаИзделия
|ИЗ
| РегистрСведений.СтруктураПриборов1.СрезПоследних(
| &НаДату,
| НомерЗаписиРСДСЕГл = &КодДСЕГл
| И (ДатаОкончанияИспользования = &ПустаяДата
| ИЛИ ДатаОкончанияИспользования > &НаДату)
| И ДопустимаяЗамена = &ДопустимаяЗамена) КАК СтруктураПриборов1СрезПоследних
|
|УПОРЯДОЧИТЬ ПО
| ДСЕВходящийВидПредметаПорядок,
| Код";
Запрос.УстановитьПараметр("НаДату", НаДату);
Запрос.УстановитьПараметр("КодДСЕГл", КодДСЕГл);
Запрос.УстановитьПараметр("ПустаяДата", '00010101');
Запрос.УстановитьПараметр("ДопустимаяЗамена", ДопустимаяЗамена);
Возврат(Запрос.Выполнить());
КонецФункции
Прелесть! Выполняется около минуты. При чем этот код дублируется почти во всех отчетах.
После оптимизации объем кода сократился в 3 раза, а время выполнения составило 1-2 сек.
+16
//...
ret.value(_val != "" ? _val : "");
//...
+157
<SCRIPT language=JavaScript> <!--#### Подпрограммы (скрипты) для вывода фотографий составных частей ПК #### -->
function picture1(){
window.open("P4P800.jpg", "newwindow01", config="width=460, height=515, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
function picture2(){
window.open("CPU.jpg", "newwindow02", config="width=355, height=380, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
function picture3(){
window.open("Video.jpg", "newwindow03", config="width=475, height=380, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
function picture4(){
window.open("Syst.jpg", "newwindow04", config="width=220, height=220, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
function picture5(){
window.open("audio.jpg", "newwindow05", config="width=315, height=200, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
function picture6(){
window.open("Seti.jpg", "newwindow06", config="width=190, height=120, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
function picture7(){
window.open("hdd.jpg", "newwindow07", config="width=725, height=425, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
function picture8(){
window.open("dvd.jpg", "newwindow08", config="width=520, height=205, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
function picture9(){
window.open("korpus.jpg", "newwindow09", config="width=820, height=435, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
function picture10(){
window.open("monitor.jpg", "newwindow10", config="width=320, height=320, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
function picture11(){
window.open("Klava.jpg", "newwindow11", config="width=510, height=250, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
function picture12(){
window.open("Mouse.jpg", "newwindow12", config="width=340, height=285, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
function picture13(){
window.open("print.jpg", "newwindow13", config="width=467, height=295, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
function picture14(){
window.open("RAM.jpg", "newwindow14", config="width=530, height=135, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
}
</script> <!--#### Конец скриптов ####-->
+83
if ((decoded.length() > 40) && (el != null))
el.addMsg("Info: Decoded More Characters Than Is Specified By The Track 2 ANSI/ISO Standards");
else if ((decoded.length() > 107) && (el != null)) {
el.addMsg("Info: Decoded More Characters Than Is Specified By The Track 3 ANSI/ISO Standards");
}
Декодинг содержимого магнитной полосы карты в софте одного банка.
+135
int index = 0;
this.item[index].SetDefaults("Mining Helmet");
index++;
this.item[index].SetDefaults("Piggy Bank");
index++;
this.item[index].SetDefaults("Iron Anvil");
index++;
this.item[index].SetDefaults("Copper Pickaxe");
index++;
this.item[index].SetDefaults("Copper Axe");
index++;
this.item[index].SetDefaults("Torch");
index++;
this.item[index].SetDefaults("Lesser Healing Potion");
index++;
...