- 1
if (numberOfAnimals == 3 || numberOfAnimals == 3)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−89
if (numberOfAnimals == 3 || numberOfAnimals == 3)
"Чтоб наверняка"
Новичок нашел заказчика. Дал мне код, чтобы я сделал "чтобы работал". Начал смотреть, ужаснулся.
+46
<?php
echo implode(", ", array_map(create_function('$tag', 'return \'<a href="?tag=\' . hs($tag) . \'">\' . hs($tag) . \'</a>\';'), $post['tags']));
?>
Нашел в дебрях своей древней CMS. Как говорится, экономика должна быть экономичной, а конь коническим.
+55
if($contact == null){
$msg = JText::_('INSERT_CONTACT_DETAILS');
if($contact == null){
$mainframe->redirect('index.php?option=com_xxx&act=Agents',Text::_($msg).$user->name);
}
return;
}
Правильно грят: бережённого бог бережёт :)
+79
if (scannedLiteralType.compareTo("<!") == 0) {
if (textPosition + 5 < text.length) {
if (scannedByte == (byte)'[') {
if (text[textPosition] == (byte)'C') {
if (text[textPosition + 1] == (byte)'D') {
if (text[textPosition + 2] == (byte)'A') {
if (text[textPosition + 3] == (byte)'T') {
if (text[textPosition + 4] == (byte)'A') {
if (text[textPosition + 5] == (byte)'[') {
scanByte();
scanByte();
scanByte();
scanByte();
scanByte();
scanByte();
scanByte();
Element childNode = createNode("");
node.addChild(childNode);
scanBytes("]]>".getBytes(), false);
byte[] bytes = new byte[literalPosition - 1];
System.arraycopy(literal, 0, bytes, 0, literalPosition - 1);
try {
String string = new String(bytes, encoding);
childNode.setValue(string);
childNode.setIdentifier("<![SDATA[]]");
} catch (Exception exception) {
childNode.setValue(bytes);
childNode.setIdentifier("<![CDATA[]]");
}
scanByte();
scanByte();
scanByte();
scanToken();
continue;
}
}
}
}
}
}
}
}
проверка "CDATA"
+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*/;
}
*/
Мелочь, конечно же, но всё-таки чушь, несмотря на пользу.