- 1
model = (IModel)Activator.CreateInstance("DataModel", type).Unwrap() as IModel;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+137
model = (IModel)Activator.CreateInstance("DataModel", type).Unwrap() as IModel;
−109
// код в модели - создаются фильтры для колонок
override protected function createFiltersData():IList
{
var filtersDescription:IList = new ArrayList();
filtersDescription.addItem(new StatusFilter());
filtersDescription.addItem(new ProdUIDFilter());
filtersDescription.addItem(new ProdLongNameFilter());
filtersDescription.addItem(new ProductTypeFilter());
filtersDescription.addItem(new LatestRecordFilter());
filtersDescription.addItem(new LastActionFilter(true));
filtersDescription.addItem(new UsersFilter(this.userModel.users, true));
filtersDescription.addItem(new PublishFilter(true));
filtersDescription.addItem(new ProdNameFilter(true));
filtersDescription.addItem(new ProductComplexityRatingFilter(true));
filtersDescription.addItem(new ProductDescriptionFilter(true));
return filtersDescription;
}
// код в контроллере - создаются сами колонки
override protected function createTableColumns () : Array
{
var columns : Array = new Array();
columns.push(new ProdUIDColumn(0));
columns.push(new ProdLongNameColumn(1));
columns.push(new ProdNameColumn(2));
columns.push(new ProductDescriptionColumn(8));
columns.push(new ProdTypeColumn(3));
columns.push(new ProdComplRatingColumn(4));
columns.push(new EditorSeparator(40, 5));
columns.push(new CommentsColumn(9));
columns.push(new ValidStartDateColumn(6));
columns.push(new ValidEndDateColumn(7));
columns.push(new LastActionColumn());
columns.push(new UserColumn());
columns.push(new LastActionDateColumn());
columns.push(new LatestRecordColumn());
columns.push(new StatusColumn());
columns.push(new PublishColumn());
return columns;
}
Со слезами в глазах вопрошаю - ну нахуя, а????
+129
F[numbers_, setNumber_, ParenNum_] :=
Block[{func = {"+", "-", "*", "/"}[[setNumber]],
parens = {{"", "", "", "", "", ""}, {"", "(", "", "", ")",
""}, {"", "", "", "(", "", ")"}, {"", "(", "", "", "",
")"}, {"(", "", ")", "(", "", ")"}}[[ParenNum]], e},
e = ToExpression[
ToString[
StringJoin[parens[[1]], ToString[numbers[[1]]], func[[1]],
parens[[2]], ToString[numbers[[2]]], parens[[3]], func[[2]],
parens[[4]], ToString[numbers[[3]]], parens[[5]], func[[3]],
ToString[numbers[[4]]], parens[[6]]]]]; e];Timing[c = 0; d = 0;
b = Permutations[{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, {3}];
For[n1 = 1, n1 < 10, n1++,
For[n2 = 1, n2 < n1, n2++,
For[n3 = 1, n3 < n2, n3++,
For[n4 = 1, n4 < n3, n4++,
a = Permutations[{n1, n2, n3, n4}, {4}]; sol = {};
For[i = 1, i <= Length[a], i++,
For[j = 1, j <= 64, j++,
For[n = 1, n <= 5, n++, g = F[a[[i]], b[[j]], n];
If[IntegerQ[g] && g > 0, AppendTo[sol, g]]]];
m = Sort[DeleteDuplicates[sol]];
l = Complement[Range[1000], m][[1]];
If[l > c, c = l; d = {n1, n2, n3, n4}]]]]]];
FromDigits[Reverse[d]]]
http://projecteuler.net/problem=93
http://projecteuler.net/thread=93&page=6
Язык, кстати, Mathematica.
−98
Private Sub Command2_Click()
Cls
For x = 1 To Text2 + 1
For y = 1 To Text2 + 1
A(x, y) = Round(Rnd(1))
If A(x, y) = 0 Then A(x, y) = -1
Next
Next
For x = 2 To Text2
For y = 2 To Text2
PSet (1200 + x * 15, 200 + y * 15), A(x, y)
Next
Next
End Sub
Private Sub Command3_Click()
Cls
For x = 1 To Text2 + 1
For y = 1 To Text2 + 1
A(x, y) = 1
Next
Next
A(Text20, Text21) = -1
A(Text22, Text23) = -1
A(Text24, Text25) = -1
A(Text26, Text27) = -1
For x = 2 To Text2
For y = 2 To Text2
PSet (1200 + x * 15, 200 + y * 15), A(x, y)
Next
Next
End Sub
Private Sub Form_Load()
For x = 1 To Text2 + 1
For y = 1 To Text2 + 1
A(x, y) = Round(Rnd(1))
If A(x, y) = 0 Then A(x, y) = -1
Next
Next
'For x = 1 To Text2 + 1
'For y = 1 To Text2 + 1
'A(x, y) = 1
'Next
'Next
'A(10, 10) = -1
End Sub
Private Sub Command1_Click()
Cls
For k = 1 To Text1
For x = 1 To Text2 + 1
A(x, 1) = A(x, Text2)
A(x, Text2 + 1) = A(x, 2)
Next
For y = 1 To Text2 + 1
A(1, y) = A(Text2, y)
A(Text2 + 1, y) = A(2, y)
Next
For x = 2 To Text2
For y = 2 To Text2
xp = A(x - 1, y - 1) + A(x, y - 1) + A(x + 1, y - 1) + A(x - 1, y) + A(x + 1, y) + A(x - 1, y + 1) + A(x, y + 1) + A(x + 1, y + 1)
Select Case xp
Case -8
B(x, y) = Text3
Case -7
B(x, y) = Text4
Case -6
B(x, y) = Text5
Case -5
B(x, y) = Text6
Case -4
B(x, y) = Text7
Case -3
B(x, y) = Text8
Case -2
B(x, y) = Text9
Case -1
B(x, y) = Text10
Case 0
B(x, y) = Text11
Case 1
B(x, y) = Text12
Case 2
B(x, y) = Text13
Case 3
Жестокий, безумный мозг пятнадцатилетнего пацана родил клеточный автомат. Нашел свои исходники десятилетней давности.
А ведь я себя тогда считал крутым программистом... стыдно вспоминать.
+76
public static void main(String[] args) {
List<String> parameters = new ArrayList<String>();
if (args.length > 1) {
int count = 0;
for (String arg : args) {
if (count == 0) {
count++;
continue;
}
parameters.add(arg);
}
}
...
Ах Индия, Индия...
(все имена переменных изменены, все совпадения - исключительно случайны)
+15
#pragma once
#include <assert.h>
template<typename T>
inline T notNull(T arg)
{
assert(arg!=NULL);
return arg;
}
/*
//example:
class AnotherClass;
class SomeClass
{
AnotherClass * m_another;
//...
SomeClass(AnotherClass * another, /*skipped*/) : m_another(notNull(another)), /*skipped*/;
}
*/
Мелочь, конечно же, но всё-таки чушь, несмотря на пользу.
+5
template<class T>
bool IsAligned(T SizeOrAddress, const size_t AlignStep)
{
return SizeOrAddress==Align(SizeOrAddress, AlignStep);
}
+12
if(maxbits<3) x = genrand64_int64() & genrand64_int64() & genrand64_int64() & genrand64_int64() & genrand64_int64();
else
{
if(maxbits<6) x = genrand64_int64() & genrand64_int64() & genrand64_int64() & genrand64_int64();
else x = genrand64_int64() & genrand64_int64() & genrand64_int64();
}
+137
#define FMT_2_LEN 16
#define FMT_4_LEN 24
// и т.д. всего около десятка форматов
void calc_check_code(const unsigned char * from, unsigned fmt, unsigned * code)
{
switch (fmt) {
case 2:
//...
memset(data, 0, sizeof(FMT_2_LEN));
// выборочное наполнение data из from
make_code(data, FMT_2_LEN, code);
break;
case 4:
//...
memset(data, 0, sizeof(FMT_4_LEN));
// выборочное наполнение data из from
make_code(data, FMT_2_LEN, code);
break;
// для всех остальных аналогично
}
странно, и почему контрольный код не совпадает с эталонными примерами...
+135
public TOscillPanel getOscillPanel(String nameTable, XmlNodeList parameters, String idCHPU)
{
var actions=new Dictionary<string, object>
{
{"addParamOscill", new Action<string, string>(addParamOscill)},
{"removeParamOscill", new Action<string, string>(removeParamOscill)},
{"includeRealTimeMode",new Action<string>(includeRealTimeMode)}
};
return (new TOscillPanel(nameTable, parameters, actions));
}
//...
((Action<String, String>)_actions["addParamOscill"])(_tableChpu, ((TOptionNode)_oscillTreeView.Nodes[0]).getId());
((Action<String, String>)_actions["addParamOscill"])(_tableChpu, idParameters);
}
else
{
((Action<String, String>)_actions["removeParamOscill"])(_tableChpu, ((TOptionNode)_oscillTreeView.Nodes[0]).getId());
((Action<String, String>)_actions["removeParamOscill"])(_tableChpu, idParameters);
}
Это практически единственные и основные упоминания в коде контейнера _actions.
Говорила же мне мама: "возьми динамически типизированный язык", а я её не слушал. Не мне конечно же. Код из очень крупного частного проекта.
Динамически типизированный язык тут конечно же не нужен. Просто создаем трудности, а потом стоически их решаем.