- 1
//А почему PHP кода на этом сайте больше всего?
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+141
//А почему PHP кода на этом сайте больше всего?
+156
jQuery('.favoriteStar'+json.id).each(function(){
var src = jQuery(this).attr('src');
if (json.status != 1) {
src = src.replace('ico_heart.png','ico_heart_grey.png');
} else {
src = src.replace('ico_heart_grey.png','ico_heart.png');
}
jQuery(this).attr('src',src);
});
Установка элемента как favorite
+156
a=5; l=0;
.....
l= (l>a) ? 0 : l++;
Писал вчера свою задумку и были там вот эти строки... Я долго не мог вкурить, почему же у меня l все время рвано 0 ...)
+117
[TestInitialize]
public void Init()
{
relashions = new List<PersonRelationship>();
relashions.Add( new PersonRelationship()
{
PersonId = 1,
RalationshipPersonId = 2,
RelationshipTypeId = (int)DAL.Dictionaries.RelationshipType.Friend
});
relashions.Add(new PersonRelationship()
{
PersonId = 1,
RalationshipPersonId = 2,
RelationshipTypeId = (int)DAL.Dictionaries.RelationshipType.Friend
});
relashions.Add(new PersonRelationship()
{
PersonId = 2,
RalationshipPersonId = 1,
RelationshipTypeId = (int)DAL.Dictionaries.RelationshipType.Friend
});
}
[TestMethod()]
public void GetMyFriends_Get_Success()
{
long personId = 1;
var relationService = new Mock<IRelationService>();
relationService.Setup(c => c.GetMyFriends(personId)).Returns
(
from rl in relashions.Where(r => r.PersonId == personId && r.RelationshipTypeId == (int)DAL.Dictionaries.RelationshipType.Friend)
select new PersonShortDescriptionViewModel()
{
FirstName = personId.ToString(),
LastName = personId.ToString(),
}
);
var friends = relationService.Object.GetMyFriends(personId);
Assert.IsNotNull(friends);
}
Найден правильный метод написания тестов!
−107
GraphicsWindow.Width = 640
GraphicsWindow.Height = 480
GraphicsWindow.PenColor = "Yellow"
For i = 0 To 250
GraphicsWindow.DrawLine(0 + i, 480 - i, 640 - i, 480 - i )
EndFor
GraphicsWindow.PenColor = "Orange"
For i = 0 To 250 Step 10
GraphicsWindow.DrawLine(0 + i, 480 - i, 640 - i, 480 - i)
EndFor
GraphicsWindow.BrushColor = "SteelBlue"
GraphicsWindow.FillRectangle (0,0, 640 , 230)
GraphicsWindow.BrushColor = "lightGreen"
GraphicsWindow.FillTriangle(0, 480, 0, 230, 250, 230)
GraphicsWindow.FillTriangle(640, 480, 640, 230, 390, 230)
GraphicsWindow.BrushColor = "Orange"
GraphicsWindow.FillEllipse (10, 30, 50, 50)
GraphicsWindow.PenColor = "Yellow"
Turtle.Show()
y = 0
For i = 0 To 360 Step 30
Turtle.X =35
Turtle.Y = 55
Turtle.Angle = i
Turtle.PenUp()
Turtle.Move(25)
Turtle.PenDown()
If y = 1 Then
Turtle.Move(10)
y = 0
else
Turtle.Move(20)
y = 1
endif
endfor
+147
if($element_id===false)
{
//этот код не должен работать
$sql = 'SELECT `countmessage` FROM `mes_topic` WHERE `id`='.(int)$board_id;
}else{
....
}
А зачем его писать?!
+154
public function invokeMethod($method, $params = array()) {
switch (count($params)) {
case 0:
return $this->{$method}();
case 1:
return $this->{$method}($params[0]);
case 2:
return $this->{$method}($params[0], $params[1]);
case 3:
return $this->{$method}($params[0], $params[1], $params[2]);
case 4:
return $this->{$method}($params[0], $params[1], $params[2], $params[3]);
case 5:
return $this->{$method}($params[0], $params[1], $params[2], $params[3], $params[4]);
default:
return call_user_func_array(array(&$this, $method), $params);
}
}
Из сорцов Lithium
+76
private static List<Character> englishAlphabet;
public static final Integer ENGLISH_ALPHABET_LENGTH = 26;
static {
englishAlphabet = new ArrayList<Character>();
englishAlphabet.add('#');
for (int i = 0; i < ENGLISH_ALPHABET_LENGTH; i++) {
englishAlphabet.add((char) ('A' + i));
}
}
Товарищ уже уволился :)
+111
while (true)
{
if (sec > 10)
{
sec = 0;
// Вызор функции
}
else
sec++;
Thread.Sleep(1000);
}
Боевой код, который допиливаю(
+150
if (!isset($pmas_table[0][3])) $pmas_table[0][3]='';
if (!isset($pmas_table[0][5])) $pmas_table[0][5]='';
if (!isset($pmas_table[0][6])) $pmas_table[0][6]='';
if (!isset($pmas_table[0][7])) $pmas_table[0][7]='';
UserSide v2.48 again. Так как там каждая строчка имеет право быть на этом сайте, выкладываю The best of the best =)